A high-throughput and memory-efficient inference and serving engine for LLMs
Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git
Synced Nov 10, 04:00 UTC
[misc] Remove is_torch_equal_or_newer(2.4) cases (#32296)
Signed-off-by: angelayi <yiangela7@gmail.com>
Angela Yi committed
Jan 13, 2026 at 23:22 UTC
79336380518a95db1b2b78edf156b88a5605f190
4 files changed
+24
-54
vllm/compilation/decorators.py
+1
-2
@@ -28,7 +28,7 @@ from vllm.config.compilation import DynamicShapesType
28
from vllm.logger import init_logger
29
from vllm.sequence import IntermediateTensors
30
from vllm.utils.import_utils import resolve_obj_by_qualname
31
-from vllm.utils.torch_utils import is_torch_equal_or_newer, supports_dynamo
31
+from vllm.utils.torch_utils import is_torch_equal_or_newer
32
33
from .monitor import start_monitoring_torch_compile
34
@@ -312,7 +312,6 @@ def _support_torch_compile(
312
self.do_not_compile = (
313
self.compilation_config.mode
314
in [CompilationMode.NONE, CompilationMode.STOCK_TORCH_COMPILE]
315
- or not supports_dynamo()
315
or _should_ignore_torch_compile(self.__class__)
316
or not enable_compile
317
)
vllm/distributed/parallel_state.py
+23
-25
@@ -53,7 +53,6 @@ from vllm.utils.network_utils import get_distributed_init_method
53
from vllm.utils.system_utils import suppress_stdout
54
from vllm.utils.torch_utils import (
55
direct_register_custom_op,
56
- supports_custom_op,
56
)
57
58
@@ -246,33 +245,32 @@ def patched_fused_scaled_matmul_reduce_scatter(
245
)
246
247
249
-if supports_custom_op():
250
- direct_register_custom_op(
251
- op_name="all_reduce",
252
- op_func=all_reduce,
253
- fake_impl=all_reduce_fake,
254
- )
248
+direct_register_custom_op(
249
+ op_name="all_reduce",
250
+ op_func=all_reduce,
251
+ fake_impl=all_reduce_fake,
252
+)
253
256
- direct_register_custom_op(
257
- op_name="reduce_scatter",
258
- op_func=reduce_scatter,
259
- fake_impl=reduce_scatter_fake,
260
- )
254
+direct_register_custom_op(
255
+ op_name="reduce_scatter",
256
+ op_func=reduce_scatter,
257
+ fake_impl=reduce_scatter_fake,
258
+)
259
262
- direct_register_custom_op(
263
- op_name="all_gather",
264
- op_func=all_gather,
265
- fake_impl=all_gather_fake,
266
- )
260
+direct_register_custom_op(
261
+ op_name="all_gather",
262
+ op_func=all_gather,
263
+ fake_impl=all_gather_fake,
264
+)
265
268
- # TODO: Remove this once the pytorch fix
269
- # (https://github.com/pytorch/pytorch/pull/165086) gets released,
270
- # in either 2.9.1 or 2.10
271
- direct_register_custom_op(
272
- op_name="patched_fused_scaled_matmul_reduce_scatter",
273
- op_func=patched_fused_scaled_matmul_reduce_scatter,
274
- fake_impl=patched_fused_scaled_matmul_reduce_scatter_fake,
275
- )
266
+# TODO: Remove this once the pytorch fix
267
+# (https://github.com/pytorch/pytorch/pull/165086) gets released,
268
+# in either 2.9.1 or 2.10
269
+direct_register_custom_op(
270
+ op_name="patched_fused_scaled_matmul_reduce_scatter",
271
+ op_func=patched_fused_scaled_matmul_reduce_scatter,
272
+ fake_impl=patched_fused_scaled_matmul_reduce_scatter_fake,
273
+)
274
275
276
class GroupCoordinator:
vllm/utils/torch_utils.py
-25
@@ -704,13 +704,6 @@ def is_torch_equal(target: str) -> bool:
704
return Version(importlib.metadata.version("torch")) == Version(target)
705
706
707
-# Using dynamo with vLLM doesn't really work well with PyTorch versions < 2.4.0.
708
-# In particular, the FakeScalarType is not supported for earlier versions of
709
-# PyTorch which breaks dynamo for any ops registered using ScalarType.
710
-def supports_dynamo() -> bool:
711
- return is_torch_equal_or_newer("2.4.0")
712
-
713
-
707
# Supports xccl with PyTorch versions >= 2.8.0.dev for XPU platform
708
def supports_xccl() -> bool:
709
return (
@@ -718,12 +711,6 @@ def supports_xccl() -> bool:
711
)
712
713
721
-# Some backends use pytorch version < 2.4.0 which doesn't
722
-# support `torch.library.custom_op`.
723
-def supports_custom_op() -> bool:
724
- return hasattr(torch.library, "custom_op")
725
-
726
-
714
# create a library to hold the custom op
715
vllm_lib = Library("vllm", "FRAGMENT") # noqa
716
@@ -752,18 +739,6 @@ def direct_register_custom_op(
739
library object. If you want to bind the operator to a different library,
740
make sure the library object is alive when the operator is used.
741
"""
755
- if not supports_custom_op():
756
- from vllm.platforms import current_platform
757
-
758
- assert not current_platform.is_cuda_alike(), (
759
- "cuda platform needs torch>=2.4 to support custom op, "
760
- "chances are you are using an old version of pytorch "
761
- "or a custom build of pytorch. It is recommended to "
762
- "use vLLM in a fresh new environment and let it install "
763
- "the required dependencies."
764
- )
765
- return
766
-
742
if mutates_args is None:
743
mutates_args = []
744
vllm/v1/worker/gpu_model_runner.py
-2
@@ -96,7 +96,6 @@ from vllm.utils.platform_utils import is_pin_memory_available
96
from vllm.utils.torch_utils import (
97
get_dtype_size,
98
kv_cache_dtype_str_to_dtype,
99
- supports_dynamo,
99
)
100
from vllm.v1.attention.backend import (
101
AttentionBackend,
@@ -3944,7 +3943,6 @@ class GPUModelRunner(
3943
if (
3944
self.vllm_config.compilation_config.mode
3945
== CompilationMode.STOCK_TORCH_COMPILE
3947
- and supports_dynamo()
3946
):
3947
backend = self.vllm_config.compilation_config.init_backend(self.vllm_config)
3948
compilation_counter.stock_torch_compile_count += 1