Skip to content

[Performance] Route Qwen4Exp short prefill through Union GBSA - #23373

Merged
ShyRa1n merged 2 commits into
vllm-project:mainfrom
Dean11879:qwen38_qsa_remove_fia_prefill
Nov 26, 2026
Merged

ShyRa1n merged 2 commits into
vllm-project:mainfrom
Dean11879:qwen38_qsa_remove_fia_prefill

Conversation

@Dean11879

@Dean11879 Dean11879 commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

What this PR does

Use Union GBSA for Qwen3.8-Flash-Next prefill chunks that previously used FIA. The dispatcher introduced in #20304 selected FIA when a chunk started with less than 24K cached KV tokens. With the Union GBSA path from #21627, these chunks can use the same attention implementation as later prefill chunks.

This removes the 24K threshold, the per-request FIA execution loop, and the Qwen-specific FIA mask and output kernels. Decode continues to use standard GBSA.

Performance results

A3 end-to-end TTFT — 24K input / 1-token output

Both versions used the same Qwen3.8-Flash-Next W4A8 weights and A3 B050 operator package on 8 A3 NPUs (TP2×PP4, DP1). Each request had 24,576 input tokens, processed in six 4,096-token chunks at concurrency 1. Prefix caching was disabled, EP was enabled, and MTP was disabled.

Metric Unit Before (FIA) After (Union GBSA) Change Change rate
TTFT ms 1420.26 1269.83 −150.43 −10.59%

TTFT was averaged over seven requests per version after two warm-up requests. All 14 measured requests completed and produced the same first token.

A3 single-module performance — first six prefill chunks

The benchmark measured dispatch_qsa_attention() on one A3 NPU with 4,096 query tokens per chunk, 12 local query heads, one KV head, and head dimension 256. Each value is the median of five device measurements using synthetic inputs and candidate indices. The timed region covers attention input preparation and execution. Q/K/V projection, Lightning Indexer, and inter-rank communication are outside that region.

Chunk Cumulative KV tokens Before (FIA), ms After (Union GBSA), ms Latency reduction
0–4K 4,096 2.337 1.191 49.02%
4–8K 8,192 3.330 1.328 60.11%
8–12K 12,288 4.289 1.321 69.20%
12–16K 16,384 5.260 1.330 74.71%
16–20K 20,480 6.420 1.354 78.90%
20–24K 24,576 7.598 1.323 82.59%

The performance comparison used vllm-ascend main 7124690ce and the same baseline with the FIA removal applied (68dd0683f), with vLLM 62d4bc3c7. The tested change has the same Git patch ID as branch commit 4a8f4a190.

A5 single-module performance — 16K prefill in two 8K chunks

We compared dispatch_qsa_attention() at the PR base (5e4e3a22f, FIA + mask) and PR head (14ee596a9, Union GBSA) on one Ascend 950 NPU. Both paths used the same inputs for each chunk, with query shape [8192, 12, 256]. Runs alternated in the same environment, with 6 warm-up rounds and 30 measured rounds using NPU events.

Prefill chunk Cumulative KV tokens FIA + mask P50 (ms) Union GBSA P50 (ms) Latency reduction Speedup
0–8K 8,192 4.17 2.69 35.5% 1.55×
8K–16K 16,384 8.14 3.47 57.3% 2.34×
Sum of chunk P50s 16,384 12.30 6.16 49.9% 2.00×

The second chunk replayed captured inputs and showed the larger reduction, from 8.14 ms to 3.47 ms. The first chunk reused captured Q/K/V with candidate indices constructed for its 0–8K causal range. Both chunks matched the FIA output within atol=0.01 and rtol=0.03.

Timing covers single-layer FIA mask construction or Union input preparation, followed by attention execution. Shared per-step Union metadata was prepared before timing. Q/K/V projection, Lightning Indexer, inter-rank communication, and end-to-end TTFT are outside the measured scope.

A3 GPQA Diamond accuracy

We evaluated PR commit 14ee596a9 on 8 A3 NPUs (TP2×PP4, concurrency 32) with Thinking enabled and the model’s recommended sampling parameters.

Method Correct Accuracy Truncated responses
GPQA Diamond (AISBench) 179/198 90.40% 2

All 198 requests completed successfully. Both truncated responses counted toward the 19 incorrect answers. AISBench extracted an incorrect choice from one and found no answer choice in the other.

Plan Union batches from the first query row of each prefill request. Remove the selected-token FIA adapter and mask kernels and cover short and mixed requests in the dispatch tests.

Signed-off-by: Dean11879 <81577875+Dean11879@users.noreply.github.com>
@github-actions github-actions Bot added documentation Improvements or additions to documentation module:tests module:ops labels Nov 26, 2026
@github-actions

Copy link
Copy Markdown
Contributor

👋 Hi! Thank you for contributing to the vLLM Ascend project. The following points will speed up your PR merge:‌‌

  • A PR should do only one thing, smaller PRs enable faster reviews.
  • Every PR should include unit tests and end-to-end tests ‌to ensure it works and is not broken by other future PRs.
  • Write the commit message by fulfilling the PR description to help reviewer and future developers understand.

If CI fails, you can run linting and testing checks locally according Contributing and Testing.

🤖 How to trigger CI

CI runs automatically when the PR is opened or reopened. Pushing a new commit no longer re-runs the E2E CI (to save NPU runner resources), so use the comment commands below when needed. They are available to the PR author and users with triage permission or above:

  • /run — run the full PR CI gate on the latest commit.
  • /rerun — re-run the failed CI jobs (e.g. after a flaky failure).
  • /e2e — run selected E2E tests instead of the full gate.
  • /nightly / /presmoke / /weekly — run the corresponding large-scale tests (triage permission or above; blocked during the nightly maintenance window).
  • /cancel — cancel a running CI on this PR.

Note

Until the CI gate has run on a commit, the required ci-gate check stays pending and the PR cannot merge — remember to comment /run after pushing.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request removes the Fused Infer Attention (FIA) prefill path and its associated Triton kernels, workspace management, and tests for the Qwen4Exp model. Prefill requests are now consolidated to always use Union GBSA (Group-Block Sparse Attention), which simplifies the dispatch logic and removes the need for tracking CPU sequence lengths for FIA routing. Standard GBSA continues to be used for the decode path. I have no additional feedback to provide as there are no review comments.

@github-actions

github-actions Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Last updated: 2026-11-26 17:30 UTC+8 for commit 14ee596.

ci-gate failed Resolved: the ci-gate passed for commit 14ee596. Keeping this comment so the history stays visible; it will be updated again if a later run on this commit fails.

@github-actions

github-actions Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Coverage

Total Coverage Diff Coverage
Total 158702 lines 9 lines
Missing 45043 lines 8 lines
Coverage 72% 11%

More info see: Summary

Signed-off-by: Dean11879 <81577875+Dean11879@users.noreply.github.com>
@MrZ20 MrZ20 added the ready-precise run selected e2e test for pr label Nov 26, 2026

@ShyRa1n ShyRa1n left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, by the way ,check if this deleted op is called by other caller other than your model or scope.

@Dean11879

Copy link
Copy Markdown
Contributor Author

LGTM, by the way ,check if this deleted op is called by other caller other than your model or scope.

Checked all in-repo callers. The three deleted Triton kernels were used only by the Qwen4Exp QSA prefill path. No other model or backend references them, and the shared FIA operator used by other attention backends is unaffected.

@ShyRa1n
ShyRa1n merged commit ebaaeee into vllm-project:main Nov 26, 2026
57 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation module:ops module:tests ready-precise run selected e2e test for pr

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants