okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
09fadfee6
main
1#!/usr/bin/env python3 2"""Aggregate per-context + per-model results. 3 4Inputs (8 rows): 5./32k.json IQ2_XS @ 32k (KV=int8) - 2026-10-05 (re-run with cold-prefill) 6./64k.json IQ2_XS @ 64k (KV=int8) - 2026-10-05 7./128k.json IQ2_XS @ 128k (KV=int8) - 2026-10-05 (CORRECTED from q4_0) 8./256k.json IQ2_XS @ 256k (KV=int8) - 2026-10-05 (CORRECTED from k8v4) 9./iq3_xxs_32k.json IQ3_XXS @ 32k (KV=int8) - 2026-10-05 10./iq3_xxs_64k.json IQ3_XXS @ 64k (KV=int8) - 2026-10-05 11./iq3_xxs_128k.json IQ3_XXS @ 128k (KV=q4_0) - 2026-10-05 12./iq3_xxs_256k.json IQ3_XXS @ 256k (KV=k8v4) - 2026-10-05 13 14Two prefill columns are now reported: 15Cold Prefill = engine-emitted timings.prompt_per_second on a 16max_tokens=1 non-stream call after a fresh /unload 17and /re-fetch (true cold wall-clock) 18SSE Prefill = engine-emitted timings.prompt_per_second on the 19streamed call - reflects time-to-first-decode chunk, 20which is shorter because --prefill auto overlaps 21with the start of the decode (8192-token chunks) 22 23Outputs: 24./matrix.json, ./matrix.md, ./summary.json 25./logs/<label>.md per-row audit trail 26""" 27from __future__import annotations 28 29import json 30import statistics 31from pathlib import Path 32 33BASE = Path (__file__ ).resolve ().parent 34LOGS = BASE / "logs" 35LOGS .mkdir (exist_ok = True ) 36 37OUT_MATRIX = BASE / "matrix.json" 38OUT_MD = BASE / "matrix.md" 39OUT_SUMMARY = BASE / "summary.json" 40 41# (label, src_path, kv, model_name) 42FILES = [ 43 ("32k" ,BASE / "32k.json" ,"int8" ,"IQ2_XS" ), 44 ("64k" ,BASE / "64k.json" ,"int8" ,"IQ2_XS" ), 45 ("128k" ,BASE / "128k.json" ,"int8" ,"IQ2_XS" ), 46 ("256k" ,BASE / "256k.json" ,"int8" ,"IQ2_XS" ), 47 ("IQ3_XXS @32k" ,BASE / "iq3_xxs_32k.json" ,"int8" ,"IQ3_XXS" ), 48 ("IQ3_XXS @64k" ,BASE / "iq3_xxs_64k.json" ,"int8" ,"IQ3_XXS" ), 49 ("IQ3_XXS @128k" ,BASE / "iq3_xxs_128k.json" ,"q4_0" ,"IQ3_XXS" ), 50 ("IQ3_XXS @256k" ,BASE / "iq3_xxs_256k.json" ,"k8v4" ,"IQ3_XXS" ), 51] 52 53 54def md_text (rows :list )-> str : 55L = [ 56"# Strata TPS benchmark results - Shin-BlackMamba - 2026-10-05 (corrected)" , 57"" , 58"Engine: Strata Qwen3.8-Flash-Next on RTX 4070 Ti SUPER (16 GiB, sm_89)." , 59"Image: strata:latest, sm_89 fat-binary, vision decoder NOT compiled." , 60"Container: --network host --gpus all --ulimit memlock=-1 --shm-size=4g." , 61"Bench harness: `run.py` issues, per row:" , 62" 1. **Cold prefill probe** (max_tokens=1, non-stream): `timings.prompt_per_second` after `POST /unload`" , 63" 2. **Three SSE stream calls** with reasoning_effort=minimal, max_tokens=192, t=0" , 64"" , 65"KV choices per row:" , 66" - IQ2_XS rows use KV=int8. **CORRECTED 2026-10-05** - KV-streaming keeps KV table small in RAM so int8 is viable for ALL IQ2_XS contexts." , 67" - IQ3_XXS rows at 32k/64k use KV=int8; at 128k/256k use KV=q4_0/k8v4 because IQ3_XXS residents 47 GB of experts and KV=int8 would push past VRAM at > 64 k." , 68"" , 69"Two prefill columns are reported:" , 70" - **Cold Prefill** = true end-of-prompt throughput (after /unload / re-fetch)." , 71" - **SSE Prefill** = engine-reported time-to-first-chunk throughput during streaming, lower because --prefill auto overlaps decode with the next 8K-token chunk's prefill." , 72"" , 73"## Matrix" , 74"" , 75"| Label | Model | KV | Prompt tokens | Avg TPS | Peak TPS (best of 3) | Engine TPS (avg) | Cold Prefill | SSE Prefill | Draft accepted | TTFT (avg) |" , 76"|---|:---:|---|---:|---:|---:|---:|---:|---:|---:|---:|" , 77 ] 78for label ,model_name ,kv ,ctx in rows : 79avgs = [round (x ["decode_avg_tps" ],2 )for x in ctx ["runs" ]] 80peaks = [round (x ["decode_peak_tps" ],2 )for x in ctx ["runs" ]] 81engs = [round (x ["eng_predicted_per_second" ],2 )for x in ctx ["runs" ]] 82cp = ctx .get ("cold_prefill" )or {} 83cold_prefill_tps = cp .get ("prompt_per_second" ,0.0 ) 84sse_prefill_avgs = [round (x .get ("eng_prompt_per_second" ,0.0 ),2 )for x in ctx ["runs" ]if x .get ("eng_prompt_per_second" )] 85draft_total_ac = sum (x ["eng_draft_n_accepted" ]for x in ctx ["runs" ]) 86draft_total_pr = sum (x ["eng_draft_n" ]for x in ctx ["runs" ]) 87draft_pct = round (100 * draft_total_ac / max (1 ,draft_total_pr ),1 ) 88ttft = [round (x ["ttft_ms" ])for x in ctx ["runs" ]] 89L .append ( 90f"| { label } | { model_name } | { kv } | { ctx [ 'prompt_tokens_target' ]:,d } | " 91f"** { statistics . mean ( avgs ):.2f } ** | " 92f" { max ( peaks ):.2f } | " 93f"** { statistics . mean ( engs ):.2f } ** | " 94f"** { cold_prefill_tps :.1f } ** | " 95f" { statistics . mean ( sse_prefill_avgs ):.1f } | " 96f" { draft_pct } % | " 97f" { int ( statistics . mean ( ttft )) } ms |" 98 ) 99L .append ("" ) 100L .append ("## Quality-vs-Speed comparison (IQ2_XS vs IQ3_XXS at same KV)" ) 101L .append ("" ) 102L .append ("| Context | KV | IQ2_XS engine TPS | IQ3_XXS engine TPS | IQ3 decode-TPS tax | IQ3 peak tax |" ) 103L .append ("|---|---|---:|---:|---:|---:|" ) 104pairings = [("32k" ,"int8" ,"IQ3_XXS @32k" ), 105 ("64k" ,"int8" ,"IQ3_XXS @64k" ), 106 ("128k" ,"int8" ,"IQ3_XXS @128k" ), 107 ("256k" ,"int8" ,"IQ3_XXS @256k" )] 108iq2_by_label_kv = {r [0 ]:r for r in rows if r [1 ]== "IQ2_XS" } 109iq3_by_label = {r [0 ]:r for r in rows if r [1 ]== "IQ3_XXS" } 110for label ,kv ,iq3_label in pairings : 111iq2 = iq2_by_label_kv .get (label ) 112iq3 = iq3_by_label .get (iq3_label ) 113if iq2 and iq3 : 114iq2_eng = statistics .mean (round (x ["eng_predicted_per_second" ],2 )for x in iq2 [3 ]["runs" ]) 115iq2_pk = max (round (x ["decode_peak_tps" ],2 )for x in iq2 [3 ]["runs" ]) 116iq3_eng = statistics .mean (round (x ["eng_predicted_per_second" ],2 )for x in iq3 [3 ]["runs" ]) 117iq3_pk = max (round (x ["decode_peak_tps" ],2 )for x in iq3 [3 ]["runs" ]) 118L .append (f"| { label } | { kv } | { iq2_eng :.2f } | { iq3_eng :.2f } | " 119f" { ( iq3_eng - iq2_eng ) / iq2_eng * 100 :+.1f } % | " 120f" { ( iq3_pk - iq2_pk ) / iq2_pk * 100 :+.1f } % |" ) 121L .append ("" ) 122L .append ("## Per-row audit trails" ) 123L .append ("" ) 124for label ,_m ,_kv ,_c in rows : 125fn = label .replace (' ' ,'_' ).replace ('@' ,'at' ) 126L .append (f"- [ { label } ](./logs/ { fn } .md)" ) 127L .append ("" ) 128L .append ("## Per-run detail" ) 129L .append ("" ) 130for label ,model_name ,kv ,ctx in rows : 131L .append (f"### { label } (model= { model_name } , KV= { kv } , prompt= { ctx [ 'prompt_tokens_target' ]:,d } tok)" ) 132L .append ("" ) 133cp = ctx .get ("cold_prefill" )or {} 134L .append (f" Cold prefill probe: prompt_n= { cp . get ( 'prompt_tokens_actual' ) } " 135f"prompt_total_ms= { cp . get ( 'prompt_total_ms' , 0 ):.1f } " 136f"prompt_per_second= { cp . get ( 'prompt_per_second' , 0 ):.1f } t/s" ) 137L .append ("" ) 138L .append ("| Run | Prompt tok | Completion | TTFT | Avg TPS | Peak TPS | Engine TPS | SSE Prefill (per-run rpt) | Draft | Finish |" ) 139L .append ("|---:|---:|---:|---:|---:|---:|---:|---:|---:|---|" ) 140for rr in ctx ["runs" ]: 141L .append ( 142f"| { rr [ 'seq' ] } | { rr [ 'prompt_tokens_actual' ]:,d } | { rr [ 'completion_tokens' ] } | " 143f" { rr [ 'ttft_ms' ]:.0f } ms | { rr [ 'decode_avg_tps' ]:.2f } | { rr [ 'decode_peak_tps' ]:.2f } | " 144f" { rr [ 'eng_predicted_per_second' ]:.2f } | { rr [ 'eng_prompt_per_second' ]:.1f } | " 145f" { rr [ 'eng_draft_n_accepted' ] } / { rr [ 'eng_draft_n' ] } | { rr [ 'finish_reason' ] } |" 146 ) 147L .append ("" ) 148return "\n" .join (L ) 149 150 151def per_context_log (label :str ,model_name :str ,kv :str ,ctx :dict )-> str : 152cp = ctx .get ("cold_prefill" )or {} 153L = [ 154f"# Audit trail - { label } " , 155"" , 156f"- Engine model: { label } " , 157f"- Configured model_name (POST body.model): { model_name } " , 158f"- Context: { ctx [ 'target_ctx' ] } tokens" , 159f"- KV cache: { kv } " , 160f"- Prompt tokens landed: { ctx [ 'prompt_tokens_target' ]:,d } " , 161f"- Fill chars: { ctx [ 'fill_chars' ]:,d } " , 162f"- Runs: 1 cold-prefill probe (max_tokens=1, non-stream, after /unload/reload) + 3 stream calls" , 163"" , 164"## Container deploy line" , 165"" , 166"```" , 167"docker rm -f strata && sleep 2" , 168"docker run -d --name strata --network host --gpus all \\" , 169" --ulimit memlock=-1 --shm-size=4g \\" , 170" -v strata-data:/data \\" , 171f" -e FAMILY=qwen -e MODEL= { model_name } -e CONTEXT= { ctx [ 'target_ctx' ] } \\" , 172f" -e VISION=no -e KV= { kv } -e REINSTALL=1 \\" , 173" -e HOST=127.0.0.1 -e PORT=8090 --restart unless-stopped strata" , 174"```" , 175"" , 176"## Cold prefill probe (max_tokens=1, non-stream)" , 177"" , 178f"- prompt_n: ** { cp . get ( 'prompt_tokens_actual' ) } **" , 179f"- prompt_total_ms: ** { cp . get ( 'prompt_total_ms' , 0 ):.1f } ** ms" , 180f"- prompt_per_second: ** { cp . get ( 'prompt_per_second' , 0 ):.1f } ** t/s" , 181f"- completion_tokens: { cp . get ( 'completion_tokens' , 0 ) } " , 182"" , 183"These are the numbers that match the README's 2,000+ t/s headline (the engine's end-of-prompt prefill throughput)." , 184"" , 185"## Per-run captures (SSE stream)" , 186"" , 187"| Run | Prompt tok | Completion | TTFT | Avg TPS | Peak TPS | Engine predicted_per_second | SSE Prefill (timings.prompt_per_second) | Draft | Finish |" , 188"|---:|---:|---:|---:|---:|---:|---:|---:|---:|---|" , 189 ] 190for rr in ctx ["runs" ]: 191L .append ( 192f"| { rr [ 'seq' ] } | { rr [ 'prompt_tokens_actual' ]:,d } | { rr [ 'completion_tokens' ] } | " 193f" { rr [ 'ttft_ms' ]:.0f } ms | { rr [ 'decode_avg_tps' ]:.2f } | " 194f" { rr [ 'decode_peak_tps' ]:.2f } | { rr [ 'eng_predicted_per_second' ]:.2f } | " 195f" { rr [ 'eng_prompt_per_second' ]:.1f } | " 196f" { rr [ 'eng_draft_n_accepted' ] } / { rr [ 'eng_draft_n' ] } | " 197f" { rr [ 'finish_reason' ] } |" 198 ) 199L .append ("" ) 200L .append (f"Raw: [`../ { label } .json`](../ { label } .json)" ) 201L .append ("" ) 202return "\n" .join (L ) 203 204 205def main (): 206out = { 207"header" : { 208"engine" :"Strata Qwen3.8-Flash-Next" , 209"host" :"Shin-BlackMamba / Ubuntu 24.04.5 LTS" , 210"kernel" :"6.8.0-146-generic" , 211"nvidia_driver" :"595.91.07" , 212"nvidia_ctk" :"1.20.1" , 213"gpu" :"NVIDIA GeForce RTX 4070 Ti SUPER (16 GiB, sm_89)" , 214"ram" :"94 GiB" , 215"engine_build" :"sm_89 fat-binary (CUDA_ARCHITECTURES=89); BUILD_VISION=0; VISION=no" , 216"method" : ( 217"Two probe types per row: (1) cold-prefill max_tokens=1 non-stream after /unload; " 218"(2) three SSE stream calls (reasoning_effort=minimal, max_tokens=192, t=0)." 219 ), 220"kv_strategy" :"IQ2_XS uses KV=int8 across all 4 contexts after correction 2026-10-05. IQ3_XXS at 32k/64k uses int8; at 128k/256k uses q4_0/k8v4 because IQ3_XXS residents 47 GiB of experts and int8 plus attention would push past the 16 GiB VRAM envelope." , 221 }, 222"per_context" : [], 223 } 224 225rows_for_md = [] 226for label ,fp ,kv ,model_name in FILES : 227d = json .load (open (fp )) 228r = d ["results" ][0 ] 229ctx = { 230"target_ctx" :r ["target_ctx" ], 231"kv" :kv , 232"prompt_tokens_target" :r ["target_prompt_tokens" ], 233"fill_chars" :r ["fill_chars" ], 234"cold_prefill" :r .get ("cold_prefill" )or {}, 235"runs" :r ["runs" ], 236 } 237avgs = [round (x ["decode_avg_tps" ],2 )for x in ctx ["runs" ]] 238peaks = [round (x ["decode_peak_tps" ],2 )for x in ctx ["runs" ]] 239engs = [round (x ["eng_predicted_per_second" ],2 )for x in ctx ["runs" ]] 240out ["per_context" ].append ({ 241"label" :label , 242"model_name" :model_name , 243"kv" :kv , 244"prompt_tokens_target" :r ["target_prompt_tokens" ], 245"cold_prefill" :ctx ["cold_prefill" ], 246"runs" :ctx ["runs" ], 247"avg_decode_avg_tps" :round (statistics .mean (avgs ),2 ), 248"max_peak_tps" :round (max (peaks ),2 ), 249"engine_predicted_avg_tps" :round (statistics .mean (engs ),2 ), 250"sse_prefill_avg_tps" :round (statistics .mean (round (x .get ("eng_prompt_per_second" ,0 ),2 )for x in ctx ["runs" ]),2 ), 251"draft_total_accepted" :sum (x ["eng_draft_n_accepted" ]for x in ctx ["runs" ]), 252"draft_total_proposed" :sum (x ["eng_draft_n" ]for x in ctx ["runs" ]), 253"draft_pct" :round (100 * sum (x ["eng_draft_n_accepted" ]for x in ctx ["runs" ])/ 254max (1 ,sum (x ["eng_draft_n" ]for x in ctx ["runs" ])),1 ), 255"ttft_ms_per_run" : [int (x ["ttft_ms" ])for x in ctx ["runs" ]], 256 }) 257 258log_path = LOGS / f" { label . replace ( ' ' , '_' ). replace ( '@' , 'at' ) } .md" 259log_path .write_text (per_context_log (label ,model_name ,kv ,ctx )) 260 261rows_for_md .append ((label ,model_name ,kv ,ctx )) 262 263OUT_MATRIX .write_text (json .dumps (out ,indent = 2 )) 264OUT_MD .write_text (md_text (rows_for_md )) 265OUT_SUMMARY .write_text (json .dumps (out ,indent = 2 )) 266 267written = [OUT_MATRIX ,OUT_MD ,OUT_SUMMARY ] 268written += [LOGS / f" { label . replace ( ' ' , '_' ). replace ( '@' , 'at' ) } .md" 269for label ,_m ,_k ,_c in FILES ] 270"Wrote:" ) 271for f in written : 272f" - { f . relative_to ( BASE ) } ( { f . stat (). st_size } bytes)" ) 273 274 275if __name__ == "__main__" : 276main ()