Repository navigation
[Feature] Enable PTPC FP8 for compressed tensors moe (aiter kernel) - #12181
Conversation
Summary of ChangesHello @qichu-yun, 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 enhances the quantization capabilities by introducing support for Per-Token Per-Channel FP8 quantization within Mixture-of-Experts layers, powered by the AITer kernel. The primary goal is to enable the use of advanced quantized models like Deepseek-R1 PTPC FP8, improving efficiency and compatibility without compromising accuracy. The changes involve core modifications to how weights are processed and how MoE and linear operations are executed under specific quantization schemes. Highlights
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 PR enables PTPC FP8 for compressed tensors MoE with the aiter kernel, which is a great feature for AMD GPUs. The changes look mostly correct, but I've found a few issues related to code duplication, typos, and incorrect logic in shape calculation and weight processing. Specifically, there's a critical bug in compressed_tensors_w8a8_fp8.py due to a misplaced refactoring that could lead to incorrect model behavior, and another one in fp8_utils.py regarding output shape calculation. I've provided suggestions to fix these issues and improve code maintainability.
|
Could you please review this PR when you're free, thanks! ? @wuhuikx @zejunchen-zejun @HaiShaw |
629746c to
861b38a
Compare
4feafe3 to
cda5676
Compare
fae7837 to
e3ff6cc
Compare
3eb4a32 to
e3ff6cc
Compare
494f175 to
d83463b
Compare
HaiShaw
left a comment
There was a problem hiding this comment.
Please address comment left
e907820 to
f33b8ba
Compare
|
/tag-and-rerun-ci 11/26 |
| else: | ||
| # keep the weight as (K, N) | ||
| layer.weight = Parameter(weight.t(), requires_grad=False) | ||
|
|
There was a problem hiding this comment.
L105-L113 is redundant to L86-L91 in one case, if so (not intended to do twice), then need to refactor code.
There was a problem hiding this comment.
I have organized the code uniformly under the “elif self.strategy == QuantizationStrategy.CHANNEL:” branch.
| @@ -277,16 +284,77 @@ def process_weights_after_loading(self, layer: torch.nn.Module | FusedMoE) -> No | |||
| max_w13_scales, requires_grad=False | |||
| ) | |||
|
|
|||
| if self.weight_quant.strategy == QuantizationStrategy.CHANNEL and _use_aiter: | |||
| if _use_aiter: | |||
| padding_size = get_int_env_var("AITER_MOE_PADDING_SIZE") | |||
There was a problem hiding this comment.
AITER_MOE_PADDING_SIZE - undocumented ENV introduced, not have its description, neither tests in PR body.
Please document it, describe its purpose.
Note - see if this serves the purpose:
https://github.com/sgl-project/sglang/blob/main/python/sglang/srt/layers/moe/fused_moe_triton/fused_moe.py#L58
There was a problem hiding this comment.
I have removed the env AITER_MOE_PADDING_SIZE. There is no need to use this env in this case.
f33b8ba to
6bf1e36
Compare
|
@qichu-yun why keep the |
6bf1e36 to
e322bf7
Compare
3ef8df6 to
d3e6bb1
Compare
d3e6bb1 to
cb2621d
Compare
Motivation
Deepseek-R1 PTPC FP8 model for llm-compressor quantized model can be supported on MI308.
Accuracy Tests
Here is my script.
model=/data/models/Deepseek-R1-FP8-Dynamic TP=8 EP=1 python3 -m sglang.launch_server \ --model-path ${model} \ --host localhost \ --port 9000 \ --tp-size ${TP} \ --ep-size ${EP} \ --trust-remote-code \ --chunked-prefill-size 16384 \ --mem-fraction-static 0.85 \ --disable-radix-cache \ --max-prefill-tokens 16384 \ --cuda-graph-max-bs 128 \ 2>&1 | tee log.server.log &Parallel strategy:TP8
acc:
Parallel strategy:TP8 + EP8
acc:
Benchmarking
Here is my script.
Parallel strategy:TP8
Parallel strategy:TP8 + EP8
As you can see, TP8 has better performance than TP8+EP8, and we recommend running TP8 for the PTPC model.