From 6ffe85309e27c99b1dfcf460fa701c5a4458d37f Mon Sep 17 00:00:00 2001 From: Brian Dellabetta Date: Wed, 25 Jun 2025 18:34:24 +0000 Subject: [PATCH 1/2] require torch 2, allow numpy>2, remove unnecessary warnings Signed-off-by: Brian Dellabetta --- setup.py | 4 +-- src/llmcompressor/pytorch/__init__.py | 45 --------------------------- 2 files changed, 2 insertions(+), 47 deletions(-) diff --git a/setup.py b/setup.py index 3a5230eb5..257fb9c68 100644 --- a/setup.py +++ b/setup.py @@ -112,10 +112,10 @@ def localversion_func(version: ScmVersion) -> str: install_requires=[ "loguru", "pyyaml>=5.0.0", - "numpy>=1.17.0,<2.0", + "numpy>=1.17.0", "requests>=2.0.0", "tqdm>=4.0.0", - "torch>=1.7.0", + "torch>=1.7.0,!=1.10,!=1.11", "transformers>4.0,<4.53.0", "datasets", "accelerate>=0.20.3,!=1.1.0", diff --git a/src/llmcompressor/pytorch/__init__.py b/src/llmcompressor/pytorch/__init__.py index 66d4be1b4..e69de29bb 100644 --- a/src/llmcompressor/pytorch/__init__.py +++ b/src/llmcompressor/pytorch/__init__.py @@ -1,45 +0,0 @@ -""" -Functionality for working with and sparsifying Models in the PyTorch framework -""" - -import os -import warnings - -from packaging import version - -try: - import torch - - _PARSED_TORCH_VERSION = version.parse(torch.__version__) - - if _PARSED_TORCH_VERSION.major >= 2: - torch_compile_func = torch.compile - - def raise_torch_compile_warning(*args, **kwargs): - warnings.warn( - "torch.compile is not supported by llmcompressor for torch 2.0.x" - ) - return torch_compile_func(*args, **kwargs) - - torch.compile = raise_torch_compile_warning - - _BYPASS = bool(int(os.environ.get("NM_BYPASS_TORCH_VERSION", "0"))) - if _PARSED_TORCH_VERSION.major == 1 and _PARSED_TORCH_VERSION.minor in [10, 11]: - if not _BYPASS: - raise RuntimeError( - "llmcompressor does not support torch==1.10.* or 1.11.*. " - f"Found torch version {torch.__version__}.\n\n" - "To bypass this error, set environment variable " - "`NM_BYPASS_TORCH_VERSION` to '1'.\n\n" - "Bypassing may result in errors or " - "incorrect behavior, so set at your own risk." - ) - else: - warnings.warn( - "llmcompressor quantized onnx export does not work " - "with torch==1.10.* or 1.11.*" - ) -except ImportError: - pass - -# flake8: noqa From 374401494eb72656a1fb66e2eb2dc85333d0b6d2 Mon Sep 17 00:00:00 2001 From: Brian Dellabetta Date: Wed, 25 Jun 2025 14:47:36 -0500 Subject: [PATCH 2/2] Update setup.py Signed-off-by: Brian Dellabetta --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index 257fb9c68..e9df38928 100644 --- a/setup.py +++ b/setup.py @@ -115,6 +115,7 @@ def localversion_func(version: ScmVersion) -> str: "numpy>=1.17.0", "requests>=2.0.0", "tqdm>=4.0.0", + # torch 1.10 and 1.11 do not support quantized onnx export "torch>=1.7.0,!=1.10,!=1.11", "transformers>4.0,<4.53.0", "datasets",