okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
6e1085c1d
main
1"""Regenerate the figure from results.json: python plot.py (requires matplotlib).""" 2import json 3from pathlib import Path 4import matplotlib 5matplotlib .use ('Agg' ) 6import matplotlib .pyplot as plt 7from matplotlib .patches import FancyBboxPatch 8 9HERE = Path (__file__ ).resolve ().parent 10data = json .loads ((HERE / 'results.json' ).read_text ()) 11rows = data ['runs' ] 12BG = '#f5f7fb' ;INK = '#14243a' ;MUTED = '#516379' ;GRID = '#dbe2ec' 13colors = ['#426b9f' if r ['rope' ]== 'none' else '#008879' for r in rows ] 14labels = [('Ordinary RoPE' if r ['rope' ]== 'none' else 'YaRN 4x' )+ ' / ' + ('512K' if r ['input_tokens' ]== 524288 else '1M' )for r in rows ] 15plt .rcParams .update ({'font.family' :'DejaVu Sans' ,'font.size' :12 ,'text.color' :INK ,'axes.labelcolor' :MUTED ,'xtick.color' :MUTED ,'ytick.color' :INK }) 16fig = plt .figure (figsize = (14 ,9 ),facecolor = BG ) 17fig .text (.055 ,.945 ,'Ordinary RoPE vs YaRN at long context' ,fontsize = 25 ,weight = 'bold' ) 18fig .text (.055 ,.900 ,'Existing Strata on untouched main | ISTA IQ3_XXS | FP16 KV | RTX PRO 6000 Blackwell' ,fontsize = 12 ,color = MUTED ) 19left = fig .add_axes ([.24 ,.52 ,.24 ,.29 ],facecolor = BG ) 20right = fig .add_axes ([.64 ,.52 ,.30 ,.29 ],facecolor = BG ) 21for ax in (left ,right ): 22for spine in ax .spines .values ():spine .set_visible (False ) 23ax .set_ylim (2.6 ,- .6 );ax .tick_params (axis = 'both' ,length = 0 ) 24left .set_title ('Correct code associations' ,loc = 'left' ,pad = 24 ,fontsize = 14 ,weight = 'bold' ) 25left .set_yticks (range (3 ),labels );left .tick_params (axis = 'y' ,pad = 15 );left .set_xticks ([]);left .set_xlim (0 ,3.65 ) 26for i ,r in enumerate (rows ): 27correct = r ['correct_code_pairs' ] 28for j in range (3 ): 29left .add_patch (FancyBboxPatch ((j + .04 ,i - .24 ),.87 ,.48 ,boxstyle = 'round,pad=0.015,rounding_size=.05' , 30linewidth = 0 ,facecolor = colors [i ]if j < correct else GRID )) 31left .text (3.12 ,i ,f' { correct } /3' ,va = 'center' ,weight = 'bold' ,fontsize = 15 ) 32right .set_title ('Fresh prefill time' ,loc = 'left' ,pad = 24 ,fontsize = 14 ,weight = 'bold' ) 33right .set_yticks ([]);right .set_xlim (0 ,max (r ['prefill_s' ]for r in rows )* 1.23 ) 34right .set_xlabel ('Seconds · lower is faster' ,labelpad = 12 ) 35right .xaxis .grid (True ,color = GRID );right .set_axisbelow (True ) 36for i ,r in enumerate (rows ): 37right .barh (i ,r ['prefill_s' ],height = .48 ,color = colors [i ]) 38right .text (r ['prefill_s' ]+ 5 ,i ,f' { r [ "prefill_s" ]:.1f } s' ,va = 'center' ,weight = 'bold' ) 39fig .text (.055 ,.425 ,'The exact answers' ,fontsize = 16 ,weight = 'bold' ) 40fig .text (.055 ,.382 ,'Expected' ,color = MUTED ,fontsize = 11 ) 41fig .text (.25 ,.382 ,data ['expected' ].replace ('|' ,' | ' ),family = 'DejaVu Sans Mono' ,fontsize = 12 ,weight = 'bold' ) 42for i ,r in enumerate (rows ): 43y = .329 - i * .047 44fig .text (.055 ,y ,labels [i ],fontsize = 11 ,color = colors [i ]) 45fig .text (.25 ,y ,r ['answer' ].replace ('|' ,' | ' ),family = 'DejaVu Sans Mono' ,fontsize = 12 ) 46fig .text (.055 ,.125 ,'One prompt per condition; three facts amid repeated filler. Zero cached tokens reused.' ,fontsize = 11 ,color = MUTED ) 47fig .text (.055 ,.090 ,'512K success does not establish a safe cutoff. Fresh YaRN at 1M does not validate cache migration.' ,fontsize = 11 ,color = MUTED ) 48fig .text (.055 ,.055 ,'Actual inputs: 524,288 / 1,048,576 tokens. Allocation: 1,048,832 (includes output headroom).' ,fontsize = 10 ,color = MUTED ) 49fig .savefig (HERE / 'overview.png' ,dpi = 180 ,facecolor = BG ) 50fig .savefig (HERE / 'overview.svg' ,facecolor = BG ) 51plt .close (fig )