From 1fe3932c8b48f0de96f7247a3930d498f002915d Mon Sep 17 00:00:00 2001 From: Andreas Karatzas Date: Mon, 16 Mar 2026 22:34:49 -0500 Subject: [PATCH] [ROCm] Fix AttributeError for torch.compiler.skip_all_guards_unsafe on older PyTorch (#37219) Signed-off-by: Andreas Karatzas (cherry picked from commit 54a62a79f70982742a227c845b96148e6401d0e7) --- vllm/compilation/wrapper.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/vllm/compilation/wrapper.py b/vllm/compilation/wrapper.py index ce85bae53..f5e62402a 100644 --- a/vllm/compilation/wrapper.py +++ b/vllm/compilation/wrapper.py @@ -112,7 +112,12 @@ class TorchCompileWithNoGuardsWrapper: entry.guard_type == "SHAPE_ENV" for entry in x ] else: - options["guard_filter_fn"] = torch.compiler.skip_all_guards_unsafe + if hasattr(torch.compiler, "skip_all_guards_unsafe"): + # Torch 2.10+ provides skip_all_guards_unsafe + options["guard_filter_fn"] = torch.compiler.skip_all_guards_unsafe + else: + # Equivalent fallback for older PyTorch: skip all guards + options["guard_filter_fn"] = lambda x: [False for _ in x] compiled_ptr: Any = self.forward # Validate that unbacked dynamic shapes require VLLM_USE_BYTECODE_HOOK=False