diff --git a/vllm/compilation/decorators.py b/vllm/compilation/decorators.py index 1370862d580a..58f70ef9ef0a 100644 --- a/vllm/compilation/decorators.py +++ b/vllm/compilation/decorators.py @@ -267,8 +267,24 @@ def _support_torch_compile( code.co_filename) return inline_call(parent, func, args, kwargs) + # Disable the C++ compilation of symbolic shape guards. C++-fication + # of symbolic shape guards can improve guard overhead. But, since + # vllm skip guards anyways, setting this flag to False can improve + # compile time. + dynamo_config_patches = {} + try: + _ = torch._dynamo.config.enable_cpp_symbolic_shape_guards + dynamo_config_patches[ + "enable_cpp_symbolic_shape_guards"] = False + except AttributeError: + # Note: this config is not available in torch 2.6, we can skip + # if the config doesn't exist + logger.debug( + "enable_cpp_symbolic_shape_guards config not available") + with patch.object(InliningInstructionTranslator, 'inline_call', - patched_inline_call): + patched_inline_call), torch._dynamo.config.patch( + **dynamo_config_patches): output = self.compiled_callable(*args, **kwargs) return output