← Back to Pull requests

Fused QSA prepare to MUSA (Qwen4Exp / Qwen3.8-Flash-Next) #367

Open
unknown opened this pull request with 376 lines diff across 4 files
View on GitHub
unknown unknown commented on Nov 25, 2026 13:34 UTC
Author

Summary

Enables the existing fused QSA prepare path on MUSA instead of forcing the
unfused reference chain. One Triton kernel now performs indexer prepare
(Q/K norm + RoPE), compression group pooling, raw/compressed cache row writes,
and the main-attention QK-norm/RoPE/gate/KV write in a single launch per QSA
layer per step.

Previously use_fused_qk_norm_rope_gate required current_platform.is_cuda(),
so use_fused_qsa_prepare was always false on MUSA and every QSA layer ran
~16 launches (2x gemma_rmsnorm, 2x apply_qsa_rope,
qsa_compress_groups_with_ratio, 2x qsa_store_cache_rows, plus the
main-attention q/k norm, RoPE and do_kv_cache_update).

Changes

  • vllm_musa/kernels/qsa_prepare.py: MUSA port of the CUDA fused prepare

  • kernel (same launch signature, so the upstream model code is unchanged).
  • models/qwen4_exp/nvidia/qsa.py: allow the fused gate on MUSA, guarded by

  • VLLM_MUSA_QSA_FUSED_PREPARE (default on, =0 restores the old chain).
  • models/qwen4_exp/nvidia/indexer_qsa.py: dispatch to the MUSA kernel when

  • current_platform.is_musa().
  • model_executor/warmup/qwen4_exp_qsa_warmup.py: pre-warm the fused

  • specializations before graph capture, so no JIT happens on the capture stream.

    Results (MTT S5000 80 GiB x8, driver 5.2.0, vLLM 0.32.0, TP8 + EP8)

    Qwen3.8-Flash-Next BF16, 1024-token inputs, warm JIT, 3 runs per leg, only
    VLLM_MUSA_QSA_FUSED_PREPARE toggled:

    | Metric | OFF | ON | Delta |
    | --- | --- | --- | --- |
    | TTFT, 24 req x 1024 in / 1 out | 1388 ms | 1355 ms | -2.4% |
    | TTFT, 16 req x 1024 in / 128 out | 1181.5 ms | 1128.7 ms | -4.5% |
    | TPOT / ITL, batch 16 | 40.72 ms | 36.78 ms | -9.7% |
    | Output throughput, 128-out leg | 322.0 tok/s | 352.7 tok/s | +9.5% |
    | Wall duration, 128-out leg | 6.36 s | 5.80 s | -9.4% |

    Kernel launches per QSA layer per step: 16 -> 1 (12 QSA layers).

    Run-to-run spread: TPOT +-0.24 ms, TTFT +-27 ms, so the TPOT gain is well
    outside noise; the TTFT gain is small but consistently in the same direction.

    Correctness

  • Standalone A/B against the unfused reference: 1D and MRoPE (11, 11, 10)

  • positions, aligned and cross-chunk; max abs diff <= 3.1e-2 for indexer
    q/main q, <= 1.6e-2 for compressed/main outputs, gate and raw ring buffers
    bit-exact, no NaN.
  • TP8 serving: 8/8 ranks pre-warm the fused specializations, /health 200,

  • coherent Chinese answer, no failed requests in any benchmark run.

    Test configuration

    vllm serve /home/dist/models/Qwen/Qwen3.8-Flash-Next \
      -cc.cudagraph_mode=FULL_DECODE_ONLY \
      --attention-backend FLASH_ATTN --tensor-parallel-size 8 --enable-expert-parallel \
      --max-model-len 8192 --gpu-memory-utilization 0.9 \
      --max-num-batched-tokens 20480 --max-num-seqs 16 \
      --mamba-ssm-cache-dtype float32 --no-enable-prefix-caching --no-enable-chunked-prefill
    
    vllm bench serve --backend vllm --dataset-name random \
      --random-input-len 1024 --random-output-len 128 \
      --num-prompts 16 --request-rate inf --seed 42
    

    Diff: 376 lines (+282 / -94) across 4 files Reviewer: yeahdongcn Review duration: 8013m
    All Vouch review confidence checks passed
    Residual risk 0.26 = Change Risk (0.48) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.48 · 376 lines diff across 4 files
    0.48
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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.355
    Shallow Review Depth shallow_review_depth
    0.344
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    1 comments
    "Review active on #367"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 47.9% (MEDIUM) · Higher = larger blast radius
    47.9%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 25.5% · Safe to merge
    25.5%