diff --git a/tests/compile/test_config.py b/tests/compile/test_config.py index 913d7eb46a..12ea2e1370 100644 --- a/tests/compile/test_config.py +++ b/tests/compile/test_config.py @@ -205,6 +205,22 @@ def test_enforce_eager(vllm_runner, monkeypatch): pass +@pytest.mark.forked +def test_torch_compile_disable(vllm_runner, monkeypatch): + monkeypatch.setenv("VLLM_ENABLE_V1_MULTIPROCESSING", "0") + monkeypatch.setenv("TORCH_COMPILE_DISABLE", "1") + monkeypatch.setenv("VLLM_DISABLE_COMPILE_CACHE", "1") + + with ( + compilation_counter.expect(num_graphs_seen=0, stock_torch_compile_count=0), + vllm_runner( + "facebook/opt-125m", + gpu_memory_utilization=0.4, + ) as _, + ): + pass + + def test_splitting_ops_dynamic(): # Default config config = VllmConfig() diff --git a/vllm/config/vllm.py b/vllm/config/vllm.py index 0726e93d2f..8575711e25 100644 --- a/vllm/config/vllm.py +++ b/vllm/config/vllm.py @@ -900,6 +900,13 @@ class VllmConfig: self.compilation_config.mode = CompilationMode.NONE self.compilation_config.cudagraph_mode = CUDAGraphMode.NONE + if os.environ.get("TORCH_COMPILE_DISABLE") == "1": + logger.warning( + "TORCH_COMPILE_DISABLE is set, disabling torch.compile. " + "This is equivalent to setting -cc.mode=none" + ) + self.compilation_config.mode = CompilationMode.NONE + if self.compilation_config.backend == "eager" or ( self.compilation_config.mode is not None and self.compilation_config.mode != CompilationMode.VLLM_COMPILE