|
24 | 24 | from tqdm import tqdm |
25 | 25 |
|
26 | 26 | import vllm.envs as envs |
| 27 | +from vllm.compilation.breakable_cudagraph import ( |
| 28 | + BreakableCUDAGraphWrapper, |
| 29 | + is_breakable_cudagraph_enabled, |
| 30 | +) |
27 | 31 | from vllm.compilation.counter import compilation_counter |
28 | 32 | from vllm.compilation.cuda_graph import CUDAGraphStat |
29 | 33 | from vllm.compilation.monitor import set_cudagraph_capturing_enabled |
| 34 | +try: |
| 35 | + from vllm.compilation.breakable_cudagraph import ( |
| 36 | + BreakableCUDAGraphWrapper, |
| 37 | + is_breakable_cudagraph_enabled, |
| 38 | + ) |
| 39 | + _BREAKABLE_CUDAGRAPH_AVAILABLE = True |
| 40 | +except ImportError: |
| 41 | + _BREAKABLE_CUDAGRAPH_AVAILABLE = False |
| 42 | + |
| 43 | + def is_breakable_cudagraph_enabled() -> bool: # type: ignore[misc] |
| 44 | + return False |
30 | 45 | from vllm.config import ( |
31 | 46 | CompilationMode, |
32 | 47 | CUDAGraphMode, |
@@ -5370,6 +5385,22 @@ def load_model(self, load_dummy_weights: bool = False) -> None: |
5370 | 5385 | cudagraph_mode = self.compilation_config.cudagraph_mode |
5371 | 5386 | assert cudagraph_mode is not None |
5372 | 5387 | if ( |
| 5388 | + is_breakable_cudagraph_enabled() |
| 5389 | + and cudagraph_mode.has_full_cudagraphs() |
| 5390 | + and not self.parallel_config.use_ubatching |
| 5391 | + ): |
| 5392 | + # vLLM 0.24.0+ breakable CUDA graph: splits the graph at |
| 5393 | + # @eager_break_during_capture decorated ops (e.g. attention). |
| 5394 | + # OOT vendor attention ops are wrapped by |
| 5395 | + # vllm_fl.compilation.break_graph.wrap_attention_ops_for_break_graph |
| 5396 | + # which is called from register_builtins(). |
| 5397 | + self.model = BreakableCUDAGraphWrapper(self.model, self.vllm_config) |
| 5398 | + drafter = getattr(self, "drafter", None) |
| 5399 | + if drafter is not None and hasattr(drafter, "model"): |
| 5400 | + drafter.model = BreakableCUDAGraphWrapper( |
| 5401 | + drafter.model, self.vllm_config |
| 5402 | + ) |
| 5403 | + elif ( |
5373 | 5404 | cudagraph_mode.has_full_cudagraphs() |
5374 | 5405 | and not self.parallel_config.use_ubatching |
5375 | 5406 | ): |
|
0 commit comments