From b545a0b20776cbb5eb9b9575954a55268edf5339 Mon Sep 17 00:00:00 2001 From: Boyuan Feng Date: Thu, 9 Oct 2025 23:39:19 -0700 Subject: [PATCH] fix test_simple_inductor_graph_partition (#26522) Signed-off-by: Boyuan Feng --- tests/compile/piecewise/test_simple.py | 6 +++++- vllm/compilation/compiler_interface.py | 10 ++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/tests/compile/piecewise/test_simple.py b/tests/compile/piecewise/test_simple.py index 8241d248fa532..5d65df67f5a6e 100644 --- a/tests/compile/piecewise/test_simple.py +++ b/tests/compile/piecewise/test_simple.py @@ -143,10 +143,14 @@ def test_simple_piecewise_compile(use_inductor): @torch.inference_mode() @pytest.mark.parametrize("splitting_ops", [["silly.attention"], []]) -def test_simple_inductor_graph_partition(splitting_ops): +def test_simple_inductor_graph_partition(splitting_ops, monkeypatch): if not is_torch_equal_or_newer("2.9.0.dev"): pytest.skip("inductor graph partition is only available in PyTorch 2.9+") + # disable compile cache so that we run separately for different splitting_ops + # and get the expected number of cudagraphs captured. + monkeypatch.setenv("VLLM_DISABLE_COMPILE_CACHE", "1") + _run_simple_model( # Inductor graph partition automatically resets splitting_ops to an empty list splitting_ops=splitting_ops, diff --git a/vllm/compilation/compiler_interface.py b/vllm/compilation/compiler_interface.py index 3b5fecaf189bc..d1774489320f9 100644 --- a/vllm/compilation/compiler_interface.py +++ b/vllm/compilation/compiler_interface.py @@ -332,7 +332,10 @@ class InductorAdaptor(CompilerInterface): nonlocal file_path compiled_fn = inductor_compiled_graph.current_callable file_path = compiled_fn.__code__.co_filename # noqa - if not file_path.startswith(self.base_cache_dir): + if ( + not file_path.startswith(self.base_cache_dir) + and compiled_fn.__closure__ is not None + ): # hooked in the align_inputs_from_check_idxs function # in torch/_inductor/utils.py for cell in compiled_fn.__closure__: @@ -359,7 +362,10 @@ class InductorAdaptor(CompilerInterface): nonlocal file_path compiled_fn = inductor_compiled_graph.current_callable file_path = compiled_fn.__code__.co_filename # noqa - if not file_path.startswith(self.base_cache_dir): + if ( + not file_path.startswith(self.base_cache_dir) + and compiled_fn.__closure__ is not None + ): # hooked in the align_inputs_from_check_idxs function # in torch/_inductor/utils.py for cell in compiled_fn.__closure__: