[MUSA] fa3: per-attention-window AOT scheduler metadata (opt-in) #314
All Vouch review confidence checks passed
Residual risk 0.30 = Change Risk (0.52) × (1 − Review Confidence (0.43)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #314"
general
weight: 0.35
yeahdongcn
Why
MUSA's FA3 builder can hold only one AOT scheduler-metadata tensor, so a model that
mixes full attention with sliding-window attention loses the prebuilt split plan
for every layer.
_get_sliding_window_configs()sees more than one config andthe builder answers by disabling AOT scheduling model-wide:
That hits every hybrid full + SWA checkpoint we support: gemma2 / gemma3 / gemma4,
gpt-oss, llama4 iRoPE, minimax_m2, plamo3 (arbitrary window list), modernbert. A
gemma4 layer whose window is
(-1, -1)runs exactly the same attention problem as adense model's layer, but it still pays the wrapper-side heuristic because a different
layer in the same model has a window.
The two schedules are genuinely not interchangeable — the window bounds the visible KV
blocks, hence
num_n_blocks, hence the split count — so the fix is one slot perattention kind, not one slot for all of them. This mirrors what SGLang did for MUSA FA3
in sgl-project/sglang#46834 (per-kind scheduler-metadata slots, fail-fast instead of
fallback, per-window graph buffers) and is the first step of aligning our backend with
that capability set.
What
_normalize_attention_window()/_get_attention_window_layouts(): enumerate onelayout per distinct paged-KV attention window, full attention first, normalized and
de-duplicated. Encoder-only / encoder layers are excluded: they never read a KV-cache
schedule, and their per-layer window would otherwise look like a distinct decoder kind.
FlashAttentionMetadata.kind_scheduler_metadata+scheduler_metadata_for(window):the builder fills one schedule per window; each
FlashAttentionImplreads the slot thatmatches its own
sliding_window. A window that is missing from a populated map resolvesto
None, i.e. MATE derives a schedule inside the wrapper (slower, always correct) —never another window's plan.
CUDA graph: one persistent buffer per window, allocated on the first AOT build (i.e.
before capture), so recorded FULL graphs read a fixed address exactly like the primary
slot does today.
Qwen direct-decode-schedule path (
_use_musa_qwen_direct_decode_schedule) hands everylayer the same prebuilt schedule, so it now requires a single-window model.
DCP keeps its previous single-slot behaviour:
_forward_with_dcpbuilds one two-sidedschedule for one window and every layer reads it, so a window-mixed batch still keeps
AOT off rather than silently feeding SWA layers a full-attention plan.
The per-window path is opt-in via
VLLM_MUSA_FA3_AOT_PER_WINDOW=1. The default isbit-for-bit the current behaviour (see the measurement below for why).
Evidence
Correctness (CPU, in the v0.32.0 prebuilt container)
The new suite covers window normalization, dedup + full-first ordering, encoder
exclusion, the opt-in gate, "one schedule per window" (distinct
data_ptrs), single-windowmodels keeping the upstream fast path, DCP, cascade, fast/spec builds, per-window graph
buffers (device address preserved, tail zeroed, rewritten in place), the selection matrix,
and the three forward paths that consume a schedule (decode fast path, paged varlen,
layer whose window is absent).
Two pre-existing failures reproduce identically with the pristine
v0.32.0-devfile andare unrelated:
test_flash_attn_dcp.py::test_forward_dispatches_to_dcp_path(test fixturebuilds an unpacked
kv_cache, the backend expects packed K/V) andtest_attention_backend_capabilities.py::...supports_rswa.Functional (S5000, gemma-3-270m-it: 18 layers, 5 sliding : 1 full, window 512)
The shared model store does carry
gemma-4-31B-it, but on this build it selectsTRITON_ATTNand never reaches FA3 (see Reachability below), sogoogle/gemma-3-270m-itis the only FA3 hybrid available in either round — it alternates full and sliding layers
exactly like gemma4 does. With the opt-in flag on, the builder logs
MUSA FA3 AOT scheduling across 2 attention windows: ((-1, -1), (511, 0)).Greedy completion, 3 prompts × 24 tokens,
temperature=0, logprobs captured:| run | tokens | max abs dlogprob vs |
| --- | --- | --- |
| baseline eager | 72/72 | — |
| candidate eager (flag on) | 72/72 identical | baseline eager 0.00000 |
| baseline graph (
FULL_AND_PIECEWISE, capture[1,2,4,8]) | 72/72 identical | baseline eager 0.66630 (pre-existing eager-vs-graph delta) || candidate graph (flag on) | 72/72 identical | candidate eager 0.66630 (same delta) |
base-eager == cand-eagerandbase-graph == cand-graphat 0.00000, and FULL graphs forboth capture sets were recorded and replayed, so the per-window persistent buffers survive
capture. Cold start: the first flag-on graph run paid one-time MATE scheduler JIT for the
extra window (210 s to ready vs 63 s); with warm caches both are 62-63 s.
Performance — why the flag defaults off
Decode-heavy workload,
vllm bench serve, random 512-in / 128-out, batch 32, same GPU,3 reps each, medians (TPOT ms):
| variant | TPOT | output tok/s |
| --- | --- | --- |
| baseline (
v0.32.0-dev, AOT off by the multi-window rule) | 4.49 | 5960 || this PR, default (flag off) | 4.37 | 6187 |
| this PR,
VLLM_MUSA_FA3_AOT_PER_WINDOW=1| 8.96 | 1709 || flag on, window plan with
num_splits=1| 7.47 | 3915 || flag on, primary plan only (window self-schedules) | 57.47 | 2402 |
The refresh is not what costs. Instrumented over 4400 decode steps, building the extra
plan is 40-47 us for
get_scheduler_metadataplus 26-29 us for the copy into itspersistent buffer, i.e. ~65 us/step, ~1.5% of a 4.4 ms step. The cost is on the device
side: consuming a prebuilt plan in a sliding-window layer loses to letting MATE
self-schedule that layer. The split budget explains only a third of the gap, and the
per-layer compromise is unusable - a graph that plans the full window while the sliding
window self-schedules runs at 57 ms/step - which is why the choice has to stay model-wide,
the way upstream shapes it. Prefill agrees: 4096-token prompts at batch 8 are ~8% slower
with the extra plan (TTFT 2627 ms vs 2440 ms).
So: the capability ships, the default does not change, and the blocker is not a Python-side
cache we forgot to write - it is MATE's scheduled sliding-window path losing to
self-scheduling on this shape. A model where the better split plan saves more than it
costs would win, but 270M parameters with 640-token sequences is not that model.
Hence: the capability ships, the default does not change. Flipping the default needs a
measurement on a hybrid model big enough to amortize the refresh (gemma4-31B, gpt-oss,
MiniMax-M2). The blocker is not availability —
gemma-4-31B-itandMiniMax-M2are bothon the shared store — it is that neither reaches this backend today (see Reachability).
Second round: long context, speculative decoding, embedding
Same host class, greedy, chat endpoint, base vs this PR's default, token-identical with
max |Δlogprob| = 0.000000everywhere:| scenario | run | result |
| --- | --- | --- |
| 32K max-len, 24,460-token prompt | graphs, prefix cache on | 9/9 tokens, 0.000000 |
| same, prefix cache off | graphs | identical to cache-on |
| same, eager vs graph | - | 9/9 tokens, 0.056 Δlogprob (pre-existing numeric delta) |
| speculative decoding, 3 draft tokens |
draft_model, graphs | 31/31 tokens, 0.000000 || embedding / encoder-only |
bge-small-en-v1.5,--runner pooling| 384-dim, cosine 1.00000000 |Warm alternating A/B on the same compiled path (each variant warmed, 2 reps, medians):
concurrency 1 → TTFT 19.00 vs 19.49 ms, TPOT 2.79 vs 2.81 ms, 342 vs 340 tok/s;
concurrency 32 → TTFT 108.4 vs 100.3 ms, TPOT 4.43 vs 4.55 ms, 6075 vs 6010 tok/s.
Default is parity within noise.
Reachability: two scenarios this PR cannot reach
gemma-4-31B-itruns onTRITON_ATTN, not FA3. Its startup log has noFlashAttention versionline andgrep -c flash_attnis 0, so the flagship hybrid archis unaffected by any FA3 metadata work — including the pre-existing model-wide AOT
disable this PR removes. Separate ticket.
FA3 rejects context parallel in this build.
-tp 2 -dcp 2fails backend selectionwith
FLASH_ATTN: [DCP not supported], for a sliding-window model and for an all-fullvariant alike. The DCP branch touched here is therefore defensive only; the comment in
the code says so.
Follow-ups (not in this PR)
MATE's scheduled sliding-window path is slower than self-scheduling it. Measured here:
forcing the window plan down to one split recovers about a third of the gap, and mixing
a planned full window with a self-scheduled sliding window is far worse than either, so
the fix has to make the planned path win rather than move the choice per layer.
SGLang does not cache a schedule: it refreshes the metadata on every replay and copies
the fresh values into the captured tensor addresses, which is the same thing this
backend already gets from its persistent buffer. There is no Python-side cache to port.
update_draft_decode_metadata/supports_draft_decode_metadata_updatedo not exist inthis shadow, so spec-decode draft steps still run
fast_build=Truewith AOT off.Pre-existing and untouched here:
cu_seqlens_kis computed but never read; the encoderpath silently drops softcap/sinks/ALiBi/
num_splits;supports_mm_prefix = Truewithoutan mm-prefix path;
supports_rswais not declared.Test plan
v0.32.0-dev(identical tokens,0.00000 logprob delta)
construction, see the code comments)