Repository navigation
Conversation
Optional query_start_loc for pa_decode_gluon (PS path): gluon head_1 and multi-head attention kernels, PS reduce in Triton, HIP and FlyDSL. Uniform path unchanged. Tests in op_tests/triton_tests/test_pa_decode_gluon_varlen.py. Signed-off-by: Sergei Shliapnikov <[email protected]>
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: |
|
@ukannika could you please take a look at these changes when you get a chance? |
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Backend scope, device validation, test organization/runtime, and the temporary-buffer contract require correction.
Review effort: Balanced
Findings: 1
Open (5)
What changed in this PR
Adds ragged-query support to Gluon paged-attention decode across PS attention and reduction backends.
Changes:
- Adds packed
query_start_lochandling. - Extends Triton, HIP, and FlyDSL reducers.
- Adds broad ragged-query coverage and corrects temporary-buffer dtype allocation.
| File | Description |
|---|---|
op_tests/triton_tests/test_pa_decode_gluon_varlen.py |
Tests ragged decode configurations. |
csrc/cpp_itfs/pa/pa_ps.py |
Extends HIP JIT launcher. |
csrc/cpp_itfs/pa/pa_ps.cuh |
Adds packed-row HIP reduction. |
csrc/cpp_itfs/pa/pa_ps.cpp.jinja |
Threads ragged metadata into HIP. |
aiter/ops/triton/gluon/pa_decode_gluon.py |
Implements ragged Gluon/Triton dispatch. |
aiter/ops/flydsl/pa_decode.py |
Extends FlyDSL reduction launcher. |
aiter/ops/flydsl/kernels/pa_decode_reduce.py |
Adds packed-row FlyDSL stores. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
0a7c04c to
e90a906
Compare
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The multi-KV zero-length path performs unnecessary full attention work, and the new test violates the required mirrored folder layout.
Review effort: Balanced
Findings: 1
Open (1)
Resolved since last review (1)
|
Per the CI guide's one-backend-per-PR rule, this PR is now split, with @sshlyapn kept as commit author:
This PR conflicted with
The HIP files are byte-identical to this PR. Suggest closing this PR once the split is acknowledged. |
|
@andrei-kochin can we close this PR now? |
New optional query_start_loc ([num_seqs + 1], int32) for pa_decode_gluon, PS path only. Sequence i owns packed query/output rows [query_start_loc[i], query_start_loc[i + 1]); query_length must be >= every per-sequence length; rows not owned by any sequence are left untouched. Non-PS paths assert on it. - Supported in the gluon head_1 and multi-KV attention kernels and in the Triton PS reduce, each behind a compile-time IS_VARLEN flag; the HIP PS reduce is used through its query_start_loc argument. - Causal masks use the per-sequence query length, on top of the per-split causal mask from ROCm#5915. - Fix the default temporary_output dtype: the attention kernels store bf16 for fp8 compute (otherwise compute_type), not query.dtype. An fp8 query with fp8 compute and no temporary_output failed to compile before. - New test op_tests/triton_tests/test_pa_decode_gluon_varlen.py: each sequence of a ragged call must match a batch-1 uniform call, and unowned rows must keep a sentinel. Covers bf16, fp8 KV, fp8 Q+KV, sinks, sliding window, block 16/64/128 with shuffled V, head_1 and multi-KV, one-shot and split runs through the HIP and Triton reduces, and zero-length sequences. Split out of ROCm#6099, rebased onto main. The FlyDSL reduce part of ROCm#6099 is dropped: since ROCm#5809 the Gluon path no longer dispatches to the FlyDSL PS reduce, and the no-work-plan mode it extended no longer exists. Signed-off-by: Sergei Shliapnikov <[email protected]> Signed-off-by: Andrei Kochin <[email protected]> Co-authored-by: Cursor <[email protected]>
…n) output Optional query_start_loc ([num_seqs + 1], int32) for the HIP partitioned- softmax reduce. With it, the output is packed per token as [1, num_tokens, num_kv_heads, group, head] and sequence b writes rows [query_start_loc[b], query_start_loc[b + 1]); rows past a sequence's query length are not stored. - The varlen code sits behind the IS_VARLEN template parameter, which is also part of the JIT cache key; uniform calls build IS_VARLEN=false and pass nullptr, so uniform kernels never touch the pointer. - Bump the launcher ABI version: the JIT cache is keyed on the template kwargs, not the source, and the C signature gained a parameter. Split out of ROCm#6099; the Gluon PA decode consumer and its tests follow in a stacked PR. Signed-off-by: Sergei Shliapnikov <[email protected]> Signed-off-by: Andrei Kochin <[email protected]> Co-authored-by: Cursor <[email protected]>
New optional query_start_loc ([num_seqs + 1], int32) for pa_decode_gluon, PS path only. Sequence i owns packed query/output rows [query_start_loc[i], query_start_loc[i + 1]); query_length must be >= every per-sequence length; rows not owned by any sequence are left untouched. Non-PS paths assert on it. - Supported in the gluon head_1 and multi-KV attention kernels and in the Triton PS reduce, each behind a compile-time IS_VARLEN flag; the HIP PS reduce is used through its query_start_loc argument. - Causal masks use the per-sequence query length, on top of the per-split causal mask from ROCm#5915. - Fix the default temporary_output dtype: the attention kernels store bf16 for fp8 compute (otherwise compute_type), not query.dtype. An fp8 query with fp8 compute and no temporary_output failed to compile before. - New test op_tests/triton_tests/test_pa_decode_gluon_varlen.py: each sequence of a ragged call must match a batch-1 uniform call, and unowned rows must keep a sentinel. Covers bf16, fp8 KV, fp8 Q+KV, sinks, sliding window, block 16/64/128 with shuffled V, head_1 and multi-KV, one-shot and split runs through the HIP and Triton reduces, and zero-length sequences. Split out of ROCm#6099, rebased onto main. The FlyDSL reduce part of ROCm#6099 is dropped: since ROCm#5809 the Gluon path no longer dispatches to the FlyDSL PS reduce, and the no-work-plan mode it extended no longer exists. Signed-off-by: Sergei Shliapnikov <[email protected]> Signed-off-by: Andrei Kochin <[email protected]> Co-authored-by: Cursor <[email protected]>
New optional query_start_loc ([num_seqs + 1], int32) for pa_decode_gluon, PS path only. Sequence i owns packed query/output rows [query_start_loc[i], query_start_loc[i + 1]); query_length must be >= every per-sequence length; rows not owned by any sequence are left untouched. Non-PS paths assert on it. - Supported in the gluon head_1 and multi-KV attention kernels and in the Triton PS reduce, each behind a compile-time IS_VARLEN flag; the HIP PS reduce is used through its query_start_loc argument. - Causal masks use the per-sequence query length, on top of the per-split causal mask from ROCm#5915. - Fix the default temporary_output dtype: the attention kernels store bf16 for fp8 compute (otherwise compute_type), not query.dtype. An fp8 query with fp8 compute and no temporary_output failed to compile before. - New test op_tests/triton_tests/test_pa_decode_gluon_varlen.py: each sequence of a ragged call must match a batch-1 uniform call, and unowned rows must keep a sentinel. Covers bf16, fp8 KV, fp8 Q+KV, sinks, sliding window, block 16/64/128 with shuffled V, head_1 and multi-KV, one-shot and split runs through the HIP and Triton reduces, and zero-length sequences. Split out of ROCm#6099, rebased onto main. The FlyDSL reduce part of ROCm#6099 is dropped: since ROCm#5809 the Gluon path no longer dispatches to the FlyDSL PS reduce, and the no-work-plan mode it extended no longer exists. Signed-off-by: Sergei Shliapnikov <[email protected]> Signed-off-by: Andrei Kochin <[email protected]> Co-authored-by: Cursor <[email protected]>
…n) output Optional query_start_loc ([num_seqs + 1], int32) for the HIP partitioned- softmax reduce. With it, the output is packed per token as [1, num_tokens, num_kv_heads, group, head] and sequence b writes rows [query_start_loc[b], query_start_loc[b + 1]); rows past a sequence's query length are not stored. - The varlen code sits behind the IS_VARLEN template parameter, which is also part of the JIT cache key; uniform calls build IS_VARLEN=false and pass nullptr, so uniform kernels never touch the pointer. - Bump the launcher ABI version: the JIT cache is keyed on the template kwargs, not the source, and the C signature gained a parameter. Split out of ROCm#6099; the Gluon PA decode consumer and its tests follow in a stacked PR. Signed-off-by: Sergei Shliapnikov <[email protected]> Signed-off-by: Andrei Kochin <[email protected]> Co-authored-by: Cursor <[email protected]>
New optional query_start_loc ([num_seqs + 1], int32) for pa_decode_gluon, PS path only. Sequence i owns packed query/output rows [query_start_loc[i], query_start_loc[i + 1]); query_length must be >= every per-sequence length; rows not owned by any sequence are left untouched. Non-PS paths assert on it. - Supported in the gluon head_1 and multi-KV attention kernels and in the Triton PS reduce, each behind a compile-time IS_VARLEN flag; the HIP PS reduce is used through its query_start_loc argument. - Causal masks use the per-sequence query length, on top of the per-split causal mask from ROCm#5915. - Fix the default temporary_output dtype: the attention kernels store bf16 for fp8 compute (otherwise compute_type), not query.dtype. An fp8 query with fp8 compute and no temporary_output failed to compile before. - New test op_tests/triton_tests/test_pa_decode_gluon_varlen.py: each sequence of a ragged call must match a batch-1 uniform call, and unowned rows must keep a sentinel. Covers bf16, fp8 KV, fp8 Q+KV, sinks, sliding window, block 16/64/128 with shuffled V, head_1 and multi-KV, one-shot and split runs through the HIP and Triton reduces, and zero-length sequences. Split out of ROCm#6099, rebased onto main. The FlyDSL reduce part of ROCm#6099 is dropped: since ROCm#5809 the Gluon path no longer dispatches to the FlyDSL PS reduce, and the no-work-plan mode it extended no longer exists. Signed-off-by: Sergei Shliapnikov <[email protected]> Signed-off-by: Andrei Kochin <[email protected]> Co-authored-by: Cursor <[email protected]>
…n) output Optional query_start_loc ([num_seqs + 1], int32) for the HIP partitioned- softmax reduce. With it, the output is packed per token as [1, num_tokens, num_kv_heads, group, head] and sequence b writes rows [query_start_loc[b], query_start_loc[b + 1]); rows past a sequence's query length are not stored. - The varlen code sits behind the IS_VARLEN template parameter, which is also part of the JIT cache key; uniform calls build IS_VARLEN=false and pass nullptr, so uniform kernels never touch the pointer. - Bump the launcher ABI version: the JIT cache is keyed on the template kwargs, not the source, and the C signature gained a parameter. Split out of ROCm#6099; the Gluon PA decode consumer and its tests follow in a stacked PR. Signed-off-by: Sergei Shliapnikov <[email protected]> Signed-off-by: Andrei Kochin <[email protected]> Co-authored-by: Cursor <[email protected]>
New optional query_start_loc ([num_seqs + 1], int32) for pa_decode_gluon, PS path only. Sequence i owns packed query/output rows [query_start_loc[i], query_start_loc[i + 1]); query_length must be >= every per-sequence length; rows not owned by any sequence are left untouched. Non-PS paths assert on it. - Supported in the gluon head_1 and multi-KV attention kernels and in the Triton PS reduce, each behind a compile-time IS_VARLEN flag; the HIP PS reduce is used through its query_start_loc argument. - Causal masks use the per-sequence query length, on top of the per-split causal mask from ROCm#5915. - Fix the default temporary_output dtype: the attention kernels store bf16 for fp8 compute (otherwise compute_type), not query.dtype. An fp8 query with fp8 compute and no temporary_output failed to compile before. - New test op_tests/triton_tests/test_pa_decode_gluon_varlen.py: each sequence of a ragged call must match a batch-1 uniform call, and unowned rows must keep a sentinel. Covers bf16, fp8 KV, fp8 Q+KV, sinks, sliding window, block 16/64/128 with shuffled V, head_1 and multi-KV, one-shot and split runs through the HIP and Triton reduces, and zero-length sequences. Split out of ROCm#6099, rebased onto main. The FlyDSL reduce part of ROCm#6099 is dropped: since ROCm#5809 the Gluon path no longer dispatches to the FlyDSL PS reduce, and the no-work-plan mode it extended no longer exists. Signed-off-by: Sergei Shliapnikov <[email protected]> Signed-off-by: Andrei Kochin <[email protected]> Co-authored-by: Cursor <[email protected]>
…n) output Optional query_start_loc ([num_seqs + 1], int32) for the HIP partitioned- softmax reduce. With it, the output is packed per token as [1, num_tokens, num_kv_heads, group, head] and sequence b writes rows [query_start_loc[b], query_start_loc[b + 1]); rows past a sequence's query length are not stored. - The varlen code sits behind the IS_VARLEN template parameter, which is also part of the JIT cache key; uniform calls build IS_VARLEN=false and pass nullptr, so uniform kernels never touch the pointer. - Bump the launcher ABI version: the JIT cache is keyed on the template kwargs, not the source, and the C signature gained a parameter. Split out of ROCm#6099; the Gluon PA decode consumer and its tests follow in a stacked PR. Signed-off-by: Sergei Shliapnikov <[email protected]> Signed-off-by: Andrei Kochin <[email protected]> Co-authored-by: Cursor <[email protected]>
New optional query_start_loc ([num_seqs + 1], int32) for pa_decode_gluon, PS path only. Sequence i owns packed query/output rows [query_start_loc[i], query_start_loc[i + 1]); query_length must be >= every per-sequence length; rows not owned by any sequence are left untouched. Non-PS paths assert on it. - Supported in the gluon head_1 and multi-KV attention kernels and in the Triton PS reduce, each behind a compile-time IS_VARLEN flag; the HIP PS reduce is used through its query_start_loc argument. - Causal masks use the per-sequence query length, on top of the per-split causal mask from ROCm#5915. - Fix the default temporary_output dtype: the attention kernels store bf16 for fp8 compute (otherwise compute_type), not query.dtype. An fp8 query with fp8 compute and no temporary_output failed to compile before. - New test op_tests/triton_tests/test_pa_decode_gluon_varlen.py: each sequence of a ragged call must match a batch-1 uniform call, and unowned rows must keep a sentinel. Covers bf16, fp8 KV, fp8 Q+KV, sinks, sliding window, block 16/64/128 with shuffled V, head_1 and multi-KV, one-shot and split runs through the HIP and Triton reduces, and zero-length sequences. Split out of ROCm#6099, rebased onto main. The FlyDSL reduce part of ROCm#6099 is dropped: since ROCm#5809 the Gluon path no longer dispatches to the FlyDSL PS reduce, and the no-work-plan mode it extended no longer exists. Signed-off-by: Sergei Shliapnikov <[email protected]> Signed-off-by: Andrei Kochin <[email protected]> Co-authored-by: Cursor <[email protected]>
…n) output Optional query_start_loc ([num_seqs + 1], int32) for the HIP partitioned- softmax reduce. With it, the output is packed per token as [1, num_tokens, num_kv_heads, group, head] and sequence b writes rows [query_start_loc[b], query_start_loc[b + 1]); rows past a sequence's query length are not stored. - The varlen code sits behind the IS_VARLEN template parameter, which is also part of the JIT cache key; uniform calls build IS_VARLEN=false and pass nullptr, so uniform kernels never touch the pointer. - Bump the launcher ABI version: the JIT cache is keyed on the template kwargs, not the source, and the C signature gained a parameter. Split out of ROCm#6099; the Gluon PA decode consumer and its tests follow in a stacked PR. Signed-off-by: Sergei Shliapnikov <[email protected]> Signed-off-by: Andrei Kochin <[email protected]> Co-authored-by: Cursor <[email protected]>
…n) output (#6444) * [HIP] PA decode PS reduce: optional query_start_loc for ragged (varlen) output Optional query_start_loc ([num_seqs + 1], int32) for the HIP partitioned- softmax reduce. With it, the output is packed per token as [1, num_tokens, num_kv_heads, group, head] and sequence b writes rows [query_start_loc[b], query_start_loc[b + 1]); rows past a sequence's query length are not stored. - The varlen code sits behind the IS_VARLEN template parameter, which is also part of the JIT cache key; uniform calls build IS_VARLEN=false and pass nullptr, so uniform kernels never touch the pointer. - Bump the launcher ABI version: the JIT cache is keyed on the template kwargs, not the source, and the C signature gained a parameter. Split out of #6099; the Gluon PA decode consumer and its tests follow in a stacked PR. Signed-off-by: Sergei Shliapnikov <[email protected]> Signed-off-by: Andrei Kochin <[email protected]> Co-authored-by: Cursor <[email protected]> * [HIP] Update the OPUS MLA sparse prefill caller to the new PS reduce kernel signature. Signed-off-by: Sergei Shliapnikov <[email protected]> --------- Signed-off-by: Sergei Shliapnikov <[email protected]> Signed-off-by: Andrei Kochin <[email protected]> Co-authored-by: Sergei Shliapnikov <[email protected]> Co-authored-by: Cursor <[email protected]>
New optional query_start_loc ([num_seqs + 1], int32) for pa_decode_gluon, PS path only. Sequence i owns packed query/output rows [query_start_loc[i], query_start_loc[i + 1]); query_length must be >= every per-sequence length; rows not owned by any sequence are left untouched. Non-PS paths assert on it. - Supported in the gluon head_1 and multi-KV attention kernels and in the Triton PS reduce, each behind a compile-time IS_VARLEN flag; the HIP PS reduce is used through its query_start_loc argument. - Causal masks use the per-sequence query length, on top of the per-split causal mask from ROCm#5915. - Fix the default temporary_output dtype: the attention kernels store bf16 for fp8 compute (otherwise compute_type), not query.dtype. An fp8 query with fp8 compute and no temporary_output failed to compile before. - New test op_tests/triton_tests/test_pa_decode_gluon_varlen.py: each sequence of a ragged call must match a batch-1 uniform call, and unowned rows must keep a sentinel. Covers bf16, fp8 KV, fp8 Q+KV, sinks, sliding window, block 16/64/128 with shuffled V, head_1 and multi-KV, one-shot and split runs through the HIP and Triton reduces, and zero-length sequences. Split out of ROCm#6099, rebased onto main. The FlyDSL reduce part of ROCm#6099 is dropped: since ROCm#5809 the Gluon path no longer dispatches to the FlyDSL PS reduce, and the no-work-plan mode it extended no longer exists. Signed-off-by: Sergei Shliapnikov <[email protected]> Signed-off-by: Andrei Kochin <[email protected]> Co-authored-by: Cursor <[email protected]>



Motivation
pa_decode_gluonneeds the samequery_lengthfor every sequence, so it can't take a decode batch with mixed lengths, e.g. speculative decodes next to plain decodes. vLLM'sROCM_AITER_FAbackend sends such batches tounified_attention, which doesn't support the shuffled KV layout. With shuffled KV it asserts instead.Example: MiniMax-M3-MXFP8 on MI355X (TP4, ROCM_AITER_FA, shuffled fp8 KV, EAGLE3 with 3 draft tokens). The server dies during warmup on the mixed spec/non-spec decode step:
AssertionError: Shuffle KV cache layout is not supported with sliding window, sinks, or speculative decoding (multi-token decode).This PR adds ragged (varlen) input, so each sequence uses only its own rows. With this PR plus a vLLM change that passes
query_start_locfor ragged decode batches, the same server starts and answers correctly (see Accuracy).Changes
query_start_loc([num_seqs + 1], int32) forpa_decode_gluon, PS path only. Sequenceiowns packed query/output rows[query_start_loc[i], query_start_loc[i + 1]).query_lengthmust be >= every per-sequence length. Rows not owned by any sequence are left untouched. Non-PS paths assert on it.constexpr/const_expr/IS_VARLENtemplate parameter, which is also part of the HIP JIT cache key), so uniform kernels don't contain it.temporary_outputdtype. It wasquery.dtype, but the attention kernels store bf16 for fp8 compute (otherwisecompute_type). Before this fix, an fp8 query with fp8 compute and notemporary_outputfailed to compile (amdg.buffer_storeelement type mismatch). Configs that compiled before are unaffected.op_tests/triton_tests/test_pa_decode_gluon_varlen.py. Each sequence of a ragged call must match a batch-1 uniform call, and unowned rows must keep a sentinel value. Coverage:Uniform path impact
query_start_loc_ptris only read underif constexpr(IS_VARLEN). Uniform calls build theIS_VARLEN=falseinstance and passnullptr, so uniform kernels never touch it.Reproduce