diff --git a/tests/compile/test_config.py b/tests/compile/test_config.py index 57fd1f1c49b1..52e0fcc2881f 100644 --- a/tests/compile/test_config.py +++ b/tests/compile/test_config.py @@ -11,6 +11,16 @@ from .piecewise.test_simple import SillyModel +def test_use_cudagraphs_dynamic(monkeypatch): + assert vllm.envs.VLLM_USE_V1 + vllm_config = VllmConfig() + assert vllm_config.compilation_config.use_cudagraph + + monkeypatch.setenv('VLLM_USE_V1', '0') + vllm_config = VllmConfig() + assert not vllm_config.compilation_config.use_cudagraph + + @pytest.mark.parametrize("enabled", [True, False]) def test_use_cudagraphs(enabled): assert vllm.envs.VLLM_USE_V1 diff --git a/vllm/config.py b/vllm/config.py index 3fbb6015fe40..32ef83a1866d 100644 --- a/vllm/config.py +++ b/vllm/config.py @@ -3931,7 +3931,7 @@ class CompilationConfig: constructor, e.g. `CompilationConfig(inductor_passes={"a": func})`.""" # CudaGraph compilation - use_cudagraph: bool = envs.VLLM_USE_V1 + use_cudagraph: bool = field(default_factory=lambda: envs.VLLM_USE_V1) """Whether to use cudagraph inside compilation. - False: cudagraph inside compilation is not used. - True: cudagraph inside compilation is used. It requires