← Back to Pull requests

[Perf][GDN] Pack unquantized Qwen3.5 GDN input projections and restore compiled FP8 dual-stream overlap #387

Closed
unknown closed this pull request without merging on Dec 01, 2026 00:45 UTC
View on GitHub
unknown unknown commented on Nov 28, 2026 02:41 UTC
Author

Summary

Fixes two input-projection bottlenecks in MusaQwenGatedDeltaNetAttention (Qwen3.5 / Qwen3.6 GDN hybrid layers) on MUSA S5000:

1. Packed Single-GEMM Fusion for Unquantized BF16/FP16 GDN (MUSA_GDN_PACKED_PROJ=1, default on):
- Previously, every GDN layer (18 layers on Qwen3.5-2B, 30 layers on Qwen3.5-35B-A3B) executed two separate GEMMs (in_proj_qkvz + tiny [M, 2 num_v_heads_tp] in_proj_ba), paying an extra GEMM launch and redundant hidden_states DRAM read per layer.
- process_weights_after_loading horizontally packs [in_proj_qkvz.weight; in_proj_ba.weight] once after weight loading when eligible (MergedColumnParallelLinear, unquantized BF16/FP16, bias is None, not disable_tp_for_ba_proj, not gqa_interleaved_layout, 16B-aligned ba width) and rebinds qkvz_w.data / ba_w.data to views of the packed tensor (zero extra VRAM).
- Pairs single F.linear(hidden_states, packed_weight) with a new fused_zba_packed TileLang kernel (gdn_fused_proj.py) that materializes contiguous (z, b, a) in one launch while keeping mixed_qkv = mixed_qkvzba[:, :qkv_size] as a zero-copy strided view.
-
Note*: At very large compute-bound prefill M >= 1024, appending 32 ba columns (N = 10240 -> 10272 on Qwen3.5-2B TP=1) adds one muBLASLt N-tile (0.91x–0.99x isolated GEMM), while M = 1..512 gains 1.27x–1.50x eager and 1.30x–1.56x CUDAGraph (+1.27% compiled E2E prefill, +8.72% c=1 decode, +3.43% c=64 decode).

2. Submodule-Deduped Dynamo-Opaque Dual-Stream Overlap for Block-FP8 GDN (MUSA_GDN_OPAQUE_DUAL_STREAM=1, default on):
- Under torch.compile, _forward_input_projections previously evaluated _is_current_stream_capturing() during Dynamo warmup tracing (False), specializing the graph on the serial path so in_proj_qkvz + in_proj_ba dual-stream overlap became dead code during CUDAGraph capture and replay across all 30 GDN layers.
- Introduces a stateless, layer_name-free custom op torch.ops.vllm.musa_gdn_fp8_qkvz_bf16_ba_proj(hidden_states, qkvz_weight, qkvz_weight_scale, ba_weight, group_size, use_deep_gemm_e8m0):
- Avoids per-layer string constants so vLLM's Inductor cache preserves 100% submodule deduplication (24 compiled artifacts on Qwen3.5-35B-A3B-FP8, identical to baseline) and bypasses 30 nested MergedColumnParallelLinear.forward -> Fp8LinearMethod.apply Python dispatches during eager prefill.
- During CUDAGraph capture (0 < num_tokens < 1024), overlaps run_deepgemm(...) (in_proj_qkvz) on current_stream concurrently with torch.mm(..., out=ba) (in_proj_ba) on alt_stream.

---

S5000 Hardware Validation (MTT S5000, 64 MPs, torch 2.13.0.post1+musa5.2.0, mate 0.2.8.post1)

1. Unit & Compile Tests


  • pytest tests/test_gdn_dual_stream_source.py tests/test_gdn_full_graph_metadata_source.py tests/test_gdn_fused_zba_compile.py tests/test_qwen_gdn_output_allocation.py tests/kernels/test_qwen_gdn_proj_musa.py: 46 passed.

  • python3 tools/musa_sync.py check-series & verify: PASS (222 clean / 257 total / 0 need attention).
  • 2. Cold-Cache Eager & Multi-Layer CUDAGraph Microbenchmarks

    (a) Unquantized BF16 Packed Single-GEMM + fused_zba_packed


    | Shape (layers_cg) | M | Eager Ref (ms) | Eager Packed (ms) | Eager Speedup | CG Serial (ms) | CG Dual-Stream (ms) | CG Packed (ms) | CG vs Serial | CG vs Dual |
    |---|---:|---:|---:|---:|---:|---:|---:|---:|---:|
    | Qwen3.5-2B TP=1 (18L) | 1 | 0.1305 | 0.0990 | 1.319x | 0.8477 | 0.8350 | 0.6152 | 1.378x | 1.357x |
    | Qwen3.5-2B TP=1 (18L) | 16 | 0.0911 | 0.0648 | 1.405x | 0.8860 | 0.8645 | 0.6189 | 1.432x | 1.397x |
    | Qwen3.5-2B TP=1 (18L) | 64 | 0.0964 | 0.0658 | 1.465x | 0.8700 | 0.8376 | 0.6373 | 1.365x | 1.314x |
    | Qwen3.5-2B TP=2 (18L) | 1 | 0.1333 | 0.1052 | 1.268x | 0.6623 | 0.6503 | 0.4475 | 1.480x | 1.453x |
    | Qwen3.5-2B TP=2 (18L) | 64 | 0.0893 | 0.0599 | 1.489x | 0.6984 | 0.6867 | 0.4485 | 1.557x | 1.531x |
    | Qwen3.5-35B-A3B TP=1 (30L) | 1 | 0.0891 | 0.0654 | 1.362x | 1.6524 | 1.3766 | 1.2750 | 1.296x | 1.080x |
    | Qwen3.5-35B-A3B TP=2 (30L) | 1 | 0.0920 | 0.0647 | 1.422x | 1.2080 | 1.1907 | 0.8060 | 1.499x | 1.477x |
    | Qwen3.5-35B-A3B TP=2 (30L) | 16 | 0.0939 | 0.0647 | 1.451x | 1.2386 | 1.2103 | 0.8161 | 1.518x | 1.483x |

    (b) Block-FP8 30-Layer torch.compile + CUDAGraph (musa_gdn_fp8_qkvz_bf16_ba_proj)


    | Shape (30L) | M=1 (ms) | M=4 (ms) | M=16 (ms) | M=32 (ms) | M=64 (ms) |
    |---|---:|---:|---:|---:|---:|
    | Qwen3.5-35B-A3B-FP8 TP=1 (base -> dual) | 1.2836 -> 1.0351 (1.240x) | 1.2961 -> 1.0408 (1.245x) | 1.3218 -> 1.0528 (1.255x) | 1.3499 -> 1.0747 (1.256x) | 1.3596 -> 1.2711 (1.070x) |
    | Qwen3.5-35B-A3B-FP8 TP=2 (base -> dual) | 1.0745 -> 0.9602 (1.119x) | 1.0862 -> 0.9735 (1.116x) | 1.0861 -> 0.9691 (1.121x) | 1.1054 -> 0.9961 (1.110x) | 1.1444 -> 1.0497 (1.090x) |

    3. Compiled + CUDAGraph End-to-End Serving A/B/A/B (Isolated VLLM_CACHE_ROOT, enable_prefix_caching=False)

    | Model (TP=1, FULL_AND_PIECEWISE) | Stage | Baseline (tok/s) | Optimized (tok/s) | E2E Gain |
    |---|---|---:|---:|---:|
    | Qwen3.5-2B (BF16) | Prefill (4 × 274) | 18,737.81 | 18,975.96 | +1.27% |
    | Qwen3.5-2B (BF16) | Decode (c=1) | 210.87 | 229.25 | +8.72% |
    | Qwen3.5-2B (BF16) | Batched Decode (c=64) | 8,798.06 | 9,100.15 | +3.43% |
    | Qwen3.5-35B-A3B-FP8 (FP8) | Prefill (4 × 274) | 6,686.35 | 6,816.23 | +1.94% |
    | Qwen3.5-35B-A3B-FP8 (FP8) | Decode (c=1) | 95.05 | 97.08 | +2.13% |
    | Qwen3.5-35B-A3B-FP8 (FP8) | Batched Decode (c=16) | 1,001.06 | 1,014.93 | +1.39% |

    4. TP=2 Compiled + CUDAGraph Regression Smokes


  • dense_tp2 (Qwen3-8B, FLASH_ATTN): PASS

  • moe_fp8_tp2 (Qwen3-30B-A3B-FP8, FLASH_ATTN): PASS

  • mla_tp2 (DeepSeek-V2-Lite-Chat, FLASH_MLA): PASS

  • gdn_moe_fp8_tp2 (Qwen3.5-35B-A3B-FP8, GDN+FLASH_ATTN): PASS
  • Diff: 650 lines (+487 / -163) across 8 files Reviewer: yeahdongcn Review duration: 4204m
    All Vouch review confidence checks passed
    Residual risk 0.22 = Change Risk (0.52) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 650 lines diff across 8 files
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    56%
    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.388
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #387"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% 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: 52% (MEDIUM) · Higher = larger blast radius
    52%
    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: 56.8% · Lower = rushed or shallow review
    56.8%
    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: 22.5% · Safe to merge
    22.5%