Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions tests/compile/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,29 @@ def test_splitting_ops_dynamic():
assert config.compilation_config.cudagraph_mode == CUDAGraphMode.PIECEWISE


@pytest.mark.parametrize(
("cudagraph_mode", "expected_cudagraph_mode"),
[
(CUDAGraphMode.PIECEWISE, CUDAGraphMode.NONE),
(CUDAGraphMode.FULL_AND_PIECEWISE, CUDAGraphMode.FULL),
],
)
def test_empty_splitting_ops_disable_piecewise_cudagraphs(
cudagraph_mode: CUDAGraphMode,
expected_cudagraph_mode: CUDAGraphMode,
):
config = CompilationConfig(
mode=CompilationMode.NONE,
cudagraph_mode=cudagraph_mode,
splitting_ops=[],
)

config.set_splitting_ops_for_v1(all2all_backend="")

assert config.splitting_ops == []
assert config.cudagraph_mode == expected_cudagraph_mode


def test_moe_splitting_ops_deepep_ht_inductor_partition():
# Inductor partition case: user-provided splitting_ops should be
# preserved and MoE ops should be appended for DeepEP HT with dp>1.
Expand Down
53 changes: 28 additions & 25 deletions vllm/config/compilation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1131,6 +1131,31 @@ def post_init_cudagraph_sizes(self) -> None:
if self.cudagraph_capture_sizes:
assert self.cudagraph_capture_sizes[-1] == self.max_cudagraph_capture_size

def _set_cudagraph_mode_for_empty_splitting_ops(self) -> None:
if (
self.cudagraph_mode == CUDAGraphMode.PIECEWISE
or self.cudagraph_mode == CUDAGraphMode.FULL_AND_PIECEWISE
):
logger.warning_once("Using piecewise cudagraph with empty splitting_ops")
if self.cudagraph_mode == CUDAGraphMode.PIECEWISE:
logger.warning_once(
"Piecewise compilation with empty splitting_ops does not "
"contain piecewise cudagraph. Setting cudagraph_"
"mode to NONE. Hint: If you are using attention "
"backends that support cudagraph, consider manually "
"setting cudagraph_mode to FULL or FULL_DECODE_ONLY "
"to enable full cudagraphs."
)
self.cudagraph_mode = CUDAGraphMode.NONE
elif self.cudagraph_mode == CUDAGraphMode.FULL_AND_PIECEWISE:
logger.warning_once(
"Piecewise compilation with empty splitting_ops does "
"not contain piecewise cudagraph. Setting "
"cudagraph_mode to FULL."
)
self.cudagraph_mode = CUDAGraphMode.FULL
self.splitting_ops = []

def set_splitting_ops_for_v1(
self, all2all_backend: str, data_parallel_size: int = 1
):
Expand All @@ -1139,6 +1164,8 @@ def set_splitting_ops_for_v1(
if self.mode != CompilationMode.VLLM_COMPILE:
if self.splitting_ops is None:
self.splitting_ops = []
if len(self.splitting_ops) == 0:
self._set_cudagraph_mode_for_empty_splitting_ops()
return

if self.pass_config.fuse_attn_quant and not self.use_inductor_graph_partition:
Expand Down Expand Up @@ -1185,31 +1212,7 @@ def set_splitting_ops_for_v1(
self.splitting_ops.append("vllm::unified_mla_kv_cache_update")

elif len(self.splitting_ops) == 0:
if (
self.cudagraph_mode == CUDAGraphMode.PIECEWISE
or self.cudagraph_mode == CUDAGraphMode.FULL_AND_PIECEWISE
):
logger.warning_once(
"Using piecewise cudagraph with empty splitting_ops"
)
if self.cudagraph_mode == CUDAGraphMode.PIECEWISE:
logger.warning_once(
"Piecewise compilation with empty splitting_ops does not "
"contain piecewise cudagraph. Setting cudagraph_"
"mode to NONE. Hint: If you are using attention "
"backends that support cudagraph, consider manually "
"setting cudagraph_mode to FULL or FULL_DECODE_ONLY "
"to enable full cudagraphs."
)
self.cudagraph_mode = CUDAGraphMode.NONE
elif self.cudagraph_mode == CUDAGraphMode.FULL_AND_PIECEWISE:
logger.warning_once(
"Piecewise compilation with empty splitting_ops does "
"not contain piecewise cudagraph. Setting "
"cudagraph_mode to FULL."
)
self.cudagraph_mode = CUDAGraphMode.FULL
self.splitting_ops = []
self._set_cudagraph_mode_for_empty_splitting_ops()

if (
not self.use_inductor_graph_partition
Expand Down
Loading