Skip to content

attention: Triton paged_attention_decode kernel for Muse Spark - #81

Merged
kyle-256 merged 6 commits into
mainfrom
fanxingran/muse-spark-attention-paged-triton
Nov 18, 2026
Merged

kyle-256 merged 6 commits into
mainfrom
fanxingran/muse-spark-attention-paged-triton

Conversation

@fanxingran

@fanxingran fanxingran commented Nov 6, 2026 •

Copy link
Copy Markdown
Collaborator

Why

Muse Spark's one-token decode on vLLM's ROCM_AITER_FA backend calls aiter's paged_attention_v1; this
adds a Triton kernel for its [email protected] shape (16/2/64/16, NHD kv_split_pages): one
program per (request, KV segment) runs all 16 query heads as one MFMA tile over both kv heads, and a
second kernel merges the segments.

The contract and its definition schema reached main in #114 (#79, this PR's former base, is closed);
this PR now targets main and adds only the kernel schema.

Scope

  • paged_attention_decode_kv_split_pages_n_heads16_n_kv_heads2_head_dim64_block_size16 (Triton,
    requires: {"triton": ">=3.8"}): batch 1..64 except 25, 41, 49, 54 and 59, and 65..76, 78, 80, 81,
    83, 89, 98 (77 batches; vLLM's Muse recipe runs --max-num-seqs 128, the others stay on AITER).
    Main's definition schema for the shape (6c3a63a04ab9207f.json, no sources) stays: it still lists
    the batches this kernel does not serve.
  • On the latest vLLM (vllm/vllm-openai-rocm:nightly) Muse with DSpark decodes through
    unified_attention only (attention: Triton unified_attention decode kernel for Muse Spark #80); this kernel serves deployments without speculative decoding.
  • Also serves one-token sliding-window decode (sliding_window > 0, any table width), as vLLM main's
    use_swa_paged calls it (table trimmed to the window's 129 blocks, sliding_window=2048).

Tradeoffs

  • At the 1.05 bar (feat(validation): one 5% bar for admission and dispatch, and acceptance criteria for kernel and plugin PRs #153), 58 of the 77 workloads reach 1.05 in this run; the other 19 (batch 26..98,
    1.023 – 1.049x) are kept, measured but not served unless the publish-measurement bot's run on main
    reaches 1.05. These batches are memory bound (below), and which of them clear a given bar follows
    each one's drawn contexts more than its launch shape: in earlier runs batch 66 ran 1.04 – 1.06x and
    42 ran 1.04 – 1.05x.
  • A request of at most 2560 tokens is cut into up to 32 segments of at least 128 tokens. Without that,
    the trimmed-window and short-context calls at batch >= 16 ran 0.55 – 0.99x of AITER (too few
    programs); with it they run 1.12 – 1.59x, and the bench's workloads lose about 0.5%.
  • The bench's contexts (uniform 1..32768) are memory bound: AITER reads at 4.1 – 5.7 TB/s and a plain
    Triton streaming read reaches 5.0 – 5.2 TB/s here, so batch 25..64 has little headroom.
  • Batch 65..128 is more memory bound still: four other plans ((tile, tiles per segment, warps) =
    (32, 32, 1), (32, 16, 2), (32, 32, 2), (64, 8, 2)) did worse (geomean 0.966 – 1.002); only the 18
    batches at 1.04x or more in three earlier runs are listed.

Verification

Environment: head 3500481 (main 78496c0 merged in), MI355X x1,
lmsysorg/sglang:v0.5.22-rocm10-mi35x (sha256:1438dd8b), torch 2.11.0+rocm10.0.0, FlyDSL 0.3.2,
Triton 3.8.0, AITER dbd8bf5bd (AKLR_BASELINE_AITER)
Gate overrides: none

Kernels

contract baseline measured accuracy (bound) speedup
paged_attention_decode (16/2/64/16) aiter paged_attention_v1 77/77 77/77 1.023 – 1.327 (geomean 1.095; batch 1..24 1.051 – 1.327, 25..64 1.023 – 1.198, 65..98 1.035 – 1.075); 58/77 at 1.05 or more

Stress (every workload of batch 1..64 on streams limited to 16 and 64 CUs and beside a second call,
the same kernel source): bitwise the same output, PASS.

Sliding-window and short-context decode (local, the same kernel source; graph replay, against aiter on
the same call; max abs error vs float64 at most aiter's):

call batch 1..64
trimmed table, sliding_window=2048, contexts 1..32768 1.12 – 1.59x, error <= 2.3e-3
full table, sliding_window=2048, contexts 2048..32768 1.55 – 6.69x
full table, no window, contexts 100..2048 1.14 – 1.48x
full table, sliding_window=1000, contexts 100..2048 1.19 – 1.50x
full table, sliding_window=5, contexts 1..32768 1.57 – 12.8x
full table, no window, contexts 1..32768 1.04 – 1.45x
Validation log
$ python -m aklr validate --base origin/main --stages audit,bench --devices 0 aklr/ops/attention/impls/triton/paged_attention_decode_kv_split_pages_n_heads16_n_kv_heads2_head_dim64_block_size16/6070d2d9cef49ec6.json
audit: passed, findings: 0
bench: passed, findings: 0 (77 workloads: 58 passed, 19 not_faster (demoted); accuracy ok 77)
$ python -m aklr export check; echo rc=$?
rc=0
$ python -m pytest -q tests
FAILED tests/ops/test_reference.py::TestReference::test_backend_matches_reference[[email protected]]
1 failed, 1155 passed, 196 skipped, 35 warnings, 119 subtests passed in 1710.75s (0:28:30)

The one test failure (qwen3_next_gdn_prefill_group_fp8_quant's delta_state bound) fails the
same on main 78496c0 and touches nothing here.

Not run

  • Muse Spark end-to-end on AKLR: not an e2e scenario, its vLLM model is not on vLLM main yet, and no
    vLLM plugin route calls aklr.ops.paged_attention_decode yet.
  • The bench's workloads are sliding_window=0; the sliding-window rows above are a local check.

Risk

Affects: aklr.ops.paged_attention_decode calls at Muse's shape (16/2/64/16) on MI355X.
If wrong: wrong attention output for Muse one-token decode.
Undo: [email protected] runs AITER; otherwise git revert. The schema has no
speedup until the publish-measurement bot measures it on main.

…contracts

[email protected] is one-token paged decode on vLLM's kv_split_pages
cache, timed against aiter's paged_attention_v1; [email protected] is the
multi-token decode vLLM's ROCM_AITER_FA backend runs, timed against aiter's
Triton unified_attention. Both baselines call aiter as that backend does. An
attr value may now be a tuple of ints, so window_size is the attr (-1, -1) or
(2047, 0) as vLLM passes it; softcap is a scalar and the descales optional
inputs that must be absent. Adds the KvSplitPages and StridedRows layouts and
Muse (16/2/64/16) definition schemas for both.
…one-token decode

One program per (request, KV segment) runs all 16 query heads as one MFMA tile
over both kv heads' K/V tiles (a block's two heads are 8 KB contiguous in vLLM's
kv_split_pages cache), the cross-head logits masked. A request is cut into
segments of a per-batch tile count, one of at most 2560 tokens (vLLM's
2048-token sliding window, a short context) into up to 32 segments; the launch
depends only on batch and table width. fp32 partials merge in a second kernel;
no program waits for another. Replaces the kernel-less definition schema and
serves batch 1..64 except 25, 41, 49 and 59 (0.98-1.03x), which stay on aiter.
…t clears AITER

Non-spec Muse decode runs up to --max-num-seqs 128. Batch 65..128 is memory bound against
AITER's paged_attention_v1 (0.87-1.10x over three runs with the batch 56 plan; four other
plans did worse), so add only the 18 batches at 1.04x or more in all three runs. Batch 54
leaves: 1.028-1.035x over four runs.
…-attention-paged-triton

# Conflicts:
#	aklr/ops/README.md
#	tests/ops/names.txt
…on 3.8

kernel.requires (#168) for the kernel this PR adds; its uuid changes with it.
@fanxingran
fanxingran changed the base branch from fanxingran/muse-spark-attention-contracts to main November 16, 2026 06:37
@fanxingran fanxingran added ci:gpu and removed ci:gpu labels Nov 16, 2026
@kyle-256
kyle-256 merged commit 94a2631 into main Nov 18, 2026
17 checks passed

This branch was previously deployed

1 inactive deployment
gpu-trusted — 32a72274 Deployed Nov 17, 2026 by fanxingran via prepare-gpu / prepare #1011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants