unparallelled commited on
Commit
8884745
·
verified ·
1 Parent(s): c399f59

Upload scripts/mk_final_results.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. scripts/mk_final_results.py +121 -0
scripts/mk_final_results.py ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Every figure from 2026-09-16. All numbers read from the published eval CSVs."""
3
+ import csv,os,sys,math
4
+ import matplotlib; matplotlib.use("Agg")
5
+ import matplotlib.pyplot as plt
6
+ E=sys.argv[1]
7
+ S={"surface":"#fcfcfb","ink":"#0b0b0b","ink2":"#52514e","grid":"#e4e4e1"}
8
+ def sty(ax):
9
+ ax.set_facecolor(S["surface"])
10
+ for s in ax.spines.values(): s.set_color(S["grid"])
11
+ ax.grid(True,color=S["grid"],lw=.7,alpha=.9); ax.tick_params(colors=S["ink2"],labelsize=9)
12
+ def read(n,model,task="niah_single"):
13
+ f=os.path.join(E,f"{n}_summary.csv")
14
+ if not os.path.exists(f): f=os.path.join(E,n)
15
+ if not os.path.exists(f): return None
16
+ r=list(csv.reader(open(f)))
17
+ if len(r)<2: return None
18
+ h=r[0]
19
+ for row in r[1:]:
20
+ if row and row[0]==task and model in h:
21
+ try: return float(row[h.index(model)])
22
+ except Exception: return None
23
+ return None
24
+ SRC={(4,1024):"eshort_cache16k_len1024",(8,1024):"eshort_cache32k_len1024",
25
+ (4,4096):"eshort_cache16k_len4096",(8,4096):"eshort_cache32k_len4096",
26
+ (16,4096):"e64k_len4096",(32,4096):"e128k_len4096",(64,4096):"fin_x64_4096",
27
+ (8,8192):"e32k_len8192",(8,16360):"e32k_len16360",(8,32744):"e32k_len32744",
28
+ (16,16360):"e64k_len16360",(16,32744):"e64k_len32744",(16,65512):"e64k_len65512",
29
+ (32,32744):"e128k_len32744",(32,65512):"e128k_len65512",
30
+ (64,32744):"fin_x64_32744",(64,65512):"fin_x64_65512"}
31
+ base={};p1={}
32
+ for (sc,pl),n in SRC.items():
33
+ b=read(n,"base680"); p=read(n,"p1final")
34
+ if b is not None: base[(sc,pl)]=b
35
+ if p is not None: p1[(sc,pl)]=p
36
+ base[(4,8192)]=84.0; base[(4,16360)]=40.0 # prior box, same haystack
37
+ p1[(4,8192)]=77.0; p1[(4,16360)]=42.0
38
+
39
+ fig=plt.figure(figsize=(19.5,11.4),facecolor=S["surface"])
40
+ gs=fig.add_gridspec(2,3,hspace=.32,wspace=.26)
41
+ PL=[1024,4096,8192,16360,32744,65512]
42
+ cols=plt.cm.viridis([i/(len(PL)-1) for i in range(len(PL))])
43
+
44
+ axA=fig.add_subplot(gs[0,0])
45
+ for pl,c in zip(PL,cols):
46
+ pts=sorted((s,v) for (s,p),v in base.items() if p==pl)
47
+ if len(pts)>1: axA.plot([x[0] for x in pts],[x[1] for x in pts],"o-",color=c,lw=2,ms=6,label=f"{pl:,}")
48
+ sty(axA); axA.set_xscale("log",base=2); axA.set_xticks([4,8,16,32,64])
49
+ axA.set_xticklabels(["x4","x8","x16","x32","x64"]); axA.set_ylim(0,100)
50
+ axA.set_xlabel("YARN_SCALE (ORIG fixed at 4096)",color=S["ink2"],fontsize=9.5)
51
+ axA.set_ylabel("niah_single (%)",color=S["ink2"],fontsize=9.5)
52
+ axA.set_title("A. Same untrained weights, only RoPE scale changes",color=S["ink"],fontsize=11,loc="left",pad=9)
53
+ axA.legend(frameon=False,fontsize=7.6,labelcolor=S["ink2"],loc="lower right",title="tokens",title_fontsize=7.6)
54
+
55
+ axB=fig.add_subplot(gs[0,1])
56
+ for pl,c in zip(PL,cols):
57
+ pts=sorted((pl/s,v) for (s,p),v in base.items() if p==pl)
58
+ if pts: axB.plot([x[0] for x in pts],[x[1] for x in pts],"o-",color=c,lw=2,ms=6,label=f"{pl:,}")
59
+ sty(axB); axB.set_xscale("log",base=2); axB.set_ylim(0,100)
60
+ axB.axvspan(2000,4400,color="#f3eceb",zorder=0)
61
+ axB.text(2950,6,"pretrain p90\n~2,721 tok",ha="center",fontsize=7.2,color=S["ink2"],style="italic")
62
+ axB.set_xlabel("virtual position of last token (real / scale)",color=S["ink2"],fontsize=9.5)
63
+ axB.set_ylabel("niah_single (%)",color=S["ink2"],fontsize=9.5)
64
+ axB.set_title("B. Collapses onto virtual position; spread = distractor load",color=S["ink"],fontsize=11,loc="left",pad=9)
65
+
66
+ axC=fig.add_subplot(gs[0,2])
67
+ ks=[4,8,16,32,64]
68
+ sums=[]
69
+ for k in ks:
70
+ d=[p1[(k,p)]-base[(k,p)] for p in PL if (k,p) in p1 and (k,p) in base]
71
+ sums.append(sum(d) if d else 0)
72
+ axC.bar(range(len(ks)),sums,color=["#b3243b" if s<0 else "#12508f" for s in sums])
73
+ axC.axhline(0,color=S["ink2"],lw=.9)
74
+ sty(axC); axC.set_xticks(range(len(ks))); axC.set_xticklabels([f"x{k}" for k in ks])
75
+ axC.set_xlabel("evaluation config",color=S["ink2"],fontsize=9.5)
76
+ axC.set_ylabel("p1final - base680, summed (pp)",color=S["ink2"],fontsize=9.5)
77
+ axC.set_title("C. Training's value is INVISIBLE at x4, clear at x64",color=S["ink"],fontsize=11,loc="left",pad=9)
78
+ for i,s in enumerate(sums): axC.text(i,s+(1.4 if s>=0 else -3),f"{s:+.0f}",ha="center",fontsize=9,color=S["ink2"])
79
+
80
+ axD=fig.add_subplot(gs[1,0])
81
+ X=[0,1,2]; lab=["16k","32k","64k"]
82
+ axD.plot(X,[70,50,31],"o--",color="#b0b0aa",lw=1.6,ms=6,label="1.06B, own config")
83
+ axD.plot(X,[78,73,65],"o-",color="#b3243b",lw=2.4,ms=7,label="1.06B, corrected")
84
+ axD.plot(X,[66,70,65],"s--",color="#eb6834",lw=1.6,ms=6,label='1.06B "collapsed", corrected')
85
+ axD.plot(X,[92,79,75],"^-",color="#12508f",lw=2.4,ms=8,label="680M base, NO long-ctx training")
86
+ sty(axD); axD.set_xticks(X); axD.set_xticklabels(lab); axD.set_ylim(0,100)
87
+ axD.set_xlabel("prompt length",color=S["ink2"],fontsize=9.5)
88
+ axD.set_ylabel("niah_single (%)",color=S["ink2"],fontsize=9.5)
89
+ axD.set_title("D. Control: training wins at the length it trained (64k)",color=S["ink"],fontsize=11,loc="left",pad=9)
90
+ axD.legend(frameon=False,fontsize=7.8,labelcolor=S["ink2"],loc="lower left")
91
+
92
+ axE=fig.add_subplot(gs[1,1])
93
+ tasks=["niah_single","niah_multikey","val_backward"]
94
+ b=[79,42,3]; p=[90,39,1]; m=[73,36,0]
95
+ w=.26; xs=range(len(tasks))
96
+ axE.bar([x-w for x in xs],b,w,color="#9dc3ea",label="680M base")
97
+ axE.bar(list(xs),p,w,color="#12508f",label="680M p1final")
98
+ axE.bar([x+w for x in xs],m,w,color="#b3243b",label="1.06B trained to 64k")
99
+ sty(axE); axE.set_xticks(list(xs)); axE.set_xticklabels(tasks,fontsize=8.6); axE.set_ylim(0,100)
100
+ axE.set_ylabel("accuracy (%)",color=S["ink2"],fontsize=9.5)
101
+ axE.set_title("E. The gains are on the EASY task only",color=S["ink"],fontsize=11,loc="left",pad=9)
102
+ axE.legend(frameon=False,fontsize=7.8,labelcolor=S["ink2"],loc="upper right")
103
+ axE.text(1.75,8,"Qwen3-0.6B ~24%\non val_backward",fontsize=7.4,color=S["ink2"],style="italic",ha="center")
104
+
105
+ axF=fig.add_subplot(gs[1,2])
106
+ st=[0,800,1000,1200]; sc=[90,49,55,51]
107
+ axF.plot(st,sc,"o-",color="#b3243b",lw=2.4,ms=8)
108
+ axF.axhline(90,color="#12508f",ls="--",lw=1.4)
109
+ axF.text(600,92,"p1final parent (90)",fontsize=8,color="#12508f")
110
+ axF.fill_between([0,1200],[49,49],[55,55],color="#f3eceb",zorder=0)
111
+ sty(axF); axF.set_ylim(0,100)
112
+ axF.set_xlabel("32k-training step",color=S["ink2"],fontsize=9.5)
113
+ axF.set_ylabel("niah_single @32,744, x64 (%)",color=S["ink2"],fontsize=9.5)
114
+ axF.set_title("F. Training INSIDE the compressed range destroys it",color=S["ink"],fontsize=11,loc="left",pad=9)
115
+ axF.annotate("already collapsed by step 800,\nthen flat -- fewer steps would\nnot have helped",xy=(800,49),xytext=(250,20),
116
+ fontsize=7.8,color=S["ink2"],arrowprops=dict(arrowstyle="->",color=S["ink2"],lw=1))
117
+ fig.text(.005,.005,"680M niah_single unless noted. N=100 per point, greedy, identical haystack (199,754,694 B) across every measurement. "
118
+ "Wilson 95% CI is +/-9-13pp at N=100: differences inside a bar are not differences.",fontsize=8,color=S["ink2"])
119
+ fig.savefig("results_2026-09-16/all_results.png",dpi=150,bbox_inches="tight")
120
+ print(" wrote results_2026-09-16/all_results.png")
121
+ print(f" base680 points: {len(base)} p1final points: {len(p1)}")