mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-05 07:48:45 +00:00
qsa_prefill_attn runs INT8 pools through int8 mma (m16n8k32): a block per (KV head, query), its 12 query heads the rows of the fragments, 64 cells a tile. q and the probabilities go in as 24-bit fixed point, three 8-bit limbs each (q against its row's power-of-two bound, a probability times its V scale against the tile's), so the integer sums are exact; converting the limbs back takes magic-number adds and FMAs, not I2F. The block is warp-specialized: 4 warps score 16 cells each over all 256 dims (q's limbs in registers) and run the online softmax, 4 multiply a 64-dim group of V each (V through ldmatrix.trans, cells and dims permuted inside the fragments), 4 fetch K, V and their scales by cp.async into rings of 2 and 3 slots, the pool rows two tiles ahead; named barriers between them. FP16 pools keep the FP32 kernel. On a 131K-token prompt's selections (one layer, 2048 queries, cells spread over 131K): 2.5e-6 of a head's largest output from FP64 at worst, 2.6e-7 on average (the FP32 kernel 3.1e-6 and 4.6e-7); 16-bit fixed point for q or the probabilities would be ~5e-4. 10.8 -> 3.5 ms a call (4.5 ms with the clocks settled; gathering the cells alone takes 2.0 ms, the L2's limit). --prefill-profile, IQ3_XXS: QSA attention 16K 0.95 -> 0.39 s, 131K 8.6 -> 3.4 s. Prompt time, both GPUs: 16K 8.96 -> 8.34 s (1832 -> 1970 tok/s), 131K 69.5 -> 64.1 s (1886 -> 2044 tok/s). Not bitwise: 300 tokens of fixed text after the 16K prompt give 4 (IQ3_XXS) and 2 (UD-Q4_K_XL) different argmaxes, all near-ties by llama.cpp's probabilities (0.39/0.36, 0.27/0.20, 0.32/0.43, 0.42/0.41; 0.36/0.52, 0.32/0.57), llama.cpp siding with the old build at 3 and the new at 3. verify_parity: within 2.4e-6 of the decode kernel. Claude-Session: https://claude.ai/code/session_01YDx8gSYSbts2783qXv2Nxz