[NPU] NZ for non-quantized MOE, Qwen3 MOE double memory consumption fix#15904
[NPU] NZ for non-quantized MOE, Qwen3 MOE double memory consumption fix#15904iforgetmyname merged 57 commits intosgl-project:mainfrom
Conversation
Summary of ChangesHello @OrangeRedeng, 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 enhances the efficiency of Mixture-of-Experts (MoE) models, particularly Qwen3, by integrating NPU-specific optimizations for weight handling and introducing lazy loading for expert weights. These changes aim to reduce memory consumption and improve performance when running MoE models on NPU hardware, ensuring more efficient resource utilization during model initialization. Highlights
🧠 New Feature in Public Preview: You can now enable Memory 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 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 counter productive. 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. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces two main changes: adding NPU support for non-quantized Mixture-of-Experts (MoE) layers and fixing a memory consumption issue in Qwen3 MoE models. The NPU support is well-implemented by casting weights to the required NPU format within a conditional block. The memory fix correctly uses LazyValue to defer the loading of expert weights, which should effectively address the double memory consumption problem. The changes are clear and well-targeted. I have one suggestion to improve code clarity by replacing a magic number with an existing enum.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
|
/rerun-failed-ci |
…ix (sgl-project#15904) Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
…ix (sgl-project#15904) Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
…ix (sgl-project#15904) Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
…ix (sgl-project#15904) Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
…ix (sgl-project#15904) Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Motivation
The part of closed PR #11984.
Adding weight conversion from ND to FRACTAL_NZ speeds up the GroupedMatmul kernel
Modifications
Accuracy Tests
NZ acceleration:
Benchmarking and Profiling
NZ acceleration:
Server:
python -m sglang.launch_server --model-path ./Qwen3-30B-A3B --port 30088 --trust-remote-code --tp-size 4 --mem-fraction-static 0.8 --attention-backend ascend --device npu --quantization modelslim --base-gpu-id 0 --cuda-graph-bs 64 --disable-radix-cacheClient:
python -m sglang.bench_serving --backend sglang --random-range-ratio 1.0 --dataset-path /data/data/ShareGPT_Vicuna_unfiltered/ShareGPT_V3_unfiltered_cleaned_split.json --dataset-name random --flush-cache --num-prompts * --max-concurrency * --random-input-len * --random-output-len * --host 127.0.0.1 --port 30088Checklist