Repository navigation
[Triton/Gluon] Gluon PA decode: fix causal mask across splits - #5915
Conversation
For non-sliding decode with query_length > 1 and multiple splits, the causal offset shifted each split's key range, dropping keys at split boundaries aligned to the 256-key partition. Mask by the split's own range and apply the causal cut against context_length.
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: |
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]>
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]>
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]>
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]>
Problem
In the PS decode kernels (
paged_attention_decode_sliding_window_head_1andpaged_attention_decode_sliding_window), non-sliding causal decode with query_length > 1 and multiple splits drops valid keys at internal split boundaries. The mask shifted each split's key range by the causal offsetext = query_length - 1 - j(start <= ext + col < end), so keys[start, start + ext)belong to no split wheneverstart % 256 < ext. This hits spec-decode verification, e.g. vLLMROCM_AITER_FAwith EAGLE k=3 (query_length=4).Power-of-2 contexts are the worst case, because their split starts are 256-aligned. Not affected: the last query token, query_length=1, a single split, sliding window.
Fix
Mask by the split's own range and apply the causal cut once, against
context_length:Applied to all 3 non-sliding causal branches (head_1 single-token, head_1 multi-token, multi-KV-head). The sliding-window branch is unchanged.
Also adds a
ps_accuracycase set toCASE_SET_NAME_OPTIONS(12 cases, ~4 s): PS, non-sliding, bf16 unquantized, fixed contexts 2048/8192, query_length 1/4, heads (8,1)/(16,1)/(64,8), which covers all 3 fixed branches. The existing CI sets miss the bug:normal_accuracyrunsps=False,sliding_window_accuracyuses random varlen contexts and quantized KV (the 5e-3 tolerance hides a few missing keys), andsliding_window_performanceruns query_length=1.Accuracy
MI355X, Triton 3.8.0:
-k ps_accuracy(12 cases)Reproduce
With main's kernel,
ps_accuracyfails with6 test case(s) exceeded the error threshold.