SPB Git

spb/wpai0001_uqo

Public
3.9 KB · 61 lines python
1#!/usr/bin/env python32"""Figure 1: system map of the experiment (donor → localization → map → graft → evaluation), with the models,3backends and hosts actually used (read from run manifests). Vector PDF; no data values plotted."""4from __future__ import annotations56import json7import sys8from pathlib import Path910import matplotlib.pyplot as plt11from matplotlib.patches import FancyArrowPatch, FancyBboxPatch1213ROOT = Path(__file__).resolve().parents[1]14sys.path.insert(0, str(ROOT / "src"))15from wp_ai_0001.visualization.style import CATEGORICAL, DOUBLE_WIDTH_IN, ENTITY_COLORS, GRID, TEXT_PRIMARY, TEXT_SECONDARY, apply_style  # noqa: E4021617runs = [json.loads(l) for l in (ROOT / "experiments" / "registry" / "runs.jsonl").read_text().splitlines() if l.strip()]18n_completed = len({r["run_id"] for r in runs if r["status"] == "completed"})19n_invalid = len({r["run_id"] for r in runs if r["status"] == "invalidated"})20man = ROOT / "experiments" / "manifests"21hosts = set()22for f in man.glob("*.json"):23    m = json.loads(f.read_text())24    hosts.add(m["hardware"].get("chip", "?"))2526apply_style()27fig, ax = plt.subplots(figsize=(DOUBLE_WIDTH_IN, 3.6))28ax.set_xlim(0, 100)29ax.set_ylim(0, 60)30ax.axis("off")313233def box(x, y, w, h, title, lines, color, fc="#ffffff"):34    ax.add_patch(FancyBboxPatch((x, y), w, h, boxstyle="round,pad=0.6,rounding_size=1.5", linewidth=1.0, edgecolor=color, facecolor=fc))35    ax.text(x + 1.0, y + h - 1.4, title, fontsize=6.2, fontweight="bold", color=color, va="top")36    ax.text(x + 1.0, y + h - 5.0, "\n".join(lines), fontsize=4.6, color=TEXT_PRIMARY, va="top", linespacing=1.3)373839def arrow(x0, y0, x1, y1, label=None, color=TEXT_SECONDARY):40    ax.add_patch(FancyArrowPatch((x0, y0), (x1, y1), arrowstyle="-|>", mutation_scale=9, linewidth=0.9, color=color))41    if label:42        ax.text((x0 + x1) / 2, (y0 + y1) / 2 + 2.2, label, fontsize=4.4, color=TEXT_SECONDARY, ha="center")434445# Tier-0 chain (top row)46box(1, 36, 17.5, 22, "Donor D", ["toy transformer 4 L, d=128", "all 8 operators (incl. Ω)", "3 seeds; Tier 1–2: 1.5B–7B"], ENTITY_COLORS["donor"])47box(21.5, 36, 17.5, 22, "Causal localization", ["interchange patching", "zero-ablation, heads", "ablation → rescue", "organ: post-L0 row, read pos."], CATEGORICAL[6])48box(42, 36, 17.5, 22, "Alignment map A", ["Procrustes / ridge / CCA", "fitted on task-free rows", "sham: random orthogonal", "Prop. 1: regression kills Ω"], CATEGORICAL[3])49box(62.5, 36, 17.5, 22, "Graft into R", ["activation (donor in loop)", "subspace k, steering,", "adapter, weights, persistent", "controls: random/shuffled/unrelated"], ENTITY_COLORS["graft"])50box(83, 36, 16, 22, "Evaluation", ["held-out target / control", "Δ_T^adj vs sham", "cluster bootstrap", "preregistered freeze"], ENTITY_COLORS["recipient"])51arrow(18.5, 39, 21.5, 39, "activations")52arrow(39, 39, 42, 39, "component")53arrow(59.5, 39, 62.5, 39, "A(S_D)")54arrow(80, 39, 83, 39, "R′")55# Tier 0 vs Tier 1 lanes (bottom row)56box(1, 6, 46, 24, "Tier 0 — micro-world (PyTorch, MPS)", ["OPSEQ: invented operators on Z_11, scratchpad trace", "recipient trained without Ω (manufactured gap)", "17 models (matrix_v1); runs: pilot, v1, v2, confirmatory", "fresh-process persistence; supervised / distillation references"], ENTITY_COLORS["donor"], fc="#f7f9fc")57box(52, 6, 47, 24, "Tier 1–2 — open-weight models (MLX, wrapped layers)", ["Qwen2.5-1.5B/3B (laptop), Llama-3.2-3B, Qwen2.5-7B (M3U96b)", "capability: zero-shot task (antonym, capital, morph, add-three)", "organ: few-shot − zero-shot last-token state; task-free map", "dev split selects, confirmatory split tests (frozen rule, A1–A2)"], CATEGORICAL[1], fc="#fdf8f5")58ax.text(1, 2.0, f"Registry: {n_completed} completed runs, {n_invalid} invalidated; hosts: {', '.join(sorted(h for h in hosts if h != '?'))}. Hooks: bitwise no-op when idle (PyTorch and MLX).", fontsize=4.8, color=TEXT_SECONDARY)59fig.savefig(ROOT / "paper" / "figures" / "fig_system_map.pdf")60print("written fig_system_map.pdf")61
Files · main
Menu

Theme