Skip to content

Commit 5dbb2c6

Browse files
feat: add BreakableCUDAGraphWrapper support in model_runner
1 parent 85b18c5 commit 5dbb2c6

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

vllm_fl/worker/model_runner.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,24 @@
2424
from tqdm import tqdm
2525

2626
import vllm.envs as envs
27+
from vllm.compilation.breakable_cudagraph import (
28+
BreakableCUDAGraphWrapper,
29+
is_breakable_cudagraph_enabled,
30+
)
2731
from vllm.compilation.counter import compilation_counter
2832
from vllm.compilation.cuda_graph import CUDAGraphStat
2933
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
3045
from vllm.config import (
3146
CompilationMode,
3247
CUDAGraphMode,
@@ -5370,6 +5385,22 @@ def load_model(self, load_dummy_weights: bool = False) -> None:
53705385
cudagraph_mode = self.compilation_config.cudagraph_mode
53715386
assert cudagraph_mode is not None
53725387
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 (
53735404
cudagraph_mode.has_full_cudagraphs()
53745405
and not self.parallel_config.use_ubatching
53755406
):

0 commit comments

Comments
 (0)