← Back to Pull requests

[Perf][Attention] Restore Qwen FA3 single-request metadata across S5000 MP bins and DSV4 FlashMLA direct-out on MATE 0.2.8 #383

Closed
unknown closed this pull request without merging on Dec 01, 2026 00:44 UTC
View on GitHub
unknown unknown commented on Nov 27, 2026 16:52 UTC
Author

Summary

On the current v0.32.0 MUSA stack (mate == 0.2.8.post1, flash_attn_3 == 0.2.8.post1+musa), two attention fast paths silently fell back to their slower paths because their version gates were pinned to mate == "0.2.4" and sm_count == 60:

1. Qwen Single-Request FA3 Scheduler Metadata (vllm_musa/jit_kernel/fa3_metadata.py, vllm_musa/v1/attention/backends/flash_attn.py):
- Support mate 0.2.8 / 0.2.8.post1 alongside 0.2.4 in _has_supported_fa3_scheduler_layout().
- Mirror MATE >= 0.2.8's split_waves = max(ceil_div(num_heads_kv max_num_splits, sm_count), 1) and wave_capacity = sm_count split_waves in blocks_per_mp (while keeping split_waves = 1 for 0.2.4), caching _use_fa3_wave_capacity() via @functools.cache so importlib.metadata.version("mate") is never queried per decode step.
- Generalize sm_count across all full-card S5000 MP bins {48, 56, 60, 64} while still rejecting 24-core MPX slices.
- Regenerate vllm_musa/patches/module-drift/v1.attention.backends.flash_attn.diff.

2. DeepSeek-V4 TP8 MATE Sparse Prefill Direct-Out (vllm_musa/v1/attention/ops/flashmla.py):
- Support mate 0.2.8 / 0.2.8.post1's updated sparse_attention_fwd_kernel_model1 private TileLang ABI (result_idx == (3, 4, 5) via jit_for_tensor_addressing, prepare_sparse_mla_strided_tensor, validate_token_lengths, validate_prefill_attn_sink, skip_kernel_launch_if_dry_run, tensor_byte_span, and runtime_sm_scale = sm_scale * log2(e)) while preserving 0.2.4 compatibility and fail-closed fallback to public flash_mla_sparse_fwd.
- Keep full-device num_mps persistent blocks on MATE >= 0.2.8's TMA-pipelined kernel while preserving the legacy num_mps // 3 partitioning on 0.2.4.

S5000 Validation Evidence

  • Image: sh-harbor.mthreads.com/mcctest/vllm:v0.32.0-ph1-5.2.0-torch2.13.0.post1-20261126 (torch 2.13.0a0+git2d71ffa, torch_musa 2.13.0.post1+deb14ae, mate 0.2.8.post1, flash_attn_3 0.2.8.post1+musa, flash_mla 0.2.8.post1+musa, MTT S5000 60-MP, driver 5.2.0-server).

  • Sync & Unit Tests:

  • - musa_sync check-series, check-series --replay, and verify against vllm@5df63a7203cdb9328d824a27b682e77c7b9928be: 222 clean / 257 total / 0 need attention.
    - On-device pytest (tests/jit_kernel/test_fa3_metadata.py, tests/test_flashmla_sparse_direct_out.py, tests/test_flash_attn_scheduler_fast_path.py, tests/test_musa.py): 155 passed, 0 failed.
    - 180-case Multi-MP-Bin FA3 Metadata Golden Check (SM = 60, 56, 48 via mp_margin × 10 Qwen geometries × seq_len in {1, 64, 65, 384, 385, 4096}): 180 / 180 exact match against mate.get_scheduler_metadata, plus CUDAGraph 8-replay bitwise parity PASS.

    1. Qwen Single-Request FA3 Metadata Cold-Cache Microbenchmark

    | Geometry (Hq, Hkv, D) | SeqLen | Fallback get_scheduler_metadata + cumsum (ms) | Direct Triton LUT (ms) | Speedup |
    |---|---:|---:|---:|---:|
    | (12, 2, 128) | 64 / 512 / 2048 / 4096 | 0.0404 / 0.0397 / 0.0403 / 0.0382 | 0.0160 / 0.0158 / 0.0153 / 0.0152 | 2.51x–2.63x |
    | (28, 4, 128) | 64 / 512 / 2048 / 4096 | 0.0377 / 0.0379 / 0.0396 / 0.0395 | 0.0149 / 0.0149 / 0.0159 / 0.0154 | 2.49x–2.56x |
    | (32, 8, 128) | 64 / 512 / 2048 / 4096 | 0.0378 / 0.0374 / 0.0374 / 0.0375 | 0.0149 / 0.0150 / 0.0150 / 0.0149 | 2.49x–2.54x |
    | (64, 8, 128) | 64 / 512 / 2048 / 4096 | 0.0379 / 0.0377 / 0.0377 / 0.0383 | 0.0151 / 0.0150 / 0.0149 / 0.0150 | 2.51x–2.55x |

    2. DeepSeek-V4 TP8 MATE Sparse Prefill Direct-Out Cold-Cache A/B ([S, 64, 512] BF16)

    | Mode | SeqLen | Public flash_mla_sparse_fwd + copy_ (ms) | Zero-Copy DirectOut (ms) | Speedup | Bitwise Exact (out, max_logits, lse) |
    |---|---:|---:|---:|---:|---|
    | single_stream | 256 | 1.0953 | 0.1132 | 9.68x | True |
    | single_stream | 1024 | 1.5677 | 0.5175 | 3.03x | True |
    | single_stream | 2048 | 2.0218 | 0.8970 | 2.25x | True |
    | 3stream_ovlp (Q-proj + KV-comp + MLA) | 2048 | 2.2126 | 1.2053 | 1.84x | True |
    | single_stream | 4096 | 3.2824 | 1.8553 | 1.77x | True |
    | 3stream_ovlp (Q-proj + KV-comp + MLA) | 4096 | 3.2444 | 2.3456 | 1.38x | True |
    | single_stream | 8192 | 5.2621 | 3.5337 | 1.49x | True |
    | 3stream_ovlp (Q-proj + KV-comp + MLA) | 8192 | 5.8105 | 4.5970 | 1.26x | True |

    3. Compiled vllm serve Qwen3-8B TP=1 c=1 A/B & Subsystem Regressions


  • Compiled Qwen3-8B TP=1 c=1 (FULL_AND_PIECEWISE CUDA graphs):

  • - in=512, out=128: Mean TPOT 14.004 -> 13.985 ms (-19 µs/step), Median TPOT 13.986 -> 13.967 ms, P99 ITL 15.32 -> 14.51 ms, Output throughput 70.46 -> 70.52 tok/s.
    - in=2048, out=128: Mean TPOT 14.271 -> 14.246 ms (-25 µs/step), Median TPOT 14.271 -> 14.249 ms, P99 TTFT 115.40 -> 111.08 ms, Output throughput 66.63 -> 66.74 tok/s.
  • Mandatory 3-Subsystem Attention Regression Smokes (TP=2, compiled):

  • - Dense FA3 (Qwen3-8B): PASS
    - Hybrid GDN + FP8 MoE + FA3 (Qwen3.5-35B-A3B-FP8): PASS
    - MLA (DeepSeek-V2-Lite-Chat): PASS

    Diff: 648 lines (+486 / -162) across 8 files Reviewer: yeahdongcn Review duration: 4792m
    All Vouch review confidence checks passed
    Residual risk 0.23 = Change Risk (0.57) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.57 · 648 lines diff across 8 files
    0.57
    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%
    60%
    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.387
    Shallow Review Depth shallow_review_depth
    0.289
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    1 comments
    "Review active on #383"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% 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: 57.0% (MEDIUM) · Higher = larger blast radius
    57.0%
    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: 60.5% · Lower = rushed or shallow review
    60.5%
    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%