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
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,11 @@ 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.10 and 1.11 do not support quantized onnx export
"torch>=1.7.0,!=1.10,!=1.11",
"transformers>4.0,<5.0",
"datasets",
"accelerate>=0.20.3,!=1.1.0",
Expand Down
45 changes: 0 additions & 45 deletions src/llmcompressor/pytorch/__init__.py
Original file line number Diff line number Diff line change
@@ -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
Loading