mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[GH-ISSUE #5523] [Engine] prompt_attn_v70: measured — K/V union is bitwise-safe and ~2x for fp16/K8V4 on Volta (1→2 blocks/SM); int8 stays at 2 blocks, launch_bounds(,3) spills +8% #5496
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#5496
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Lennier on GitHub (Nov 7, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/5523
Hardware/stack (ours): Tesla V100-SXM2-32GB (sm_70, SXM2→PCIe adapter), Windows Server 2022, driver 582.16, engine 0.1.57 (Strata v0.2.11,
c3b3f503), IQ3_S pack,--kv int8 --max-context 262144 --prefill auto:32768.Problem (measured, nsys 2025.1.3, one 101,733-token prefill; window 50.4 s, GPU-busy 45.7 s)
prompt_attn_v70_kernel<1>is the top single kernel after expert GEMMs: 6.35 s = 13.9% of GPU-busy, 48 calls (12 QSA layers × 4 chunks), avg 132.3 ms. CUPTI launch records: 128 threads, 218 registers/thread, 47,568 B dynamic smem → 2 blocks/SM (25% occupancy); 3 blocks would need 83.7K regs > 65.5K per SM.The kernel is already tensor-core-optimized (
mma.m8n8k4, hi/lo q split) and the alternative path is worse on this card by your own numbers (NVIDIA_V100.md, 114K: 973 vs 1123 t/s forSTRATA_PROMPT_ATTN_OLD=1). Remaining headroom looks like occupancy/ILP, not kernel choice.Proposed directions (now MEASURED on our box — we built and A/B-tested the patch locally)
We applied the K/V union to
Smem70(V's loads still issue at the gather, the store moves after the scores' closing sync; zero extra syncs) and A/B'd it withqsa_prompt_attn_parity+qsa_prompt_attn_sm70_bench(0.1.58, q=4096, ctx 32K/131K, reps 10):--kv int8): 47,568 B already gives 2 blocks/SM (95,136 ≤ 98,304); the union's 38,864 B still gives 2 (3 blocks need ≤32,768).__launch_bounds__(THREADS, 3)alone just caps regs 218→170 and spills: +8% slower (23.08 vs 21.30 ms). Union alone: −2.3% (20.77 ms) - small, scheduling/L1, not occupancy.qsa_prompt_attn_parityoutput checksums bitwise identical to unpatched (the patch only reorders stores). We did not ship it (our live mode is int8, below our +5% bar), but it looks like a free, bitwise-safe ~2x for Volta fp16/K8V4 users.STRATA_QSA_STATselection-overlap diagnostic fromlaunch_wmma(qsa_prompt_attn.cu:2316-2342, HIP-only — on CUDA the key is silent) into the CUDA launcher; it is host-side code. Done and measured on our box (patch: call the same block fromlaunch70, cap raised to 48 = 12 QSA layers x 4 chunks): one 101,816-token prefill, real QSA selections, cap 2051. Mean union of R consecutive queries' selections: x2.39 at R=4, x3.78 at R=8, x5.90 at R=16, x8.90 at R=32 (i.e. adjacent selections overlap only ~58% at R=4; overlap gets slightly worse in deeper chunks: 2.23 -> 2.44). So a row-union attention would cut K/V reads only 1.67x at R=4 while multiplying tensor-core work (masked cells) by 2.39x - and the kernel is TC-bound (our smem/L1 union patch moved it only +/-3%). Row-union verdict: NO at real selection overlap. (The stat costs ~2.2 s a call at n_q=32768 - fine as a diagnostic, the CUDA port is worth having anyway.)What we measured vs not
Measured on our V100: kernel share/avg/call, regs/smem/occupancy (CUPTI), end-to-end prefill t/s A/B at 100K (2 runs/arm, idle, fresh prompts), and now the patch itself:
qsa_prompt_attn_parity(PASS, bitwise) +qsa_prompt_attn_sm70_bench(both ctx, all three KV modes, baseline vs union vs union+launch_bounds). Not measured: e2e with the patch (int8 gain −2.3% kernel × 13.9% share ≈ −0.3% e2e, below noise).Tooling note
Filed separately as its own issue (see #5524): nsys 2025.1.3 converter crash with
STRATA_PREFILL_ROUTED_STREAM=1.