Skip to content

Conversation

@yiliu30
Copy link
Owner

@yiliu30 yiliu30 commented Sep 12, 2025

No description provided.

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.

Summary of Changes

Hello @yiliu30, 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 convert_weights_for_gaudi2.py script by introducing a new option to handle quantized MLP gate projection weights, making the conversion process more adaptable for different model configurations. It also improves the script's logging to provide clearer visibility into the weight conversion steps.

Highlights

  • New Command-Line Argument: Introduced --quant_mlp_gate to control the quantization of MLP gate projection weights, providing more flexibility for specific model architectures.
  • Extended Functionality: The convert_files_per_tensor and convert_files functions now accept an args object, allowing them to utilize the new quantization flag and other potential future arguments.
  • Conditional Quantization Logic: The script now supports conditional quantization of mlp.gate weights within the convert_files function, activated by the new --quant_mlp_gate argument.
  • Improved Logging: Added print statements to provide more detailed feedback during the weight conversion process, showing which weights are being updated and their resulting data types.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

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 issue 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 updates the weight conversion script to add support for quantizing MLP gate projection weights, controlled by a new command-line argument. The changes are functional, but there are a few areas for improvement regarding code clarity and maintainability. I've pointed out an unused function parameter and some potentially verbose print statements that could be refined.


# Use Case: Hunyuan_V1 Dense and MOE models
def convert_files_per_tensor(input_path, output_path):
def convert_files_per_tensor(input_path, output_path, args):
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 args parameter is added to the function signature but is not used within the convert_files_per_tensor function. To improve code clarity and maintainability, unused parameters should be removed. The corresponding call at line 151 should also be updated.

Suggested change
def convert_files_per_tensor(input_path, output_path, args):
def convert_files_per_tensor(input_path, output_path):

weight_nv = tensor_file.get_tensor(weight_name).float()
weight_fp32 = weight_scale_nv * weight_nv
weight_fp8, scale = quant_per_tensor(weight_fp32)
print(f"Update weight {weight_name} and scale {k}")
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This print statement is inside a loop that iterates over all tensor keys. For models with many tensors, this will produce a large amount of output, which can make the script's progress hard to follow. It would be better to use the logging module for such diagnostic messages, allowing users to control the verbosity level.

raise NotImplementedError(f"Cannot covert {k}")
else:
print(f"skip {k}.")
print(f"update {k} to dtype {tensor.dtype}")
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This print statement is executed for every tensor in the file, which can lead to very verbose output. For better user experience, consider replacing it with a proper logging mechanism or making it conditional based on a --verbose flag.

copy_other_files(input_path, output_path)
if per_tensor:
convert_files_per_tensor(input_path, output_path)
convert_files_per_tensor(input_path, output_path, args)
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 args parameter is passed to convert_files_per_tensor here, but it is not used within that function. This argument should be removed from the function call to align with the suggested change at line 43 and improve code clarity.

Suggested change
convert_files_per_tensor(input_path, output_path, args)
convert_files_per_tensor(input_path, output_path)

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