-
Notifications
You must be signed in to change notification settings - Fork 4.3k
[2/N] Quantization Refactor: Compressed tensors MoE schemes #17503
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
[2/N] Quantization Refactor: Compressed tensors MoE schemes #17503
Conversation
Summary of ChangesHello @TamirBaydasov, 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 significantly refactors the Mixture-of-Experts (MoE) quantization implementation within the compressed-tensors library. The primary goal is to transition from a monolithic class structure to a more flexible scheme-based design. This change not only simplifies the integration of future quantization functionalities but also explicitly highlights and enhances support for NPU hardware, ensuring better compatibility and performance across different platforms. 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.
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 refactors the Mixture of Experts (MoE) schemes for compressed tensors by moving them into a new schemes directory. This is a positive structural change that should improve modularity and extensibility. However, the review has identified several critical issues that appear to be oversights from the refactoring process. These include typos that will lead to runtime errors, incorrect method signatures and implementations in the new CompressedTensorsFusedMoEMethod class, and missing methods in one of the new scheme files. Addressing these issues is crucial for the correctness of the implementation.
python/sglang/srt/layers/quantization/compressed_tensors/compressed_tensors.py
Show resolved
Hide resolved
python/sglang/srt/layers/quantization/compressed_tensors/compressed_tensors.py
Outdated
Show resolved
Hide resolved
...lang/srt/layers/quantization/compressed_tensors/schemes/compressed_tensors_w4a4_nvfp4_moe.py
Show resolved
Hide resolved
...glang/srt/layers/quantization/compressed_tensors/schemes/compressed_tensors_w4a8_int8_moe.py
Show resolved
Hide resolved
python/sglang/srt/layers/quantization/compressed_tensors/compressed_tensors.py
Outdated
Show resolved
Hide resolved
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
...glang/srt/layers/quantization/compressed_tensors/schemes/compressed_tensors_w4a8_int8_moe.py
Outdated
Show resolved
Hide resolved
...glang/srt/layers/quantization/compressed_tensors/schemes/compressed_tensors_w4a8_int8_moe.py
Outdated
Show resolved
Hide resolved
...glang/srt/layers/quantization/compressed_tensors/schemes/compressed_tensors_w4a8_int8_moe.py
Outdated
Show resolved
Hide resolved
|
/tag-and-rerun-ci |
Motivation
Add MoE schemes to compressed-tensors instead of storing all classes in a single file. This should make it easier to implement additional functionality as well as clearly show that compressed-tensors also supports NPU hardware in some cases.
Images and motivation for this PR can be viewed in our roadmap: #15194
Modifications
Moved all classes from
compressed_tensors_moe.pyto new schemes in quantization/compressed_tensors/schemes/Removed
compressed_tensors_moe.pyfileAdded
get_moe_schemefunction tocompressed_tensors.pyfileFixed quant method check in
FusedMoEclass to reflect new changesAccuracy Tests
GPU tests:
Qwen3-30B-A3B-Instruct-2507-AWQ
Qwen3-30B-A3B-Instruct-2507-FP8
NPU tests:
Qwen3-30B-A3B-Instruct-2507-W8A8

Benchmarking and Profiling
Not affected
Checklist
Review Process
/tag-run-ci-label,/rerun-failed-ci,/tag-and-rerun-ci