Skip to content

Commit c01d1c5

Browse files
authored
use .dev for version comparison with pytorch nightly release (#20031)
Signed-off-by: Boyuan Feng <boyuan@meta.com>
1 parent ead3698 commit c01d1c5

File tree

4 files changed

+19
-5
lines changed

4 files changed

+19
-5
lines changed

tests/compile/test_config.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@
55
import vllm
66
from vllm.compilation.counter import compilation_counter
77
from vllm.config import VllmConfig
8+
from vllm.utils import _is_torch_equal_or_newer
9+
10+
11+
def test_version():
12+
assert _is_torch_equal_or_newer('2.8.0.dev20250624+cu128', '2.8.0.dev')
13+
assert _is_torch_equal_or_newer('2.8.0a0+gitc82a174', '2.8.0.dev')
14+
assert _is_torch_equal_or_newer('2.8.0', '2.8.0.dev')
15+
assert _is_torch_equal_or_newer('2.8.1', '2.8.0.dev')
16+
assert not _is_torch_equal_or_newer('2.7.1', '2.8.0.dev')
817

918

1019
def test_use_cudagraphs_dynamic(monkeypatch):

vllm/compilation/backends.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
def make_compiler(compilation_config: CompilationConfig) -> CompilerInterface:
3333
if compilation_config.use_inductor:
3434
if envs.VLLM_USE_STANDALONE_COMPILE and is_torch_equal_or_newer(
35-
"2.8.0a"):
35+
"2.8.0.dev"):
3636
logger.debug("Using InductorStandaloneAdaptor")
3737
return InductorStandaloneAdaptor()
3838
else:

vllm/model_executor/layers/quantization/torchao.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ def __init__(self,
4444
"""
4545
# TorchAO quantization relies on tensor subclasses. In order,
4646
# to enable proper caching this needs standalone compile
47-
if is_torch_equal_or_newer("2.8.0a"):
47+
if is_torch_equal_or_newer("2.8.0.dev"):
4848
os.environ["VLLM_TEST_STANDALONE_COMPILE"] = "1"
4949
logger.info(
5050
"Using TorchAO: Setting VLLM_TEST_STANDALONE_COMPILE=1")
5151
5252
# TODO: remove after the torch dependency is updated to 2.8
5353
if is_torch_equal_or_newer(
54-
"2.7.0") and not is_torch_equal_or_newer("2.8.0a"):
54+
"2.7.0") and not is_torch_equal_or_newer("2.8.0.dev"):
5555
os.environ["VLLM_DISABLE_COMPILE_CACHE"] = "1"
5656
logger.info("Using TorchAO: Setting VLLM_DISABLE_COMPILE_CACHE=1")
5757
"""

vllm/utils.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2919,8 +2919,13 @@ def is_torch_equal_or_newer(target: str) -> bool:
29192919
Whether the condition meets.
29202920
"""
29212921
try:
2922-
torch_version = version.parse(str(torch.__version__))
2923-
return torch_version >= version.parse(target)
2922+
return _is_torch_equal_or_newer(str(torch.__version__), target)
29242923
except Exception:
29252924
# Fallback to PKG-INFO to load the package info, needed by the doc gen.
29262925
return Version(importlib.metadata.version('torch')) >= Version(target)
2926+
2927+
2928+
# Helper function used in testing.
2929+
def _is_torch_equal_or_newer(torch_version: str, target: str) -> bool:
2930+
torch_version = version.parse(torch_version)
2931+
return torch_version >= version.parse(target)

0 commit comments

Comments
 (0)