From 6278bc829eb6214f3375cc50347d58dbae81bc31 Mon Sep 17 00:00:00 2001 From: Richard Zou Date: Thu, 27 Mar 2025 06:33:41 -0400 Subject: [PATCH] Fix incorrect filenames in vllm_compile_cache.py (#15494) Signed-off-by: Signed-off-by: youkaichao Co-authored-by: youkaichao --- vllm/compilation/compiler_interface.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/vllm/compilation/compiler_interface.py b/vllm/compilation/compiler_interface.py index 571e2b832e95f..ab0f98bdaa3e5 100644 --- a/vllm/compilation/compiler_interface.py +++ b/vllm/compilation/compiler_interface.py @@ -229,7 +229,20 @@ class InductorAdaptor(CompilerInterface): inductor_compiled_graph = output if inductor_compiled_graph is not None: nonlocal file_path - file_path = inductor_compiled_graph.current_callable.__code__.co_filename # noqa + compiled_fn = inductor_compiled_graph.current_callable + file_path = compiled_fn.__code__.co_filename # noqa + if not file_path.startswith(self.cache_dir): + # hooked in the align_inputs_from_check_idxs function + # in torch/_inductor/utils.py + for cell in compiled_fn.__closure__: + if not callable(cell.cell_contents): + continue + code = cell.cell_contents.__code__ + if code.co_filename.startswith(self.cache_dir): + # this is the real file path + # compiled from Inductor + file_path = code.co_filename + break hash_str = inductor_compiled_graph._fx_graph_cache_key return output