Skip to content
Merged
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
26 changes: 26 additions & 0 deletions tests/distributed/test_dcp_a2a.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,32 @@ def test_b12x_query_gather_requires_env(monkeypatch: pytest.MonkeyPatch):
assert actual is expected


def test_warmup_skips_unsupported_world_size(monkeypatch: pytest.MonkeyPatch):
from vllm.v1.attention.ops import dcp_alltoall

monkeypatch.setenv("VLLM_USE_B12X_DCP_A2A", "1")
monkeypatch.setattr(
dcp_alltoall,
"_try_b12x_dcp_all_gather_heads",
lambda *args, **kwargs: pytest.fail(
"warmup must not touch the B12X channel for world size 6"
),
)
group = _FakeCPGroup(6, None) # type: ignore[arg-type]

# Must log-and-return instead of raising: the runtime dispatchers fall
# back to NCCL for DCP world sizes without a B12X channel (e.g. TP6).
dcp_alltoall.warmup_b12x_dcp_a2a(
group, # type: ignore[arg-type]
device=torch.device("cpu"),
dtype=torch.bfloat16,
max_batch_size=8192,
total_heads=66,
head_dim=512,
query_head_dim=576,
)


class TestPackedA2AKernels:
@pytest.mark.skipif(
torch.accelerator.device_count() < 1, reason="CUDA is required."
Expand Down
5 changes: 5 additions & 0 deletions vllm/model_executor/layers/attention/mla_attention.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,11 @@ def __init__(
self.dcp_a2a
and envs.VLLM_USE_B12X_DCP_A2A
and self.attn_backend.get_name() == "B12X_MLA_SPARSE"
# The B12X PCIe DCP channel only exists for world sizes 2/4/8;
# other DCP sizes (e.g. TP6 with DCP3/DCP6) use NCCL collectives.
and _vllm_config is not None
and _vllm_config.parallel_config.decode_context_parallel_size
in (2, 4, 8)
)
self.dcp_max_batch_size = (
int(_vllm_config.scheduler_config.max_num_batched_tokens)
Expand Down
10 changes: 10 additions & 0 deletions vllm/v1/attention/ops/dcp_alltoall.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,16 @@ def warmup_b12x_dcp_a2a(
"""Create and exercise the B12X DCP channel before CUDA graph capture."""
if not envs.VLLM_USE_B12X_DCP_A2A:
return
if cp_group.world_size not in (2, 4, 8):
# The PCIe channel only exists for these world sizes. The runtime
# dispatchers already fall back to NCCL collectives per call, so an
# unsupported DCP size (e.g. TP6 with DCP3/DCP6) must not fail boot.
logger.warning_once(
"B12X PCIe DCP collectives support world sizes 2/4/8; "
"DCP world size %d uses NCCL collectives instead.",
cp_group.world_size,
)
return
if query_head_dim is None:
query_head_dim = head_dim
local_query = torch.empty(
Expand Down
Loading