[Config] Round 6.5: a namespace declares what it derives, next to what it derives it from (#38113)
Fifth of five; stacked on #38049. The split gave every namespace a file, but only for the half an operator types. This is the other half. ## The parallel quotients are declared, not written out `attn_tp_size` and its five siblings were sixty lines of near-identical properties in the runtime context, a file away from the leaves they are quotients of, so reading `parallel.py` told you what you could set and nothing about what that decides. They are declared in `Parallel` now, in the same class as those leaves. They carry no annotation, so they are not dataclass fields and `collect_input_fields` never puts them on the record -- the same mechanism that already keeps `_NS_PATH` off it. That is the right exclusion: a quotient has no operator input to preserve, and the record is what crosses a process boundary, where a stamped width is one an elastic scale-up will not refresh. ## A quotient is a value in the bag, like every other derived one `_derived_width` answered from a stamp or, failing that, a live process group. The group read could never disagree with the stamp: - `initialize_model_parallel` stamps all six as its last statement, unconditionally; - an elastic scale-up restamps `attn_dp_size` through `update_dp_attention_post_scale` -- the comment claiming it does *not* was wrong; - no hardware backend builds groups of its own; - `multimodal_gen`, which has its own `initialize_model_parallel` and does not stamp, never reads a quotient. So a built group was always already stamped, and the group read goes -- and with it the last reason for a quotient to be resolved on every read. Every input to `derive_parallel_widths` is a record field. `dcp_enabled` is `decode_context_parallel_size > 1`, not a fact about a built group; it was spelled `_DCP is not None`, which is a longer way to say the same thing. So the six are fixed once the configuration is fixed -- the same test every other `Derived(fn=...)` in this PR passes. They are declared the same way and computed the same way: once, at publish, into ordinary bag leaves. What remains is override -> stamp -> published leaf. The stamp stays above the leaf because an elastic scale-up restamps `attn_dp_size`; the override stays on top because that is how a test names a width. ## One answer for the config-derived predicates `enable_mamba_extra_buffer` and its lazy variant, `is_ep_joiner`, `is_ep_scale_joiner`, `is_startup_weight_load_overlap`: each existed as a `ServerArgs` member for the resolution pipeline and, for most of them, again as a `runtime_context` function for readers after publish. Three places to keep saying the same thing. A `Derived(fn=...)` is a pure function of the published configuration, so `publish` computes it once and stores it as an ordinary bag leaf -- a plain attribute load, which is what a read inside compiled model code needs. The function is handed the whole resolved config rather than the bag it lands in, because a derivation is free to span namespaces and the mamba one does: it reads `memory.disable_radix_cache` alongside its own `exec.mamba` strategy, which is why it could never have been a method on either bag. The pre-publish helpers stay -- resolution needs the predicate before there is a bag to read -- and three readers keep them, because they run before their own process publishes: `initialize_dp_attention`, which the weight-cache daemon calls while building its groups thirty lines before its `publish`, and `PortArgs.init_new`, a factory handed the record that already reads eighteen other fields off it. ## Notes for a reviewer **Overriding a leaf does not move its quotient.** `override(tp_size=2)` leaves `attn_tp_size` where the published config put it, because nothing is recomputed on read. A test states a topology by publishing a config -- which is what a real process does -- or by naming the width it wants, `override(attn_tp_size=2)`. Six tests say it that way now. This is the price of having one answer computed once, and it is the same price every other derived value in the config already carries. A caller that reads a quotient without publishing or overriding now gets an explicit error naming the field, instead of a default that an uninitialised group happened to supply. One fixture was in that state -- `TestMlaWriteDoorsUnderDcp` built a bare pool and asked whether DCP was on -- and it publishes a config now, which is what the process it stands in for does. Eighteen sites read these predicates without calling them. That is correct -- they are properties -- but it is worth saying they were checked, because a census that assumes otherwise reports eighteen always-true conditions. ## The skill that documents this subsystem is updated with it `.claude/rules/modify-component-must-read.md` points at `.claude/skills/sglang-runtime-context/SKILL.md` before anyone touches these files, so a stale sentence there is a wrong instruction rather than a stale note. Four of its load-bearing statements stopped being true across this series and are corrected here: `NS(...)` is no longer how a field states its namespace (the declaring class is); the DCP degrade rule is gone, because the quotients are not live reads; `mamba_extra_buffer_enabled()` and the other predicate functions it named as the shape to copy no longer exist; and the namespace-coverage ratchet is described in terms of the marker. The docstring of `test_server_args_namespaces.py` said the same thing and is fixed too. The consequence a test author actually trips over is stated there as well: overriding a leaf no longer moves its quotient, so a topology is stated by publishing a config or by naming the width. ## Verification A full registered-unit sweep (648 files) against this stack's merge-base: 19 failures on both sides, the same 19 -- AMD `gfx950`, `modelopt`, `cuda_vmm`, `weight_checker` and friends, none of them config. The narrower 139-file config sweep used earlier in this series does not contain the files this change reaches -- `test_kv_index_translator` never names `get_parallel()`, it constructs an object that does -- which is why the baseline differential over everything is what is quoted here.
This commit is contained in:
@@ -20,7 +20,10 @@ Usage:
|
||||
python -m pytest test/registered/unit/mem_cache/test_decode_radix_lock_ref.py -v
|
||||
"""
|
||||
|
||||
from sglang.srt.runtime_context import get_context, publish, reset_context
|
||||
from sglang.srt.server_args import ServerArgs
|
||||
from sglang.test.ci.ci_register import register_cpu_ci
|
||||
from sglang.test.test_utils import enter_override
|
||||
|
||||
register_cpu_ci(est_time=11, suite="base-a-test-cpu")
|
||||
|
||||
@@ -97,14 +100,26 @@ def _make_req(fill_ids, req_pool_idx=0, cache_protected_len=0, last_node=None):
|
||||
|
||||
|
||||
class TestDecodeLockRefScenarios(unittest.TestCase):
|
||||
def setUp(self):
|
||||
# The decode queue reads its config from the bags.
|
||||
reset_context()
|
||||
self.addCleanup(reset_context)
|
||||
publish(ServerArgs(model_path="dummy"), role="scheduler")
|
||||
|
||||
"""Test lock_ref balance across decode transfer scenarios."""
|
||||
|
||||
def test_swa_tail_len_keeps_page_aligned_matchable_window(self):
|
||||
enter_override(
|
||||
self,
|
||||
get_context().override_server_args(
|
||||
disaggregation_decode_enable_radix_cache=True
|
||||
),
|
||||
)
|
||||
queue = DecodePreallocQueue.__new__(DecodePreallocQueue)
|
||||
queue._uses_swa_tail_prealloc = MagicMock(return_value=True)
|
||||
queue.scheduler = SimpleNamespace(
|
||||
sliding_window_size=127,
|
||||
server_args=SimpleNamespace(disaggregation_decode_enable_radix_cache=True),
|
||||
server_args=SimpleNamespace(),
|
||||
)
|
||||
queue.token_to_kv_pool_allocator = MagicMock(page_size=64)
|
||||
|
||||
@@ -420,7 +435,12 @@ class TestDecodeLockRefScenarios(unittest.TestCase):
|
||||
running_batch = MagicMock()
|
||||
running_batch.reqs = []
|
||||
server_args = MagicMock()
|
||||
server_args.disaggregation_decode_enable_radix_cache = True
|
||||
enter_override(
|
||||
self,
|
||||
get_context().override_server_args(
|
||||
disaggregation_decode_enable_radix_cache=True
|
||||
),
|
||||
)
|
||||
scheduler = MagicMock()
|
||||
scheduler.running_batch = running_batch
|
||||
scheduler.server_args = server_args
|
||||
|
||||
@@ -280,6 +280,17 @@ class TestMlaWriteDoorsUnderDcp(unittest.TestCase):
|
||||
already collapsed -- so there is no single correct translation and refusing
|
||||
is the contract."""
|
||||
|
||||
def setUp(self):
|
||||
# `set_kv_buffer` asks the parallel context whether DCP is in play, and
|
||||
# that is a value the configuration decides at publish -- so a case
|
||||
# here states its topology the way a process does, by publishing one.
|
||||
from sglang.srt.runtime_context import publish, reset_context
|
||||
from sglang.srt.server_args import ServerArgs
|
||||
|
||||
reset_context()
|
||||
self.addCleanup(reset_context)
|
||||
publish(ServerArgs(model_path="dummy"), role="test")
|
||||
|
||||
def _bare_mla_pool(self):
|
||||
from sglang.srt.mem_cache.memory_pool import MLATokenToKVPool
|
||||
|
||||
|
||||
@@ -17,6 +17,8 @@ CPU-only: these exercise the builder's pure-torch reference path, not the
|
||||
Triton kernel.
|
||||
"""
|
||||
|
||||
from sglang.srt.runtime_context import publish, reset_context
|
||||
from sglang.srt.server_args import ServerArgs
|
||||
from sglang.test.ci.ci_register import register_cpu_ci
|
||||
|
||||
register_cpu_ci(est_time=10, suite="base-a-test-cpu")
|
||||
@@ -115,6 +117,12 @@ def _reference_table(req_to_token, req_pool_indices, seq_lens, v2p, mult, ps, wi
|
||||
|
||||
|
||||
class TestPassthrough(unittest.TestCase):
|
||||
def setUp(self):
|
||||
# The code under test reads its config from the bags.
|
||||
reset_context()
|
||||
self.addCleanup(reset_context)
|
||||
publish(ServerArgs(model_path="dummy"), role="tokenizer")
|
||||
|
||||
def test_non_unified_returns_same_objects(self):
|
||||
"""Strict passthrough: no copy, no branch. Any tensor op on the
|
||||
non-unified path breaks byte-identity for every static-pool server."""
|
||||
@@ -160,6 +168,12 @@ def _alloc_and_fill(allocator, ps, lens):
|
||||
|
||||
|
||||
class TestReadTableBuild(unittest.TestCase):
|
||||
def setUp(self):
|
||||
# The code under test reads its config from the bags.
|
||||
reset_context()
|
||||
self.addCleanup(reset_context)
|
||||
publish(ServerArgs(model_path="dummy"), role="tokenizer")
|
||||
|
||||
def test_read_table_matches_reference_across_multipliers(self):
|
||||
"""Both read tables must equal the independent per-element derivation,
|
||||
across page sizes and both multiplier regimes (MLA=1, MHA=2L); the swa
|
||||
@@ -274,6 +288,12 @@ class TestBuildInto(unittest.TestCase):
|
||||
FULL-side read-table entries -- the trtllm_mla / flashmla consumption route
|
||||
(their rows ARE the read table's rows)."""
|
||||
|
||||
def setUp(self):
|
||||
# The code under test reads its config from the bags.
|
||||
reset_context()
|
||||
self.addCleanup(reset_context)
|
||||
publish(ServerArgs(model_path="dummy"), role="tokenizer")
|
||||
|
||||
def test_prefix_filled_tail_sentinel_preserved_width_capped(self):
|
||||
"""The -1 tail sentinel belongs to the backend, and a table padded
|
||||
WIDER than the req_to_token page span (trtllm's LCM alignment) must be
|
||||
@@ -339,6 +359,12 @@ class TestPoolOwnership(unittest.TestCase):
|
||||
to address a buffer with only num_slots rows.
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
# The code under test reads its config from the bags.
|
||||
reset_context()
|
||||
self.addCleanup(reset_context)
|
||||
publish(ServerArgs(model_path="dummy"), role="tokenizer")
|
||||
|
||||
def test_real_factory_bundle_satisfies_the_ownership_identity(self):
|
||||
"""The guard rests on `allocator.get_kvcache() is token_to_kv_pool`, so
|
||||
a factory returning a pool the allocator does not hold would silently
|
||||
@@ -420,6 +446,12 @@ class TestPoolOwnership(unittest.TestCase):
|
||||
|
||||
|
||||
class TestCaptureContract(unittest.TestCase):
|
||||
def setUp(self):
|
||||
# The code under test reads its config from the bags.
|
||||
reset_context()
|
||||
self.addCleanup(reset_context)
|
||||
publish(ServerArgs(model_path="dummy"), role="tokenizer")
|
||||
|
||||
def test_caller_owned_table_is_returned_whole_and_filled_prefix_only(self):
|
||||
ps = 4
|
||||
allocator = _build_composite(ps)
|
||||
@@ -503,6 +535,12 @@ class TestViewMemo(unittest.TestCase):
|
||||
identity, so per-batch state stays out of the ForwardBatch while one
|
||||
metadata build's many consumers still share one table build."""
|
||||
|
||||
def setUp(self):
|
||||
# The code under test reads its config from the bags.
|
||||
reset_context()
|
||||
self.addCleanup(reset_context)
|
||||
publish(ServerArgs(model_path="dummy"), role="tokenizer")
|
||||
|
||||
def _fb(self, allocator, ps, lens):
|
||||
req_to_token, rows, seq_lens = _alloc_and_fill(allocator, ps, lens=lens)
|
||||
fb = _FakeForwardBatch(
|
||||
@@ -562,6 +600,12 @@ class TestWriteLoc(unittest.TestCase):
|
||||
POINTWISE from the full-side values -- pads, slices, and fresh copies
|
||||
included -- with no handover and no stored per-forward state."""
|
||||
|
||||
def setUp(self):
|
||||
# The code under test reads its config from the bags.
|
||||
reset_context()
|
||||
self.addCleanup(reset_context)
|
||||
publish(ServerArgs(model_path="dummy"), role="tokenizer")
|
||||
|
||||
def _built(self, ps=1, n=4):
|
||||
allocator = _build_composite(ps)
|
||||
req_to_token, rows, seq_lens = _alloc_and_fill(allocator, ps, lens=[max(n, 1)])
|
||||
|
||||
@@ -44,7 +44,8 @@ from sglang.srt.mem_cache.unified_memory_pool import (
|
||||
MLASubPoolSpec,
|
||||
UnifiedKVPool,
|
||||
)
|
||||
from sglang.srt.runtime_context import get_parallel
|
||||
from sglang.srt.runtime_context import get_parallel, publish, reset_context
|
||||
from sglang.srt.server_args import ServerArgs
|
||||
|
||||
_DEV = "cpu"
|
||||
|
||||
@@ -103,6 +104,12 @@ class _RejectScalarIndexTensor:
|
||||
|
||||
|
||||
class TestUnifiedKVPoolViews(unittest.TestCase):
|
||||
def setUp(self):
|
||||
# The code under test reads its config from the bags.
|
||||
reset_context()
|
||||
self.addCleanup(reset_context)
|
||||
publish(ServerArgs(model_path="dummy"), role="tokenizer")
|
||||
|
||||
def test_min_slot_index_and_disjoint_bytes(self):
|
||||
full = _make_mha_spec("full", "up", layer_num=4)
|
||||
mamba = _make_mamba_spec("mamba", "down", layer_num=2)
|
||||
@@ -173,6 +180,12 @@ class TestUnifiedKVPoolViews(unittest.TestCase):
|
||||
|
||||
|
||||
class TestMultiEndedAllocator(unittest.TestCase):
|
||||
def setUp(self):
|
||||
# The code under test reads its config from the bags.
|
||||
reset_context()
|
||||
self.addCleanup(reset_context)
|
||||
publish(ServerArgs(model_path="dummy"), role="tokenizer")
|
||||
|
||||
def _build_pair(self, n_full_slots=64, n_mamba_slots=16):
|
||||
full = _make_mha_spec("full", "up", layer_num=2)
|
||||
mamba = _make_mamba_spec("mamba", "down", layer_num=2)
|
||||
@@ -526,6 +539,12 @@ class TestUnifiedSWATokenToKVPoolAllocator(unittest.TestCase):
|
||||
"""The SWA composite: joint byte-budget, slot-conservation, `free_swa`
|
||||
tombstone semantics, and divergent compaction of the two sub-pools."""
|
||||
|
||||
def setUp(self):
|
||||
# The code under test reads its config from the bags.
|
||||
reset_context()
|
||||
self.addCleanup(reset_context)
|
||||
publish(ServerArgs(model_path="dummy"), role="tokenizer")
|
||||
|
||||
def _build(
|
||||
self,
|
||||
n_full_slots=32,
|
||||
@@ -891,6 +910,12 @@ class TestPagedMultiEndedAllocator(unittest.TestCase):
|
||||
"""`MultiEndedAllocator(page_size=8)`: free-list, v2p/p2v and compaction are
|
||||
page-granular, while the external API stays in token ids as at page_size 1."""
|
||||
|
||||
def setUp(self):
|
||||
# The code under test reads its config from the bags.
|
||||
reset_context()
|
||||
self.addCleanup(reset_context)
|
||||
publish(ServerArgs(model_path="dummy"), role="tokenizer")
|
||||
|
||||
PAGE_SIZE = 8
|
||||
|
||||
def _build(self, n_full_pages=16, n_swa_pages=8, full_layer_num=2, swa_layer_num=2):
|
||||
@@ -1693,6 +1718,12 @@ class TestLazyCompaction(unittest.TestCase):
|
||||
`_flush` only waits on `forward_stream` when one is passed, so these
|
||||
allocators stay CPU-only."""
|
||||
|
||||
def setUp(self):
|
||||
# The code under test reads its config from the bags.
|
||||
reset_context()
|
||||
self.addCleanup(reset_context)
|
||||
publish(ServerArgs(model_path="dummy"), role="tokenizer")
|
||||
|
||||
def _make_full(self, *, lazy: bool, n_full_slots=64, n_mamba_slots=16):
|
||||
full = _make_mha_spec("full", "up", layer_num=2)
|
||||
mamba = _make_mamba_spec("mamba", "down", layer_num=2)
|
||||
@@ -1969,6 +2000,12 @@ class TestO3FusedAllocBind(unittest.TestCase):
|
||||
"""Fused take_physical_pages + bind_pages via `_alloc_bind_fast_or_slow`.
|
||||
GPU-only: the fused kernel is Triton."""
|
||||
|
||||
def setUp(self):
|
||||
# The code under test reads its config from the bags.
|
||||
reset_context()
|
||||
self.addCleanup(reset_context)
|
||||
publish(ServerArgs(model_path="dummy"), role="tokenizer")
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
if not torch.cuda.is_available():
|
||||
@@ -2218,6 +2255,12 @@ class TestSWACompositeKernelIdSurface(unittest.TestCase):
|
||||
`translate_kv_loc_for_kernel` / `full_v2p_page_table`, and every id must
|
||||
follow `kernel_id(t) = v2p[t // ps] * (ps * mult) + t % ps`."""
|
||||
|
||||
def setUp(self):
|
||||
# The code under test reads its config from the bags.
|
||||
reset_context()
|
||||
self.addCleanup(reset_context)
|
||||
publish(ServerArgs(model_path="dummy"), role="tokenizer")
|
||||
|
||||
PS = 4
|
||||
FULL_L = 4
|
||||
SWA_L = 2
|
||||
@@ -2328,6 +2371,12 @@ class TestPs64MLACompositeFeasibility(unittest.TestCase):
|
||||
pages stress the sink-page floor, the per-layer-view tail pad and the
|
||||
page-granular alloc at once."""
|
||||
|
||||
def setUp(self):
|
||||
# The code under test reads its config from the bags.
|
||||
reset_context()
|
||||
self.addCleanup(reset_context)
|
||||
publish(ServerArgs(model_path="dummy"), role="tokenizer")
|
||||
|
||||
PS = 64
|
||||
LAYERS = 3
|
||||
|
||||
@@ -2424,6 +2473,12 @@ class TestChainFrontierWalk(unittest.TestCase):
|
||||
"""N-pool chain walk: 2-pool byte-identity with the single-peer formulas,
|
||||
transparent-middle skipping, and growth-side-neighbor credit routing."""
|
||||
|
||||
def setUp(self):
|
||||
# The code under test reads its config from the bags.
|
||||
reset_context()
|
||||
self.addCleanup(reset_context)
|
||||
publish(ServerArgs(model_path="dummy"), role="tokenizer")
|
||||
|
||||
def _build_pair(self):
|
||||
full = _make_mha_spec("full", "up", layer_num=2)
|
||||
mamba = _make_mamba_spec("mamba", "down", layer_num=2)
|
||||
@@ -2552,6 +2607,12 @@ class TestFloatMultiEndedAllocator(unittest.TestCase):
|
||||
larger-gap extension, boundary absorption with park-on-empty transparency,
|
||||
and the on-demand movers `make_room` and `compact_holes`."""
|
||||
|
||||
def setUp(self):
|
||||
# The code under test reads its config from the bags.
|
||||
reset_context()
|
||||
self.addCleanup(reset_context)
|
||||
publish(ServerArgs(model_path="dummy"), role="tokenizer")
|
||||
|
||||
def _build_tri(self, n_state=8, n_float=32, n_full=32):
|
||||
state = _make_mamba_spec("state", "up", layer_num=2)
|
||||
fl = _make_mha_spec("swa", "float", layer_num=2)
|
||||
@@ -2844,6 +2905,12 @@ class TestDcpWidening(unittest.TestCase):
|
||||
"""`dcp_size > 1`: the alloc surface speaks a widened virtual id space while
|
||||
the pool keeps storing one row per `dcp_size` logical ids."""
|
||||
|
||||
def setUp(self):
|
||||
# The code under test reads its config from the bags.
|
||||
reset_context()
|
||||
self.addCleanup(reset_context)
|
||||
publish(ServerArgs(model_path="dummy"), role="tokenizer")
|
||||
|
||||
@contextlib.contextmanager
|
||||
def _dcp(self, dcp_size, dcp_rank=0):
|
||||
"""The width comes from the parallel context, not a constructor
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
"""Unit tests for the radix-cache registry, routing, and selection chain."""
|
||||
|
||||
from sglang.srt.runtime_context import get_context
|
||||
from sglang.test.ci.ci_register import register_cpu_ci
|
||||
|
||||
register_cpu_ci(est_time=11, suite="base-a-test-cpu")
|
||||
@@ -16,7 +17,7 @@ from sglang.srt.mem_cache.registry import (
|
||||
register_radix_cache_backend,
|
||||
registered_radix_cache_backends,
|
||||
)
|
||||
from sglang.test.test_utils import CustomTestCase
|
||||
from sglang.test.test_utils import CustomTestCase, enter_override
|
||||
|
||||
|
||||
def _publish(testcase, **fields):
|
||||
@@ -340,14 +341,14 @@ class TestDefaultRadixCacheFactory(CustomTestCase):
|
||||
from sglang.srt.mem_cache.storage.umbp import umbp_direct_linker
|
||||
|
||||
ctx = _make_ctx(self)
|
||||
object.__setattr__(
|
||||
ctx.server_args, "enable_unified_cache_external_linker", True
|
||||
# The factory reads the linker settings from the bags.
|
||||
enter_override(
|
||||
self,
|
||||
get_context().override_server_args(
|
||||
enable_unified_cache_external_linker=True,
|
||||
unified_cache_external_linker_backend="mori",
|
||||
),
|
||||
)
|
||||
object.__setattr__(
|
||||
ctx.server_args, "unified_cache_external_linker_backend", "mori"
|
||||
)
|
||||
self.assertTrue(ctx.server_args.enable_unified_cache_external_linker)
|
||||
self.assertEqual(ctx.server_args.unified_cache_external_linker_backend, "mori")
|
||||
fake_components = MagicMock()
|
||||
fake_components.ComponentType.FULL = "full"
|
||||
fake_radix = MagicMock()
|
||||
|
||||
@@ -32,6 +32,8 @@ from test_multi_ended_allocator import (
|
||||
)
|
||||
|
||||
from sglang.srt.mem_cache.allocator import unified_sub_pool as mea
|
||||
from sglang.srt.runtime_context import publish, reset_context
|
||||
from sglang.srt.server_args import ServerArgs
|
||||
from sglang.test.ci.ci_register import register_cpu_ci
|
||||
|
||||
register_cpu_ci(est_time=10, suite="base-a-test-cpu")
|
||||
@@ -51,6 +53,12 @@ def _paged_pair(lazy: bool):
|
||||
|
||||
|
||||
class TestHealthyLifecycleReportsClean(unittest.TestCase):
|
||||
def setUp(self):
|
||||
# The code under test reads its config from the bags.
|
||||
reset_context()
|
||||
self.addCleanup(reset_context)
|
||||
publish(ServerArgs(model_path="dummy"), role="tokenizer")
|
||||
|
||||
def test_lazy_end_pool_clean_through_free_and_flush(self):
|
||||
full, _swa = _paged_pair(lazy=True)
|
||||
self.assertEqual(full._byte_accounting_violations(), [])
|
||||
@@ -68,6 +76,12 @@ class TestDriftReportsLoudly(unittest.TestCase):
|
||||
passes every other test -- the pool still 'works', it just lies about
|
||||
capacity."""
|
||||
|
||||
def setUp(self):
|
||||
# The code under test reads its config from the bags.
|
||||
reset_context()
|
||||
self.addCleanup(reset_context)
|
||||
publish(ServerArgs(model_path="dummy"), role="tokenizer")
|
||||
|
||||
def _lazy_full(self):
|
||||
full, _swa = _paged_pair(lazy=True)
|
||||
v = full.alloc(full.page_size * 4)
|
||||
@@ -112,6 +126,12 @@ class TestDriftReportsLoudly(unittest.TestCase):
|
||||
|
||||
|
||||
class TestChainFrontierOrder(unittest.TestCase):
|
||||
def setUp(self):
|
||||
# The code under test reads its config from the bags.
|
||||
reset_context()
|
||||
self.addCleanup(reset_context)
|
||||
publish(ServerArgs(model_path="dummy"), role="tokenizer")
|
||||
|
||||
def test_overlapping_frontiers_report(self):
|
||||
"""Both bands hold pages, then the up member's watermark is pushed
|
||||
past the down member's LIVE low frontier. Both sides must be populated
|
||||
|
||||
@@ -367,6 +367,18 @@ class TestUnifiedMHATokenToKVPool(unittest.TestCase):
|
||||
|
||||
|
||||
class TestFactoryViews(unittest.TestCase):
|
||||
def setUp(self):
|
||||
# `KVIndexTranslator.__init__` asks the parallel context for
|
||||
# `attn_dcp_size`, which is a quotient of the configured leaves and is
|
||||
# computed at publish. A bare process has none, so state one the way a
|
||||
# real process does.
|
||||
from sglang.srt.runtime_context import publish, reset_context
|
||||
from sglang.srt.server_args import ServerArgs
|
||||
|
||||
reset_context()
|
||||
self.addCleanup(reset_context)
|
||||
publish(ServerArgs(model_path="dummy"), role="test")
|
||||
|
||||
"""Over the real SWA factory: matching kernel-facing multipliers in the
|
||||
composite allocator, and a rebind that emits both write locs."""
|
||||
|
||||
|
||||
@@ -26,6 +26,8 @@ import unittest
|
||||
|
||||
import torch
|
||||
|
||||
from sglang.srt.runtime_context import publish, reset_context
|
||||
from sglang.srt.server_args import ServerArgs
|
||||
from sglang.test.ci.ci_register import register_cuda_ci
|
||||
|
||||
register_cuda_ci(est_time=10, stage="base-b", runner_config="1-gpu-small")
|
||||
@@ -107,6 +109,12 @@ def _rand_locs(max_tokens: int, ps: int, n: int) -> torch.Tensor:
|
||||
|
||||
@unittest.skipUnless(_HAS_CUDA, "requires CUDA")
|
||||
class TestUnifiedMLAPoolGPUParity(unittest.TestCase):
|
||||
def setUp(self):
|
||||
# The code under test reads its config from the bags.
|
||||
reset_context()
|
||||
self.addCleanup(reset_context)
|
||||
publish(ServerArgs(model_path="dummy"), role="tokenizer")
|
||||
|
||||
def _assert_parity(self, unified, ref, locs, ps, layers=range(_L)):
|
||||
for l in layers:
|
||||
got = unified.get_key_buffer(l)[_kernel_id(locs, ps)]
|
||||
|
||||
Reference in New Issue
Block a user