Repository navigation
[Feature] Select a dedicated V4.1 DeepInfer MegaMoE module - #20395
linfeng-yuan wants to merge 20 commits into
Conversation
Signed-off-by: linfeng-yuan <1102311262@qq.com>
Signed-off-by: linfeng-yuan <1102311262@qq.com>
Replace the experimental MegaMoE Prefill host fence with the tested MLA lifetime adjustment. Document allocator assumptions, diagnostic evidence, broader wrapper scope, and outstanding hardware validation. Signed-off-by: linfeng-yuan <1102311262@qq.com>
Reuse upstream factory, checkpoint and graph-op interfaces while removing ALLTOALL aliasing and the W4A8 execution interception. Preserve local routing, FP32 gate weights and fused shared-expert ownership. Signed-off-by: linfeng-yuan <1102311262@qq.com>
Signed-off-by: linfeng-yuan <1102311262@qq.com>
|
👋 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! |
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 an experimental DeepInfer MegaMoE backend designed for DeepSeek V4.1 models running on Ascend 950 NPUs. By implementing a dedicated execution module, the changes bypass generic MoE communication paths, allowing for more efficient fused EP kernel utilization and symmetric scratchpad management. Additionally, the PR includes a memory management optimization for MLA tensors to improve performance and stability during inference. 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. 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
|
There was a problem hiding this comment.
Code Review
Suggested PR Title:
[Ops][Feature] Add DeepInfer MegaMoE backend for DeepSeek V4.1 on Ascend 950Suggested PR Summary:
### What this PR does / why we need it?
This pull request introduces an experimental, opt-in DeepInfer MegaMoE backend with fused shared experts for DeepSeek V4.1 on Ascend 950 (TP1 and linear EP8). It also includes a same-stream lifetime adjustment for native MLA to reduce deferred tensor reuse, replacing the previous prefill host synchronization.
Feedback:
Two issues were identified in `vllm_ascend/ops/fused_moe/deepgemm_v41.py` where calling `.view()` on potentially non-contiguous weight and scale tensors could raise a `RuntimeError`. It is recommended to ensure these tensors are contiguous by calling `.contiguous()` before performing `.view()` operations.
### Does this PR introduce _any_ user-facing change?
Yes, it adds an experimental opt-in configuration option `deepgemm_mega_moe` in `AscendConfig`.
### How was this patch tested?
The changes are covered by new unit tests in `tests/ut/ops/fused_moe/test_deepgemm_v41.py`, `tests/ut/ops/fused_moe/test_deepgemm_v41_module.py`, and `tests/ut/ops/test_packaged_attention.py`.| (w13, s13), (w2, s2) = deep_gemm.transform_weights_for_mega_moe( | ||
| ( | ||
| layer.w13_weight.data.view(torch.int8), | ||
| layer.w13_weight_scale.data.view(torch.uint8).contiguous().view(torch.int16), | ||
| ), | ||
| ( | ||
| layer.w2_weight.data.view(torch.int8), | ||
| layer.w2_weight_scale.data.view(torch.uint8).contiguous().view(torch.int16), | ||
| ), | ||
| ) |
There was a problem hiding this comment.
To prevent potential RuntimeErrors when weights or scales are not contiguous (which can happen depending on how the checkpoint is loaded or sharded), it is safer to call .contiguous() before performing any .view() operations. Additionally, we can simplify the double .view() on the weight scales by calling .contiguous() directly on the original tensor before viewing it as torch.int16.
(w13, s13), (w2, s2) = deep_gemm.transform_weights_for_mega_moe(\n (\n layer.w13_weight.data.contiguous().view(torch.int8),\n layer.w13_weight_scale.data.contiguous().view(torch.int16),\n ),\n (\n layer.w2_weight.data.contiguous().view(torch.int8),\n layer.w2_weight_scale.data.contiguous().view(torch.int16),\n ),\n )| if scale.dtype == torch.float32: | ||
| # Match the DS checkpoint conversion: FP32 powers of two to UE8M0. | ||
| scale = ((scale.view(torch.int32) >> 23) & 0xFF).to(torch.uint8) | ||
| elif scale.dtype in (torch.uint8, getattr(torch, "float8_e8m0fnu", None)): | ||
| scale = scale.view(torch.uint8) |
There was a problem hiding this comment.
If scale is not contiguous, calling .view() directly on it will raise a RuntimeError. Ensuring the tensor is contiguous before calling .view() prevents potential runtime crashes during weight processing.
if scale.dtype == torch.float32:\n # Match the DS checkpoint conversion: FP32 powers of two to UE8M0.\n scale = ((scale.contiguous().view(torch.int32) >> 23) & 0xFF).to(torch.uint8)\n elif scale.dtype in (torch.uint8, getattr(torch, Build the DeepInfer-pinned operator with its native setup.py and ship its extension and JIT resources in the Ascend namespace. Replace serving-time header overrides with two version-scoped device include corrections. Resolve external NPU packages safely and use the vLLM cache root by default. Signed-off-by: linfeng-yuan <1102311262@qq.com> (cherry picked from commit bb5cb3c)
Signed-off-by: linfeng-yuan <1102311262@qq.com>
Signed-off-by: linfeng-yuan <1102311262@qq.com> (cherry picked from commit 11c1799)
Signed-off-by: linfeng-yuan <1102311262@qq.com> (cherry picked from commit d4ab6ab)
Signed-off-by: linfeng-yuan <1102311262@qq.com>
Signed-off-by: linfeng-yuan <1102311262@qq.com> (cherry picked from commit 041e706)
Signed-off-by: linfeng-yuan <1102311262@qq.com> (cherry picked from commit 144b752)
Signed-off-by: linfeng-yuan <1102311262@qq.com>
Signed-off-by: linfeng-yuan <1102311262@qq.com>
Signed-off-by: linfeng-yuan <1102311262@qq.com>
Signed-off-by: linfeng-yuan <1102311262@qq.com>
Signed-off-by: linfeng-yuan <1102311262@qq.com>
Signed-off-by: linfeng-yuan <1102311262@qq.com>
Signed-off-by: linfeng-yuan <1102311262@qq.com>
Signed-off-by: linfeng-yuan <1102311262@qq.com>
|
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
7 similar comments
|
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
|
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
|
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
|
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
|
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
|
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
|
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
What this PR does / why we need it?
Add opt-in DeepInfer MegaMoE for DeepSeek V4.1 on Ascend 950: routed MXFP4 and shared FP8 experts execute in one dispatch/GEMM/SwiGLU/combine launch.
A dedicated
DeepGemmV41MoEuses the existingFusedMoEFactoryextension points and owns local routing and fused communication.Pack weights once and reuse process-group-owned symmetric storage across layers and serialized target/draft calls. Validate configuration before native loading; reject unsupported configurations explicitly. The MLA stream-lifetime adjustment stays outside graph capture and imports the private NPU API lazily.
Pinned native sources, JIT resources, licenses and provenance follow RFC #20620. A5 images and CI share one build-prerequisite installer; parser pins remain build-only.
Target:
main. Matching release backport: #20520.Does this PR introduce any user-facing change?
Enable with
--additional-config '{"deepgemm_mega_moe":true,"enable_fused_mc2":0}'. Supports V4.1, Ascend 950, TP1/linear EP8 and serialized target/draft execution. EPLB replicas, nonlinear placement and overlapping microbatches are rejected. Ordinary MoE remains the default. Release note:release_notes/fragments/20395.yaml.How was this patch tested?
bash format.sh cipassed locally. Latest-head official pre-commit/mypy, both full CPU UT lanes and selected hardware E2E all passed: CI gate.Checklist
Boundary and failure-path regression coverage.
Focused tests exercise production code and assert behavior.
Latest-head pre-commit, full CPU UT and selected E2E gates all passed.
vLLM main: vllm-project/vllm@24420b7