GOVINDFROM commited on
Commit
231820f
·
verified ·
1 Parent(s): 9bd057f

Retract input-injection claim; correct batch-size pooling error

Browse files
Files changed (1) hide show
  1. src/plot_sudoku.py +43 -25
src/plot_sudoku.py CHANGED
@@ -20,18 +20,29 @@ CLASSICAL = {"constraint propagation": 0.0300, "greedy MRV": 0.0590}
20
 
21
 
22
  def cfg_label(a):
 
 
 
 
 
 
 
 
 
23
  if a.get("objective") == "ar":
24
- return "autoregressive prefix-LM"
25
- if a.get("objective") == "direct":
26
- return "direct recurrent classifier"
27
- if not a.get("recurrent"):
28
- return f"feed-forward {a['layers']}L ({a['mode']})"
29
- tags = []
30
- if a.get("no_inject"):
31
- tags.append("no-inject")
32
- if a.get("no_deep_sup"):
33
- tags.append("no-deepsup")
34
- return "recurrent " + a["mode"] + (" [" + ",".join(tags) + "]" if tags else "")
 
 
35
 
36
 
37
  runs = defaultdict(list)
@@ -49,11 +60,13 @@ for f in sorted(glob.glob(f"{RUNS}/*/result.json")):
49
  # ---- Figure 1: board accuracy against decoding passes -----------------------
50
  fig, ax = plt.subplots(figsize=(7.2, 4.6))
51
  GRID = [1, 2, 4, 8, 16, 32, 61]
52
- style = {"recurrent full": ("#1a5276", "o", 2.4),
53
- "recurrent mdlm": ("#2980b9", "s", 1.6),
54
- "feed-forward 12L (full)": ("#c0392b", "^", 1.6),
55
- "feed-forward 12L (mdlm)": ("#e67e22", "v", 1.4),
56
- "feed-forward 32L (full)": ("#8e44ad", "D", 1.4)}
 
 
57
  for label, rs in sorted(runs.items()):
58
  if label not in style:
59
  continue
@@ -72,7 +85,8 @@ for name, v in CLASSICAL.items():
72
  ax.set_xscale("log", base=2)
73
  ax.set_xlabel("denoising passes (NFE)")
74
  ax.set_ylabel("board accuracy (%) — all 81 cells correct")
75
- ax.set_title("Hard Sudoku: recurrence beats capacity")
 
76
  ax.grid(alpha=.3); ax.legend(fontsize=7.5, loc="lower right"); ax.set_ylim(-3, 103)
77
  fig.tight_layout(); fig.savefig(f"{OUT}/sud_fig1_passes.png", dpi=170)
78
 
@@ -87,7 +101,7 @@ for label, rs in runs.items():
87
  best = np.mean([max(v["board"] for v in r["decode"].values()) for r in rs])
88
  pts.append((npar, best * 100, label))
89
  for npar, acc, label in pts:
90
- hero = label == "recurrent full"
91
  ax.scatter(npar, acc, s=170 if hero else 70,
92
  color="#1a5276" if hero else "#888",
93
  marker="*" if hero else "o", zorder=3 if hero else 2)
@@ -98,7 +112,8 @@ ax.text(2.3e5, 99.5 + 0.9, "Recurrent Transformer 99.5% @211k params "
98
  "(different clue distribution)", fontsize=6.6, color="#117a65")
99
  ax.set_xscale("log")
100
  ax.set_xlabel("parameters"); ax.set_ylabel("board accuracy (%)")
101
- ax.set_title("180× fewer parameters, 10 points better")
 
102
  ax.grid(alpha=.3); ax.set_ylim(-5, 108)
103
  fig.tight_layout(); fig.savefig(f"{OUT}/sud_fig2_params.png", dpi=170)
104
 
@@ -122,22 +137,25 @@ if os.path.exists(sw):
122
  fig.tight_layout(); fig.savefig(f"{OUT}/sud_fig3_rsweep.png", dpi=170)
123
 
124
  # ---- Figure 4: ablation ladder ---------------------------------------------
125
- order = ["feed-forward 12L (mdlm)", "feed-forward 12L (full)",
126
- "feed-forward 32L (full)", "recurrent mdlm",
127
- "recurrent full [no-deepsup]", "recurrent full [no-inject]",
128
- "recurrent full"]
129
  have = [(o, np.mean([max(v["board"] for v in r["decode"].values())
130
  for r in runs[o]]) * 100) for o in order if o in runs]
131
  if have:
132
  fig, ax = plt.subplots(figsize=(7.4, 4.0))
133
  names = [h[0] for h in have]; vals = [h[1] for h in have]
134
- cols = ["#1a5276" if n == "recurrent full" else "#9fb6c8" for n in names]
 
135
  ax.barh(range(len(vals)), vals, color=cols)
136
  for i, v in enumerate(vals):
137
  ax.text(v + 0.8, i, f"{v:.2f}%", va="center", fontsize=8)
138
  ax.set_yticks(range(len(names))); ax.set_yticklabels(names, fontsize=8)
139
  ax.set_xlabel("board accuracy (%)"); ax.set_xlim(0, 108)
140
- ax.set_title("Every ingredient is load-bearing")
 
 
141
  ax.grid(alpha=.3, axis="x")
142
  fig.tight_layout(); fig.savefig(f"{OUT}/sud_fig4_ablation.png", dpi=170)
143
 
 
20
 
21
 
22
  def cfg_label(a):
23
+ """Identify a configuration.
24
+
25
+ The training budget is part of the identity. An earlier version of this
26
+ function left it out, so a 32-layer run at batch 256 (94.50%) and one at
27
+ batch 64 (83.40%) were averaged into a single "88.95%" that belonged to
28
+ neither. That artefact is what produced the claim that depth was worth
29
+ nothing. Runs at different budgets are different configurations and are
30
+ never pooled.
31
+ """
32
  if a.get("objective") == "ar":
33
+ base = "autoregressive prefix-LM"
34
+ elif a.get("objective") == "direct":
35
+ base = "direct recurrent classifier"
36
+ elif not a.get("recurrent"):
37
+ base = f"feed-forward {a['layers']}L ({a['mode']})"
38
+ else:
39
+ tags = []
40
+ if a.get("no_inject"):
41
+ tags.append("no-inject")
42
+ if a.get("no_deep_sup"):
43
+ tags.append("no-deepsup")
44
+ base = "recurrent " + a["mode"] + (" [" + ",".join(tags) + "]" if tags else "")
45
+ return f"{base} @bs{a.get('bs')}"
46
 
47
 
48
  runs = defaultdict(list)
 
60
  # ---- Figure 1: board accuracy against decoding passes -----------------------
61
  fig, ax = plt.subplots(figsize=(7.2, 4.6))
62
  GRID = [1, 2, 4, 8, 16, 32, 61]
63
+ style = {"recurrent full @bs256": ("#1a5276", "o", 2.4),
64
+ "recurrent mdlm @bs256": ("#2980b9", "s", 1.6),
65
+ "feed-forward 12L (full) @bs256": ("#c0392b", "^", 1.6),
66
+ "feed-forward 12L (mdlm) @bs256": ("#e67e22", "v", 1.4),
67
+ "feed-forward 32L (full) @bs256": ("#8e44ad", "D", 1.4),
68
+ "recurrent full [no-inject] @bs64": ("#16a085", "P", 1.4),
69
+ "feed-forward 32L (full) @bs64": ("#7f8c8d", "X", 1.2)}
70
  for label, rs in sorted(runs.items()):
71
  if label not in style:
72
  continue
 
85
  ax.set_xscale("log", base=2)
86
  ax.set_xlabel("denoising passes (NFE)")
87
  ax.set_ylabel("board accuracy (%) — all 81 cells correct")
88
+ ax.set_title("Hard Sudoku: recurrence beats capacity\n(batch size is part of each label - runs at different budgets are not pooled)",
89
+ fontsize=10)
90
  ax.grid(alpha=.3); ax.legend(fontsize=7.5, loc="lower right"); ax.set_ylim(-3, 103)
91
  fig.tight_layout(); fig.savefig(f"{OUT}/sud_fig1_passes.png", dpi=170)
92
 
 
101
  best = np.mean([max(v["board"] for v in r["decode"].values()) for r in rs])
102
  pts.append((npar, best * 100, label))
103
  for npar, acc, label in pts:
104
+ hero = label == "recurrent full @bs256"
105
  ax.scatter(npar, acc, s=170 if hero else 70,
106
  color="#1a5276" if hero else "#888",
107
  marker="*" if hero else "o", zorder=3 if hero else 2)
 
112
  "(different clue distribution)", fontsize=6.6, color="#117a65")
113
  ax.set_xscale("log")
114
  ax.set_xlabel("parameters"); ax.set_ylabel("board accuracy (%)")
115
+ ax.set_title("At batch 256: fewer parameters, better accuracy, monotonically\n"
116
+ "37.9M → 88.90% | 6.34M → 94.50% | 212k → 99.70%", fontsize=10)
117
  ax.grid(alpha=.3); ax.set_ylim(-5, 108)
118
  fig.tight_layout(); fig.savefig(f"{OUT}/sud_fig2_params.png", dpi=170)
119
 
 
137
  fig.tight_layout(); fig.savefig(f"{OUT}/sud_fig3_rsweep.png", dpi=170)
138
 
139
  # ---- Figure 4: ablation ladder ---------------------------------------------
140
+ order = ["feed-forward 12L (mdlm) @bs256", "feed-forward 12L (full) @bs256",
141
+ "feed-forward 32L (full) @bs256", "recurrent mdlm @bs256",
142
+ "recurrent full [no-deepsup] @bs256", "recurrent full @bs256",
143
+ "feed-forward 32L (full) @bs64", "recurrent full [no-inject] @bs64"]
144
  have = [(o, np.mean([max(v["board"] for v in r["decode"].values())
145
  for r in runs[o]]) * 100) for o in order if o in runs]
146
  if have:
147
  fig, ax = plt.subplots(figsize=(7.4, 4.0))
148
  names = [h[0] for h in have]; vals = [h[1] for h in have]
149
+ cols = ["#1a5276" if n == "recurrent full @bs256"
150
+ else ("#d5dbdb" if "@bs64" in n else "#9fb6c8") for n in names]
151
  ax.barh(range(len(vals)), vals, color=cols)
152
  for i, v in enumerate(vals):
153
  ax.text(v + 0.8, i, f"{v:.2f}%", va="center", fontsize=8)
154
  ax.set_yticks(range(len(names))); ax.set_yticklabels(names, fontsize=8)
155
  ax.set_xlabel("board accuracy (%)"); ax.set_xlim(0, 108)
156
+ ax.set_title("Ablation at matched budget\n"
157
+ "pale = batch 64, a separate budget: compare within a batch size",
158
+ fontsize=10)
159
  ax.grid(alpha=.3, axis="x")
160
  fig.tight_layout(); fig.savefig(f"{OUT}/sud_fig4_ablation.png", dpi=170)
161