Skip to content

Drop unnecessary torch warnings, allow numpy v2 support #1595

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

brian-dellabetta
Copy link
Collaborator

@brian-dellabetta brian-dellabetta commented Jun 25, 2025

SUMMARY:
Drop torch extraneous warnings, including warning about use of torch.compile on torch v2. Allow numpy v2 as a dependency (unclear why this was previously not allowed)

  • vllm pins torch==2.7.0 and has no restrictions on numpy
  • compressed-tensors has torch>=1.7.0 and no explicit numpy dependency
  • pytorch has no restrictions on numpy

TEST PLAN:
no net new src code

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 @brian-dellabetta, 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 primarily focuses on modernizing the project's dependency stack by aligning with newer versions of torch and numpy, and removing outdated compatibility code. Additionally, it introduces a significant new feature: a TransformModifier that enables applying advanced model transformations, enhancing the project's capabilities in model optimization.

Highlights

  • Dependency Updates: I've updated the project's core dependencies in setup.py. The numpy dependency now allows for version 2.0 and above by removing the upper bound, and the torch dependency has been bumped to require torch>=2.7.0, effectively dropping support for torch v1.
  • Removal of Legacy Torch Compatibility: I've removed the src/llmcompressor/pytorch/__init__.py file entirely. This file contained logic for handling torch v1.x versions and warnings related to torch.compile on torch v2.x, which are no longer necessary with the updated torch dependency requirement.
  • Introduction of Transform Modifier: I've added a new TransformModifier under src/llmcompressor/modifiers/transform/. This new modifier introduces the capability to apply model transformations, such as QUIP (Quantization-aware Unit-wise Input Preprocessing) and SpinQuant, to models. This includes new template configurations for these transforms and an example script demonstrating its usage with a Llama-3 model.
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 is currently in preview and 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 to provide feedback.

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.

@brian-dellabetta brian-dellabetta force-pushed the bdellabe/torch-version-update branch from c3ce42b to ae3915b Compare June 25, 2025 18:33
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.

@brian-dellabetta brian-dellabetta force-pushed the bdellabe/torch-version-update branch from ae3915b to 6afe1fa Compare June 25, 2025 18:34
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 drops support for PyTorch v1 and enables NumPy v2. It also introduces a new TransformModifier, complete with templates, an example, and tests. My review focuses on improving the new additions. The TransformModifier implementation has some hardcoded values that should be generalized. The new example and test files have some device-handling issues (hardcoded "cuda") that could be made more robust. I've also identified a likely typo in one of the new transform templates. Addressing these points will improve the quality and reusability of the new code.

@brian-dellabetta brian-dellabetta changed the title Drop torch v1 support, allow numpy v2 support Drop torch v1 support and unnecessary warnings, allow numpy v2 support Jun 25, 2025
@brian-dellabetta brian-dellabetta changed the title Drop torch v1 support and unnecessary warnings, allow numpy v2 support Drop unnecesarry torch warnings, allow numpy v2 support Jun 25, 2025
@brian-dellabetta brian-dellabetta changed the title Drop unnecesarry torch warnings, allow numpy v2 support Drop unnecessary torch warnings, allow numpy v2 support Jun 25, 2025
@brian-dellabetta brian-dellabetta force-pushed the bdellabe/torch-version-update branch from 9138e5f to 4eb30bd Compare June 25, 2025 19:50
@brian-dellabetta brian-dellabetta marked this pull request as ready for review June 25, 2025 19:50
@brian-dellabetta brian-dellabetta added the ready When a PR is ready for review label Jun 25, 2025
Signed-off-by: Brian Dellabetta <[email protected]>
@brian-dellabetta brian-dellabetta force-pushed the bdellabe/torch-version-update branch from 4eb30bd to 88d4bb3 Compare June 25, 2025 20:03
Copy link
Collaborator

@kylesayrs kylesayrs left a comment

Choose a reason for hiding this comment

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

Looks like the numpy restriction was related to some random tensorboard conflict

neuralmagic/sparseml#2333

Copy link
Collaborator

@shanjiaz shanjiaz left a comment

Choose a reason for hiding this comment

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

Looks good to me! Thanks for cleaning this up : )

@brian-dellabetta brian-dellabetta enabled auto-merge (squash) June 26, 2025 16:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready When a PR is ready for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants