Repository navigation
[QSA] Enable breakable prefill CUDA graphs for text-only Qwen3.8 Flash-Next (capture-safe metadata, MTP side-channel padding) - #41729
Conversation
ba70bd6 to
051c6c6
Compare
e64ae0c to
a4c9d22
Compare
Run the prefill indexer in an eager break using the current batch metadata. Use scheduler CPU lengths and the prepared slot table to avoid capture-time D2H. Share top-k storage across token buckets; leave eager and decode paths unchanged.
Capture HC state as an explicit output and restore it before the logits tail. Pad present draft embeddings to the token bucket while preserving text-only None. Cover live metadata, bucket boundaries, and the draft embedding fallback in three tests.
Allow the text-only Qwen4Exp configuration through the multimodal compatibility gate. Keep the runtime multimodal replay guard and other backend restrictions. Do not change decode graphs or enable full prefill graphs.
Include multimodal admission in the shared DP prefill graph vote. Run PLE layout, prefetch, convolution, and state commits in eager breaks. Cover mixed-rank admission and layer-two 1x8 to 2x4 replay on CPU.
Cache target HC and draft embedding policy with is_qwen4_exp at initialization. Use the multimodal allowlist and the registered small-GPU test suite. Clarify D2H and buffer costs, and use keyword arguments for private helpers.
…st sizes Record the same token prompts with MTP disabled and 64 greedy output tokens. Compare argmax and logprobs at concurrency one and eight with prefix tracking. Keep the end-to-end server check manual and retain every differing position.
Move live-length, HC padding, PLE layout and DP voting checks into existing suites. Keep the manual comparison tool with the external accuracy evidence. Preserve production behavior and update affected CPU fixtures.
Provide the multimodal predicate in the hidden-state and CP test fixtures. Use a plain PLE holder with __dict__ for eager-break output replacement. Keep replay behavior unchanged and remove the new dataclass import.
a4c9d22 to
b2292ef
Compare
…ble graphs Pad the shared top-k bridge with 0 to keep the zero-padding the eager path used, and route a materialized idle batch through PLE forward_idle inside the eager break so replay never calls the PLE layer with no batch. Co-Authored-By: Claude Fable 5.1 <[email protected]>
b2292ef to
c5a53d6
Compare
…ble MTP embed padding Breakable replays run the PLE prefetch inside an eager break with live token counts while capture mode is still on, so the per-size graph buffer cache grew without bound; use it only outside breakable graphs. The Qwen MTP embedding padding was unreachable because replay already rejects multimodal batches. Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
Pushed ed6cbce: after the rebase, main's replay closure (f4c2563) also matches |
…ble replay main's replay closure now matches both input_embeds and inputs_embeds (f4c2563). Qwen4-Exp's MTP draft passes its hyper-connection stream (hidden x hc_count) in that position, so the copy into the input_embeds slot failed with a width mismatch on every real prefill. Skip the fill for the Qwen BCG draft; the body reads that stream from the spec hidden-state slot.
# Conflicts: # python/sglang/srt/layers/attention/qwen_sparse_attn_backend.py
Breakable prefill reduced MTP accept length by 4-5% without a material task-accuracy change. The draft passes a hidden_size * hc_count HC stream as inputs_embeds, but the replay slot was registered at hidden_size, so the copy was skipped and replay ran on capture-time input. Declare input_embeds_hidden_size on the MTP draft and keep the live input copy before replay. GSM8K-200 accept length: TP1 3.31 -> 3.47 (197/200), TP4 with the CI args 3.44 (197/200).
|
Pushed 9887f73 for the base-c MTP accept-length failure (2.88 < 2.9): with breakable prefill the MTP draft's replay was running on capture-time input — the draft passes its hidden×hc_count HC stream in the |
|
CI status on c5c6ee3: all base-c jobs pass except base-c-test-4-gpu-b200 (0) (GLM-5.3-Flash GSM8K, threshold 0.93). The failing class alternates between attempts (attempt 1: DFlash2 0.926/0.92/0.92; attempt 2: DFlash2 passes at 0.934 and LowLatency fails at 0.928/0.926/0.926), and both failing classes run with the prefill CUDA graph disabled, so this PR's code is not on their path |
Motivation
Qwen4Exp breakable prefill is blocked by the multimodal compatibility rules, including for text-only batches. Once the indexer runs in an eager break, live lengths and the prepared slot table avoid one D2H synchronization per QSA layer on replay. MTP replay also needs current HC state and matching target/draft token buckets. PLE request layouts must follow the live batch rather than the capture batch.
Modifications
contains_mm_inputsindp_attn's unified vote and share eligibility between scheduling and execution, rejecting multimodal target and draft batches.multimodal_breakable_cuda_graph_supported_model_archsand remove the special-case hook.is_qwen4_exponce in runner initialization and read cached target/draft policy during forward.Nonefallback.Σbucket_tokens × 512 × 4B × 12drops from 765 MiB to 384 MiB (381 MiB saved; thebuckets × max_tokensupper bound is 3 GiB).Accuracy Tests
Bit-identical outputs between graph replay and eager are not expected: breakable capture pads prefill to token buckets, which changes kernel shapes and reduction order.
GSM8K task accuracy is unchanged: 200 questions, 5-shot, strict scoring gives 197/200 with prefill graphs enabled, the same as disabled and base (measured on the pre-rebase branch).
For greedy, MTP-off generation over 16 prompts × 64 tokens (measured before this rebase), shared-prefix absolute logprob differences for the same reference-eager token are:
Serial graph/eager has a higher p90 but a similar p99 to the batching baseline; on the 337 positions shared by all comparisons, their p90 values are 0.094516 and 0.093125, while concurrent graph/eager has smaller tails.
Only 2/12, 0/8 and 0/3 flips respectively have a top-1/top-2 gap below 0.05 on either side (none on both), so the flips are not uniformly near-ties; distribution details and CDF retain the measured tails and limits of this comparison.
Speed Tests and Profiling
These results are pre-rebase measurements, not performance validation of the current revision. Static benchmark, same patched branch, disabled → breakable, MTP on, 300 s admission:
AgentX AGG TP1 C64, 900 s, Golden AL 2.32: base disabled → patched breakable improved 1000/ITL p90 from 35.6 to 38.8 (+8.9%) and total tok/s/GPU from 201.5k to 205.2k (+1.8%), with zero profile request errors. Target capture cost was 33 s / 10.5 GB.
Checklist
CI States
Latest PR Test (Base): ❌ Run #37051030206
Latest PR Test (Extra): ❌ Run #37051029314
Latest PR Test (AMD ROCm 10): ❌ Run #37051029739