[AMD][MORI] Deduplicate CP-replicated state transfers (#36025)
This commit is contained in:
@@ -8,6 +8,7 @@ import numpy as np
|
||||
import torch
|
||||
|
||||
from sglang.srt.disaggregation.base.conn import KVArgs, StateType
|
||||
from sglang.srt.disaggregation.common.conn import CommonKVManager
|
||||
from sglang.srt.disaggregation.common.staging_handler import (
|
||||
handle_staging_req,
|
||||
)
|
||||
@@ -138,6 +139,53 @@ class TestDisaggregationWire(unittest.TestCase):
|
||||
self.assertEqual(unpack_list_of_buffers(pack_list_of_buffers(bufs)), bufs)
|
||||
|
||||
|
||||
class TestCPReplicatedStateTransfer(unittest.TestCase):
|
||||
def test_only_nonzero_cp_ranks_without_layer_split_skip_state(self):
|
||||
cases = [
|
||||
(1, 0, False, False),
|
||||
(8, 0, False, False),
|
||||
(8, 1, False, True),
|
||||
(8, 7, False, True),
|
||||
(8, 1, True, False),
|
||||
]
|
||||
|
||||
for cp_size, cp_rank, layer_split, expected in cases:
|
||||
with self.subTest(
|
||||
cp_size=cp_size,
|
||||
cp_rank=cp_rank,
|
||||
layer_split=layer_split,
|
||||
):
|
||||
manager = object.__new__(CommonKVManager)
|
||||
manager.attn_cp_size = cp_size
|
||||
manager.attn_cp_rank = cp_rank
|
||||
parallel = SimpleNamespace(
|
||||
enable_dsa_cache_layer_split=layer_split,
|
||||
)
|
||||
with patch(
|
||||
"sglang.srt.disaggregation.common.conn.get_parallel",
|
||||
return_value=parallel,
|
||||
):
|
||||
self.assertEqual(
|
||||
manager._should_skip_cp_replicated_state_transfer(),
|
||||
expected,
|
||||
)
|
||||
|
||||
def test_mooncake_uses_common_cp_state_policy(self):
|
||||
manager = object.__new__(MooncakeKVManager)
|
||||
manager.attn_cp_size = 8
|
||||
manager.attn_cp_rank = 3
|
||||
manager.is_hybrid_mla_backend = False
|
||||
|
||||
with patch(
|
||||
"sglang.srt.disaggregation.common.conn.get_parallel",
|
||||
return_value=SimpleNamespace(enable_dsa_cache_layer_split=False),
|
||||
):
|
||||
self.assertEqual(
|
||||
manager._get_dsa_cache_transfer_skip_flags(None),
|
||||
(False, True),
|
||||
)
|
||||
|
||||
|
||||
class TestGroupConcurrentContiguous(unittest.TestCase):
|
||||
@staticmethod
|
||||
def _arr(values):
|
||||
|
||||
Reference in New Issue
Block a user