Skip to content

[gfx1250] Add gfx1250 ReplaySSM KDA verification - #7992

Open
Liang-jianhao97 wants to merge 1 commit into
feat/gfx1250-kda-packed-writebackfrom
feat/gfx1250-replayssm-kda-verify
Open

Liang-jianhao97 wants to merge 1 commit into
feat/gfx1250-kda-packed-writebackfrom
feat/gfx1250-replayssm-kda-verify

Conversation

@Liang-jianhao97

Copy link
Copy Markdown
Contributor

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

  • Add replayssm_sigmoid_gating_delta_rule for gfx1250 with K=V=128.
  • Use one CTA per request and value head, with shared record staging and vector checkpoint access.
  • Use interleaved state layouts and AMD DPP reductions.
  • Use a compiler reduction for FP32 output.
  • Reuse the shared fast launcher and JSON config loaders.
  • Support strided beta inputs, checkpoint flushing, negative slots, slot zero, and multi-chunk token processing.
  • Preserve the existing one-token decode interface.
  • Add reference tests and a benchmark with standard do_bench() and Graph/Event timing.

Performance

Hardware: gfx1250.

Configuration:

  • Request capacity: 128.
  • H=HV=12, K=V=128, record capacity=16, max_query_len=5.
  • BF16 activations and k/u records; FP32 checkpoint and g records.
  • Fixed inputs use one writable state set. Rotating inputs use 16 distinct writable state sets.
  • Timings cover the complete public call.

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.

Hardware Workload/configuration Before After Change
gfx1250 109 active / 545 tokens, fixed, do_bench 44.227 µs 20.792 µs 2.13×
gfx1250 109 active / 545 tokens, rotating ×16, do_bench 48.593 µs 22.554 µs 2.15×
gfx1250 109 active / 545 tokens, fixed, Graph/Event 39.592 µs 16.744 µs 2.36×
gfx1250 109 active / 545 tokens, rotating ×16, Graph/Event 44.979 µs 18.662 µs 2.41×
gfx1250 128 active / 640 tokens, fixed, do_bench 50.316 µs 22.755 µs 2.21×
gfx1250 128 active / 640 tokens, rotating ×16, do_bench 54.281 µs 24.637 µs 2.20×
gfx1250 128 active / 640 tokens, fixed, Graph/Event 45.644 µs 18.503 µs 2.47×
gfx1250 128 active / 640 tokens, rotating ×16, Graph/Event 50.628 µs 20.473 µs 2.47×

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

  • Unit tests added or updated
  • Performance benchmarks run
  • Tested on MI250X
  • Tested on MI300X

Documentation

  • Docstrings updated
  • User guide updated
  • Performance guide updated
  • No documentation change is needed, with the reason stated below

The public wrapper docstring defines supported inputs, state updates, output behavior, and limits. No separate docs/ changes are included.

Dependencies

  • No new third-party dependencies added
  • New dependencies are listed and justified below

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:

pytest op_tests/triton_tests/attention/test_kda_replayssm.py -q

Result: 24 passed.

pytest op_tests/triton_tests/attention/test_kda_one_token.py op_tests/triton_tests/attention/test_kda_atom.py -q

Result: 36 passed.

python op_tests/op_benchmarks/triton/bench_kda_replayssm.py --requests 128 --live 109
python op_tests/op_benchmarks/triton/bench_kda_replayssm.py --requests 128

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:

  • PyTorch 2.11.0+rocm10.1.0a20260811-bkc.20260820
  • HIP 7.16.26315
  • Triton 3.9.0

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.py

    • Checks output, checkpoint, records, and metadata against a PyTorch reference.
    • Covers flush boundaries, skipped requests, slot zero, M128 verification, consecutive transitions, BF16/FP16/FP32, token chunks, side streams, and graph capture.
    • Adds ReplaySSM state-history coverage that the ordinary decode tests do not provide.
  • op_tests/op_benchmarks/triton/bench_kda_replayssm.py

    • Measures the complete public ReplaySSM call with do_bench and Graph/Event.
    • Supports fixed and rotating writable state sets and partially active M128 batches.
    • Covers checkpoint/history workloads that the ordinary decode benchmark does not exercise.

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.
@Liang-jianhao97 Liang-jianhao97 changed the title Add gfx1250 ReplaySSM KDA verification [gfx1250] Add gfx1250 ReplaySSM KDA verification Nov 15, 2026
@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

No activity for 15 days, so this is now labelled stale. A push or a comment clears it; keep-open exempts it. Nothing is closed automatically.

@github-actions github-actions Bot added the stale The PR hasn't been updated in 2 weeks label Dec 1, 2026
gbyu-amd pushed a commit that referenced this pull request Dec 3, 2026
…-15T03:50:39Z)

Applied as the diff 33ae4ce..9c0c33e (5 files) onto the rebased 1116 tree; PR state: open, author Liang-jianhao97, base feat/gfx1250-kda-packed-writeback.

(cherry picked from commit abf0b0f)

Rebase onto main 12-03: imports fast_launch from aiter.ops.triton.utils.fast_launch; main's #8061 moved it there from _triton_kernels/kimi_delta_attn/.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale The PR hasn't been updated in 2 weeks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant