okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

albedocmake: strata_kernels links strata_kernels_cpu (iq_kernels.cu reads the latent colscale table from expert_layout.cpp; strata-q36ref failed to link)a4af4df61

main
2 files

files

README.md9.3 KiB
hc_persist_bench.cpp5.3 KiB

STRATA_HC_PERSIST=1: the verifier's hyper-connection read as one persistent kernel (gfx1030)

2x RX 6900 XT (gfx1030, 16 GB, PCIe 4.0 x8 each), Ryzen 5 5600X, 128 GB DDR4-3200, Ubuntu 26.04, kernel 7.0.0-38, ROCm 10.0. Qwen3.8-Flash-Next IQ3_S (and Unsloth UD-Q4_K_XL), two-card layer split.

Result

What the read does and why it was slow here

Every layer the verifier reads the hyper-connection twice: RMS norm over 4 x 2560, a 320-row down projection (plus 4 inject rows) and a 320 -> 10240 up projection. At 1-8 tokens this is three small launches with two global dependencies between them; on gfx1030 the down kernel runs 41 blocks on 40 WGPs and the card idles between launches.

The persistent kernel runs 80 blocks (two per WGP) and two grid barriers on an atomic counter:

  1. each block takes 128 columns of the 10240 (norm sum of squares + partial dots of the 324 down/inject rows),
  2. barrier, each block reduces 4-5 of the 324 rows,
  3. barrier, the up projection (a thread pair per row) and the same epilogue as gr_up_kernel.

An ablation found only two parts that matter: the down projection split by columns over all 80 blocks, and one launch instead of three. Prefetching the up weights (into registers, or touching them into L2 / Infinity Cache across the barrier) and prefetching the epilogue inputs measured 0 and were removed - the 13 MB are read from VRAM once either way.

tokensdefault read, uspersistent, us
151.638.11.35x
255.138.91.41x
360.040.51.48x
463.943.61.46x
567.643.11.57x
671.546.11.55x
796.446.32.08x
8104.449.72.10x

(hc_persist_bench.cpp, one card, a graph of 48 reads over 40 weight sets so the weights are cold, best of 3.)

Safety: what happens on a card it was not written for

strata hc: CUDA0: STRATA_HC_PERSIST=1: the verifier's hyper-connection read runs as one persistent kernel (80 blocks on
40 multiprocessors, up to 8 tokens; 0 token counts timed out in the check; checked against the default read, max
relative difference 1.8e-07)

Smaller cards, simulated on one 6900 XT with HSA_CU_MASK (ROCR_VISIBLE_DEVICES=1), both with ROCm 10.0 and with the HIP 7.1 runtime (the same numbers within 0.2 us):

WGPs (CU mask)liketokenspersistent vs default
406900 XT1-81.35-2.10x
30 (0:0-59)68001-81.36-1.84x
20 (0:0-39)6700 XT's CU count1-81.38-2.07x
5 (0:0-9), 1 (0:0-1)--check timed out, default read, no hang

The mask keeps Navi 21's 256-bit bus and 128 MB Infinity Cache; a real 6700 XT / 6600 (narrower bus, smaller cache) is not simulated by it.

End to end

strata-split.json: --layer-split, IQ3_S, --kv int8 --kv-resident 32768, speculation 3 with min-p 0.7, --pipeline-windows 2, STRATA_SH_STREAM=1, STRATA_SPLIT_MTP_BATCH=1. Main (a0116b27) with this change, one binary, cold server per arm, the variable unset (default) and set alternating, 6 rounds, two 4K and two 32K requests per arm (256 tokens out), ms per verify window from STRATA_DECODE_TIMING:

default readSTRATA_HC_PERSIST=1rounds
4K, ms per window25.8124.73-4.2 %-4.3 / -2.6 / -3.6 / -3.4 / -5.8 / -5.2
32K, ms per window24.4023.72-2.8 %-2.8 / -2.1 / -5.6 / -2.7 / -1.3 / -2.1
tokens per window1.93 / 1.941.92 / 1.94
prompt, tok/s (4K / 32K)848 / 1,636850 / 1,632

Run-to-run noise in ms per window is about +-3 % per round here, which is why the rounds alternate. An earlier version of the kernel (the up weights prefetched into registers, since removed) measured -2.8 % / -2.0 % against the default read (two builds, 6 rounds) on Unsloth UD-Q4_K_XL (STRATA_MMQ_KQUANTS=ON, 0.1.42); this version was not re-measured on it.

Ten interleaved pairs, no other switch

0.1.43.1 (a0116b27) with this change, one binary, the engine's defaults (no environment variable at all) plus STRATA_DECODE_TIMING=1, the variable unset / set. IQ3_S layer split, --spec 3 --spec-min-p 0.7 --pipeline-windows 2, no vision. Ten pairs of cold servers, the order inside a pair alternating (off-on, on-off, ...), one 4K and one 32K request per server, 256 tokens out. Each server's log carries the STRATA_HC_PERSIST=1 line on both cards when set and not when unset (checked per arm).

ms per verify windowunset (median)set (median)per-pair medianpairs fasterthe ten pairs
4K27.0825.26-6.6 %10 / 10-3.5 -8.5 -6.1 -7.1 -1.3 -8.0 -5.7 -4.2 -8.2 -10.3
32K26.3725.15-4.4 %10 / 10-6.2 -5.8 -1.9 -2.9 -4.7 -2.1 -5.3 -9.2 -3.4 -4.1

Without the other switches the default read is a larger share of the window, so the gain is larger than in the 6-round table above.

Quality

STRATA_LOGPOS over three chats (9.4K, 34.7K, 105.8K tokens; ~500 scored positions each, top-256), pipeline windows off, on this PR's code on main (a0116b27). Only the 106K chat is reproducible run to run on this machine (the first two differ in all positions between two runs of the same binary), so it is the one compared. STRATA_HC_PERSIST=3 is a reference that accumulates the same kernel in double.

106K chat, against the double referenceKL meanargmax same
default read0.013695.0 %
STRATA_HC_PERSIST=10.013196.3 %

On 0.1.42 the same comparison gave 0.047 (default) and 0.038 (the earlier version of the kernel).

Default path unchanged: main (a0116b27) built without and with this change, the same options, the variable unset: the 106K chat's 481 scored positions are bitwise identical. With the variable unset fused_gr_persist_init and fused_gr_read_persist return in their first line.

0 stalls in every engine run with it (more than 30); three Strata slots on this machine use it daily since 2026-10-12.

Tried and dropped

Not tested

Help wanted

On any RDNA card, with STRATA_HC_PERSIST=1 in the engine's environment:

  1. the strata hc: line from the engine log (does it run, up to how many tokens, any timeouts?), and
  2. two runs of the same prompt with STRATA_DECODE_TIMING=1, with and without the variable (ms per window).

To time the read alone (from the repository root, after a HIP build in build/):

hipcc -O3 --offload-arch=<your gfx> -I include -c bench/results/2026-10-12-hc-persist-gfx1030/hc_persist_bench.cpp -o hcpb.o
hipcc --offload-arch=<your gfx> hcpb.o build/libstrata_kernels.a build/libstrata_core.a -lrocblas -o hc_persist_bench
STRATA_HC_PERSIST=1 ./hc_persist_bench

Developed with an AI coding assistant; every number above was measured on 2x RX 6900 XT (gfx1030, PCIe 4.0 x8 each) / Ryzen 5 5600X, ROCm 10.0.