@tduncan / Nvidia-Optimization-Stack-VLLM Mirror · read-only / commits / 002b07c4b2
Fork 0

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 13, 18:15 UTC

[Bugfix] vLLM should check Inductor config for compile cache enablement status (#27637)

Signed-off-by: Yanan Cao <gmagogsfm@gmail.com>

gmagogsfm committed Nov 5, 2025 at 09:22 UTC 002b07c4b201ac0ec31ce69d820070802e32d13c
2 files changed +26 -7
vllm/compilation/backends.py
+5 -2
@@ -33,6 +33,7 @@ from .compiler_interface import (
33 EagerAdaptor,
34 InductorAdaptor,
35 InductorStandaloneAdaptor,
36 + is_compile_cache_enabled,
37 )
38 from .counter import compilation_counter
39 from .inductor_pass import InductorPass
@@ -239,7 +240,7 @@ class CompilerManager:
240 assert compiled_graph is not None, "Failed to compile the graph"
241
242 # store the artifact in the cache
242 - if not envs.VLLM_DISABLE_COMPILE_CACHE and handle is not None:
243 + if is_compile_cache_enabled(additional_inductor_config) and handle is not None:
244 self.cache[(runtime_shape, graph_index, self.compiler.name)] = handle
245 compilation_counter.num_cache_entries_updated += 1
246 self.is_cache_updated = True
@@ -611,7 +612,9 @@ class VllmBackend:
612 os.makedirs(local_cache_dir, exist_ok=True)
613 self.compilation_config.local_cache_dir = local_cache_dir
614
614 - disable_cache = envs.VLLM_DISABLE_COMPILE_CACHE
615 + disable_cache = not is_compile_cache_enabled(
616 + self.compilation_config.inductor_compile_config
617 + )
618
619 if disable_cache:
620 logger.info_once("vLLM's torch.compile cache is disabled.", scope="local")
vllm/compilation/compiler_interface.py
+21 -5
@@ -163,6 +163,23 @@ def get_inductor_factors() -> list[Any]:
163 return factors
164
165
166 +def is_compile_cache_enabled(
167 + vllm_additional_inductor_config: dict[str, Any],
168 +) -> bool:
169 + vllm_inductor_config_disable_cache = vllm_additional_inductor_config.get(
170 + "force_disable_caches", False
171 + )
172 +
173 + # TODO(gmagogsfm): Replace torch._inductor.config.force_disable_caches
174 + # with torch.compiler.config.force_disable_caches when minimum PyTorch
175 + # version reaches 2.10
176 + return (
177 + not envs.VLLM_DISABLE_COMPILE_CACHE
178 + and not torch._inductor.config.force_disable_caches
179 + and not vllm_inductor_config_disable_cache
180 + )
181 +
182 +
183 class InductorStandaloneAdaptor(CompilerInterface):
184 """
185 The adaptor for the Inductor compiler.
@@ -222,7 +239,8 @@ class InductorStandaloneAdaptor(CompilerInterface):
239 # Save the compiled artifact to disk in the specified path
240 assert key is not None
241 path = os.path.join(self.cache_dir, key)
225 - if not envs.VLLM_DISABLE_COMPILE_CACHE:
242 +
243 + if is_compile_cache_enabled(compiler_config):
244 compiled_graph.save(path=path, format=self.save_format)
245 compilation_counter.num_compiled_artifacts_saved += 1
246 return compiled_graph, (key, path)
@@ -472,10 +490,8 @@ class InductorAdaptor(CompilerInterface):
490 config_patches=current_config,
491 )
492
475 - # We treat VLLM_DISABLE_COMPILE_CACHE as the overall switch for torch
476 - # compilation cache. So turn off the checks if we disable the
477 - # compilation cache.
478 - if not envs.VLLM_DISABLE_COMPILE_CACHE:
493 + # Turn off the checks if we disable the compilation cache.
494 + if is_compile_cache_enabled(compiler_config):
495 if hash_str is None:
496 raise RuntimeError(
497 "vLLM failed to compile the model. The most "