Skip to content

attention: Triton unified_attention decode kernel for Muse Spark - #80

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

kyle-256 merged 7 commits into
mainfrom
fanxingran/muse-spark-attention

Conversation

@fanxingran

@fanxingran fanxingran commented Nov 6, 2026 •

Copy link
Copy Markdown
Collaborator

Why

Muse Spark's multi-token decode (DSpark verify, q=8; drafter, q=7) on vLLM's ROCM_AITER_FA backend
runs aiter's Triton unified_attention. This adds a split-KV, GQA-packed Triton kernel for
[email protected]: one program per (request, KV head, KV segment) loads each K/V tile once for
all of the request's queries and the 8 query heads sharing that KV head, and a second kernel merges
the segments.

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

Scope

  • Kernel schemas for Muse (16 heads, 2 KV heads, head_dim 64, block 16), batch 1..128 (vLLM's Muse
    recipe runs --max-num-seqs 128): q=8 global, q=8 window (2047, 0) and q=7 window (2047, 0),
    each requires: {"triton": ">=3.8"}.
  • Replaces main's q=8 and q=8 window definition schemas (98e71b8c93780330.json,
    9e6e990978c3fdd3.json), whose workloads the kernel schemas list.
  • Since the last review: the split-KV plan is retuned. Software pipelining (num_stages 2 or 3)
    and per-batch segment counts sized to about 2 programs per CU (non-power-of-two segment counts
    merged); batches without a consistent gain keep the previous config. Main is merged in (no
    force-push).

Tradeoffs

Verification

Environment: head eacb09c (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
unified_attention q=8 global aiter unified_attention 128/128 128/128 0.949 – 3.091 (geomean 2.160); 127/128 at 1.05 or more (batch 2 demoted)
unified_attention q=8 window (2047, 0) aiter unified_attention 128/128 128/128 1.666 – 4.275 (geomean 2.233)
unified_attention q=7 window (2047, 0) aiter unified_attention 128/128 128/128 1.651 – 4.376 (geomean 2.257)
Validation log
$ python -m aklr validate --base origin/main --stages audit,bench --devices 0 <one schema per run, three runs>
audit: passed, findings: 0
bench: passed, findings: 0 (q8 global: 127 passed, 1 not_faster (demoted); q8 window: 128 passed; q7 window: 128 passed; accuracy ok 384)
$ 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 1707.42s (0:28:27)

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.

Muse Spark on vLLM (manual, outside CI)

With the previous revision of these kernels (before the split-KV retune):
vllm/vllm-openai-rocm:nightly (vllm 0.33.0rc1.dev806+ga2bcb5657, aiter 0.1.27), Muse's recipe
(TP8 + expert parallel, DSpark k=7, --max-num-seqs 128, FULL_AND_PIECEWISE graphs), MI355X x8.
A sitecustomize hook (not in this PR) routes vLLM's unified_attention calls through
aklr.ops.unified_attention; calls no schema serves fall back to aiter. Decode there is q=8 on 46
window and 16 global layers and q=7 on the drafter's 5 window layers, contexts 8k - 9k at batch 1,
4 and 32.

aiter (3 runs) AKLR (2 runs)
ITL c1 / c4 / c32, random 8192 in / 1024 out (ms, mean of runs) 14.86 / 19.13 / 47.32 13.12 / 18.03 / 45.36
gsm8k 5-shot greedy, 200 questions 0.970 / 0.970 / 0.965 0.955 / 0.965
DSpark mean acceptance length on gsm8k 3.92 – 3.97 3.90 – 3.96

Greedy outputs differ run to run on either side (two aiter runs agree on 69 of 200 gsm8k answers'
texts), so the accuracy rows are within noise (one question is 0.005).

Not run

  • Muse Spark end-to-end in CI: Muse is not among the e2e scenarios, its vLLM model is not on vLLM
    main yet, and no vLLM plugin route calls aklr.ops.unified_attention yet.

Risk

Affects: Muse Spark multi-token decode (unified_attention, 16/2/64/16, q=8 and q=7) on MI355X.
If wrong: wrong attention output for Muse decode.
Undo: [email protected] runs AITER; otherwise git revert. New schemas carry no
speedup until the publish-measurement bot measures them on main, so nothing serves before that.

…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.
…for Muse decode

One program per (request, kv head, KV segment) loads each K/V tile once for all
8 queries x 8 query heads of a kv head; segments are cut from each request's own
length on the device (graph-safe launch from the batch alone), edge tiles only
are masked, a sliding window restricts the walk, fp32 partials merge in a
second kernel. Global layers serve batch 5..64 (1..4 stay on aiter), sliding
window 2047 layers batch 1..64.
…ified_attention

The drafter calls unified_attention with max_seqlen_q 7 on its window-2047 layers
(total_q = 7 x batch, batch 1..64), which had no schema and fell back to aiter.
Add the q=7 window (2047, 0) kernel schema with the q=8 kernel unchanged: a
7-query request runs the same 8-row query tile with its last row masked, and the
launch plan depends only on batch and window.
vLLM's Muse recipe runs --max-num-seqs 128, so decode batches 65..128 reach the
unified_attention schemas. Measure all three at batches 1..128 with the same kernel.
The q8 global schema leaves batch 2 to AITER: both sit near the launch floor there
and six plans ran 0.71-0.98x of it, while batches 1, 3 and 4 clear it.
…-attention

# Conflicts:
#	aklr/ops/README.md
#	tests/ops/names.txt
…d_attention, pinned to Triton 3.8

The q8 global, q8 sliding window (2047, 0) and DSpark drafter's q7 window kernels at batches
1-128, with software pipelining (num_stages 2/3) and per-batch segment counts sized to about
2 programs per CU (non-power-of-two segments merged); rows without a consistent gain keep the
previous config. The schemas this PR adds now pin kernel.requires (#168), and main's q8 and q8
window schemas they replace are removed.
@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

Copy link
Copy Markdown
Collaborator

please rebase main to pass the CI

@kyle-256
kyle-256 merged commit dc4149c into main Nov 18, 2026
17 checks passed

This branch was previously deployed

1 inactive deployment
gpu-trusted — e81c3da4 Deployed Nov 17, 2026 by fanxingran via prepare-gpu / prepare #1010
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