Repository navigation
[Triton/Gluon] Feat/gfx1250 replayssm kda verify - #7975
Liang-jianhao97 wants to merge 9 commits into
Conversation
Select a JSON write-back config for supported BF16 paged decode with FP32 state. Reuse the existing recurrence and add a short launch entry with an exact specialization cache, current-stream launches and hook fallback. Use a 4D register layout, clause-free b64 whole-line state stores, staged output and spread chunks. Keep full gating, normalization and state math. Keep slot zero valid and skip negative slots, including multi-token stores. Validation on d07 B0: 27 new public API tests passed; selected existing regressions plus the new tests passed 69 with 12 expected dtype skips. Black, Ruff, compileall and diff checks passed. RotatingBufferBench pool1 and pool16 smoke tests passed. Standard direct-public-call do_bench measured 9.574/14.823 us versus main 37.416/37.656 us, geometric mean 3.151x.
Accept gfx1250-strict in the write-back selector and KDA test markers. Use the gfx1250 configuration tree for both compiler targets, including the test config fixture. Keep the native compiler target unchanged. Validation on g21-10: 27 write-back tests and 66 selected existing KDA tests passed, with 12 expected BF16-state skips. Black, Ruff and diff checks passed. RotatingBufferBench pool1 and pool16 smoke tests passed. Two direct public-call do_bench runs measured 14.82-14.86 us fixed and 14.90-14.94 us with 16 rotating states. The main control uses the same strict config-path correction; geometric-mean speedup was 2.18-2.22x.
The fast path is selected only for length-0/1 sequences, and longer sequences stay on the generic kernel. Co-authored-by: Cursor <[email protected]>
The length check uses itertools.pairwise, which is what ruff 0.16.0 reports on this PR. Co-authored-by: Cursor <[email protected]>
…slots. Ordinary gfx1250 decode still uses the one-token kernel. A state fork or speculative verify can load one slot and store another, including slot 0 and negative slots, without clobbering the checkpoint. Co-authored-by: Cursor <[email protected]>
…chmark. Move ssm_state_indices_in in try_kda_one_token_decode to a keyword-only argument so existing positional callers that pass out keep working. Fix a nested-if lint issue in fused_recurrent_kda, format the new test, and add bench_kda_atom.py comparing one-token, generic, and the ATOM entry (same slots, split tensors, state fork) on gfx1250. Co-authored-by: Cursor <[email protected]>
Fold the separate one-token and ATOM benches into bench_kda's shape and metric table, including a state-fork column that reads a disjoint slot. Co-authored-by: Cursor <[email protected]>
Add checkpoint replay and fused token verification with a Gluon kernel. Use the shared fast launcher and JSON config loaders. Keep the existing one-token decode interface unchanged. Cover flushes, strided beta, FP16 and FP32 output, graph capture and state updates. Add a benchmark for standard do_bench and graph/event timing. Validation on gfx1250: 24 ReplaySSM tests and 36 existing decode/ATOM tests passed. Ruff and Black checks passed.
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: Reviews: |
WAITING ON AUTHORPR Self-ReviewRevision Waiting for the PR author. The readiness report will appear after the self-review answers are complete for this revision. Questions to answer in the PR description
Edit the Missing or invalid answers
Shadow mode reports what would block but keeps the status successful. Set |
There was a problem hiding this comment.
🟡 Changes recommended
Critical issues can leave tokens unwritten during graph capture, select a missing configuration tree on gfx1250-strict, and load the wrong state when cached updates use distinct read/write tables.
14 open issues
Cached replay uses the write table for checkpoint and history loads · New Graph capture can select a kernel that leaves tokens unwritten · New ReplaySSM config is missing for the strict gfx1250 target · New Eager decode copies cu_seqlens to the host on every eligible call · New Benchmark input builder ignores the selected device · New Custom timer bypasses RotatingBufferBench and under-exercises pools · New Split-slot helpers duplicate existing one-token logic · New Config loader duplicates get_kda_config logic · New _kda_rowsum8_t duplicates the DPP reduction block · New _kda_dot8 duplicates the eight-block dot-product chain · New Sigmoid expressions duplicate shared activation helpers · New Unused import creates a second public home for the function · New One-token and ATOM changes violate the separate-kernel PR rule · New Test bypasses the public wrapper by installing a private launcher · New
What changed in this PR
Adds gfx1250 ReplaySSM verification to AITER’s Kimi Delta Attention support. The new entry rebuilds committed state from checkpoints and history, processes current tokens, and updates records without advancing the caller’s commit cursor.
Changes:
- Adds a ReplaySSM wrapper, Gluon kernel, and JSON configuration for K=V=128.
- Adds one-token decode dispatch and ATOM read/write slot support, plus shared launcher compatibility changes.
- Adds reference tests and benchmarks for state transitions, graph capture, and fixed or rotating state pools.
| File | Description |
|---|---|
op_tests/triton_tests/attention/test_kda.py |
Enables existing tests for the strict gfx1250 target. |
op_tests/triton_tests/attention/test_kda_replayssm.py |
Tests replay, checkpoint flushing, records, dtypes, and capture. |
op_tests/triton_tests/attention/test_kda_one_token.py |
Tests one-token dispatch, fallback, strides, and launch behavior. |
op_tests/triton_tests/attention/test_kda_atom.py |
Tests separate read/write slots and speculative verification. |
op_tests/op_benchmarks/triton/bench_kda.py |
Adds one-token and ATOM benchmark providers. |
op_tests/op_benchmarks/triton/bench_kda_replayssm.py |
Adds ReplaySSM timing with fixed and rotating state pools. |
aiter/ops/triton/configs/gfx1250/gluon/attention/kda_replayssm/DEFAULT.json |
Defines ReplaySSM launch settings. |
aiter/ops/triton/configs/gfx1250/gluon/attention/kda_decode/DEFAULT.json |
Adds a one-token configuration bucket. |
aiter/ops/triton/attention/kda.py |
Integrates one-token dispatch and read/write slot arguments. |
aiter/ops/triton/attention/kda_replayssm.py |
Adds the public ReplaySSM entry and input checks. |
aiter/ops/triton/attention/kda_one_token.py |
Selects and launches supported one-token decode calls. |
aiter/ops/triton/attention/kda_atom.py |
Adds the ATOM-compatible fused gating entry. |
aiter/ops/triton/_triton_kernels/kimi_delta_attn/fast_launch.py |
Adds launch-hook checks and launcher-signature fallback. |
aiter/ops/triton/_gluon_kernels/gfx1250/attention/kda_replayssm.py |
Implements checkpoint reconstruction and token recurrence. |
aiter/ops/triton/_gluon_kernels/gfx1250/attention/kda_decode.py |
Adds one-token kernels and split-slot handling. |
Review effort: Balanced
| if ssm_state_indices_in is not None: | ||
| if ssm_state_indices is None: | ||
| raise ValueError("ssm_state_indices_in requires ssm_state_indices") |
| """True when every sequence length is 0 or 1. | ||
|
|
||
| The bounds live on device. Reading them syncs, which is what keeps a longer | ||
| sequence on the generic kernel instead of dropping its extra tokens. CUDA | ||
| graph capture cannot sync, so a captured call is required to already be a | ||
| one-token batch; the eager path still checks. | ||
| """ | ||
| if torch.cuda.is_current_stream_capturing(): | ||
| return True |
| @functools.lru_cache(maxsize=8) | ||
| def _config(arch, cu_num): | ||
| # Include the CU count to keep device-specific config trees separate. | ||
| path = resolve_config_dir("attention", "kda_replayssm", backend="gluon") |
| """ | ||
| if torch.cuda.is_current_stream_capturing(): | ||
| return True | ||
| bounds = starts.tolist() |
| def bench_kda(H, B, T, provider): | ||
| torch.manual_seed(0) | ||
| if provider in ONE_TOKEN_BACKENDS: | ||
| case = make_one_token_case(B, provider, args.padded) |
| def _kda_dot8(S0, S1, S2, S3, S4, S5, S6, S7, x0, x1, x2, x3, x4, x5, x6, x7): | ||
| """Row sums of S * x: an fma chain over the blocks, then across lanes.""" | ||
| p = S0 * x0[None, :] | ||
| p = gl.fma(S1, x1[None, :], p) | ||
| p = gl.fma(S2, x2[None, :], p) |
| b_beta = 1.0 / (1.0 + gl.exp(-b_b)) | ||
| if USE_LOWER_BOUND: | ||
| b_g = LOWER_BOUND * (1.0 / (1.0 + gl.exp(-(gl.exp(b_Alog) * x)))) |
| from aiter.ops.triton.attention.kda_atom import ( # noqa: F401 | ||
| fused_sigmoid_gating_delta_rule_update, | ||
| ) |
| if _ARCH in ("gfx1250", "gfx1250-strict"): | ||
| result = try_kda_one_token_decode( |
| from aiter.ops.triton._gluon_kernels.gfx1250.attention import kda_decode | ||
| from aiter.ops.triton._triton_kernels.kimi_delta_attn.fast_launch import fast_launch |
|
No activity for 15 days, so this is now labelled |



Summary
Add a gfx1250 Gluon implementation of ReplaySSM KDA verification.
The new public entry rebuilds committed state from checkpoint and history records, processes the current tokens, and writes output and updated records.
Motivation
The existing one-token decode entry does not implement ReplaySSM checkpoint and history-buffer semantics.
This change adds an optimized path for speculative verification, including the M128 workload with four draft tokens and one verification token per active request.
Changes
replayssm_sigmoid_gating_delta_rulefor gfx1250 with K=V=128.do_bench()and Graph/Event timing.Performance
Hardware: gfx1250.
Configuration:
Before is the frozen ATOM ReplaySSM implementation, not the ordinary one-token decode kernel. After is this AITER implementation. Before and After were collected in separate runs on the same machine and software stack; speedups are representative cross-run comparisons.
do_bench()uses 25 ms warmup and 100 ms measurement. Graph/Event uses 64 calls per graph and nine event samples.These are standalone operator measurements, not full-model speedups.
Testing
Documentation
The public wrapper docstring defines supported inputs, state updates, output behavior, and limits. No separate
docs/changes are included.Dependencies
Uses the existing PyTorch, Triton/Gluon, launcher, and config utilities.
Breaking Changes
None. This adds a separate public entry and does not change existing decode APIs.
PR Self-Review
Reviewed revision
Candidate HEAD:
9c0c33ec038abdb449dfdd932bbb67db2272a88f.Automated PR Self-Review revision confirmation is pending.
Behavior and intent
The entry reconstructs committed state, flushes the checkpoint when required, processes the current tokens, and appends k/u/g records.
It does not advance
write_pos; the caller commits accepted tokens separately. Negative slots and empty sequences write nothing. Slot zero remains valid.The implementation requires gfx1250, K=V=128, and the input constraints documented in the wrapper.
Validation and unverified scope
Executed on d01-3, gfx1250:
Result: 24 passed.
Result: 36 passed.
Both benchmarks completed with standard do_bench and Graph/Event timing for state pools of 1 and 16.
Ruff, Black, and Git whitespace checks passed.
Software:
MI250X and MI300X were not tested. This kernel uses gfx1250-specific instructions. Other architectures and full-model integration remain unverified.
PR-specific question
Pending the path-specific question from the automated PR Self-Review comment.
Changed op tests
op_tests/triton_tests/attention/test_kda_replayssm.pyop_tests/op_benchmarks/triton/bench_kda_replayssm.py