Skip to content

Conversation

@aaarrvind
Copy link

SUMMARY:
Part of #1927

  • Updated type hints to Python 3.10+ built-in generics
  • Replaced List[] with list[]
  • No functional changes

TEST PLAN:

  • Ran make quality (ruff format and lint checks)
  • Verified no functional code changes were introduced

@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 @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 logarithmic_equalization modifier. By adopting Python 3.10's built-in generic types, the code becomes more concise and aligned with contemporary Python best practices, without altering any runtime functionality.

Highlights

  • Type Hint Modernization: Updated type hints to utilize Python 3.10+ built-in generic types, specifically replacing List[] from the typing module with the native list[] syntax.
  • Functional Equivalence: This change is purely syntactic and introduces no functional modifications to the codebase, ensuring existing behavior remains unchanged.
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 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.

@aaarrvind
Copy link
Author

Hi! I've completed local testing, updated the type hint as requested, and the PR is ready for review.

@aaarrvind
Copy link
Author

/gemini review

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 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.

@aaarrvind
Copy link
Author

/gemini review

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 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.

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.

1 participant