Repository navigation
[FlyDSL] FlyDSL QSA indexer scorer + sparse GQA - #5996
SamiAario-AMD wants to merge 178 commits into
Conversation
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: |
05c08d3 to
5f182c1
Compare
|
I'm not sure if we need other public entry points than Also |
5f182c1 to
1bdae6e
Compare
There was a problem hiding this comment.
Thanks Sami. I'm wiring this into vLLM's Qwen4Exp (Flash-Next) QSA path at TP2, and hit three things. Details are inline.
- K2 copies vLLM's paged KV cache on every call. vLLM keeps a QSA layer's K and V in one
[pages, page_size, H, 2*D]buffer and hands attention two strided views of it (kv_cache.transpose(1, 2).split(D, dim=-1)invllm/models/qwen4_exp/amd/qsa.py).qsa_k2makes both contiguous, which copies the whole layer's K/V cache rather than the selected rows, and does it inside every captured decode graph.qsa_k2_servesaccepts those views, so nothing flags it. autonever picks FlyDSL beyond TP1._MEASURED_QUERIESis keyed on the per-rank GQA shape. Flash-Next has 24 query heads over 2 KV heads, so at TP2 a rank sees(12, 256)over 1 KV head, andqsa_layer(backend="auto")stays on Triton without logging anything.- Please keep
qsa_k1_block_idsandqsa_k2public. This is about your comment on narrowing the public entry points toqsa_layer. In vLLM, selection runs inside the indexer, and sparse attention runs later in the attention owner after the KV-cache update. MTP also reuses one step's selection across later draft steps (skip_topk), so the two halves don't run back to back. vLLM's integration therefore calls K1 (and then the same expand kernel) and K2 separately rather thanqsa_layer. Dropping the Triton backend fromqsa_layeris fine from our side.
Proposed fix for 1: one commit on top of this branch, mjkvaak-amd@4a932f0. The inline suggestions below are the call-site parts of it.
- Normal path: only the
.contiguous()calls go. FlyDSL passes a torch tensor's non-leading strides at runtime by default (layout-dynamicTorchTensorJitArg), and the normal-path descriptor already indexes through that layout. - Over-4 GiB path: it takes the page, token and head strides as build parameters of
build_qsa_k2_module/_plan. A non-dense set is added to the kernel name, so dense caches keep today's symbols and AOT names. - 4 GiB decision: it uses the view's byte span.
numelundercounts a K|V-interleaved view by about 2×. qsa_k2_serves: it now rejects views the kernel can't read in place.- Tests: two new K2 cases in
op_tests/test_flydsl_qsa.py.test_k2_interleaved_kv_view_matches_contiguousrequires bit-equal output against contiguous copies, at family A and its TP2 shard, M = 2 and 512.test_k2_interleaved_kv_page_past_4gibuses an interleaved view whose far page starts at byte 2^32. Itsnumelalone would pick the narrow descriptor.
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Dispatch gaps, unsafe Triton output handling, dropped scale parameters, and backend-scope violations must be resolved.
Review effort: Balanced
Findings: 2
Open (22)
Validate output shape, dtype, and device · New Validate the supplied output tensor · New Mirror build constraints in qsa_k2_serves · New Gate auto backend selection by supported GPU architecture · New Fallback for unsupported FlyDSL selection geometry · New Propagate score and softmax scales to Triton · New Require contiguous metadata for kernel indexing · New Initialize visible_blocks when columns are zero · New Validate compression ratio and token_topk · New Handle strided expansion metadata tensors · New Handle empty selection widths without negative shifts · New Use gfx950 architecture identifier in tuning rationale · New Correct the section marker to §2.1 · New Complete qsa_layer public documentation · New Reuse probe as the indices output buffer · New Keep Triton kernel modules free of PyTorch dependencies · New Add config-aware repr to Triton kernels · New Move hardcoded Triton tuning values to config JSON · New Document the public entry point contracts · New Move dispatch tuning values into config JSON · New
And 2 more that still need to be addressed.
What changed in this PR
Adds a FlyDSL QSA indexer and sparse GQA path, with automatic dispatch and a pinned Triton fallback.
Changes:
- Implements FlyDSL K1/K2 kernels, paging utilities, oracle, and shape contracts.
- Adds public dispatch, architecture gating, and AOT jobs.
- Vendors the live AMD Triton QSA fallback.
| File | Description |
|---|---|
op_tests/qsa_shapes.py |
Defines validated QSA fixtures. |
aiter/ops/triton/attention/qsa_vllm_amd.py |
Exposes Triton fallback APIs. |
aiter/ops/triton/_triton_kernels/attention/qsa_vllm_amd.py |
Implements pinned Triton QSA kernels. |
aiter/ops/flydsl/qsa.py |
Provides public QSA dispatch and composition. |
aiter/ops/flydsl/kernels/qsa/shapes.py |
Defines QSA shape descriptors. |
aiter/ops/flydsl/kernels/qsa/paged.py |
Adds paged-cache helpers. |
aiter/ops/flydsl/kernels/qsa/oracle.py |
Implements the FP32 reference. |
aiter/ops/flydsl/kernels/qsa/k2.py |
Implements sparse GQA. |
aiter/ops/flydsl/kernels/qsa/k1.py |
Implements scoring and block selection. |
aiter/ops/flydsl/kernels/qsa/arch.py |
Defines the architecture allowlist. |
aiter/ops/flydsl/kernels/qsa/__init__.py |
Exports QSA helpers. |
aiter/ops/flydsl/__init__.py |
Exposes public QSA symbols lazily. |
aiter/aot/flydsl/qsa.py |
Registers QSA AOT jobs. |
aiter/aot/flydsl/common.py |
Adds QSA to AOT dispatch. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
mjkvaak-amd
left a comment
There was a problem hiding this comment.
Thanks for taking d10d02a and the per-TP rows so quickly. Two follow-ups from running this in vLLM, inline:
- K1 (
k1.py:920): correction to my earlier comment. I said vLLM's compressed indexer cache is contiguous, so K1's.contiguous()was harmless. That was wrong: in a real server the cache arrives as a strided view, so K1 has the same whole-cache copy problem K2 had. - TP2 row (
qsa.py:54). That shape was swept on gfx942. On gfx950 end-to-end at TP2, the FlyDSL arm lost to the existing AMD path in all three probe cells. It's not yet separated from my vLLM glue, so I'm treating it as a flag rather than a verdict.
…r and sparse GQA With VLLM_ROCM_QSA_FLYDSL=1, QSA selection scores and ranks compressed blocks with FlyDSL K1 from ROCm/aiter#5996 and keeps the Triton expand, and sparse GQA runs FlyDSL K2 directly on the paged K|V cache views. Shapes either kernel cannot serve stay on the Triton path. The kernels are called directly rather than through qsa_layer, whose auto mode only admits the TP1 query shape, and so that MTP's top-k reuse is unchanged. Signed-off-by: Mikko Tukiainen <[email protected]>
8ad96f4 to
d4cac25
Compare
|
In vLLM (#59437), K1 is slower than the existing Triton path because the block table is padded to Fix, cherry-pickable on aab0dd6: mjkvaak-amd@c453761 Both scorers skip tiles past the row's visible blocks; the 16-row scorer uses the block's largest. K1 µs per call, vLLM TP2 shapes, MI355X, CUDA graph replay:
Selections equal Triton's in every row. At 4 decode requests K1 is still 5-13% behind: dead tiles now exit early but are still launched. A tile loop bounded by K2 needs nothing: it matches or beats Triton everywhere (35 vs 45 µs at 64 x 60k). |
The fix is in as df71ed9. I am looking into closing the rest of the gap this revealed, as you suggested. |
|
K1 width readback breaks decode graph capture
Even without the error, a captured readback would freeze the width of the capture batch into the graph. Proposed fix: keep the allocation width while the stream is capturing, as prefill already does. - if n_columns > _ONE_WORKGROUP_MAX_ROW_WIDTH and m <= _DECODE_MAX_ROWS:
+ if (
+ n_columns > _ONE_WORKGROUP_MAX_ROW_WIDTH
+ and m <= _DECODE_MAX_ROWS
+ and not torch.cuda.is_current_stream_capturing()
+ ):
live_columns = _k1_max_visible_columns(Cherry pick
|
|
In vLLM serving, every K1/K2 call takes the wide (>4 GiB) path, and that path is what makes FlyDSL QSA lose to Triton end to end On Qwen3.8-Flash-Next TP2 (MI355X), turning 1. The serving cache is always wideI logged vLLM allocates one KV pool and hands each layer a strided view into it, so the page stride covers every layer's page. Each view spans the whole pool, here 194 GiB, whatever its 2. The wide body serializes the row gathers in waterfall loops
3. Kernel timings at vLLM's shapes, narrow vs wideOne MI355X on an otherwise idle node. Decode is timed under HIP-graph replay, prefill eagerly as vLLM runs it. The block table is padded to
4. K1 drops to the one-row scorer for any batch with more than one request
Changes needed
I can share the benchmark script (decode under graph replay, prefill eager, both layouts) if that helps. |
039ed37 to
cf5d41f
Compare
… selector under capture.
…that buffer twice.
…alling back on an unmeasured query.
- Launch the vendored QSA expand kernel from the public wrapper so the kernel module does not import PyTorch. - Document the packed block-id selection contract on qsa_layer. - Document the QSA AOT jobs as a family-A TP1 warm set that still requires runtime JIT. - Accept a caller-owned K1 score buffer so long-row scoring does not allocate it inside the call. - Move QSA K1 host dispatch into qsa.py so the kernel module only builds the indexer-select kernels. - Move QSA K2 host dispatch into qsa.py so the kernel module only builds the sparse-GQA kernel. - Dispatch QSA from get_gfx_runtime so the tile follows the live GPU rather than GPU_ARCHS. - Move the QSA oracle and paging fixtures out of the kernel package so the library keeps only span_bytes. - Rename the vendored QSA expand modules to qsa_expand so the filename belongs to AITER. - Rename QSA K1 and K2 to indexer and sparse GQA so the API, builders, and AOT jobs share one vocabulary. - Rename the remaining QSA labels to supported, decode scores, Flash-Next, and Gluon-parity so the names match the operations. - Reword the leftover QSA family and kernel labels so comments use the same names as the API. - Name the QSA expand specialization from its constexprs so the compiled kernel matches the other Triton kernels. - Gather the QSA indexer through a shared-pool page stride so the wide compile is tested past a doubled page. - Cover two-prompt QSA prefill for the indexer and sparse GQA so each request is checked against the oracle. - Drop the QSA experiment diary and stage labels so the comments keep the dispatch rules. - Document that qsa_layer runs only on gfx942 and gfx950. - Document expand_qsa_block_indices so the launcher states dtypes, width, and padding.
- Score a visible indexer prefill block on an invalid page as -inf so it cannot tie into the top 512. - Move the QSA shape fixtures into qsa_ref so the test no longer imports a shapes module.
… wave per D slice instead of one workgroup per head.
Adopt the tiling of vLLM #62589's Triton indexer scorer in the FlyDSL 16-row scorer: - 16 rows x 64 columns per workgroup, one wave per 16 columns over the whole head dim, so the heads accumulate in registers and each wave writes its scores directly; the cross-wave LDS C reduction is gone. - A row tile may span requests. Each request in the tile gathers its own K and writes only its own rows, so mixed prefill + decode, multi-prompt prefill and MTP batches take the 16-row scorer (from two rows per request on average) instead of the one-row scorer. - Row tiles vary fastest in the grid, so resident workgroups share K. Signed-off-by: Mikko Tukiainen <[email protected]> Co-authored-by: Cursor <[email protected]>
…fill - A prefill workgroup (16+ rows per request) walks four consecutive column tiles with one Q staging and one row setup; MTP keeps one tile per workgroup so the grid still fills the machine. - Q is staged per request next to the K gather, so its loads overlap the page-table lookup, and K validity uses the request's visible bound instead of reloading context_lens. - More than 64 rows select with the stable decode radix at any width. It stops at each row's length, and on the padded 65856-column table it ran 1.3x to 1.8x faster per 509-row chunk than the streaming selector. Signed-off-by: Mikko Tukiainen <[email protected]> Co-authored-by: Cursor <[email protected]>
With 4 indexer heads, 4 rows x 4 heads fill the 16-row MFMA M axis. In the C layout each lane then holds one row's four heads, so the ReLU head sum stays in the lane and a tile is 4 rows: an MTP batch with 4 rows per request has one request per tile, with no per-request loop and no MFMA work on other requests' rows. Batches under 16 rows per request use it; prefill keeps the 16-row tile, which reuses each K tile over 16 rows. The spanning-requests test adds uneven MTP rows (folded tiles straddle requests) and a 20-rows-per-request batch (multi-tile blocks that span requests). Signed-off-by: Mikko Tukiainen <[email protected]> Co-authored-by: Cursor <[email protected]>
- QSA K1: pad LDS rows so the MFMA reload misses bank conflicts. - Keep short QSA K1 row-scorer launches parallel
- Use the in-tree QSA expand and drop the vendored Triton kernel. - Rename the paged FlyDSL QSA host so it is distinct from the pool sparse decoder. - Replace leftover K1 and K2 names with indexer and paged GQA.
- Reuse shared QSA helpers and drop a redundant exp2 wrap. - Stop exporting QSA helpers that are not defined. - Time Flash-Next sparse GQA at the TP2, TP4, and TP8 head counts. - Drop unpinned QSA speed notes from the dispatch comments.
- Reject overlapping QSA score rows before launch. - Validate QSA expand indices before any launch. - Drop the unused QSA prefill LDS estimator. - Note the dynamic score stride on the folded-head store. - Keep qsa_k1_block_ids and qsa_k2 as one-release aliases. - Qualify the indexer LDS bank comment per architecture. - Update the indexer comment for rows above 64. - Fix D=128 decode sparse GQA for group 16 and one split. - Carry the compact selector cursor in registers. - Pack indexer block ids off a missing page. - Drop missing pages inside emit and the one-workgroup radix. - Address the prefill V store from the kv LDS symbol. - Derive folded-head lane indexes from the QK atom. - Reject sparse GQA tiles that do not fit in LDS. - Use the stable FlyDSL surface in the QSA kernels. - Rotate wide-cache timing across the pages the gather reads.
- Name why the folded Q fill stays a thread-linear copy. - Record that wide cold rotation shares one pool and distinct page addresses. - Document the gfx950 D=128 decode PV MFMA miscompile. - Make finite_only top-k reject NaN and +inf. - Broadcast the indexer wave total with gpu.shuffle_idx. - Keep the sparse GQA running max and masked scores at the finite -1e20 floor. - Scale the online softmax with fx.math.exp2. - Synchronize the LDS tile with gpu.barrier.
- Skip the empty indexer block-id fill while keeping the causal tail. - Fail QSA end-to-end benches when a candidate is outside its tolerance. - Replace private QSA mechanism checks with the public split-merge contract. - Import the QSA oracle as a package or sibling so the sweep script needs no sys.path edit. - Cover a four-tile request span and replay dynamic indexer row bounds. - Time QSA end-to-end benches on preallocated indexer and output buffers. - Rewrite three captured indexer lengths so the second replay checks dynamic row bounds. - Keep the QSA row-scorer grid row-fast after the XCD remap measured slower. - Use the shared unsigned divide and typed integer min/max in the QSA kernels.
…s softmax weight.
- Move QSA fp32 reference into test_flydsl_qsa.py and drop op_tests/qsa_ref.py - Drop ticket and external-doc references from QSA code and tests - Stage the 16-row indexer Q tile once per row tile - Fix the compact top-k race on the threshold-bucket count - Return a reason from the QSA support gates on an unsupported arch - Report skipped QSA GPU tests as skips - Keep qsa_indexer_block_ids returning a tensor - Key QSA compiles by tensor layout so a width-1 axis cannot stick - Describe QSA layouts by their strides instead of another caller - Drop the QSA LDS pad probe and its prefill V-store test - Drop the unused QSA AOT compile path and its torch patches - Use the row-bounded indexer selector for eager padded decode - Dispatch supported QSA shapes to the FlyDSL indexer and sparse GQA - Drop the D=128 decode PV MFMA workaround, no longer needed on gfx950 or gfx942 - Cap the FlyDSL indexer score workspace at 128 MiB and score long batches in row chunks - Scale the QSA prefill split target by the device CU count
- Slim test_flydsl_qsa to a sweep with shared edge checks - Remove the unused QSA gather_paged_cache helper - Add untimed wide interleaved KV coverage to QSA paged GQA test - Replace the QSA wide-cache timing harness with a rotating wide-view wrapper - Time packed and wide QSA caches in the default sweep and drop --cache-layout - Trim QSA test docstrings to one-line purposes - Drop qsa_k1_block_ids and qsa_k2 - Delete check_qsa_warns_once - Factor the QSA sweep table footers into one _summarize helper - Remove the QSA test's header prose block - Collapse the QSA sweep loops in main() into shared decode/prefill and Gluon loops - Share the QSA test fixture builders across the indexer and GQA cases - Delete dead QSA oracle arguments, unread spec fields, and redundant fixture guards
- Drop qsa_layer and warn once for an unswept sparse GQA query - Make FlyDSL QSA dispatch opt-in with allow_flydsl, default off - Publish qsa_indexer_row_bounded so the sweep stops reading private cutoffs
e8c14eb to
3483742
Compare



Motivation
Add a FlyDSL QSA layer so the measured Flash-Next / qwen4_exp shapes can run the indexer and sparse GQA on FlyDSL. A rank-3 pair outside that measured table logs once and still runs FlyDSL. A query that is not rank 3 does not log; the indexer or sparse GQA reports it.
Family A is the production shape: indexer query
[M, 4, 128]or[M, 8, 128]BF16 over paged compressed K, and sparse GQA query[M, 24, 256]BF16 over paged K/V with 2 KV heads. Family B is the #4882 Gluon-parity shape (Hq=10,D=128, indexer heads 4 or 8). The family A goal is an end-to-end layer that beats the live AMD kernels pinned from vLLM.Jira ID : SILOTIGER-1047
Technical Details
Public entry points are on
aiter.ops.flydsl.qsa_k1_block_idsandqsa_k2remain as one-release aliases ofqsa_indexer_block_idsandflydsl_qsa_paged_gqa.qsa_indexer_block_idswrites indexerblock_ids [M, 512]. Rows of at most 512 blocks use the fused emit kernel and skip scoring. Longer rows score with BF16 MFMA into an fp32 score buffer. The one-row scorer tilesBLOCK_N=32. Batches averaging two or more rows per request use the row scorer: 64 columns per workgroup and 16 query rows. gfx942 with 8 indexer heads stays on the one-row scorer; the row scorer has not been measured there. With 4 indexer heads and fewer than 16 rows per request, that scorer folds 4 rows by 4 heads onto the MFMA M axis, so a tile holds 4 rows. Head counts 4 and 8 are separate compiles. Selection depends on the row count as well as the width. Padded decode, more than 20000 columns and at most 64 rows, selects with the one-workgroup radix on the full width and stops at each row's visible length. Prefill, more than 64 rows, keeps the allocation width and uses the stable decode radix. A packed table at or under 20000 columns uses that radix as well. The scorer's streaming radix is for a prefix at or above 32768 columns on a batch of at most 64 rows that is not the padded-decode path.qsa_indexer_block_idssends that wider table down the padded-decode path instead. The score workspace is at most 128 MiB. Rows past that are scored in chunks, and the scorer and selector stay the ones chosen for the whole batch.flydsl_qsa_paged_gqawrites sparse GQAo [M, Hq, D]at the selected token ids. Decode uses aBLOCK_N=16two-wave tile (128 threads) with split-K and an FP32 LSE merge. Prefill usesBLOCK_N=32over two waves and writes the output directly once the grid fills the machine. Softmax is online in log2. Split bands are fitted onhead_dim(D<=128versus wider). gfx942 overlays K and V in one LDS tile. gfx950 decode overlays one tile. gfx950 prefill keeps separate K and V regions. A tile whose shared memory exceeds that arch's LDS capacity is rejected.qsa_layeris the opt-in. It runs the indexer, in-treeqsa_expand_block_indices(selected blocks plus the incomplete tail), and sparse GQA. The measured table is(Hq, D)at indexer heads 4 and 8:(24, 256)(Flash-Next TP1, 2 KV heads),(12, 256)(TP2, 1 KV head),(6, 256)(TP4, 1 KV head),(3, 256)(TP8, 1 KV head), and(10, 128)(Gluon-parity). A rank-3 pair outside that table logs once and still runs. A query that is not rank 3 does not log. The sigmoid gate and partial RoPE stay outside the layer.qsa_oracleis the fp32 reference. It and the family A and B fixtures live inop_tests/test_flydsl_qsa.py.op_tests/qsa_ref.pyis removed.aiter/aot/flydsl/qsa_paged.pyonly warms Flash-Next TP1 (Family A:Hq=24,Hkv=2,D=256, indexer heads 4, page size 16) on gfx942 and gfx950. The six jobs are the indexer emit kernel, the 4-head one-row scorer (decodeM=1andM=8share it), the 4-head 16-row prefill scorer, and three sparse GQA launches:M=1(BLOCK_N=16, 128 splits),M=8(BLOCK_N=16, 32 splits), andM=512(BLOCK_N=32, one split).tiles_per_wgis a runtime argument of the 16-row scorer. The prefill job isM=512,L=8192, and that launch uses four column tiles per workgroup. The long-row indexer jobs also compile the stable decode radix. Every other compile is built on first use. That includes TP2/4/8 ((12, 256),(6, 256),(3, 256)),(10, 128), the 8-head scorers, the other split counts (M=2is 64 splits,M=16isBLOCK_N=32with 32 splits), every wide-cache stride, the compact one-workgroup and streaming indexer selectors, and the valid-page pack that follows the streaming and split selectors. Wide-cache strides are compile constants, so enumerating the current keys cannot prebuild them. Collapsing those keys into runtime arguments is not part of this change.Test Plan
pytest -q op_tests/test_flydsl_qsa.pyqsa_layeragainst the oracle for Flash-Next and Gluon-parity, a one-time warning for an unswept rank-3 pair, and a HIP-graph replay of decode.(24, 256),(12, 256),(6, 256),(3, 256), and(10, 128), each at indexer heads 4 and 8. The arch allowlist accepts gfx942 and gfx950.HIP_VISIBLE_DEVICES=<gpu> python3 op_tests/test_flydsl_qsa.py --rotate 0M<=8) and prefill, for--gqa24,2/12,1/6,1/3,1; family B indexer (8 heads) and end-to-endqsa_layerat indexer heads 4 and 8; Flash-Next end-to-end at indexer heads 4; decode HIP-graph replay forM<=8. The reference is the fp32 oracle. The sweep fails on an indexer set mismatch or a sparse-GQA or end-to-end error abovertol=1e-2,atol=1e-2. Defaults timeMin{1, 8, 512}and a packed cache. The recorded result passes the fullMlist and--cache-layout packed wide.Test Result
The gfx950 grid below was recorded 2026-11-10 at
30f111b40fon GPU 5 (MI355X, 256 CUs, BDF 0000:85:00.0), flydsl_venv, torch 2.12.0+rocm7.14.0, FlyDSL 0.4.2. Cold--rotate 0, packed and wide caches,--pad-pages 0. Page size is 16, except the Gluon-parity published indexer point, which is page size 8. Packed rows use the harness auto-rotate. Wide rows rotate the live pages inside the stride gaps, and each timed view still spans past 4 GiB. The HIP-graph table is a one-buffer replay and does not follow--rotate. Performance is measured through 32768 context tokens. The device was idle before the unit gate (0% use, about 0.28 GiB resident).get_cu_num()on this GPU is 256. The sweep followed on that device and exited 0 (2026-11-10T08:28:19Z to 2026-11-10T08:35:41Z).Every
errcolumn in that grid is 0. The timed candidate is FlyDSL against the fp32 oracle. Packed and wide are separate rows.M<=8, 56 prefill).(24, 2), TP2(12, 1), TP4(6, 1), and TP8(3, 1), head dim 256.M<=8, same four ranks: 192 rows.(10, 128): 104 rows (52 atL=512andL=2048, 52 atL=8192andL=32768).M=32,L=2048, page size 8: 2 rows.No requested
Mexceeds itsL, so none of those rows were skipped. The six ahead-of-time jobs warm Flash-Next tensor-parallel 1 only. TP2/4/8,(10, 128), the 8-head scorers, and every wide-cache stride in this grid compiled on first use during the sweep. The unit cases inop_tests/test_flydsl_qsa.pycover the oracle, indexer set equality, sparse GQA numerical match, the measured-table warning, and the ahead-of-time job list. On this same idle GPU,HIP_VISIBLE_DEVICES=5 python3 -m pytest -q op_tests/test_flydsl_qsa.pypassed 61 tests in 23.15s (2026-11-10T08:27:47Z to 2026-11-10T08:28:13Z). None were skipped.aiter/aot/flydsl/common.pylistsaiter.aot.flydsl.pa_decode_planinAOT_MODULESimmediately beforeqsa_paged. Importingaiter.ops.qsaloadsqsa_sparse_prefill. The run includestest_qsa_aot_targets_follow_gpu_archs_without_a_device, the large-negative single-token score, the empty-indexer causal tail, the four-tile request span, and the graph replay that rewrites captured lengths.test_flydsl_decode_finite_only_drops_nonfinitewas called directly, becauseop_tests/test_topk_per_row.pyparses argv at import and then runs its sweep. It printed[finite-only] PASS(2026-11-10T08:28:13Z to 2026-11-10T08:28:19Z).On this head, gfx942, GPU 7 (MI300X, 304 CUs, BDF 0000:CF:00.0), flydsl_venv, torch 2.12.0+rocm7.14.0, FlyDSL 0.4.2, 2026-11-10. The device was idle before the unit gate (0% use, about 0.28 GiB resident).
get_cu_num()is 304 andmulti_processor_countis 304.ROCM_PATHpoints at the ROCm SDK wheel root. Every gfx942 run below used an emptyFLYDSL_RUNTIME_CACHE_DIR, so each kernel was compiled and serialized in that run.HIP_VISIBLE_DEVICES=7 python3 -m pytest -q op_tests/test_flydsl_qsa.pypassed 61 tests in 45.71s (2026-11-10T09:16:42Z to 2026-11-10T09:17:30Z). None were skipped. That run includestest_qsa_aot_targets_follow_gpu_archs_without_a_device, the large-negative single-token score, the empty-indexer causal tail, the four-tile request span, the graph replay that rewrites captured lengths, and the compact selector, including the captured decode replay.test_flydsl_decode_finite_only_drops_nonfinitewas called directly and printed[finite-only] PASS(2026-11-10T09:17:54Z to 2026-11-10T09:18:02Z).The compact selector was measured on
topk_per_row_decode_1wg_k512_wave64_wv0_compact1_finite1, whichqsa_indexer_block_idslaunches, and ontopk_per_row_decode_1wg_k512_wave64_wv0_compact0_finite1(2026-11-10T09:04:33Z to 2026-11-10T09:04:39Z).llvm-readobjreports a group segment of 41120 bytes with compact storage and 8352 bytes without. HIP occupancy is 1 workgroup per CU and 2. The compact object has 41 VGPRs and 76 SGPRs; the other has 36 and 74. Both are wave 64 and 1024 threads, one workgroup per row. Width is 32768 and k is 512. A row with 2000 tied winning columns takes the compact buffer. A row of equal scores is past the 4096-candidate limit, so that buffer stays unused while the compact build still reserves its LDS. Both builds matched a stable argsort before timing. Each time is the median of 5 trials of 20 HIP-graph replays, from CUDA events, after 5 warmup replays. Rows that use the compact buffer: M=1 is 49.99 µs against 57.88 µs with compact storage off, M=8 is 50.15 µs against 58.01 µs, and M=64 is 50.45 µs against 58.28 µs. Those grids fit in one wave on 304 CUs. Exact-tie rows: M=1 is 114.46 µs against 114.43 µs, M=8 is 114.58 µs against 114.51 µs, M=64 is 114.87 µs against 114.86 µs, and M=304 is 118.65 µs against 118.58 µs. M=608 is outside this dispatch: 234.16 µs with compact storage and 219.94 µs without it.The perf command from the gfx950 record was run here and exited 0 (2026-11-10T09:18:11Z to 2026-11-10T09:25:53Z). The device was idle before it (0% use). Every
errcolumn is 0, and the row counts match gfx950. Flash-Next indexer: 104 rows (48 decode, 56 prefill). Sparse GQA: 416 (192 decode, 224 prefill). End-to-end: 416. Decode HIP graph: 192. Gluon-parity indexer, 8 heads: 104. Published indexer point: 2. Gluon-parity end-to-end: 208. Each table is split evenly between packed and wide caches. The 2026-10-30 gfx942 perf record and the 2026-11-05 gfx942 unit gate do not describe this head.indexer_select.py,sparse_gqa.py,aiter/ops/flydsl/qsa_paged.py,aiter/aot/flydsl/qsa_paged.py,aiter/ops/flydsl/kernels/topk/topk_per_row_decode_persistent.py, andop_tests/test_flydsl_qsa.pydiffer from0a90af8e54bband from48cdcb28588a.op_tests/qsa_ref.pyis removed.sparse_decode_attn.pyandsparse_decode_reduce.pyare the same blobs as those commits.Submission Checklist
aiter/ops/flydsl/kernels/qsa/(indexer_select.py,sparse_gqa.py,sparse_decode_attn.py,sparse_decode_reduce.py) and theqsa_paged/qsa_sparse_decodelaunchers.Kept on purpose: 1k MFMA pair and
ds_read_tr16_b64insparse_decode_attn.py(register layout / swizzled LDS address);cvt_scalef32_pk_bf16_fp8(raw ODS operands);ds_write2st64_b64inline asm androcdl.exp2insparse_gqa.py(no atom, andv_exp_f32rather thanmath.exp2).PR Self-Review
Reviewed revision
30f111b
Behavior and intent
AITER has no FlyDSL indexer or sparse paged-GQA path for the Flash-Next and Gluon-parity QSA shapes, so those calls stay on the live AMD kernels. This revision adds
qsa_indexer_block_ids,flydsl_qsa_paged_gqa, andqsa_layeron gfx942 and gfx950, and keepsqsa_k1_block_idsandqsa_k2as one-release aliases. Measured rank-3 pairs are(24, 256),(12, 256),(6, 256),(3, 256), and(10, 128)at indexer heads 4 and 8. An unswept rank-3 pair logs once and still runs FlyDSL. The CI edit makesop_tests/test_flydsl_qsa.pyrun its pytest cases and then the perf script. The defaultpython3invocation only sweeps and would leave the unit cases uncollected.Validation and unverified scope
Unit gate on this head, gfx950, GPU 5 (MI355X, 256 CUs, BDF 0000:85:00.0), flydsl_venv, torch 2.12.0+rocm7.14.0, FlyDSL 0.4.2, 2026-11-10. The device was idle (0% use, about 0.28 GiB resident).
get_cu_num()is 256.aiter/aot/flydsl/qsa_paged.pyimportscompile_only_envfromaiter/aot/flydsl/common.py. That module listsaiter.aot.flydsl.pa_decode_planinAOT_MODULESimmediately beforeqsa_paged. Loadingaiter.ops.qsaimportsqsa_expand_block_indicesfromaiter.ops.triton.attention.qsaandflydsl_qsa_sparse_prefillfromaiter.ops.flydsl.qsa_sparse_prefill. The gate was run on this head:HIP_VISIBLE_DEVICES=5 python3 -m pytest -q op_tests/test_flydsl_qsa.py61 passed in 23.15s (2026-11-10T08:27:47Z to 2026-11-10T08:28:13Z). None were skipped. That run includes
test_qsa_aot_targets_follow_gpu_archs_without_a_device, the large-negative single-token score (one split and a merged width, plus a fully masked row), the empty-indexer causal tail, the four-tile request span, and the graph replay that rewrites captured lengths.test_flydsl_decode_finite_only_drops_nonfiniteprinted[finite-only] PASSon this GPU (2026-11-10T08:28:13Z to 2026-11-10T08:28:19Z).op_tests/test_topk_per_row.pyparses argv at import and then runs its sweep, so that check was the function rather thanpytest -k. The unit gate does run the compact selector, including the captured decode replay.Cold
--rotate 0, packed and wide caches,--pad-pages 0. The process exited 0 (2026-11-10T08:28:19Z to 2026-11-10T08:35:41Z):HIP_VISIBLE_DEVICES=5 python3 op_tests/test_flydsl_qsa.py -b 1 2 3 4 6 8 12 16 32 64 128 256 512 -s 512 2048 8192 32768 --rotate 0 --cache-layout packed wide --gqa 24,2 12,1 6,1 3,1Every
errcolumn is 0. Flash-Next indexer: 104 rows (48 decode, 56 prefill). Sparse GQA: 416 (192 decode, 224 prefill). End-to-end: 416. Decode HIP graph: 192. Gluon-parity indexer, 8 heads: 104 (52 atL=512andL=2048, 52 atL=8192andL=32768). Published indexer point, 4 heads: 2. Gluon-parity end-to-end: 208. The indexer, sparse GQA, Gluon-parity indexer, published-point, end-to-end, HIP-graph, and Gluon-parity end-to-end tables were counted from the logged summaries. No requestedMexceeds itsL, so none of those rows were skipped. The sweep does not callqsa_sparse_prefill.Unit gate on this head, gfx942, GPU 7 (MI300X, 304 CUs, BDF 0000:CF:00.0), flydsl_venv, torch 2.12.0+rocm7.14.0, FlyDSL 0.4.2, 2026-11-10. The device was idle (0% use, about 0.28 GiB resident).
get_cu_num()is 304 andmulti_processor_countis 304.ROCM_PATHis the ROCm SDK wheel root, andFLYDSL_RUNTIME_CACHE_DIRstarted empty, so every kernel below was compiled and serialized in its run. The gate was run on this head:HIP_VISIBLE_DEVICES=7 python3 -m pytest -q op_tests/test_flydsl_qsa.py61 passed in 45.71s (2026-11-10T09:16:42Z to 2026-11-10T09:17:30Z). None were skipped. That run includes
test_qsa_aot_targets_follow_gpu_archs_without_a_device, the large-negative single-token score, the empty-indexer causal tail, the four-tile request span, the graph replay that rewrites captured lengths, and the compact selector, including the captured decode replay.test_flydsl_decode_finite_only_drops_nonfiniteprinted[finite-only] PASSon this GPU (2026-11-10T09:17:54Z to 2026-11-10T09:18:02Z).topk_per_row_decode_1wg_k512_wave64_wv0_compact1_finite1(launched byqsa_indexer_block_ids) andtopk_per_row_decode_1wg_k512_wave64_wv0_compact0_finite1were measured on this GPU (2026-11-10T09:04:33Z to 2026-11-10T09:04:39Z). Group segment is 41120 bytes and 8352 bytes. HIP occupancy is 1 workgroup per CU and 2. VGPRs/SGPRs are 41/76 and 36/74. Both are wave 64 and 1024 threads, one workgroup per row, width 32768, k=512. A row with 2000 tied winning columns uses the compact buffer. An equal-score row is past 4096 candidates, so the buffer stays unused. Both builds matched a stable argsort. Each time is the median of 5 trials of 20 HIP-graph replays, CUDA events, after 5 warmup replays. Compact-buffer rows: M=1 49.99 µs against 57.88 µs, M=8 50.15 µs against 58.01 µs, M=64 50.45 µs against 58.28 µs. Exact-tie rows: M=1 114.46 µs against 114.43 µs, M=8 114.58 µs against 114.51 µs, M=64 114.87 µs against 114.86 µs, M=304 118.65 µs against 118.58 µs. M=608 is outside this dispatch: 234.16 µs with compact storage and 219.94 µs without it.The gfx950 perf command was run on this GPU and exited 0 (2026-11-10T09:18:11Z to 2026-11-10T09:25:53Z). The device was idle (0% use).
HIP_VISIBLE_DEVICES=7 python3 op_tests/test_flydsl_qsa.py -b 1 2 3 4 6 8 12 16 32 64 128 256 512 -s 512 2048 8192 32768 --rotate 0 --cache-layout packed wide --gqa 24,2 12,1 6,1 3,1Every
errcolumn is 0, and each table has the gfx950 row count, split evenly between packed and wide caches. Flash-Next indexer: 104 rows (48 decode, 56 prefill). Sparse GQA: 416 (192 decode, 224 prefill). End-to-end: 416. Decode HIP graph: 192. Gluon-parity indexer, 8 heads: 104. Published indexer point, 4 heads: 2. Gluon-parity end-to-end: 208.indexer_select.py,sparse_gqa.py,aiter/ops/flydsl/qsa_paged.py,aiter/aot/flydsl/qsa_paged.py,aiter/ops/flydsl/kernels/topk/topk_per_row_decode_persistent.py, andop_tests/test_flydsl_qsa.pydiffer from0a90af8e54bband from48cdcb28588a.op_tests/qsa_ref.pyis removed. The 2026-10-30 gfx942 perf record and the 2026-11-05 gfx942 unit gate do not describe this head.sparse_decode_attn.pyandsparse_decode_reduce.pyare the same blobs as those commits.PR-specific question
The only CI edit is a case in
.github/scripts/aiter_test.shforop_tests/test_flydsl_qsa.py. It runspython3 -m pytest -qon that file, thenpython3on the same path, under the existing 60-minute timeout. The path is the shard-list entry passed as$1. The bash body does not interpolate the PR title, body, or comments.aiter-test.yamlis unchanged and still triggers onpull_request. The standard job already checks out the PR head and executes that checkout. Fork pull requests still do not receive registry secrets: Docker login stays gated on a non-fork head. This case adds nopull_request_targettrigger, token permission,id-token, or S3 upload. Fork code can already run as the GPU test process. It cannot reach the main-only AWS upload role or the fork-withheld Docker credentials through this change.Changed op tests
qsa_oracleand the Flash-Next and Gluon-parity fixtures (visible blocks, tie-break, incomplete tail, paged gather) live inop_tests/test_flydsl_qsa.py.op_tests/qsa_ref.pyis removed, so the reference is not a second suite and is not copied into the kernel package.op_tests/test_flydsl_qsa.pyis new. Pytest covers indexer set equality, invalid pages, wide caches past 4 GiB, D=128 group-16 and single-split GQA, LDS rejection, graph capture with a second replay of rewritten lengths, a four-tile request span, the empty-indexer causal tail,qsa_layeragainst the oracle, andtest_paged_gqa_large_negative_score_keeps_weight(one live token whose scaled score is below -1e20, at one split and at a merged width, plus a fully masked row).__main__is the perf sweep.test_flydsl_qsa_sparse_decode.pycovers the pool sparse decoder, and the Triton QSA tests do not call these FlyDSL entry points. The new CI case is what runs the pytest layer.python3alone does not.op_tests/test_topk_per_row.pyaddstest_flydsl_decode_finite_only_drops_nonfinite. The indexer selector now passesfinite_onlyand must drop NaN and +inf. The existing sampled-NaN checks rank NaN above +inf whenfinite_onlyis false, so they stay green iffinite_onlystill returns a nonfinite column.