Repository navigation
Conversation
New torch-free JIT module module_kda_replayssm_decode (aiter.ops.kda_replayssm): the KDA (Kimi Delta Attention) ReplaySSM decode / speculative-verify step with the semantics of the Triton replayssm_sigmoid_gating_delta_rule, for K = V = 128, windows <= 8 tokens, cache_len <= 16. No memory access under divergent control flow (gfx1250 s_wait_xcnt), DPP reductions, 16-byte staging; one block per (request, head) also orders replay reads before flush writes. MI455X: 1.42x / 1.43x / 1.77x vs the Triton kernel at 8 / 32 / 110 requests (Kimi-K3 shape). op test: 130 passed.
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: Reviews: |
…s of a fused buffer, no copy) Kimi-K3 passes beta as a column view of its fused input projection; the op now reads a and b by token stride when each token's row is dense (16-byte aligned for a), and copies only other layouts. Test: two strided cases, bitwise equal to contiguous inputs (132 passed).
…eplayssm_decode_conv) On the verify path q, k and v come from a width-4 causal conv + SiLU over the mixed q|k|v projection (causal_conv1d_update with num_accepted_tokens). kda_replayssm_decode_conv runs it in the staging phase of the ReplaySSM kernel: three waves load the inputs and the state window (each lane 4 adjacent channels, 2 on wave64), convolve in fp32, round to bf16 into LDS and rewrite the window in place, so q/k/v never go through global memory. Unit-channel-stride conv states (token-major, as ATOM/vLLM allocate) use one 8-byte access per lane and token, other strides per-channel accesses; index tensors may be strided views. Requires H == HV. Tests: fused op vs a torch conv reference feeding the ReplaySSM reference (dim- and token-major conv state, conv state bitwise), strided index views and a forked read slot (bitwise vs contiguous). 197 passed on gfx1250 and gfx950.
Problem
The decode / speculative-verify step of KDA (Kimi Delta Attention) under ReplaySSM — ATOM's Triton
replayssm_sigmoid_gating_delta_rule(fla_ops/replayssm.py) — is latency-bound on MI455X (gfx1250). Per (request, value head) it:cache_len - window(k, u, g) records;At Kimi-K3's shape (12 value heads per TP8 rank, K = V = 128, a 5-token verify window,
cache_len16) it moves 118 MB in 49 µs at 110 requests, i.e. 2.5 TB/s. It is also only 1.2x faster than the same kernel on MI355X. Two things hold it back on gfx1250:s_wait_xcnt) before EXEC changes. A load or store under a divergent branch therefore costs a full memory round trip.Change
A torch-free JIT module
module_kda_replayssm_decode:aiter.ops.kda_replayssm.kda_replayssm_decode(...)has the same arguments, layouts and in-place updates of the checkpoint and the record buffers as the Triton function.kda_replayssm_decode_supported(...)says when it applies:cache_len≤ 16;-exp(A_log)·softplus), and the q/k L2 norm is optional.a(gate input) andb(beta) may be column views of a wider buffer, as Kimi-K3 passes beta. They are read by token stride with no copy, as long as each token's row is dense; any other layout is copied.One block per (request, value head) runs three phases separated by barriers:
write_pos, so their loads do not wait for it.kqowns the 16-byte column chunkskq, kq+4, ….quad_permadds.ugo to LDS.The staging barrier also orders every record read of the replay before the record writes of a flush. A flush rewrites the records from position 0, and in the Triton kernel the programs of one head can race on it.
Files:
csrc/kernels/kda_replayssm_decode.cu,csrc/include/kda_replayssm_decode.h,csrc/pybind/kda_replayssm_decode_pybind.cu,aiter/ops/kda_replayssm.py,op_tests/test_kda_replayssm_decode.py;KDA_REPLAYSSM_DECODE_PYBINDmacro inrocm_ops.hppand the module entry inoptCompilerConfig.json.Nothing existing changes behaviour. Callers opt in, e.g. ATOM behind
ATOM_REPLAYSSM_KDA_HIP=1.Fused short convolution:
kda_replayssm_decode_convOn the speculative-decoding path q, k and v come from a width-4 causal convolution + SiLU over the mixed q | k | v projection (
causal_conv1d_updatewithnum_accepted_tokens), a separate kernel launched right before the recurrence.kda_replayssm_decode_conv(x, conv_state, conv_weight, conv_state_indices, num_accepted_tokens, ...)runs both in one kernel:num_accepted − 1(fromconv_state_indices_inwhen a forked state is resumed). Each lane owns 4 adjacent channels of one of q, k, v (2 on wave64 parts).[hist₁, hist₂, x₀ … x_{T−1}]in place.[lines, dim, len]view. A unit channel stride (the token-major layout ATOM and vLLM allocate) takes one 8-byte access per lane and token; other strides take per-channel accesses.[batch, window]slot table).kda_replayssm_decode_conv_supported(...)says when it applies.Results
MI455X, one GPU, profiler kernel time (median of 30 calls). Inputs are rotated so they are not cache-resident, and pre-touched. Shape: 12 value heads, 5-token window,
cache_len16, record cursors uniform over the buffer (so about 40% of the requests flush), fp32 checkpoint and g records — the layout ATOM allocates.Decode chain, conv + ReplaySSM. Same method, on the serving layouts: mixed q|k|v and beta are column views of the fused in-projection output, the conv state is token-major (seen transposed), and the conv slots are a column view of the slot table. Time is every kernel the chain launches; the Triton chain includes the beta copy its wrapper makes.
kda_replayssm_decodeµskda_replayssm_decode_convµsOn gfx950 the fused kernel takes the Triton chain from 24.0 / 35.5 / 75.1 µs to 16.4 / 25.8 / 56.0 µs.
Correctness
python -m pytest op_tests/test_kda_replayssm_decode.py: 197 passed (gfx1250 and gfx950). The reference is an fp32 PyTorch ReplaySSM step, and the grid covers:slot_idxof −1, and thewrite_pos−1 sentinel;It checks the output, the checkpoint (rewritten only on a flush) and every record row (appended at
base + t, the rest untouched).Two more cases pass gate and beta as column views of a fused buffer (head steps 1 and 2). Their results are bitwise equal to contiguous inputs.
The fused op is checked against a PyTorch conv reference feeding the ReplaySSM reference, over the same request/window grid, both g record dtypes, and both a dim-major and a token-major (transposed) conv state. It compares the output, the checkpoint, the records and the rewritten conv state (bitwise). One more case passes strided index views and a forked read slot; its results are bitwise equal to contiguous indices.
Against the Triton kernel itself, through ATOM's
replayssm_sigmoid_gating_delta_rule:Testing
hipcc,--offload-arch=gfx1250, andgfx950) on aiter trees from 2026-11-13.aiter_tensor.h,aiter_stream.handaiter_hip_common.h.rocm_ops.hpp/optCompilerConfig.jsonchanges are additions.