Skip to content

[bugfix]: deepgemm online quant#1130

Merged
hiworldwzj merged 2 commits intomainfrom
dpgemm_online
Dec 1, 2025
Merged

[bugfix]: deepgemm online quant#1130
hiworldwzj merged 2 commits intomainfrom
dpgemm_online

Conversation

@shihaobai
Copy link
Collaborator

No description provided.

@shihaobai shihaobai changed the title fix deepgemm online quant [bugfix]: fix deepgemm online quant Dec 1, 2025
@shihaobai shihaobai changed the title [bugfix]: fix deepgemm online quant [bugfix]: deepgemm online quant Dec 1, 2025
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @shihaobai, 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 focuses on fixing the online quantization process within the DeepGEMM implementation. The primary change involves ensuring that the quantized weights and scales are correctly stored and utilized during the quantization process. Additionally, an update to the Triton kernel ensures correct data handling during weight quantization.

Highlights

  • Quantization Fix: This PR addresses an issue in the online quantization process for DeepGEMM, specifically how the quantized weights and scales are handled.
  • Weight Handling: The code now correctly stores the quantized weights and their corresponding scales in the w1 and w2 attributes.
  • Triton Kernel Update: The Triton kernel for weight quantization has been updated to return the quantized weight and scale without transposing.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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 introduces a bugfix for deepgemm online quantization. The changes primarily involve adjusting the quantize function's return signature to be consistent across different quantization methods by including a None value for the zero-point. The Mixture-of-Experts (MoE) weight loading logic is updated to accommodate this change. Additionally, a bug in the weight_quant function that caused incorrect transposition of weights has been fixed. My review identifies a critical bug in fused_moe_weight_ep_redundancy.py that would cause a runtime error due to a call to a non-existent method. I have also included suggestions to improve code clarity by handling unused variables properly.

Comment on lines 112 to 113
self.w1[0] = self._cuda(w1)
self.w2[0] = self._cuda(w2)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The FusedMoeWeightEPAutoRedundancy class does not have a _cuda method, which will cause an AttributeError at runtime. The _cuda method is part of the FusedMoeWeightEP instance, which is stored in self._ep_w. You should call the method on that instance to correctly move the tensors to the CUDA device.

Suggested change
self.w1[0] = self._cuda(w1)
self.w2[0] = self._cuda(w2)
self.w1[0] = self._ep_w._cuda(w1)
self.w2[0] = self._ep_w._cuda(w2)

Comment on lines +425 to +426
qw1, qw1_scale, qw1_zero_point = self.quant_method.quantize(w1)
qw2, qw2_scale, qw2_zero_point = self.quant_method.quantize(w2)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The variables qw1_zero_point and qw2_zero_point are assigned but never used. To improve code clarity and signal that these values are intentionally ignored, you should use an underscore _ for the unused variables.

Suggested change
qw1, qw1_scale, qw1_zero_point = self.quant_method.quantize(w1)
qw2, qw2_scale, qw2_zero_point = self.quant_method.quantize(w2)
qw1, qw1_scale, _ = self.quant_method.quantize(w1)
qw2, qw2_scale, _ = self.quant_method.quantize(w2)

Comment on lines +105 to +106
qw1, qw1_scale, qw1_zero_point = self._ep_w.quant_method.quantize(w1)
qw2, qw2_scale, qw2_zero_point = self._ep_w.quant_method.quantize(w2)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The variables qw1_zero_point and qw2_zero_point are assigned but never used. To improve code clarity and signal that these values are intentionally ignored, you should use an underscore _ for the unused variables.

Suggested change
qw1, qw1_scale, qw1_zero_point = self._ep_w.quant_method.quantize(w1)
qw2, qw2_scale, qw2_zero_point = self._ep_w.quant_method.quantize(w2)
qw1, qw1_scale, _ = self._ep_w.quant_method.quantize(w1)
qw2, qw2_scale, _ = self._ep_w.quant_method.quantize(w2)

Comment on lines +185 to +186
qw1, qw1_scale, qw1_zero_point = self.quant_method.quantize(w1)
qw2, qw2_scale, qw2_zero_point = self.quant_method.quantize(w2)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The variables qw1_zero_point and qw2_zero_point are assigned but never used. To improve code clarity and signal that these values are intentionally ignored, you should use an underscore _ for the unused variables.

Suggested change
qw1, qw1_scale, qw1_zero_point = self.quant_method.quantize(w1)
qw2, qw2_scale, qw2_zero_point = self.quant_method.quantize(w2)
qw1, qw1_scale, _ = self.quant_method.quantize(w1)
qw2, qw2_scale, _ = self.quant_method.quantize(w2)

@hiworldwzj hiworldwzj merged commit 5f2ce96 into main Dec 1, 2025
1 check passed
@hiworldwzj hiworldwzj deleted the dpgemm_online branch December 1, 2025 07:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants