Skip to content

Conversation

@xin3he
Copy link

@xin3he xin3he commented Dec 26, 2025

SUMMARY:
"This PR aims to extend the support of AutoRound. supported scheme are extended from 'W4A16 to W4A16, NVFP4"

TEST PLAN:
"The UT of AutoRound is extended with new NVFP4 modifier recipe"

@github-actions
Copy link

👋 Hi! Thank you for contributing to llm-compressor. Please add the ready label when the PR is ready for review.

Note: This is required to complete the testing suite, please only add the label once the PR is code complete and local testing has been performed.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @xin3he, 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 integrates the NVFP4 quantization scheme into the llmcompressor library's AutoRoundModifier. This enhancement allows for the application of NVIDIA's FP4 format during model quantization, which can lead to improved efficiency and performance. The changes involve modifying the core AutoRoundModifier to correctly process and apply NVFP4 quantization, including specific parameter handling and compatibility with the underlying auto_round library, along with corresponding test updates.

Highlights

  • NVFP4 Scheme Support: Extended AutoRound functionality to include support for the NVFP4 quantization scheme, broadening the range of available quantization strategies.
  • AutoRoundModifier Enhancements: Updated the AutoRoundModifier to properly handle NVFP4-specific parameters, including new logic for mapping quantization parameters and unwrapping quantized layers.
  • Test Coverage Expansion: Added a new test case for the NVFP4 modifier recipe, ensuring the correct implementation and functionality of the new quantization scheme.

🧠 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 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 extends AutoRound support to include the NVFP4 scheme. The changes are well-structured, introducing support for preset schemes from auto-round and improving the integration by correctly passing tokenizer and processor information. The quantization parameter mapping has been significantly improved and refactored into a dedicated method, which now handles more parameters and includes specific logic for NVFP4. Additionally, there are good improvements to the calibration and input capturing logic. A test case for the new NVFP4 scheme is also included.

I've found one critical issue regarding the handling of None quantization parameters that could lead to non-deterministic behavior, for which I've left a specific comment with a suggested fix. Otherwise, the changes look solid and improve the AutoRoundModifier's capabilities and robustness.

Comment on lines +344 to +345
if ar_value is None:
ar_value = torch.empty(1)
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 use of torch.empty(1) to handle None quantization parameters is unsafe. torch.empty() returns a tensor with uninitialized data, which can lead to non-deterministic behavior and incorrect results when used as a quantization parameter.

A None value should be handled based on the specific parameter's meaning. For instance, a None zero-point (zp) typically indicates symmetric quantization and should default to 0.0. For other parameters like scales, if None signifies they are not applicable for the current quantization scheme, they should be skipped.

                    if ar_value is None:
                        if ar_param_name == "zp":
                            # For symmetric quantization, zero point is 0
                            ar_value = 0.0
                        else:
                            # If other parameters are None, it likely means they are not used
                            # for the current quantization scheme, so we can skip them.
                            continue

model_args.config_name if model_args.config_name else model_path,
cache_dir=None,
revision=model_args.model_revision,
use_auth_token=True if model_args.use_auth_token else None,
Copy link

Choose a reason for hiding this comment

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

no need to change this?

)
},
)
recipe_modifier_nvfp4 = AutoRoundModifier(
Copy link

Choose a reason for hiding this comment

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

how about adding an example of NVFP4 model quantization, besides adding NVFP4 test?

@mratsim
Copy link
Contributor

mratsim commented Dec 31, 2025

Can vLLM load this?

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.

3 participants