eac123 commited on
Commit
c7f8cbb
·
verified ·
1 Parent(s): 54238c6

figure fixes: budget-map label placement, bar labels, schematic loop

Browse files
Files changed (1) hide show
  1. make_report.py +27 -15
make_report.py CHANGED
@@ -160,6 +160,11 @@ def plot_training(evals, out):
160
  fig.tight_layout(); fig.savefig(out, dpi=150); plt.close(fig)
161
 
162
 
 
 
 
 
 
163
  def plot_headline_bars(evals, out):
164
  """Bar-chart companion to the headline table. Two panels:
165
  (a) the matched-FLOP family, (b) the iso-param / iso-FLOP trio."""
@@ -188,7 +193,7 @@ def plot_headline_bars(evals, out):
188
  ptxt = []
189
  for f in fams:
190
  p, fl = budget_of(evals[f]) if evals[f] else (0, 0)
191
- ptxt.append(f"{LABELS[f].split(' (')[0]}\n"
192
  f"{p/1000:.0f}k params\n{fl:.2e} FLOPs")
193
  ax.set_xticks(x); ax.set_xticklabels(ptxt, fontsize=7)
194
  ax.axhline(1 / 64, color="gray", ls=":", lw=1)
@@ -205,25 +210,32 @@ def plot_headline_bars(evals, out):
205
  def plot_budget_map(evals, out):
206
  """Where each family sits in the (params, total training FLOPs) plane,
207
  with the two matching axes drawn in."""
208
- fig, ax = plt.subplots(figsize=(7.5, 5))
 
 
 
 
209
  for f in FAMILIES:
210
  if not evals[f]:
211
  continue
212
  p, fl = budget_of(evals[f])
213
  ax.scatter(p, fl, s=90, zorder=3)
214
- ax.annotate(LABELS[f], (p, fl), fontsize=7,
215
- xytext=(6, 4), textcoords="offset points")
 
216
  ax.axvline(829696, color="gray", ls="--", lw=1)
217
- ax.annotate("iso-parameter pair\n(fixed-4 vs rec-4x4)", (829696, 1.5e15),
218
  fontsize=7, color="gray", ha="right")
219
  ax.axhline(2.185e15, color="gray", ls=":", lw=1)
220
- ax.annotate("matched-FLOP family\n(same per-step and total FLOPs)",
221
- (2.4e5, 2.185e15), fontsize=7, color="gray",
222
- xytext=(6, 5), textcoords="offset points")
223
  ax.axhline(8.72e15, color="gray", ls="-.", lw=1)
224
- ax.annotate("iso-FLOP pair\n(rec-4x4 vs fixed-4-long)",
225
- (2.4e5, 8.72e15), fontsize=7, color="gray",
226
- xytext=(6, 5), textcoords="offset points")
 
 
227
  ax.set_xscale("log"); ax.set_yscale("log")
228
  ax.set_xlabel("parameters"); ax.set_ylabel("total training FLOPs")
229
  ax.set_title("Experimental design: what is matched against what")
@@ -267,11 +279,11 @@ def plot_schematic(out):
267
  box(ax, 1.2, 3.2, 1.6, 0.8, "shared blocks\n(same weights)", "tab:orange")
268
  box(ax, 1.2, 1.8, 1.6, 0.6, "readout head", "lightyellow")
269
  arrow(ax, 2.0, 3.2, 2.4)
270
- ax.annotate("", xy=(1.0, 3.6), xytext=(1.0, 4.4),
271
  arrowprops=dict(arrowstyle="-|>", connectionstyle=
272
- "arc3,rad=0.9", color="tab:red"))
273
- ax.text(0.05, 4.0, "loop\nR times\n(+step emb\neach pass)", fontsize=7,
274
- color="tab:red", ha="center")
275
  ax.text(0.15, 5.6, "input:\n[f(0..63), x, k]", fontsize=7)
276
  ax.text(2.0, 0.9, "example: 1x4 = 1 shared block, R=4\n"
277
  " 4x4 = 4 shared blocks, R=4\n"
 
160
  fig.tight_layout(); fig.savefig(out, dpi=150); plt.close(fig)
161
 
162
 
163
+ SHORT = {"fixed4x1": "fixed-4", "rec1x4": "rec-1x4", "rec2x2": "rec-2x2",
164
+ "rec1xdynamic": "rec-1x-dyn", "rec4x4": "rec-4x4",
165
+ "fixed4-long": "fixed-4-long"}
166
+
167
+
168
  def plot_headline_bars(evals, out):
169
  """Bar-chart companion to the headline table. Two panels:
170
  (a) the matched-FLOP family, (b) the iso-param / iso-FLOP trio."""
 
193
  ptxt = []
194
  for f in fams:
195
  p, fl = budget_of(evals[f]) if evals[f] else (0, 0)
196
+ ptxt.append(f"{SHORT[f]}\n"
197
  f"{p/1000:.0f}k params\n{fl:.2e} FLOPs")
198
  ax.set_xticks(x); ax.set_xticklabels(ptxt, fontsize=7)
199
  ax.axhline(1 / 64, color="gray", ls=":", lw=1)
 
210
  def plot_budget_map(evals, out):
211
  """Where each family sits in the (params, total training FLOPs) plane,
212
  with the two matching axes drawn in."""
213
+ fig, ax = plt.subplots(figsize=(7.5, 5.5))
214
+ # hand-placed label offsets (points) so nothing overlaps
215
+ OFF = {"fixed4x1": (8, -14, "left"), "rec1x4": (0, -16, "center"),
216
+ "rec2x2": (0, 10, "center"), "rec1xdynamic": (8, 6, "left"),
217
+ "rec4x4": (-8, 10, "right"), "fixed4-long": (8, -14, "left")}
218
  for f in FAMILIES:
219
  if not evals[f]:
220
  continue
221
  p, fl = budget_of(evals[f])
222
  ax.scatter(p, fl, s=90, zorder=3)
223
+ dx, dy, ha = OFF[f]
224
+ ax.annotate(LABELS[f], (p, fl), fontsize=7, ha=ha,
225
+ xytext=(dx, dy), textcoords="offset points")
226
  ax.axvline(829696, color="gray", ls="--", lw=1)
227
+ ax.annotate("iso-parameter pair\n(fixed-4 vs rec-4x4)", (829696, 1.45e15),
228
  fontsize=7, color="gray", ha="right")
229
  ax.axhline(2.185e15, color="gray", ls=":", lw=1)
230
+ ax.annotate("matched-FLOP family (same per-step and total FLOPs)",
231
+ (4.8e5, 2.185e15), fontsize=7, color="gray",
232
+ xytext=(0, 7), textcoords="offset points", ha="center")
233
  ax.axhline(8.72e15, color="gray", ls="-.", lw=1)
234
+ ax.annotate("iso-FLOP pair (rec-4x4 vs fixed-4-long)",
235
+ (5.0e5, 8.72e15), fontsize=7, color="gray",
236
+ xytext=(0, -13), textcoords="offset points", ha="center")
237
+ ax.set_xlim(1.8e5, 1.6e6)
238
+ ax.set_ylim(1.2e15, 1.1e16)
239
  ax.set_xscale("log"); ax.set_yscale("log")
240
  ax.set_xlabel("parameters"); ax.set_ylabel("total training FLOPs")
241
  ax.set_title("Experimental design: what is matched against what")
 
279
  box(ax, 1.2, 3.2, 1.6, 0.8, "shared blocks\n(same weights)", "tab:orange")
280
  box(ax, 1.2, 1.8, 1.6, 0.6, "readout head", "lightyellow")
281
  arrow(ax, 2.0, 3.2, 2.4)
282
+ ax.annotate("", xy=(2.8, 3.65), xytext=(2.8, 3.35),
283
  arrowprops=dict(arrowstyle="-|>", connectionstyle=
284
+ "arc3,rad=-1.8", color="tab:red"))
285
+ ax.text(3.35, 3.5, "loop\nR times\n(+step emb\neach pass)", fontsize=7,
286
+ color="tab:red", ha="center", va="center")
287
  ax.text(0.15, 5.6, "input:\n[f(0..63), x, k]", fontsize=7)
288
  ax.text(2.0, 0.9, "example: 1x4 = 1 shared block, R=4\n"
289
  " 4x4 = 4 shared blocks, R=4\n"