Repository navigation
[Feature] Support DiffusionGemma NPU graph and kernel cleanup - #11279
leedongkun30-arch wants to merge 1 commit into
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces comprehensive support for DiffusionGemma on Ascend NPU platforms within the V2 runner. It addresses critical stability and correctness issues related to graph capture and batched canvas serving. By implementing per-request attention metadata and a robust manual attention fallback, the changes ensure that mixed-phase batches (where requests may be in different denoising stages) are handled correctly without degrading generation quality. The PR also includes necessary scheduler adjustments to maintain the required canvas length for block-diffusion. Highlights
New Features🧠 You can now enable Memory (public preview) to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Ignored Files
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
|
👋 Hi! Thank you for contributing to the vLLM Ascend project. The following points will speed up your PR merge:
If CI fails, you can run linting and testing checks locally according Contributing and Testing. Tip 💡 Consider Linking a Related Issue or RFCYour PR title contains the [Feature] tag, indicating a bug fix or new feature. Linking a related issue or RFC in the PR description is strongly encouraged — it gives reviewers helpful context and speeds up the review. You can use any of these keywords:
🙏 Thanks for helping us keep the project well-organized! |
There was a problem hiding this comment.
Code Review
Suggested PR Title:
[Attention][Feature] Support DiffusionGemma block-diffusion canvas batching on Ascend NPUSuggested PR Summary:
### What this PR does / why we need it?
This pull request adds support for DiffusionGemma block-diffusion canvas batching on Ascend NPU. It introduces a per-request causal/bidirectional selector (`causal_per_req`) to handle mixed-phase canvas batching where some requests are in the causal/commit phase and others are in the bidirectional denoise phase. It also implements a manual attention fallback path (`_forward_manual_attention` and its capturable version) for head sizes unsupported by FIA, routes DiffusionGemma to an adapted `AscendDiffusionGemmaModelState`, and adds scheduling and model runner wiring for the block-diffusion canvas.
Feedback:
- In `_persist_seqlens`, `self._seqlens_persist` is created on the CPU tensor's device, which is CPU. This will cause PyTorch to treat it as a constant during graph capture, preventing in-place updates from being visible during replay. It should be created on `self.device`.
- In `vllm_ascend/worker/v2/model_runner.py`, `self.decode_query_len` is unconditionally overwritten later in `__init__` to `self.num_speculative_steps + 1`, which needs to be made conditional on `not self._is_diffusion_gemma` to avoid shape mismatches.
### Does this PR introduce _any_ user-facing change?
No, this is an internal backend support addition for DiffusionGemma on Ascend NPU.
### How was this patch tested?
Added end-to-end NPU support test `test_diffusion_gemma_26b_a4b.py` and unit tests in `test_diffusion_gemma_causal_per_req.py`.5fb9d29 to
ccdaee8
Compare
d133a10 to
b1d0859
Compare
|
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
956d4ed to
5f61bf2
Compare
|
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
DiffusionGemma decode performance updateI re-ran the DiffusionGemma-26B-A4B batch-1 decode measurements on Ascend 910B with E2E result
Final best speedup is PR patch-layer validationI also validated the PR-facing wiring without relying on the scratch-edited
The first clean-vLLM run exposed a fullgraph issue from calling Kernel contribution splitThe final implementation uses two graph-captured custom kernels in the pre-attention path:
The final wiring intentionally consumes the qkv MIX op's persistent scratch output, then runs the proven AIV norm_rope op. This avoids the graph-replay lifetime hazard seen when directly consuming q/k/v returned tensors from the MIX op, while still letting the qkv GEMM portion move out of the Python/graph small-op cloud. Profiling / performance JSON analysisThe earlier 3x slowdown was not consistent with the kernel microbenchmarks and was not explained by host dispatch or cos/sin preprocessing:
Those numbers cannot explain an observed Correctness checksBit-exact tolerance remains within the existing
The final E2E result keeps GSM8K accuracy at |
|
Routing follow-up: I rechecked the DiffusionGemma router side after the attention qkv/norm_rope path stabilized. The result is still do not include routing fusion in this PR, but the evidence is now a little more nuanced than the first single-run result. Measured on die2,
Same-die repeated A/B on 2026-07-18:
Average delta is Other routing checks:
Graph-profile detail for the scale postprocess:
Interpretation: routing is not currently the clean headroom item. Top-k/gating is already on the optimized Ascend path, projection should stay CANN MatMul, and the remaining router norm/scale changes are too small or negative in E2E. A real routing breakthrough would likely need the gating kernel API itself to consume |
Router-front Ascend C fusion validation (NPU3, 2026-07-19)Code update pushed to the PR. Final PR head: Related commits:
Hardware and flags:
E2E performance
Correctness gates
Perfetto / Chrome trace captureRendered directly from the torch_npu profiler Trace summary:
Trace-region speedup: Top op changes in the captured region:
|
### What this PR does / why we need it? Enable DiffusionGemma text generation from text or image inputs on Ascend 950DT through the standard vLLM serving API. The implementation reuses the upstream model, sampler and scheduler. The upstream structured diffusion server also supports decision requests on the same engine. The V2 runner preserves upstream canvas input preparation. Ascend attention selects causal or bidirectional FIA output per token and keeps the two graph tasks and workspaces distinct for replay. This is a model-scoped implementation and validation of structured decisions. Related work in #11279 explores a broader kernel optimization path. ### Does this PR introduce any user-facing change? Yes. Serve the BF16 checkpoint directly through `/v1/chat/completions` for text or image input, or use `/v1/completions` for text. The optional upstream structured diffusion server adds `/v1/systemone`. ### How was this patch tested? #### Review follow-up On Ascend 950DT in BF16 at TP=1 with vLLM `c410543`, `0e23e1a` passed all six end-to-end smoke profiles. After the review fixes, `5f10330` passed 51 CPU attention tests, including the causal sliding-window boundary and the padded query offsets used by both FIA replay providers. In a separate 950DT run with `cudagraph_mode=FULL`, three concurrent requests completed and runtime metrics recorded six FULL replays with 192 real tokens and 256 captured query rows. The structured decision smoke passed in the same run. The runtime-equivalent `ac21f01` also matched greedy token IDs across eager, FULL, and PIECEWISE on three concurrent requests with `top_k=1`. Runtime metrics recorded four 192-to-256-token replays in each graph mode. The selected-token logprobs returned by this setting were all `0.0`, so this check only establishes token ID parity. Unfiltered logprob parity remains unverified. #### Accuracy and throughput baseline Tested PR head `b2cf3b8` with upstream vLLM `c410543` and `google/diffusiongemma-26B-A4B-it@cd401955` in BF16, TP=1 on Ascend 950DT. All six end-to-end profiles passed. Both performance modes ran on the same NPU with async scheduling, up to four active sequences, a 256-token batch budget and prefix caching disabled. Each setting used a 3 s warm-up and a 15 s measurement window. All eight settings per mode had zero request errors. #### LLM serving Text and image chat, completions, streaming, chunked prefill and prefix caching passed. FULL and PIECEWISE replay were verified with four active sequences. The table measures text streaming through `/v1/chat/completions`. | Concurrent requests | Eager output tok/s | Graph output tok/s | Eager TTFT p50 (ms) | Graph TTFT p50 (ms) | | ---: | ---: | ---: | ---: | ---: | | 1 | 65.5 | 161.3 | 729 | 299 | | 4 | 198.7 | 400.3 | 1,101 | 562 | | 8 | 205.6 | 416.8 | 2,690 | 1,384 | | LLM accuracy workload | DiffusionGemma on Ascend | Google DiffusionGemma baseline | | --- | ---: | ---: | | GPQA Diamond, thinking disabled | 129/198 (65.15%) | [64.6% (Table 3)](https://arxiv.org/html/2608.00146) | GPQA ran once on all 198 questions through `/v1/chat/completions` in eager mode, with no failed requests, missing answers or length stops. The published score is a reference for the same model and benchmark. The evaluation setups differ. #### Structured decisions Text and image decisions and constrained and unconstrained reads passed. The load test sent one choice question per request through `/v1/systemone`. | Concurrent requests | Eager req/s | Graph req/s | Eager p99 (ms) | Graph p99 (ms) | | ---: | ---: | ---: | ---: | ---: | | 1 | 5.80 | 11.87 | 180 | 88 | | 2 | 7.07 | 15.20 | 291 | 145 | | 4 | 10.27 | 22.60 | 430 | 191 | | 8 | 10.40 | 22.60 | 805 | 375 | | 16 | 10.47 | 22.47 | 2,404 | 1,553 | | Decision accuracy workload | DiffusionGemma on Ascend | Reference | | --- | ---: | ---: | | System One Bench (2,200 decisions) | 68.73% / 0.6663 macro-F1 | 66.95% / 0.6435, d1-3B on the same cases | | Public JevBench (231 cases) | 194/231 (84.0%) | [194/231, published djev](https://github.com/fstandhartinger/jevbench/blob/main/results/v1.2/additions/djev-per-task.json) | All accuracy requests returned valid responses. System One ECE was 0.2375 versus 0.0333 for d1-3B. JevBench compares exact case IDs; 185 were correct in both runs. CPU regressions cover phase-mask updates, distinct FIA replay providers, padded FULL replay metadata, and the causal sliding-window boundary. Multi-card validation remains open. - vLLM main: vllm-project/vllm@c410543 --------- Signed-off-by: Deniz Özcan <66875687+do420@users.noreply.github.com> Co-authored-by: Yizhou <liu_yizhou@outlook.com>
5b09b65 to
fbcb0fa
Compare
Signed-off-by: leedongkun30-arch <237956497+leedongkun30-arch@users.noreply.github.com>
fbcb0fa to
a5f382c
Compare
|
Work on DiffusionGemma support for Atlas A2 and A3 continues in #24544. |

What this PR does
This draft adds Ascend NPU support for DiffusionGemma block-diffusion serving and records the current kernel-cleanup checkpoint for the final PR shape.
The PR-facing scope is:
head_dim=256.This PR should be reviewed as a kernel/runtime cleanup, not as an algorithm-side draft/sampling change.
Current E2E checkpoint: TP=1 N=200 150 -> 163 tok/s
Latest local kernel-cleanup validation uses CANN 9.0.1 on physical NPU 1. The baseline row is the existing TP=1 graph baseline summary with the same sample count and generation settings.
The earlier TP=1
N=20kernel-cleanup run reported181.356 tok/s, but it is no longer used as the PR headline because the shorter sample set was optimistic. The PR E2E number is now theN=200result above.Run files:
~/_workspace/results/dgemma-fusion-ab-168/summary_baseline_tp1_mml1024_util09.json~/_workspace/results/dgemma-fusion-ab-168/summary_kernelonly_cann901_mml1024_util09_manualfia_topkpost_skipabs_kv2_dev1_n200.json~/_workspace/results/dgemma-fusion-ab-168/summary_kernelonly_cann901_mml1024_util09_manualfia_topkpost_skipabs_dev1_n20_afterpathfix.jsonFusion set in the kernel-cleanup path
Enabled in the current E2E path:
VLLM_ASCEND_DGEMMA_MANUAL_FIA_BNSD=1: manual BNSD fused-infer-attention entry path.VLLM_ASCEND_DGEMMA_MOE_INIT_ROUTING_V2=1: newer MoE routing/init path.VLLM_ASCEND_DGEMMA_ROUTING_TOPK_VALUES=1andVLLM_ASCEND_DGEMMA_TOPK_VALUES_POST_ASCENDC=1: fuse the topk-values post/renorm-scale tail.VLLM_ASCEND_DGEMMA_MOE_SKIP_COMBINE_ABS=1: remove redundant abs work in the MoE combine tail.VLLM_ASCEND_DGEMMA_SKIP_RMSNORM_QUANT_SP_PATTERNS=1andVLLM_ASCEND_DGEMMA_SKIP_RMSNORM_QUANT_CUSTOM_PATTERNS=1: avoid graph-fusion pass patterns that interfere with this DiffusionGemma path.Not included:
1-block forward profile: baseline vs kernel cleanup
Captured on 2026-07-24 with CANN 9.0.1, physical NPU 1, TP=1,
max_num_seqs=1,max_model_len=1024, one dummy decode block,run_fullgraph with num_tokens=256.This profile is a device-op breakdown for the cleanup path. It explains where the kernel-side gain comes from, but the PR headline E2E number is the
N=200result above.Artifacts:
~/_workspace/results/dgemma-fusion-ab-168/profile_1block_baseline150_cann901_dev1.json~/_workspace/results/dgemma-fusion-ab-168/profile_1block_best181_cann901_dev1.json~/_workspace/results/dgemma-fusion-ab-168/profile_1block_150_181_summary.md~/_workspace/results/dgemma-fusion-ab-168/opcloud_1block_150_181/oneblock_opcloud.htmlDevice-op summary:
Selected op changes:
aclnnGroupedMatmulV5_GroupedMatmul_GroupedMatmulaclnnMatmul_MatMulCommon_MatMulV2aclnnReduceSum_ReduceSumOpAiCore_ReduceSumaclnnSoftmax_SoftmaxAiCore_SoftmaxV2aclnnSWhere_SelectV2AiCore_SelectV2aclnnRepeatInterleaveIntWithDim_RepeatInterleaveV2_RepeatInterleaveV2aclnnMoeInitRoutingV3_MoeInitRoutingV3_MoeInitRoutingV3DgemmaTopkValuesPostInterpretation: dense MatMul/GMM stayed essentially unchanged, while the routing reduction cloud and several layout/elementwise tails shrank. The next large step likely needs a safe GEMM-adjacent epilogue or producer-consumer handoff, not more standalone tiny kernels.
Earlier graph/batch validation
CANN 9.1.0 TP=2 local validation, GSM8K first 200. This is separate from the TP=1 kernel-cleanup E2E checkpoint above.
max_num_seqsLocal preflight limitations
Full
pre-commit run --all-files --hook-stage manualis blocked in this environment because Node.js isv12.22.9, whilemarkdownlint-cli@0.45.0requires Node.js>=20.Coverage tooling still reports existing uncovered CANN custom-op dynamic implementation files unrelated to this DiffusionGemma change.
Current local worktree contains experimental custom-op scratch changes; final code push should separate the E2E checkpoint changes from deferred Cloud2/GMM-epilogue experiments.
vLLM main: vllm-project/vllm@65ada0c