[Test] Fix optimistic prefill disaggregation test after mamba radix cache removal (#40469)
Co-authored-by: Mohammad Angkad <mohammad.angkad@radixark.ai>
This commit is contained in:
co-authored by
Mohammad Angkad
parent
791c7850d0
commit
8923f4d779
@@ -27,9 +27,10 @@ from sglang.srt.managers.schedule_batch import Req
|
|||||||
from sglang.srt.mem_cache.allocator import TokenToKVPoolAllocator
|
from sglang.srt.mem_cache.allocator import TokenToKVPoolAllocator
|
||||||
from sglang.srt.mem_cache.base_prefix_cache import MatchPrefixParams
|
from sglang.srt.mem_cache.base_prefix_cache import MatchPrefixParams
|
||||||
from sglang.srt.mem_cache.cache_init_params import CacheInitParams
|
from sglang.srt.mem_cache.cache_init_params import CacheInitParams
|
||||||
from sglang.srt.mem_cache.mamba_radix_cache import MambaRadixCache
|
|
||||||
from sglang.srt.mem_cache.memory_pool import HybridLinearKVPool, HybridReqToTokenPool
|
from sglang.srt.mem_cache.memory_pool import HybridLinearKVPool, HybridReqToTokenPool
|
||||||
from sglang.srt.mem_cache.radix_cache import RadixKey
|
from sglang.srt.mem_cache.radix_cache import RadixKey
|
||||||
|
from sglang.srt.mem_cache.unified_cache.components.base import ComponentType
|
||||||
|
from sglang.srt.mem_cache.unified_radix_cache import UnifiedRadixCache
|
||||||
from sglang.srt.sampling.sampling_params import SamplingParams
|
from sglang.srt.sampling.sampling_params import SamplingParams
|
||||||
from sglang.srt.server_args import ServerArgs, set_global_server_args_for_scheduler
|
from sglang.srt.server_args import ServerArgs, set_global_server_args_for_scheduler
|
||||||
from sglang.srt.utils import get_device
|
from sglang.srt.utils import get_device
|
||||||
@@ -354,16 +355,8 @@ class TestOptimisticPrefillMambaAdmission(CustomTestCase):
|
|||||||
|
|
||||||
|
|
||||||
class TestOptimisticPrefillMambaRetryRelease(CustomTestCase):
|
class TestOptimisticPrefillMambaRetryRelease(CustomTestCase):
|
||||||
"""Optimistic retry cleanup must not treat the donated Mamba checkpoint
|
"""An optimistic-prefill retry leaves the donated prefix and exactly one
|
||||||
as a second donation.
|
Mamba checkpoint in the tree -- not zero, and not a second pinned clone.
|
||||||
|
|
||||||
Bug mechanism: the retry path first inserts the unfinished prefix, which
|
|
||||||
donates the tracked checkpoint and clears ``mamba_last_track_seqlen``.
|
|
||||||
Releasing with ``is_insert=True`` afterwards re-enters the donation path
|
|
||||||
with the cleared marker, inserting a zero-length radix entry that pins a
|
|
||||||
clone of the request's live state. Releasing with ``is_insert=False``
|
|
||||||
retains the donated prefix/checkpoint and frees only the uncached tail
|
|
||||||
and the request-owned Mamba buffers.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
SIZE = 128
|
SIZE = 128
|
||||||
@@ -373,7 +366,7 @@ class TestOptimisticPrefillMambaRetryRelease(CustomTestCase):
|
|||||||
|
|
||||||
def _setup_mamba_tree(self):
|
def _setup_mamba_tree(self):
|
||||||
server_args = ServerArgs(model_path="dummy", page_size=1)
|
server_args = ServerArgs(model_path="dummy", page_size=1)
|
||||||
# MambaRadixCache reads mamba_cache_chunk_size, whose property
|
# The mamba component reads mamba_cache_chunk_size, whose property
|
||||||
# otherwise loads the HF config for the dummy model.
|
# otherwise loads the HF config for the dummy model.
|
||||||
server_args._mamba_cache_chunk_size = FLA_CHUNK_SIZE
|
server_args._mamba_cache_chunk_size = FLA_CHUNK_SIZE
|
||||||
set_global_server_args_for_scheduler(server_args)
|
set_global_server_args_for_scheduler(server_args)
|
||||||
@@ -427,13 +420,14 @@ class TestOptimisticPrefillMambaRetryRelease(CustomTestCase):
|
|||||||
kvcache=pool,
|
kvcache=pool,
|
||||||
need_sort=False,
|
need_sort=False,
|
||||||
)
|
)
|
||||||
tree = MambaRadixCache(
|
tree = UnifiedRadixCache(
|
||||||
params=CacheInitParams(
|
params=CacheInitParams(
|
||||||
disable=False,
|
disable=False,
|
||||||
req_to_token_pool=req_to_token_pool,
|
req_to_token_pool=req_to_token_pool,
|
||||||
token_to_kv_pool_allocator=allocator,
|
token_to_kv_pool_allocator=allocator,
|
||||||
page_size=1,
|
page_size=1,
|
||||||
enable_mamba_extra_buffer=True,
|
enable_mamba_extra_buffer=True,
|
||||||
|
tree_components=(ComponentType.FULL, ComponentType.MAMBA),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
return tree, allocator, req_to_token_pool
|
return tree, allocator, req_to_token_pool
|
||||||
@@ -459,7 +453,7 @@ class TestOptimisticPrefillMambaRetryRelease(CustomTestCase):
|
|||||||
req.kv.kv_committed_len = len(self.PROMPT)
|
req.kv.kv_committed_len = len(self.PROMPT)
|
||||||
req.kv.kv_allocated_len = len(self.PROMPT)
|
req.kv.kv_allocated_len = len(self.PROMPT)
|
||||||
req.kv.mamba_last_track_seqlen = self.TRACK_SEQLEN
|
req.kv.mamba_last_track_seqlen = self.TRACK_SEQLEN
|
||||||
req.last_node = tree.root_node
|
req.last_node = tree.root_node_handle()
|
||||||
|
|
||||||
scheduler = SimpleNamespace(
|
scheduler = SimpleNamespace(
|
||||||
tree_cache=tree,
|
tree_cache=tree,
|
||||||
@@ -478,13 +472,15 @@ class TestOptimisticPrefillMambaRetryRelease(CustomTestCase):
|
|||||||
scheduler, req
|
scheduler, req
|
||||||
)
|
)
|
||||||
|
|
||||||
# The donated prefix and exactly one checkpoint stay in the tree; the
|
|
||||||
# old double-donation path either asserts or pins a second state.
|
|
||||||
self.assertEqual(tree.total_size(), (self.TRACK_SEQLEN, 1))
|
self.assertEqual(tree.total_size(), (self.TRACK_SEQLEN, 1))
|
||||||
match = tree.match_prefix(
|
match = tree.match_prefix(
|
||||||
MatchPrefixParams(key=RadixKey(array("q", self.PROMPT)))
|
MatchPrefixParams(key=RadixKey(array("q", self.PROMPT)))
|
||||||
)
|
)
|
||||||
self.assertIsNotNone(match.last_device_node.mamba_value)
|
self.assertIsNotNone(
|
||||||
|
tree.tree_core.get_component_device_value(
|
||||||
|
match.last_device_node, ComponentType.MAMBA
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
# Only the uncached tail and the request-owned Mamba buffers are
|
# Only the uncached tail and the request-owned Mamba buffers are
|
||||||
# freed; the tree keeps the donated checkpoint slot.
|
# freed; the tree keeps the donated checkpoint slot.
|
||||||
|
|||||||
Reference in New Issue
Block a user