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 4, 17:30 UTC
[Bugfix] Include inductor and functorch configs in compilation cache key (#40627)
Signed-off-by: Richard Zou <zou3519@gmail.com>
Richard Zou committed
Apr 23, 2026 at 09:52 UTC
424033f4fceeb5a1469fa77dfa7fc0c5d60f002d
3 files changed
+40
-2
tests/compile/h100/test_startup.py
+2
@@ -56,6 +56,7 @@ def _cold_start(vllm_runner):
56
def test_moe_startup(monkeypatch, vllm_runner, fresh_vllm_cache, mega_aot_artifact):
57
monkeypatch.setenv("VLLM_ENABLE_V1_MULTIPROCESSING", "0")
58
monkeypatch.setenv("VLLM_USE_MEGA_AOT_ARTIFACT", mega_aot_artifact)
59
+ monkeypatch.setenv("VLLM_DEEP_GEMM_WARMUP", "skip")
60
61
# Cold start in a forked child (must fork before CUDA init).
62
# This model has 32 identical transformer layers which produce
@@ -235,6 +236,7 @@ def _cold_start_model(vllm_runner, spec: ModelStartupSpec):
236
@fork_new_process_for_each_test
237
def test_model_startup(monkeypatch, vllm_runner, fresh_vllm_cache, spec):
238
monkeypatch.setenv("VLLM_ENABLE_V1_MULTIPROCESSING", "0")
239
+ monkeypatch.setenv("VLLM_DEEP_GEMM_WARMUP", "skip")
240
241
# Cold start in a forked child (must fork before CUDA init).
242
ctx = mp.get_context("fork")
tests/compile/test_config.py
+18
@@ -617,6 +617,24 @@ def test_inductor_asserts_enabled_in_debug(monkeypatch):
617
assert config.inductor_compile_config.get("scalar_asserts") is True
618
619
620
+def test_get_inductor_factors_includes_configs():
621
+ """Changing inductor or functorch config must change the cache key factors."""
622
+ from torch._functorch import config as functorch_config
623
+ from torch._inductor import config as inductor_config
624
+
625
+ from vllm.compilation.compiler_interface import get_inductor_factors
626
+
627
+ baseline = get_inductor_factors()
628
+
629
+ with inductor_config.patch("max_autotune", not inductor_config.max_autotune):
630
+ patched = get_inductor_factors()
631
+ assert baseline != patched, "inductor config change was not reflected"
632
+
633
+ with functorch_config.patch("donated_buffer", not functorch_config.donated_buffer):
634
+ patched = get_inductor_factors()
635
+ assert baseline != patched, "functorch config change was not reflected"
636
+
637
+
638
def test_inductor_asserts_user_override(monkeypatch):
639
"""Test that explicit inductor_compile_config overrides the
640
debug-logging default."""
vllm/compilation/compiler_interface.py
+20
-2
@@ -152,6 +152,17 @@ class AlwaysHitShapeEnv:
152
return ""
153
154
155
+def _get_vllm_functorch_config() -> dict[str, Any]:
156
+ """Return the functorch config overrides that vLLM applies at compile time.
157
+
158
+ Used by both set_functorch_config() and get_inductor_factors() to ensure
159
+ the compile-time config and cache key are always consistent."""
160
+ cfg: dict[str, Any] = {}
161
+ if not envs.VLLM_USE_MEGA_AOT_ARTIFACT:
162
+ cfg["bundled_autograd_cache"] = False
163
+ return cfg
164
+
165
+
166
def get_inductor_factors() -> list[Any]:
167
factors: list[Any] = []
168
# summarize system state
@@ -165,6 +176,13 @@ def get_inductor_factors() -> list[Any]:
176
177
torch_factors = torch_key()
178
factors.append(torch_factors)
179
+
180
+ from torch._functorch import config as functorch_config
181
+ from torch._inductor import config as inductor_config
182
+
183
+ factors.append(inductor_config.save_config_portable())
184
+ with functorch_config.patch(_get_vllm_functorch_config()):
185
+ factors.append(functorch_config.save_config_portable())
186
return factors
187
188
@@ -739,8 +757,8 @@ def set_inductor_config(config: dict[str, Any], compile_range: Range) -> None:
757
758
759
def set_functorch_config() -> None:
742
- if not envs.VLLM_USE_MEGA_AOT_ARTIFACT:
743
- torch._functorch.config.bundled_autograd_cache = False
760
+ for k, v in _get_vllm_functorch_config().items():
761
+ setattr(torch._functorch.config, k, v)
762
763
764
class EagerAdaptor(CompilerInterface):