-
Notifications
You must be signed in to change notification settings - Fork 315
Modernize type hints in logarithmic equalization modifier #2121
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?
Conversation
|
👋 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. |
Summary of ChangesHello @aaarrvind, 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 modernizing the type hinting syntax within the 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.
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 modernizes type hints by replacing List with the built-in list generic, which is a good improvement. However, I found an issue with an incorrect return type hint in the modified function signature. The function _calculate_smoothing_scales is hinted to return a list[float] but actually returns a torch.Tensor. I've provided a suggestion to correct this. Fixing this will improve code clarity and correctness for static analysis, though it may reveal a type inconsistency with the parent class that should also be addressed.
|
Hi! I've completed local testing, updated the type hint as requested, and the PR is ready for review. |
|
/gemini review |
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 modernizes type hints in LogarithmicEqualizationModifier by replacing typing.List with the built-in list generic, in line with Python 3.10+ features. While reviewing, I noticed that the change to the return type hint of _calculate_smoothing_scales from List[float] to torch.Tensor, while correct for the method's implementation, introduces a type signature incompatibility with its superclass SmoothQuantModifier. I've left a comment with a recommendation to also update the base class to maintain type consistency and adhere to the Liskov Substitution Principle.
|
/gemini review |
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 effectively modernizes the type hints to Python 3.10+ style, replacing legacy typing generics like List, Dict, Tuple, and Union with their built-in counterparts and the | operator. This improves code readability and aligns with modern Python practices. I've also noted the correction of the return type hint for _calculate_smoothing_scales in both logarithmic_equalization/base.py and smoothquant/base.py from List[float] to torch.Tensor. This is a great improvement for type accuracy, as the method indeed returns a tensor. The changes are well-contained and look good.
SUMMARY:
Part of #1927
TEST PLAN:
make quality(ruff format and lint checks)