[BugFix] Make pure-TP KV receive fallback all-or-nothing across ranks (#5636)

Signed-off-by: tzhouam <tzhouam@connect.ust.hk>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Zhou TaichangandClaude Fable 5 authored and GitHub committed 2026-08-01 15:43:48 +00:00
1 parent 4b1547b4d8
commit 2c4e9a945b
3 files changed
+362

No files matched your search

@@ -682,6 +682,10 @@ class TestDistributedReceive:
mgr = _make_manager(from_tp=2, to_tp=2, local_rank=1)
req = SimpleNamespace(request_id="req-1", sampling_params=SimpleNamespace())
world_group = _MockBroadcastGroup(world_size=2, rank_in_group=1)
# broadcast_value=True: rank 0's verdict says every TP rank has the
# same KV state, so the per-rank receive result stands (see #5627
# consensus). The exchange runs on the TP group, not world.
tp_group = _MockBroadcastGroup(world_size=2, rank_in_group=1, broadcast_value=True)
mgr.receive_multi_kv_cache = MagicMock(return_value=True)
with (
@@ -704,10 +708,19 @@ class TestDistributedReceive:
return_value=0,
),
patch("vllm_omni.diffusion.distributed.parallel_state.get_sp_group", return_value=None),
patch("vllm.distributed.parallel_state.get_tp_group", return_value=tp_group),
):
assert mgr.receive_multi_kv_cache_distributed(req, target_device=torch.device("cpu")) is True
mgr.receive_multi_kv_cache.assert_called_once_with(req, None, torch.device("cpu"))
# Pure TP still fetches per-rank (no leader→follower distribution),
# but each rank now reports its KV-state signature on the TP group
# for the identical-state verdict instead of silently diverging on a
# miss (#5627). World must stay untouched — it holds DP/PP ranks.
assert len(tp_group.send_calls) == 1
dst, sig = tp_group.send_calls[0]
assert dst == 0 and sig[0] is True
assert world_group.send_calls == []
# ── SP-only scenarios ────────────────────────────────────────────