mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-04 15:28:40 +00:00
In a batch window every row reads its own slot's indexer keys and K/V, so each QSA layer ran the selection and attention once per row: four rows (16 slots) or eight (32 slots) times qsa_block_scores, qsa_block_topk and qsa_decode_attn_batch, each launch small (the top-k on one CTA, the attention on cap/64 x 2 blocks). With the switch, per window (up to 8 rows per launch): - block_scores_slots_kernel: grid (256, rows), blockIdx.y runs the single-query block_scores_multi_kernel body with that row's slot keys (block_scores_multi_kernel is now a wrapper around the same body) - qsa_block_topk over the rows in one call (it only reads the rows' scores and steps) - attn_chunk_slots_kernel: attn_chunk_kernel's body with the row's own QsaAttnPools (an 8-entry table passed by value, blockIdx.z picks), then the existing batched merge Each row is computed by the same kernel body with the same reduction order as its own call. The launchers decline (the per-row calls run) where that call would pick another kernel: STRATA_SCORES_MULTI=0, the pre-sm_75 / gfx103x attention, the gfx906 query swizzle. A streamed KV cache keeps the per-row resolve-then-attend loop. Default (switch off): unchanged. Checked on 4x RTX 3090, T16-143gsc setup (layer split 12,24,37, int8 KV): - SASS (sm_86) of every existing kernel in qsa_select.cu and of the default attn_chunk_kernel<M> and the merge is identical before/after; the opt-in lane-cell instantiations differ only in register allocation - new qsa_slots_parity (ctest, also with STRATA_ATTN_LANECELL=1): fp16, int8, q4_0 and int8-K/q4_0-V pools, 1/2/4/8 rows of different slots with their own page tables and contexts 37..32768: scores, ids and attention bitwise identical to one call per row - batch_test16/32 (greedy and t=0.7), batch_interleave_test and batch_overlap_test (STRATA_PIPE_OVERLAP=1) token-identical to the build without the change; with the switch off batch_test16 is byte-identical too - batch decode rows/s (engine level, 30 s, back to back with the reference): 16 slots 683 -> 726 (+6.3 %), 32 slots 750 -> 802 (+6.9 %); STRATA_VERIFY_PROFILE "QSA projections + attention" per stage-window 0.89 -> 0.52 ms (16) and 1.52 -> 0.79 ms (32) HIP: the new code uses only what the existing kernels use; SYCL has its own sources and only sees the new declarations. Neither was built here.