Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions python/sglang/srt/arg_groups/model_override_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,10 +263,13 @@ def mamba_extra_buffer_of(cfg: Any) -> bool:

This is the one definition of the predicate: ``ServerArgs`` delegates its
member to it, and the runtime_context accessor is its post-publish sibling
(which cannot reuse it, because the two leaves land in different bags)."""
return cfg.disable_radix_cache is False and cfg.mamba_radix_cache_strategy in (
"extra_buffer",
"extra_buffer_lazy",
(which cannot reuse it, because the leaves land in different bags).
``uses_mamba_radix_cache`` is arch-derived, so an explicit strategy stays
inert for models without mamba state."""
return (
cfg.disable_radix_cache is False
and cfg.uses_mamba_radix_cache
and cfg.mamba_radix_cache_strategy in ("extra_buffer", "extra_buffer_lazy")
)


Expand Down
4 changes: 4 additions & 0 deletions python/sglang/srt/arg_groups/model_overrides/inkling.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ def _inkling_overrides(server_args: Any, hf_config: Any) -> dict:
# against the unresolved token ("auto") if that day comes.
if cfg.mamba_radix_cache_strategy == ServerArgs.mamba_radix_cache_strategy:
overrides["mamba_radix_cache_strategy"] = "extra_buffer"
# The extra-buffer predicates also require the arch-derived leaf, which the
# generic resolution likewise never sets for Inkling.
if not cfg.disable_radix_cache:
overrides["uses_mamba_radix_cache"] = True

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Allow Inkling through the mamba extra-buffer validator

With radix caching enabled (the normal Inkling configuration), this marker makes the later unconditional handle_mamba_radix_cache() call treat Inkling as a generic mamba-cache architecture and invoke validate_mamba_extra_buffer(). That validator asserts supports_mamba_cache_extra_buffer(view, model_arch), but neither Inkling architecture is in _MAMBA_EXTRA_BUFFER_ARCHS, so default Inkling startup now fails during argument resolution with extra_buffer is not supported for InklingForConditionalGeneration. Either register Inkling as supported by that validator or avoid routing this model-specific marker through the generic validation path.

Useful? React with 👍 / 👎.

# Inkling attention runs only on the fa4 (Blackwell) or triton backends --
# models/inkling_common/attn.py asserts attention_backend in {fa4, triton}.
# The generic resolver would otherwise pick trtllm_mha (SM100) / fa3
Expand Down
1 change: 1 addition & 0 deletions python/sglang/srt/arg_groups/overrides.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,7 @@ def mamba_extra_buffer_lazy_of(cfg: Any) -> bool:
"""The lazy variant of :func:`mamba_extra_buffer_of`."""
return (
cfg.disable_radix_cache is False
and cfg.uses_mamba_radix_cache
and cfg.mamba_radix_cache_strategy == "extra_buffer_lazy"
)

Expand Down
5 changes: 4 additions & 1 deletion python/sglang/srt/runtime_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -1672,13 +1672,15 @@ def reset_context() -> None:
def mamba_extra_buffer_enabled() -> bool:
"""Whether the mamba radix cache keeps its extra state buffer.

A predicate over two published leaves (``memory.disable_radix_cache`` and
A predicate over published leaves (``memory.disable_radix_cache``,
``exec.mamba.uses_mamba_radix_cache``, and
``exec.mamba.mamba_radix_cache_strategy``), so it reads the bags rather
than the startup record — the ``ServerArgs`` member of the same name is the
pre-publish equivalent used inside the resolution pipeline.
"""
return (
get_memory().disable_radix_cache is False
and get_exec().mamba.uses_mamba_radix_cache
and get_exec().mamba.mamba_radix_cache_strategy
in ("extra_buffer", "extra_buffer_lazy")
)
Expand All @@ -1688,6 +1690,7 @@ def mamba_extra_buffer_lazy_enabled() -> bool:
"""The lazy variant of :func:`mamba_extra_buffer_enabled`."""
return (
get_memory().disable_radix_cache is False
and get_exec().mamba.uses_mamba_radix_cache
and get_exec().mamba.mamba_radix_cache_strategy == "extra_buffer_lazy"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1267,7 +1267,8 @@ def fake_release_kv_cache(release_req, tree_cache, is_insert=False):
from sglang.srt.runtime_context import get_context

override = get_context().override_server_args(
mamba_radix_cache_strategy="extra_buffer"
uses_mamba_radix_cache=True,
mamba_radix_cache_strategy="extra_buffer",
)
override.install()
try:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ def process_batch_result(result_batch, batch_result):
# disagg reads are served by the same publish at their
# defaults.
get_context().override_server_args(
uses_mamba_radix_cache=True,
mamba_radix_cache_strategy="extra_buffer",
mamba_track_interval=TRACK_INTERVAL,
_mamba_cache_chunk_size=TRACK_INTERVAL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ def _ratio(*, extra_buffer, lazy, disable_overlap, skip):
with rc.get_context().override_server_args(
disable_radix_cache=False,
disable_overlap_schedule=disable_overlap,
uses_mamba_radix_cache=True,
mamba_radix_cache_strategy=strategy,
):
return KVCacheConfigurator._calculate_mamba_ratio(fake)
Expand Down
37 changes: 22 additions & 15 deletions test/registered/unit/test_runtime_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,7 @@ class _FakeResolvedArgs:
decode_attention_backend: A[str | None, Arg(help="dab"), NS("exec.kernel")] = None
disable_radix_cache: A[bool, Arg(help="drc"), NS("memory")] = False
mamba_radix_cache_strategy: A[str, Arg(help="mrcs"), NS("exec.mamba")] = "auto"
uses_mamba_radix_cache: A[bool, Arg(help="umrc"), NS("exec.mamba")] = False
speculative_algorithm: A[str | None, Arg(help="sa"), NS("spec")] = None
speculative_num_draft_tokens: A[int | None, Arg(help="d"), NS("spec")] = None
speculative_adaptive: A[bool, Arg(help="a"), NS("spec")] = False
Expand Down Expand Up @@ -1157,21 +1158,27 @@ def test_mamba_extra_buffer_matches_the_member(self):
)

for disable_radix_cache in (False, True):
for strategy in self._STRATEGIES:
with self.subTest(radix=disable_radix_cache, strategy=strategy):
args = _FakeResolvedArgs(
disable_radix_cache=disable_radix_cache,
mamba_radix_cache_strategy=strategy,
)
get_context().set_server_args(args)
self.assertEqual(
ServerArgs.enable_mamba_extra_buffer(args),
mamba_extra_buffer_enabled(),
)
self.assertEqual(
ServerArgs.enable_mamba_extra_buffer_lazy(args),
mamba_extra_buffer_lazy_enabled(),
)
for uses_mamba_radix_cache in (False, True):
for strategy in self._STRATEGIES:
with self.subTest(
radix=disable_radix_cache,
uses=uses_mamba_radix_cache,
strategy=strategy,
):
args = _FakeResolvedArgs(
disable_radix_cache=disable_radix_cache,
uses_mamba_radix_cache=uses_mamba_radix_cache,
mamba_radix_cache_strategy=strategy,
)
get_context().set_server_args(args)
self.assertEqual(
ServerArgs.enable_mamba_extra_buffer(args),
mamba_extra_buffer_enabled(),
)
self.assertEqual(
ServerArgs.enable_mamba_extra_buffer_lazy(args),
mamba_extra_buffer_lazy_enabled(),
)

def test_prefill_buffer_ceiling_matches_the_member(self):
from sglang.srt.runtime_context import max_prefill_buffer_tokens
Expand Down
Loading