Repository navigation
[Triton/Gluon] [FlyDSL] [CI] Refactor PA decode, direct native autotune, and BF16 KV - #5809
Conversation
Use the unaligned MTP window union to bound reducer specialization, while retaining the CU-count plan cap, scratch layout and query selector. Cover partition-boundary crossings during refresh in the generic test. Validated on dzm-mi355-gpu34-dev: 196 unit tests passed, with two 70-case native accuracy/performance sweeps. W1024/B200/QL4 improves from 80.18 us to 29.14 us, excluding plan construction and refresh. Signed-off-by: fsx950223 <[email protected]>
Include pending varlen KV buffer loads, prefetch scheduling and compact reduction. Bound dense planned work for native QL2/QL4 query splitting and cover the selector and address boundaries in the generic unit test. Add offline model/batch budget sweeps with fixed-plan timing, strict FP32 validation and static recommendation keys. Keep context distributions in benchmark metadata only, and preserve failed numerical cases without recommendations. Validate with MI355 native A/B and generic GPU tests, 22 CPU tuner tests, Black 26.5.1 and Ruff 0.16.0. The existing short-context FP8 numerical limitation is not changed. Signed-off-by: fsx950223 <[email protected]>
…de-oop Preserve planned query splitting, unsigned KV buffer loads and prefetch ordering in the PA operation classes. Track the full helper source closure in offline tuning keys and test persistent-cache separation for wide/buffer specializations.
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
PR title tags & labels: |
Always normalize Q rows by absmax and scale P before FP8 conversion, compensating both scales in the QK and output stages. This prevents small queries and probability tails from underflowing on the per-tensor KV path. Add four regression cases with quantized FP8 KV caches and non-unit scales. Validated on MI355: all 264 native PA decode tests pass.
Use one parameterized correctness test with shared input construction and an independent FP32 reference. Cover query dtypes, FP8 KV quantization, cache layouts, partitioning, plans, windows and sinks, including the small-Q and probability-tail regressions. Remove the benchmark CLI, tuning CSV tests and internal scheduling assertions from this file. Run the unit test once through pytest in CI. Validated on MI355: all 80 cases pass. The four original scaling regressions still fail against the old shortcut implementation.
Remove static tile dispatch, direct output, uniform scratch layouts, and the static reducer branches. All FlyDSL decode calls now use work plans, including a partition cap of one, with sinks applied once by the reducer. Configure partition caps on plan_pa_decode and make the optional decode arguments keyword-only. Update the tuner and generic unit test, and adapt Gluon's existing FlyDSL reducer fallback to provide reduction metadata. Validate on MI355 with 80 generic cases, six Gluon reducer cases, tuner smoke, and ten graph/eager replays. All replay outputs match the previous planned implementation bit for bit, including its two-token FP8 error.
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
The architecture-independent specialization cache is a critical correctness risk, with additional tuning, performance, and validation concerns.
Review effort: Lite
Findings: 1
Open (5)
What changed in this PR
Refactors FlyDSL paged-attention decoding into modular kernel components and adds CSV-based tuning and budget selection.
Changes:
- Splits scheduling, memory movement, GEMM, softmax, pipeline, and reduction logic.
- Adds validated CSV tuning, caching, lookup, and automatic planning.
- Updates Gluon reduction integration, tests, and CI execution.
| File | Summary |
|---|---|
op_tests/test_flydsl_pa_decode.py |
Replaces broad coverage with a smaller eager test; graph replay and planning-contract paths remain untested (nit). |
aiter/ops/triton/gluon/pa_decode_gluon.py |
Adds FlyDSL reducer dispatch, but rebuilds metadata on every call, creating a moderate performance concern. |
aiter/ops/flydsl/pa_decode.py |
Adds CSV loading, caching, lookup, and automatic planning; committed API tests are missing (nit). |
aiter/ops/flydsl/pa_decode_tuning.py |
Implements tuning and CSV I/O; timing failures can discard valid candidates (moderate), and tuner/API scope is combined with the refactor (nit). |
aiter/ops/flydsl/kernels/pa_decode/traits.py |
Defines specialization traits; the cache key omits GPU architecture, causing a critical cross-architecture reuse risk. |
aiter/ops/flydsl/kernels/pa_decode/pipeline.py |
Implements the modular decode pipeline. |
aiter/ops/flydsl/kernels/pa_decode/op_softmax.py |
Implements masking and softmax operations. |
aiter/ops/flydsl/kernels/pa_decode/op_lds.py |
Handles LDS and KV movement. |
aiter/ops/flydsl/kernels/pa_decode/op_gemm.py |
Encapsulates GEMM/MFMA operations. |
aiter/ops/flydsl/kernels/pa_decode/op_epilog.py |
Stores normalized partial outputs. |
aiter/ops/flydsl/kernels/pa_decode/context.py |
Encapsulates CTA context and mappings. |
aiter/ops/flydsl/kernels/pa_decode/__init__.py |
Provides implementation organization and caching support. |
aiter/ops/flydsl/kernels/pa_decode_reduce.py |
Updates packed and compact reduction paths. |
.github/scripts/aiter_test.sh |
Runs pytest only; the tuning CLI paths are not exercised in CI (nit). |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| cache_key = ( | ||
| head_dim, | ||
| query_group_size, | ||
| block_size, | ||
| num_partitions, |
| ' | ||
| _ "$file" | ||
| ) | ||
| test_cmd=(timeout 60m python3 -m pytest -q "$file") |
Use the existing C++ PS reducer first and fall back directly to Triton. Remove FlyDSL imports, dispatch checks, and reduction-plan metadata from the Gluon wrapper.
There was a problem hiding this comment.
🔵 Needs a closer look
Unresolved moderate correctness and compatibility issues remain, along with a missing benchmark.
9 open findings
Compilation cache omits launch geometry from cache key Block collectives incorrectly operate on per-thread vectors BF16 K-loader produces too few operands for consumer indexing Prevent reshape from writing to a detached output copy Use full-wave masks for compact reduction Specialization cache key omits GPU architecture Include GPU architecture in autotune cache key Split risky kernel, autotune, and CI changes into focused PRs CI no longer exercises pa_decode_tuning CLI paths
🧠 Review effort: Lite
There was a problem hiding this comment.
🟡 Changes recommended
A critical pipeline issue and additional correctness, fallback, and tuning-coverage issues remain unresolved.
10 open findings
Typed loop bounds are required for single-tile SSA loops · New Compilation cache omits launch geometry from cache key Block collectives incorrectly operate on per-thread vectors BF16 K-loader produces too few operands for consumer indexing Prevent reshape from writing to a detached output copy Use full-wave masks for compact reduction Specialization cache key omits GPU architecture Include GPU architecture in autotune cache key Split risky kernel, autotune, and CI changes into focused PRs CI no longer exercises pa_decode_tuning CLI paths
🧠 Review effort: Lite
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]>
Transplant fp8-Q pa_decode onto the modular #5809 package (single query-scale-aware launcher, output dtype in schedule key), migrate fmha op_lds BT/V LDS access to recast_iter/add_offset/ptr_load/ptr_store, and route the adapter decode path through a retained geometry-and-stream keyed work plan with capture-safe refresh.
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]>
- Add explicit PA work plans, refactored kernels and native autotuning. - Preserve current MoE exports and the independent Gluon reducer. Signed-off-by: Xiake Sun <[email protected]>
- Add explicit PA work plans, refactored kernels and native autotuning. - Preserve current MoE exports and the independent Gluon reducer. Signed-off-by: Xiake Sun <[email protected]>
* fix(collectives): use a fixed LL128 slot stride - Keep peer slots stable across message sizes. - Use matching offsets for readers and writers. Signed-off-by: Xiake Sun <[email protected]> * test(moe): add MiMo native configs and validation - Add mixed native configs with preserved CSV bytes. - Check dispatch, numerical output and graph replay. Signed-off-by: Xiake Sun <[email protected]> * perf(moe): add adaptive A8W4 decode tiles - Register valid 16/32-row kernels for both stages. - Add the adaptive CSV with preserved bytes. Signed-off-by: Xiake Sun <[email protected]> * refactor(pa): import planned decode from PR ROCm#5809 - Add explicit PA work plans, refactored kernels and native autotuning. - Preserve current MoE exports and the independent Gluon reducer. Signed-off-by: Xiake Sun <[email protected]> * build(pa): retain required upstream decode dependencies - Align PA kernels, planner, reducer and tuning with the PR base. - Keep unrelated MoE sources, CSVs and CK pin unchanged. Signed-off-by: Xiake Sun <[email protected]> * feat(pa): add MiMo asymmetric decode from PR ROCm#5887 - Support QK192/V128 BF16 and FP8 attention with sliding windows. - Carry the upstream scheduling, accuracy fixes and regression coverage. Signed-off-by: Xiake Sun <[email protected]> * fix(pa): support FlyDSL 0.3.2 and query split overrides - Add guarded LDS/TDM helpers and forward explicit query splits. - Preserve autotune validation and cover legacy-runtime regressions. Signed-off-by: Xiake Sun <[email protected]> * perf(pa): peel protected tail tiles from decode loop - Keep V-tail masks on each task's final tile. - Preserve MiMo single-tile policy and early V-load scheduling. Signed-off-by: Xiake Sun <[email protected]> * cleanup: move legacy tuned a8w4/a16w4 moe config in eval folder Signed-off-by: Xiake Sun <[email protected]> --------- Signed-off-by: Xiake Sun <[email protected]> Co-authored-by: who who who <[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]>



Refactor FlyDSL PA decode into operation classes with explicit GPU work plans, add native BF16 KV, and separate tuning from decode execution in
aiter/ops/flydsl/pa_decode_tuning.py.work_planfor decode and graph replay. Prepare or refresh plans before execution;max_context_lengthsupplies a host scheduling bound independently of block-table padding. Decode does not import or invoke the tuning module.2*CUbaseline. Candidate allocation, compilation, and graph capture happen before timed replay.prepare_pa_decode_planfromaiter.ops.flydsl.pa_decode_tuningandaiter.ops.flydsl. Ordinary cache misses use2*CUwithout preparing or timing candidates;tune=Trueexplicitly searches without modifying environment variables.config_dirselects per-architecture result directories.op_tests/test_flydsl_pa_decode.py. Retain decode correctness, invalid-input, work-plan, and graph-replay coverage.Standalone tuning example:
python -m aiter.ops.flydsl.pa_decode_tuning \ --batch-size 32 --num-query-heads 16 --num-kv-heads 1 --head-dim 128 \ --query-length 4 --context-length 16384 --block-size 128 \ --kv-dtype fp8 --scale-mode per-token --trans-v 1 \ --output-dir /tmp/pa-configsResults are saved to
/tmp/pa-configs/<arch>/_pa_decode_autotuner.json. Without--output-dir, useaiter/ops/flydsl/configs/pa/<arch>/, or the nativeFLYDSL_AUTOTUNE_CACHE_DIRoverride. Python callers can use the same result root withconfig_dir="/tmp/pa-configs".Example with actual BF16 query/KV tensors and page64/D192:
BF16 KV follows ROCm/FlyDSL#1065: require BF16 queries, unscaled vector8 K/V, and
compute_type=torch.bfloat16. Support page sizes 16/64/128 and BF16 head dimensions in multiples of 64 through 1024, including D192. Use BF16 Q/K/P/V operands, FP32 softmax/accumulation, and query-position splitting to fit 64 KiB LDS. Allocate caller-owned graph scratch fromplan.capacity; refresh plans when context lengths change.Cache keys include attention geometry, execution modes, CU count, PA kernel/tuning source contents, and native toolchain/environment/device fingerprints. Tensor strides, allocated KV pages, block-table padding, scalar scale values, and
max_context_lengthdo not partition the tuning cache. Restart inference processes after updating cache files and use separate directories for parallel tuning processes.Validation for the standalone-script extraction: Ruff, Black, Python syntax compilation, and diff checks pass. Tests and GPU tuning were not run for this follow-up, as requested.
The previously observed FP32-reference failure for
varlen_b81_q4_c1027occurred on both monolithic and refactored kernels (maximum absolute error 0.00712435 withatol=rtol=0.005). This extraction does not change its numerical behavior.