final artifact-order parser
Browse files84 unmodified lines85868788899091929394959697989910010110210310410584 unmodified linescandidates += list(walk(json.load(open(side))))except Exception: # noqa: BLE001passlayers_found = set()for item in candidates:for pattern in (r"blocks?[.\s_]*(\d+)", r"layers?[.\s_]*(\d+)", r"mlp[.\s_]*(\d+)"):for m in re.finditer(pattern, item, re.IGNORECASE):if 0 <= int(m.group(1)) < 64:layers_found.add(int(m.group(1)))if not layers_found and re.fullmatch(r"\d+", item.strip()):layers_found.add(int(item.strip()))per_layer = {layer: 1.0 for layer in layers_found}for node, score in scores.items():m = re.search(r"blocks\.(\d+)\.", str(node))if m:layer = int(m.group(1))per_layer[layer] = max(per_layer.get(layer, 0.0), abs(float(score)))ranked = [l for l, _ in sorted(per_layer.items(), key=lambda kv: -kv[1])]results[str(max_seq_len)] = {"ok": True,"n_nodes": len(scores),84 unmodified lines85868788899091929394959697989910010110210310410510610710810911011111284 unmodified linescandidates += list(walk(json.load(open(side))))except Exception: # noqa: BLE001passartifact_order: list[int] = []if isinstance(nodes_raw, list):for item in nodes_raw:m = re.search(r"(\d+)", str(item))if m and 0 <= int(m.group(1)) < 64:artifact_order.append(int(m.group(1)))layers_found = set(artifact_order)if not layers_found:for item in candidates:for pattern in (r"blocks?[.\s_]*(\d+)", r"layers?[.\s_]*(\d+)", r"mlp[.\s_]*(\d+)"):for m in re.finditer(pattern, item, re.IGNORECASE):if 0 <= int(m.group(1)) < 64:layers_found.add(int(m.group(1)))if not layers_found and re.fullmatch(r"\d+", item.strip()):layers_found.add(int(item.strip()))per_layer = {layer: 1.0 for layer in layers_found}for node, score in scores.items():m = re.search(r"blocks\.(\d+)\.", str(node))if m:layer = int(m.group(1))per_layer[layer] = max(per_layer.get(layer, 0.0), abs(float(score)))ranked = artifact_order or [l for l, _ in sorted(per_layer.items(), key=lambda kv: -kv[1])]results[str(max_seq_len)] = {"ok": True,"n_nodes": len(scores),
scripts/discover_only.py+16-9