Repository navigation
Conversation
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: |
There was a problem hiding this comment.
🟡 Changes recommended
The wrapper accepts unsupported context-length dtypes and devices that the kernel may misinterpret.
2 open findings
What changed in this PR
Extends the gfx950 FlyDSL paged MQA logits path to consume 2D per-row context-length tables.
Changes:
- Adds runtime row-stride indexing while preserving 1D behavior.
- Validates context-length layout and adds 2D/rejection tests.
| File | Description |
|---|---|
aiter/ops/flydsl/kernels/mqa_logits/fp8_paged_mqa_logits_gfx950.py |
Adds 2D context-length handling. |
op_tests/test_flydsl_fp8_paged_mqa_logits.py |
Tests equivalent outputs and invalid layouts. |
🧠 Review effort: Balanced
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
The kernel reads context_lens as int32 words, so an int64 table gave wrong lengths. Compare the 2D and 1D logits with checkAllclose at zero tolerance.
samremes
left a comment
There was a problem hiding this comment.
Mostly minor nits on docs, validation and tests; no blockers from my side.
…lumns A (B, n) table with n other than next_n read the wrong column as the length.
… sweep -c/--ctx_lens (default 1d 2d) runs the 2D table through the existing sweep, graded against the fp32 reference and timed next to 1D. The rejection checks stay as a small separate test.
Stride 1 builds the pre-2D kernel (same code and name); stride n builds a
variant named ..._cs{n}. _compile() caches one build per stride.
…n range With next_n_lens, row j attends to [0, L_b - n_b + 1 + j) where n_b is min(next_n_lens[b], next_n), not the padded next_n.
|
@samremes My last pushes (the mixed-length test and a docstring fix) dismissed your approval. Could you take another look? |
samremes
left a comment
There was a problem hiding this comment.
Review got dismissed by merging main.
…nel (#6450) * [FlyDSL] Read (B, next_n) context lengths in the paged MQA logits kernel * [FlyDSL] Reject non-int32 or off-device context_lens in paged MQA logits The kernel reads context_lens as int32 words, so an int64 table gave wrong lengths. Compare the 2D and 1D logits with checkAllclose at zero tolerance. * [FlyDSL] Document context_lens in the wrapper; require 1 or next_n columns A (B, n) table with n other than next_n read the wrong column as the length. * [FlyDSL] Make the context_lens layout an axis of the paged MQA logits sweep -c/--ctx_lens (default 1d 2d) runs the 2D table through the existing sweep, graded against the fp32 reference and timed next to 1D. The rejection checks stay as a small separate test. * [FlyDSL] Make the context_lens stride a build-time constant Stride 1 builds the pre-2D kernel (same code and name); stride n builds a variant named ..._cs{n}. _compile() caches one build per stride. * [FlyDSL] Test paged MQA logits 2D context_lens with mixed lengths One case with B=5, next_n=3, distinct lengths and an empty (CUDA-graph padding) request, graded against the fp32 reference for 1D and 2D, with and without SplitKV. The 2D table clamps at 0 like vLLM. * [FlyDSL] Document the live row count in the paged MQA logits attention range With next_n_lens, row j attends to [0, L_b - n_b + 1 + j) where n_b is min(next_n_lens[b], next_n), not the padded next_n.
…nel (#6450) * [FlyDSL] Read (B, next_n) context lengths in the paged MQA logits kernel * [FlyDSL] Reject non-int32 or off-device context_lens in paged MQA logits The kernel reads context_lens as int32 words, so an int64 table gave wrong lengths. Compare the 2D and 1D logits with checkAllclose at zero tolerance. * [FlyDSL] Document context_lens in the wrapper; require 1 or next_n columns A (B, n) table with n other than next_n read the wrong column as the length. * [FlyDSL] Make the context_lens layout an axis of the paged MQA logits sweep -c/--ctx_lens (default 1d 2d) runs the 2D table through the existing sweep, graded against the fp32 reference and timed next to 1D. The rejection checks stay as a small separate test. * [FlyDSL] Make the context_lens stride a build-time constant Stride 1 builds the pre-2D kernel (same code and name); stride n builds a variant named ..._cs{n}. _compile() caches one build per stride. * [FlyDSL] Test paged MQA logits 2D context_lens with mixed lengths One case with B=5, next_n=3, distinct lengths and an empty (CUDA-graph padding) request, graded against the fp32 reference for 1D and 2D, with and without SplitKV. The 2D table clamps at 0 like vLLM. * [FlyDSL] Document the live row count in the paged MQA logits attention range With next_n_lens, row j attends to [0, L_b - n_b + 1 + j) where n_b is min(next_n_lens[b], next_n), not the padded next_n.
…DSL table (#6140) * [Triton][FlyDSL] Add aiter.paged_mqa_logits with a tuned Gluon/FlyDSL table Picks the paged MQA logits backend and its launch knobs per shape from paged_mqa_logits_tuned.csv. Adds the tuner and op test, and gfx950 rows for the GLM-5 indexer. Signed-off-by: Sriram Kumar <[email protected]> * [Triton][FlyDSL] Move paged_mqa_logits next to fused_moe, GLM-5 rows to model_configs Signed-off-by: Sriram Kumar <[email protected]> * [Triton][FlyDSL] Look up paged_mqa_logits on the live GPU get_gfx() follows GPU_ARCHS and skipped the tuned row. * [Triton][FlyDSL] Drop context_len from the paged_mqa_logits merge key The generic untuned header is the dedup key. Two rows that differ only in context length now collide. * fix: keep paged_mqa_logits run_config off the merge-key header The generic untuned file no longer has context_len. pre_process still runs on --run_config and needs that column. * [FlyDSL] Check the live GPU in the gfx950 paged MQA logits kernel get_gfx() follows GPU_ARCHS, so the kernel raised on gfx950 with GPU_ARCHS=gfx942 once the dispatcher picked FlyDSL. * test: run the shipped-row check with GPU_ARCHS set at process start Setting GPU_ARCHS mid-process did not reach get_gfx(); the child process also launches the real kernel. * [FlyDSL] Fall back to the tuned Gluon knobs when FlyDSL cannot run FlyDSL rows now store the winning Gluon ChunkK and WavePerEU. GLM-5 gfx950 table retuned. * test: check the dispatched paged_mqa_logits config without compiling The shipped-row check records the config and no longer launches a kernel. * ci: add paged_mqa_logits to the manual tuning recipes * [Triton][FlyDSL] Pass context_lens through to the paged MQA logits kernels Drop the 2D context_lens shim; #6153 adds 2D support in the kernels. * [Triton][FlyDSL] Tune the GLM-5 paged_mqa_logits rows at 8k and 60k context Matches the benchmark input lengths (8192 and 60000). * Document the paged_mqa_logits contract and the context_len column State the tensors the front-end takes instead of pointing at the Gluon wrapper, and say that context_len is tuning metadata dispatch does not read. * Default the paged_mqa_logits tuner context lengths to 8192;60000 A row with no context_len (a generic-schema untuned CSV, or an empty cell) got an empty context list, so the tuner timed nothing and reported the shape as failed. Such rows now use --context_len, which defaults to the lengths the shipped table was tuned over; context_len stays out of the collision-key header. * Exit nonzero when paged_mqa_logits tuning errors or is interrupted TunerCommon.run() catches the exception and calls tune_summary with status Error or Interrupted. With no failed row recorded, the script exited 0 and op_tune.sh reported a pass. * Reject a strided context_lens in paged_mqa_logits for both backends Gluon already rejects a non-contiguous context_lens, but the FlyDSL wrapper reshapes it without removing the stride and the kernel reads it as dense, so a table[:, -1] view gave wrong causal bounds on the shipped B=64, next_n=8 FlyDSL row. run_paged_mqa_logits, which the op and the tuner share, now raises ValueError for it; the test covers that view. * Document context_len as provenance and accept (B, next_n) context_lens Dispatch deliberately does not key on context length; say so up front and at the loader, where the context_len column is free text that is never parsed (only the tuner reads it). Both kernels read the (B, next_n) table vLLM builds since #6451 and #6450, so the contract now lists it. * Test (B, next_n) context_lens through paged_mqa_logits and each backend Uses the shipped B=64, next_n=8 row, which dispatches to FlyDSL, and checks the op, Gluon and FlyDSL against the reference. * Log each context's gap to its own best in the paged_mqa_logits tuner The pick minimises the geomean over the row's contexts, which can hide a context where it is well off that context's best. Print the pick's time, the per-context best and the loss for every context. * ci: upload model_configs tuned CSVs in the tuning artifact The paged_mqa_logits job writes aiter/configs/model_configs/paged_mqa_logits_tuned_glm5.csv, which aiter/configs/*.csv does not match. * Test CUDA graph replay and elementwise accuracy in paged_mqa_logits Capture the op, Gluon and FlyDSL in a CUDA graph at 1024 tokens, change context_lens to 512 in place and replay: the output must match the reference at 512 and leave columns past it untouched, which fails if a launch reads the lengths on the host. The 2D context_lens check now also runs checkAllclose with the main test's tolerances. --------- Signed-off-by: Sriram Kumar <[email protected]>
…DSL table (ROCm#6140) * [Triton][FlyDSL] Add aiter.paged_mqa_logits with a tuned Gluon/FlyDSL table Picks the paged MQA logits backend and its launch knobs per shape from paged_mqa_logits_tuned.csv. Adds the tuner and op test, and gfx950 rows for the GLM-5 indexer. Signed-off-by: Sriram Kumar <[email protected]> * [Triton][FlyDSL] Move paged_mqa_logits next to fused_moe, GLM-5 rows to model_configs Signed-off-by: Sriram Kumar <[email protected]> * [Triton][FlyDSL] Look up paged_mqa_logits on the live GPU get_gfx() follows GPU_ARCHS and skipped the tuned row. * [Triton][FlyDSL] Drop context_len from the paged_mqa_logits merge key The generic untuned header is the dedup key. Two rows that differ only in context length now collide. * fix: keep paged_mqa_logits run_config off the merge-key header The generic untuned file no longer has context_len. pre_process still runs on --run_config and needs that column. * [FlyDSL] Check the live GPU in the gfx950 paged MQA logits kernel get_gfx() follows GPU_ARCHS, so the kernel raised on gfx950 with GPU_ARCHS=gfx942 once the dispatcher picked FlyDSL. * test: run the shipped-row check with GPU_ARCHS set at process start Setting GPU_ARCHS mid-process did not reach get_gfx(); the child process also launches the real kernel. * [FlyDSL] Fall back to the tuned Gluon knobs when FlyDSL cannot run FlyDSL rows now store the winning Gluon ChunkK and WavePerEU. GLM-5 gfx950 table retuned. * test: check the dispatched paged_mqa_logits config without compiling The shipped-row check records the config and no longer launches a kernel. * ci: add paged_mqa_logits to the manual tuning recipes * [Triton][FlyDSL] Pass context_lens through to the paged MQA logits kernels Drop the 2D context_lens shim; ROCm#6153 adds 2D support in the kernels. * [Triton][FlyDSL] Tune the GLM-5 paged_mqa_logits rows at 8k and 60k context Matches the benchmark input lengths (8192 and 60000). * Document the paged_mqa_logits contract and the context_len column State the tensors the front-end takes instead of pointing at the Gluon wrapper, and say that context_len is tuning metadata dispatch does not read. * Default the paged_mqa_logits tuner context lengths to 8192;60000 A row with no context_len (a generic-schema untuned CSV, or an empty cell) got an empty context list, so the tuner timed nothing and reported the shape as failed. Such rows now use --context_len, which defaults to the lengths the shipped table was tuned over; context_len stays out of the collision-key header. * Exit nonzero when paged_mqa_logits tuning errors or is interrupted TunerCommon.run() catches the exception and calls tune_summary with status Error or Interrupted. With no failed row recorded, the script exited 0 and op_tune.sh reported a pass. * Reject a strided context_lens in paged_mqa_logits for both backends Gluon already rejects a non-contiguous context_lens, but the FlyDSL wrapper reshapes it without removing the stride and the kernel reads it as dense, so a table[:, -1] view gave wrong causal bounds on the shipped B=64, next_n=8 FlyDSL row. run_paged_mqa_logits, which the op and the tuner share, now raises ValueError for it; the test covers that view. * Document context_len as provenance and accept (B, next_n) context_lens Dispatch deliberately does not key on context length; say so up front and at the loader, where the context_len column is free text that is never parsed (only the tuner reads it). Both kernels read the (B, next_n) table vLLM builds since ROCm#6451 and ROCm#6450, so the contract now lists it. * Test (B, next_n) context_lens through paged_mqa_logits and each backend Uses the shipped B=64, next_n=8 row, which dispatches to FlyDSL, and checks the op, Gluon and FlyDSL against the reference. * Log each context's gap to its own best in the paged_mqa_logits tuner The pick minimises the geomean over the row's contexts, which can hide a context where it is well off that context's best. Print the pick's time, the per-context best and the loss for every context. * ci: upload model_configs tuned CSVs in the tuning artifact The paged_mqa_logits job writes aiter/configs/model_configs/paged_mqa_logits_tuned_glm5.csv, which aiter/configs/*.csv does not match. * Test CUDA graph replay and elementwise accuracy in paged_mqa_logits Capture the op, Gluon and FlyDSL in a CUDA graph at 1024 tokens, change context_lens to 512 in place and replay: the output must match the reference at 512 and leave columns past it untouched, which fails if a launch reads the lengths on the host. The 2D context_lens check now also runs checkAllclose with the main test's tolerances. --------- Signed-off-by: Sriram Kumar <[email protected]>


Motivation
Currently, vLLM passes
context_lensto the paged MQA logits kernels as a 2D(B, next_n)table, the same layout DeepGEMM uses. The FlyDSL kernel only reads a 1D[B]vector, so with MTP on,flydsl_fp8_paged_mqa_logitsfails with areshapeerror:This PR lets the FlyDSL paged_mqa_logits kernel accept the 2D
context_lensthat vLLM sends with MTP, while staying backward compatible with the 1D format.Split out of #6153 as requested in review (one backend per PR); the Triton and Gluon change is in #6451. The two PRs touch different files and can merge in either order.
Example: 4 requests,
next_n=3, context lengths 8192 / 1500 / 3000 / 700, vLLM sends the following 2D array:bj=0j=1j=2The fix uses the row length (
next_n) as the stride and reads the last entry of each row, which gives [8192, 1500, 3000, 700].What changes
b's length atb * ctx_stride + ctx_stride - 1; stride 1 builds the pre-PR kernel (same code and name), stridenbuilds a variant named..._cs{n}, and_compile()caches one build per stride.[B]: stride is 1, so this iscontext_lens[b], the same load as today.(B, n): stride isn, so this is the last entry of rowb, which is the full sequence length.ValueErrorunlesscontext_lensis a contiguous int32[B]or(B, n)on the same device asq_fp8, with exactlyBrows andnequal to 1 ornext_n:reshapesilently copied some strided inputs and kept others as strided views that the kernel read as dense.(B, 0)table would have made the kernel read before the start of the tensor, and a(B, n)withnother thannext_nread the wrong column as the length.RuntimeErrorfromreshapebefore; it is now aValueErrorwith the expected shape.context_lensas int32 words, so an int64 table gave wrong lengths before.Backward compatibility
[B]is unchanged, and(B, 1)behaves exactly like[B].(B, next_n)table is the only new input. vLLM already keeps its decodeseq_lenscontiguous for this.context_lensnow raisesValueError.Tests
In
op_tests/test_flydsl_fp8_paged_mqa_logits.py:context_lenslayout is a new axis of the existing sweep,-c/--ctx_lens(default1d 2d). For2d, FlyDSL gets the(B, next_n)table vLLM builds, is graded against the same fp32 reference as1d, and is timed next to it in the summary table.test_fp8_paged_mqa_logits_mixed_context_lens: B=5,next_n=3, distinct lengths and one empty (CUDA-graph padding) request, graded against the fp32 reference for1dand2d, with and withoutSplitKV. It fails if the kernel reads row 0's length for every request.test_fp8_paged_mqa_logits_bad_context_lens: too few or too many rows, no columns, a column count other thannext_n, an int64 table, a CPU table, a strided[B]and a non-contiguous(B, n)must raiseValueError.Results
MI355X, Triton 3.8, FlyDSL 0.3.4.1, upstream
mainat9fd025efdplus this change:python op_tests/test_flydsl_fp8_paged_mqa_logits.py: all tables pass. In the default sweep (batch 1-8,next_n1-8, 1k context)2dhas the same error against the reference as1din every case, and its kernel time is within +0.1% to +1.9% of1d.mainwithout this change, with thereshapeerror above.blackandruff(0.16.0) are clean.main(e.g. B=16,next_n=3: 30.6 / 30.2 us vs 30.7 / 30.2 us over two runs), and 2D stays within about 1% of 1D.