[Bugfix] Raise for unavailable piecewise CUDA graphs (#54782)
Signed-off-by: Isotr0py <Isotr0py@outlook.com>
Isotr0py committed
Sep 2, 2026 at 16:52 UTC
1c26e57d3c7b480bae4e67898784b6b976a4a515
1 file changed
+20
vllm/v1/worker/gpu/cudagraph_utils.py
+20
@@ -18,6 +18,7 @@ from vllm.compilation.breakable_cudagraph import (
18
)
19
from vllm.compilation.counter import compilation_counter
20
from vllm.compilation.cuda_graph import CUDAGraphWrapper
21
+from vllm.compilation.wrapper import TorchCompileWithNoGuardsWrapper
22
from vllm.config import VllmConfig, set_current_vllm_config
23
from vllm.config.compilation import CUDAGraphMode
24
from vllm.distributed.device_communicators.pynccl_allocator import set_graph_pool_id
@@ -108,6 +109,15 @@ def _is_compatible(
109
)
110
111
112
+def has_compiled_submodule(model: nn.Module) -> bool:
113
+ """Whether any submodule is an active @support_torch_compile module."""
114
+ return any(
115
+ isinstance(m, TorchCompileWithNoGuardsWrapper)
116
+ and not getattr(m, "do_not_compile", True)
117
+ for m in model.modules()
118
+ )
119
+
120
+
121
class CudaGraphManager:
122
def __init__(
123
self,
@@ -510,6 +520,16 @@ class ModelCudaGraphManager(CudaGraphManager):
520
if self.use_breakable_cg:
521
self.init_breakable_cg_runner(model)
522
523
+ if self.cudagraph_mode.has_piecewise_cudagraphs() and not (
524
+ self.use_breakable_cg or has_compiled_submodule(model)
525
+ ):
526
+ raise RuntimeError(
527
+ f"{type(model).__name__}: piecewise CUDA graphs "
528
+ f"(cudagraph_mode={self.cudagraph_mode.name}) unavailable, "
529
+ "model is not torch-compiled and breakable CUDA graph is off. "
530
+ "Set VLLM_USE_BREAKABLE_CUDAGRAPH=1 or cudagraph_mode=NONE/FULL."
531
+ )
532
+
533
def create_forward_fn(
534
desc: BatchExecutionDescriptor,
535
warmup: bool,