test: recover the config-namespace-migration deferrals (#33171)
The module-skipped tests injected config by faking get_server_args (a SimpleNamespace stand-in patched onto the module) or by writing fields onto a ServerArgs instance post-publish — both invisible to the namespace accessors the production code now reads. Re-enable them by publishing the config they need (get_context().override_server_args seeding, scoped per test), asserting bag state where the old assertions checked instance write-through (declare_load_time_override is bag-only), and extending the per-runner stubs the code genuinely reads (kv_cache_dtype_str, max_total_tokens, context_len). The unified-radix-cache file (which grew a large hicache/insert-walk suite while skipped) is recovered in the same change: - test_cache_finished_req_strips_thinking (19 parametrized classes) wrote strip_thinking_cache onto the ServerArgs instance; the cache reads get_serving().strip_thinking_cache — use the serving bag's scoped override. - test_shallower_crossing_backs_up_above_backuped_middle staged its broken-backup-continuity setup through insert_host, which now deliberately drops refills below an un-backed-up node under write-through (host_insert_dropped). Build the same tree state through an explicit backup + device eviction. Every config-namespace-migration deferral is recovered, so the deferral ratchet (test_migration_deferral_ratchet.py) has done its job and is retired.
This commit is contained in:
@@ -15,21 +15,6 @@ from sglang.test.ci.ci_register import register_cpu_ci
|
||||
register_cpu_ci(est_time=5, suite="base-a-test-cpu")
|
||||
|
||||
|
||||
import pytest as _pytest_defer
|
||||
|
||||
_DEFER_REASON = (
|
||||
"Temporarily skipped during the ServerArgs config-namespace migration; "
|
||||
"re-enabled once the runtime-config accessor API stabilizes."
|
||||
)
|
||||
pytestmark = _pytest_defer.mark.skip(reason=_DEFER_REASON)
|
||||
|
||||
|
||||
def setUpModule():
|
||||
import unittest
|
||||
|
||||
raise unittest.SkipTest(_DEFER_REASON)
|
||||
|
||||
|
||||
class _FakeAllocator:
|
||||
def __init__(self, base=1000, page_size=1):
|
||||
self.base = base
|
||||
|
||||
@@ -81,7 +81,7 @@ from sglang.srt.mem_cache.unified_radix_cache import (
|
||||
_OngoingPrefetch,
|
||||
_OngoingWriteThrough,
|
||||
)
|
||||
from sglang.srt.runtime_context import get_server_args
|
||||
from sglang.srt.runtime_context import get_server_args, get_serving
|
||||
from sglang.srt.sampling.sampling_params import SamplingParams
|
||||
from sglang.srt.server_args import (
|
||||
ServerArgs,
|
||||
@@ -95,21 +95,6 @@ register_cuda_ci(est_time=16, stage="base-b", runner_config="1-gpu-small")
|
||||
register_amd_ci(est_time=16, suite="stage-b-test-1-gpu-small-amd")
|
||||
|
||||
|
||||
import pytest as _pytest_defer
|
||||
|
||||
_DEFER_REASON = (
|
||||
"Temporarily skipped during the ServerArgs config-namespace migration; "
|
||||
"re-enabled once the runtime-config accessor API stabilizes."
|
||||
)
|
||||
pytestmark = _pytest_defer.mark.skip(reason=_DEFER_REASON)
|
||||
|
||||
|
||||
def setUpModule():
|
||||
import unittest
|
||||
|
||||
raise unittest.SkipTest(_DEFER_REASON)
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class CacheConfig:
|
||||
# Tree
|
||||
@@ -947,15 +932,13 @@ class UnifiedRadixCacheSuite:
|
||||
req.mamba_last_track_seqlen = kv_len
|
||||
req.reasoning_tokens = 1
|
||||
|
||||
get_server_args().strip_thinking_cache = True
|
||||
try:
|
||||
# cache_finished_req reads get_serving().strip_thinking_cache
|
||||
with get_serving().override(strip_thinking_cache=True):
|
||||
avail_before = allocator.available_size()
|
||||
cache.cache_finished_req(
|
||||
req, is_insert=True, kv_len_to_handle=req.effective_kv_committed_len()
|
||||
)
|
||||
start_p, end_p = req.effective_kv_committed_len(), req.kv.kv_allocated_len
|
||||
finally:
|
||||
get_server_args().strip_thinking_cache = False
|
||||
if ps > 1:
|
||||
start_p = ((start_p + ps - 1) // ps) * ps
|
||||
if start_p < end_p:
|
||||
@@ -5740,19 +5723,17 @@ class TestResumableInsertWalk(_InsertWalkSuite):
|
||||
self._insert(cache, allocator, req_to_token_pool, [1, 2, 3, 4])
|
||||
top = next(iter(cache.root_node.children.values()))
|
||||
|
||||
# A storage-prefetch completion host-inserts a backuped node below the
|
||||
# still-unbacked top, legitimately breaking backup continuity.
|
||||
host_indices = cache.cache_controller.mem_pool_host.alloc(8)
|
||||
host_result = cache.tree_core.insert_host(
|
||||
cache.root_node.id,
|
||||
RadixKey(array("q", list(range(1, 9)))),
|
||||
host_indices,
|
||||
[f"h{i}" for i in range(8)],
|
||||
)
|
||||
cache.cache_controller.mem_pool_host.free(
|
||||
host_indices[: host_result.prefix_len]
|
||||
)
|
||||
# Break backup continuity: a backuped (then device-evicted) middle
|
||||
# below the still-unbacked top. insert_host refills below an
|
||||
# un-backed-up node are dropped under write-through
|
||||
# (host_insert_dropped), so the state is built through an explicit
|
||||
# backup + device eviction.
|
||||
self._insert(cache, allocator, req_to_token_pool, list(range(1, 9)))
|
||||
middle = next(iter(top.children.values()))
|
||||
self.assertGreater(_write_backup(cache, middle, write_back=True), 0)
|
||||
cache.writing_check(write_back=True)
|
||||
cache.evict(EvictParams(num_tokens=4))
|
||||
self.assertTrue(middle.evicted)
|
||||
self.assertTrue(middle.backuped)
|
||||
self.assertFalse(top.backuped)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user