Skip to content

armgit / sie

Public Imported from GitHub
0

Open-source inference server and production cluster for all the models your agent needs.

feat(server): move the CUDA 13 SGLang bundle to 0.5.20 for glm5_next (#320)

Krisztian Gajdarac2358c7ed99
diff --git a/packages/sie_server/bundles/sglang-cu130.yaml b/packages/sie_server/bundles/sglang-cu130.yaml
index 0f4fa3937..c6d11ee41 100644
--- a/packages/sie_server/bundles/sglang-cu130.yaml
+++ b/packages/sie_server/bundles/sglang-cu130.yaml
@@ -2,8 +2,8 @@ name: sglang-cu130
priority: 20
default: false
# GPU platform this bundle targets — selects packages/sie_server/Dockerfile.cuda13
-# and tags images ``cuda13-sglang-cu130`` (not ``cuda12-*``). Gemma 4 needs sglang
-# 0.5.13 / torch 2.11 cu130 on a CUDA 13 devel runtime (see below). Read by the
+# and tags images ``cuda13-sglang-cu130`` (not ``cuda12-*``). The pinned engine
+# needs torch cu130 on a CUDA 13 devel runtime (see below). Read by the
# image build. Bundles without this field default to ``cuda12``.
platform: cuda13
# General CUDA 13 / cu130 SGLang worker image, introduced for Google Gemma 4
@@ -26,13 +26,31 @@ platform: cuda13
# JIT kernel (jit_kernel/csrc/elementwise/activation.cuh) fails to compile
# under strict nvcc — "select_kernel ... expected a type, got
# ActivationKind::kSiLU" — confirmed broken on BOTH CUDA 12.9 and 13.0. 0.5.13
-# fixes it. Both 0.5.11 and 0.5.13 require torch 2.11 (the torch 2.9->2.11 bump
-# landed at 0.5.11, not 0.5.12), so there is no torch-2.9 path to Gemma 4 —
-# this bundle's image carries torch 2.11 (cu130) on a CUDA 13 base — built by
+# fixed it, and this bundle pinned 0.5.13 until the move to 0.5.20 below.
+#
+# Now pinned to 0.5.20, which is the first release carrying the ``glm5_next``
+# model (python/sglang/srt/models/glm5_next.py, EntryClass
+# ``Glm5NextForConditionalGeneration``). 0.5.13 has no such module, so the
+# architecture cannot load on it at any width. 0.5.20 moves its own exact pins
+# with it: torch 2.11 -> 2.13 (cu130 wheels exist for both), transformers
+# 5.8.1 -> 5.12.1, flashinfer-python 0.6.12 -> 0.6.18, sgl-deep-gemm
+# 0.1.2 -> 0.2.0, sglang-kernel 0.4.3 -> 0.4.7, apache-tvm-ffi 0.1.9 -> 0.1.11,
+# and it adds humming-kernels and quack-kernels. xgrammar stays at 0.2.1.
+# Those versions are sglang's own ``==`` pins, not choices made here.
+#
+# 0.5.20 also renames launch flags SIE uses. ``--mamba-scheduler-strategy`` is
+# now ``--mamba-radix-cache-strategy``; ``--cuda-graph-max-bs`` is split into
+# ``--cuda-graph-max-bs-decode`` and ``--cuda-graph-max-bs-prefill``; and
+# ``--disable-piecewise-cuda-graph`` is gone, the prefill-phase graph it turned
+# off now controlled by ``--disable-prefill-cuda-graph``. The adapters routed
+# here and the profiles that use them carry the new names. The ``sglang``
+# bundle's engine keeps the old ones.
+#
+# The bundle's image carries torch (cu130) on a CUDA 13 base — built by
# the dedicated ``cuda13`` platform (packages/sie_server/Dockerfile.cuda13),
# selected via the ``platform: cuda13`` field above. The shared base venv still
-# ships torch 2.9.1, so the cu130 image carries two torches (~+3 GB); slimming
-# torch out of sie-server core would remove that (tracked follow-up in #1415).
+# ships its own torch, so the cu130 image carries two torches (~+3 GB); slimming
+# torch out of sie-server core would remove that.
#
# Distinct thin adapter modules scope routing here because bundle compatibility
# keys on module paths. Gemma models use `...sglang.gemma`; Qwen profiles that
@@ -43,28 +61,27 @@ adapters:
- sie_server.adapters.sglang.gemma
- sie_server.adapters.sglang.cuda13
deps:
- # sglang 0.5.13 = the validated Gemma 4 engine (0.5.11 has the activation.cuh
- # JIT bug above). Verified transitive resolution on the Modal L4 cu130 image:
- # torch==2.11.0 (cu130), transformers==5.8.1, kernels==0.14.1,
- # sgl-deep-gemm==0.1.2, sglang-kernel==0.4.3, and
- # flashinfer-python==0.6.12 (the exact SGLang 0.5.13 closure).
+ # sglang 0.5.20 (see the VERSION NOTE above). Verified transitive resolution
+ # on the Modal cu130 image:
+ # torch==2.13.0 (cu130), transformers==5.12.1, kernels==0.14.1,
+ # sgl-deep-gemm==0.2.0, sglang-kernel==0.4.7, and
+ # flashinfer-python==0.6.18 (the exact SGLang 0.5.20 closure).
# These resolve from the cu130 wheel indexes at build/serve time
# (download.pytorch.org/whl/cu130 + https://docs.sglang.ai/whl/cu130/),
# supplied by the build (Dockerfile.cuda13 / Modal image). torch,
- # transformers, and kernels are intentionally NOT re-pinned here — sglang
- # 0.5.13's own exact pins drive them. (Pinning kernels<0.13 makes the resolve
- # unsatisfiable: 0.5.13 requires kernels>=0.14.1,<0.15. sglang declares a
- # bare unpinned `kernels`, so without 0.5.13's transitive pin uv would grab
- # the latest, which breaks sglang's import — let sglang constrain it.)
- sglang: '==0.5.13'
+ # transformers, and kernels are intentionally NOT re-pinned here — sglang's
+ # own exact pins drive them. (sglang declares a bare unpinned `kernels`, so
+ # without its transitive pin uv would grab the latest, which breaks sglang's
+ # import — let sglang constrain it.)
+ sglang: '==0.5.20'
# Structured-output backend the Gemma model configs select
# (tasks.generate ... grammar_backend: xgrammar). Pinned to the version
- # sglang 0.5.13 resolves, to prevent silent drift (mirrors the sglang
- # bundle's rationale). NOTE: 0.5.13 uses xgrammar 0.2.x, not the 0.1.32 the
- # sglang bundle pins for the older engine.
+ # sglang 0.5.20 resolves, to prevent silent drift (mirrors the sglang
+ # bundle's rationale). NOTE: this engine uses xgrammar 0.2.x, not the 0.1.32
+ # the sglang bundle pins for the older engine.
xgrammar: '==0.2.1'
# XGrammar 0.2.1 imports ``tvm_ffi`` while its package metadata leaves the
- # dependency open at >=0.1.9. SGLang 0.5.13 pins apache-tvm-ffi==0.1.9
+ # dependency open at >=0.1.9. SGLang 0.5.20 pins apache-tvm-ffi==0.1.11
# exactly, so declare the same version explicitly: this keeps the import in
# the image and lets the bundle resolve as one compatible dependency set.
- apache-tvm-ffi: '==0.1.9'
+ apache-tvm-ffi: '==0.1.11'
diff --git a/packages/sie_server/models/Qwen__Qwen3.6-27B.yaml b/packages/sie_server/models/Qwen__Qwen3.6-27B.yaml
index 71063a9d1..d10240287 100644
--- a/packages/sie_server/models/Qwen__Qwen3.6-27B.yaml
+++ b/packages/sie_server/models/Qwen__Qwen3.6-27B.yaml
@@ -337,7 +337,7 @@ profiles:
- '{"image":{"min_pixels":65536,"max_pixels":1003520}}'
- "--quantization"
- "fp8"
- - "--mamba-scheduler-strategy"
+ - "--mamba-radix-cache-strategy"
- "extra_buffer"
- "--page-size"
- "64"
@@ -373,7 +373,7 @@ profiles:
- '{"image":{"min_pixels":65536,"max_pixels":1003520}}'
- "--quantization"
- "fp8"
- - "--mamba-scheduler-strategy"
+ - "--mamba-radix-cache-strategy"
- "extra_buffer"
- "--page-size"
- "64"
@@ -410,7 +410,7 @@ profiles:
- '{"image":{"min_pixels":65536,"max_pixels":1003520}}'
- "--quantization"
- "fp8"
- - "--mamba-scheduler-strategy"
+ - "--mamba-radix-cache-strategy"
- "extra_buffer"
- "--page-size"
- "64"
diff --git a/packages/sie_server/models/Qwen__Qwen3.8-27B-FP8.yaml b/packages/sie_server/models/Qwen__Qwen3.8-27B-FP8.yaml
index 9a62f1bc1..4801c454f 100644
--- a/packages/sie_server/models/Qwen__Qwen3.8-27B-FP8.yaml
+++ b/packages/sie_server/models/Qwen__Qwen3.8-27B-FP8.yaml
@@ -122,7 +122,7 @@ profiles:
- "bfloat16"
- "--mamba-ssm-dtype"
- "bfloat16"
- - "--mamba-scheduler-strategy"
+ - "--mamba-radix-cache-strategy"
- "extra_buffer"
- "--disable-overlap-schedule"
- "--page-size"
@@ -133,7 +133,7 @@ profiles:
- "32768"
- "--max-running-requests"
- "1"
- - "--cuda-graph-max-bs"
+ - "--cuda-graph-max-bs-decode"
- "1"
runtime:
first_chunk_timeout_s: 900
@@ -167,7 +167,7 @@ profiles:
- "bfloat16"
- "--mamba-ssm-dtype"
- "bfloat16"
- - "--mamba-scheduler-strategy"
+ - "--mamba-radix-cache-strategy"
- "extra_buffer"
- "--disable-overlap-schedule"
- "--page-size"
@@ -178,7 +178,7 @@ profiles:
- "32768"
- "--max-running-requests"
- "1"
- - "--cuda-graph-max-bs"
+ - "--cuda-graph-max-bs-decode"
- "1"
# H200-141GB: deliberately retain the measured H100 SM90 recipe and
@@ -214,7 +214,7 @@ profiles:
- "bfloat16"
- "--mamba-ssm-dtype"
- "bfloat16"
- - "--mamba-scheduler-strategy"
+ - "--mamba-radix-cache-strategy"
- "extra_buffer"
- "--disable-overlap-schedule"
- "--page-size"
@@ -225,7 +225,7 @@ profiles:
- "32768"
- "--max-running-requests"
- "1"
- - "--cuda-graph-max-bs"
+ - "--cuda-graph-max-bs-decode"
- "1"
runtime:
first_chunk_timeout_s: 900
@@ -259,7 +259,7 @@ profiles:
- "bfloat16"
- "--mamba-ssm-dtype"
- "bfloat16"
- - "--mamba-scheduler-strategy"
+ - "--mamba-radix-cache-strategy"
- "extra_buffer"
- "--disable-overlap-schedule"
- "--page-size"
@@ -270,7 +270,7 @@ profiles:
- "32768"
- "--max-running-requests"
- "1"
- - "--cuda-graph-max-bs"
+ - "--cuda-graph-max-bs-decode"
- "1"
# RTX PRO 6000 96GB (SM120): retain FlashInfer and 2K prefill chunks from the
@@ -308,7 +308,7 @@ profiles:
- "bfloat16"
- "--mamba-ssm-dtype"
- "bfloat16"
- - "--mamba-scheduler-strategy"
+ - "--mamba-radix-cache-strategy"
- "extra_buffer"
- "--disable-overlap-schedule"
- "--page-size"
@@ -317,7 +317,7 @@ profiles:
- "2048"
- "--max-running-requests"
- "1"
- - "--cuda-graph-max-bs"
+ - "--cuda-graph-max-bs-decode"
- "1"
runtime:
first_chunk_timeout_s: 900
@@ -351,7 +351,7 @@ profiles:
- "bfloat16"
- "--mamba-ssm-dtype"
- "bfloat16"
- - "--mamba-scheduler-strategy"
+ - "--mamba-radix-cache-strategy"
- "extra_buffer"
- "--disable-overlap-schedule"
- "--page-size"
@@ -360,5 +360,5 @@ profiles:
- "2048"
- "--max-running-requests"
- "1"
- - "--cuda-graph-max-bs"
+ - "--cuda-graph-max-bs-decode"
- "1"
diff --git a/packages/sie_server/src/sie_server/adapters/sglang/cuda13.py b/packages/sie_server/src/sie_server/adapters/sglang/cuda13.py
index 2f41a0bcd..5ac59b2ce 100644
--- a/packages/sie_server/src/sie_server/adapters/sglang/cuda13.py
+++ b/packages/sie_server/src/sie_server/adapters/sglang/cuda13.py
@@ -6,11 +6,18 @@ from sie_server.adapters.sglang.generation import SGLangGenerationAdapter
class SGLangCuda13Adapter(SGLangGenerationAdapter):
"""Route generic generation through the CUDA 13 SGLang bundle."""
+ _PREFILL_GRAPH_OFF_FLAG = "--disable-prefill-cuda-graph"
+ _MAMBA_STRATEGY_FLAG = "--mamba-radix-cache-strategy"
+ # SGLang 0.5.13 never captured a prefill graph for a multimodal model, and
+ # every profile routed here was sized under that engine. 0.5.20 captures
+ # one by default, which needs memory those profiles do not leave free.
+ _PREFILL_GRAPH_OFF_AT_EVERY_WIDTH = True
+
class SGLangStrictThinkingAdapter(SGLangCuda13Adapter):
"""CUDA 13 SGLang lane that guarantees a closed private thought block.
- SGLang 0.5.13 can suppress premature EOS tokens until the model emits its
+ The CUDA 13 SGLang engine can suppress premature EOS tokens until the model emits its
reasoning terminator. The older shared SGLang bundle does not expose this
launch option, so reasoning profiles that need the guarantee route through
the existing CUDA 13 bundle while retaining the generic generation adapter.
diff --git a/packages/sie_server/src/sie_server/adapters/sglang/gemma.py b/packages/sie_server/src/sie_server/adapters/sglang/gemma.py
index 0e3427b5d..7a102a228 100644
--- a/packages/sie_server/src/sie_server/adapters/sglang/gemma.py
+++ b/packages/sie_server/src/sie_server/adapters/sglang/gemma.py
@@ -10,7 +10,14 @@ class SGLangGemmaAdapter(SGLangGenerationAdapter):
subclass exists is routing: bundle compatibility keys on the adapter
*module* path, and the ``sglang`` bundle declares only
``sie_server.adapters.sglang.generation``. Giving Gemma 4 a distinct
- module lets the ``sglang-cu130`` bundle (sglang 0.5.13 + transformers 5.8) own
- it without making every Qwen3.x model compatible with that bundle too —
- so the Qwen serving stack on the ``sglang`` bundle stays untouched.
+ module lets the ``sglang-cu130`` bundle own it without making every
+ Qwen3.x model compatible with that bundle too — so the Qwen serving stack
+ on the ``sglang`` bundle stays untouched. The launch flags are spelled for
+ that bundle's engine.
"""
+
+ _PREFILL_GRAPH_OFF_FLAG = "--disable-prefill-cuda-graph"
+ _MAMBA_STRATEGY_FLAG = "--mamba-radix-cache-strategy"
+ # Gemma 4 is multimodal: SGLang 0.5.13 never captured its prefill graph,
+ # and the profiles routed here were sized under that engine.
+ _PREFILL_GRAPH_OFF_AT_EVERY_WIDTH = True
diff --git a/packages/sie_server/src/sie_server/adapters/sglang/generation.py b/packages/sie_server/src/sie_server/adapters/sglang/generation.py
index 6e256e3c8..fde96fe9e 100644
--- a/packages/sie_server/src/sie_server/adapters/sglang/generation.py
+++ b/packages/sie_server/src/sie_server/adapters/sglang/generation.py
@@ -161,18 +161,16 @@ def _resolve_profile_startup_timeout(declared: float | None, *, tensor_parallel_
return _server.resolve_startup_timeout(declared)
-def _mamba_scheduler_strategy_value(extra_launch_args: list[str]) -> str | None:
- """Return the value passed to ``--mamba-scheduler-strategy``, or ``None``.
-
- Parses both the two-token form (``["--mamba-scheduler-strategy",
- "extra_buffer"]``) and the ``--mamba-scheduler-strategy=value`` form; the
- last occurrence wins (argparse semantics). Returns ``None`` when the flag is
- absent. The speculative guard uses this to require the value be *exactly*
- ``extra_buffer`` — substring-matching the joined args would let a wrong value
- (e.g. ``--mamba-scheduler-strategy default``) slip past if the token
+def _mamba_strategy_value(extra_launch_args: list[str], flag: str) -> str | None:
+ """Return the value passed to the mamba strategy ``flag``, or ``None``.
+
+ Parses both the two-token form (``[flag, "extra_buffer"]``) and the
+ ``flag=value`` form; the last occurrence wins (argparse semantics). Returns
+ ``None`` when the flag is absent. The speculative guard uses this to require
+ the value be *exactly* ``extra_buffer`` — substring-matching the joined args
+ would let a wrong value (e.g. ``no_buffer``) slip past if the token
``extra_buffer`` happened to appear elsewhere in the args.
"""
- flag = "--mamba-scheduler-strategy"
prefix = f"{flag}="
value: str | None = None
for i, arg in enumerate(extra_launch_args):
@@ -364,6 +362,12 @@ class SGLangGenerationAdapter(GenerationAdapter):
requires_main_thread: bool = False
manages_own_load_timeout: bool = True
+ # Spellings and defaults of the engine pinned by the ``sglang`` bundle.
+ # Adapters routed to a bundle that pins a newer engine override them.
+ _PREFILL_GRAPH_OFF_FLAG = "--disable-piecewise-cuda-graph"
+ _MAMBA_STRATEGY_FLAG = "--mamba-scheduler-strategy"
+ _PREFILL_GRAPH_OFF_AT_EVERY_WIDTH = False
+
def __init__(
self,
model_name_or_path: str,
@@ -393,8 +397,8 @@ class SGLangGenerationAdapter(GenerationAdapter):
# this, so it is inert for every other model.
guard: dict[str, Any] | None = None,
speculative: dict[str, Any] | None = None,
- # When ``speculative.enabled``, the adapter normally REQUIRES
- # ``--mamba-scheduler-strategy extra_buffer`` in ``extra_launch_args``
+ # When ``speculative.enabled``, the adapter normally REQUIRES the mamba
+ # strategy flag set to ``extra_buffer`` in ``extra_launch_args``
# — the Qwen3.x Gated-DeltaNet NEXTN + radix-cache pairing. Models whose
# speculative path doesn't need it (e.g. Gemma 4 MTP — a standard
# hybrid-attention model using an external ``-it-assistant`` NEXTN draft)
@@ -430,11 +434,13 @@ class SGLangGenerationAdapter(GenerationAdapter):
# port, which is the point: the engine's own default is a random port,
# and two groups starting together can collide on it.
nccl_port: int | None = None,
- # SGLang enables a piecewise CUDA-graph capture path by default. It is
- # measured to hang indefinitely at width two and to exhaust memory at
- # width four, on a card and memory fraction where width one serves
- # normally, so any width above one disables it unless a profile opts
- # back in explicitly. None means "decide from the width".
+ # SGLang enables a prefill CUDA-graph capture path by default (the
+ # piecewise path before 0.5.20). It is measured to hang indefinitely at
+ # width two and to exhaust memory at width four, on a card and memory
+ # fraction where width one serves normally, so any width above one
+ # disables it unless a profile opts back in explicitly. None means
+ # "decide from the width", or off at every width for an adapter whose
+ # profiles were sized on an engine that never captured it.
disable_piecewise_cuda_graph: bool | None = None,
**kwargs: Any, # accept extra args from loader for compatibility
) -> None:
@@ -457,7 +463,9 @@ class SGLangGenerationAdapter(GenerationAdapter):
tensor_parallel_size=self._tensor_parallel_size,
)
self._disable_piecewise_cuda_graph = (
- self._tensor_parallel_size > 1 if disable_piecewise_cuda_graph is None else disable_piecewise_cuda_graph
+ self._PREFILL_GRAPH_OFF_AT_EVERY_WIDTH or self._tensor_parallel_size > 1
+ if disable_piecewise_cuda_graph is None
+ else disable_piecewise_cuda_graph
)
self._compute_precision = compute_precision
self._trust_remote_code = trust_remote_code
@@ -707,10 +715,10 @@ class SGLangGenerationAdapter(GenerationAdapter):
if self._disable_cuda_graph:
cmd.append("--disable-cuda-graph")
# Distinct from --disable-cuda-graph, which turns off graph replay
- # entirely. This disables only the piecewise capture path, so width
- # above one keeps ordinary graph replay and its throughput.
+ # entirely. This disables only the prefill capture path, so width
+ # above one keeps decode graph replay and its throughput.
if self._disable_piecewise_cuda_graph and not self._disable_cuda_graph:
- cmd.append("--disable-piecewise-cuda-graph")
+ cmd.append(self._PREFILL_GRAPH_OFF_FLAG)
# A forward batch that exceeds this crashes the engine rather than
# hanging, so requests fail instead of waiting on a rank that will not
# answer.
@@ -741,8 +749,8 @@ class SGLangGenerationAdapter(GenerationAdapter):
# SGLang 0.5.10+ requires ``SGLANG_ENABLE_SPEC_V2=1`` for NEXTN spec
# decoding to coexist with the radix cache on hybrid-architecture
# models (Qwen3.5 family — Gated DeltaNet + Gated Attention). The
- # ``--mamba-scheduler-strategy extra_buffer`` flag, set via the model
- # YAML's ``extra_launch_args``, is the matching CLI side; both are
+ # mamba strategy flag set to ``extra_buffer`` in the model YAML's
+ # ``extra_launch_args`` is the matching CLI side; both are
# required as a pair. Empirically validated 2026-05-18 on L4 +
# A100-40GB. Set unconditionally when speculative is on — the env var
# is a no-op when sglang doesn't see speculative args.
@@ -750,24 +758,24 @@ class SGLangGenerationAdapter(GenerationAdapter):
if self._speculative and self._speculative.get("enabled"):
extra_env["SGLANG_ENABLE_SPEC_V2"] = "1"
# The pair is required: setting ``SGLANG_ENABLE_SPEC_V2=1``
- # without ``--mamba-scheduler-strategy extra_buffer`` (or
+ # without the mamba strategy set to ``extra_buffer`` (or
# equivalent) crashes the radix cache mid-run on Qwen3.5
# hybrid models with a confusing "spec_v2 requires extra
# buffer" trace. Refuse to launch when the YAML omits the
# flag so the misconfiguration surfaces as a startup error
# instead of a runtime OOM that pages oncall.
# Require the flag AND its exact ``extra_buffer`` value — a present
- # flag with a wrong value (e.g. ``--mamba-scheduler-strategy default``)
- # must not bypass the guard. Parse the flag's value precisely (both
+ # flag with a wrong value (e.g. ``no_buffer``) must not bypass the
+ # guard. Parse the flag's value precisely (both
# the two-token and ``flag=value`` forms; last occurrence wins) rather
# than substring-matching the joined args, which a stray
# ``extra_buffer`` token elsewhere could satisfy.
if (
self._speculative_needs_extra_buffer
- and _mamba_scheduler_strategy_value(self._extra_launch_args) != "extra_buffer"
+ and _mamba_strategy_value(self._extra_launch_args, self._MAMBA_STRATEGY_FLAG) != "extra_buffer"
):
raise RuntimeError(
- "speculative decoding requires '--mamba-scheduler-strategy extra_buffer' "
+ f"speculative decoding requires '{self._MAMBA_STRATEGY_FLAG} extra_buffer' "
"in extra_launch_args (see Qwen3.5-4B model YAML). Add the flag, set "
"speculative_needs_extra_buffer=false (non-DeltaNet models e.g. Gemma 4 "
"MTP), or disable speculative.enabled in the model config."
diff --git a/packages/sie_server/tests/adapters/test_sglang_generation.py b/packages/sie_server/tests/adapters/test_sglang_generation.py
index 7542c22ea..57ce5b990 100644
--- a/packages/sie_server/tests/adapters/test_sglang_generation.py
+++ b/packages/sie_server/tests/adapters/test_sglang_generation.py
@@ -34,12 +34,13 @@ from sie_server.adapters._generation_base import (
from sie_server.adapters._types import ERR_NOT_LOADED
from sie_server.adapters.sglang import _server
from sie_server.adapters.sglang import generation as generation_module
-from sie_server.adapters.sglang.cuda13 import SGLangStrictThinkingAdapter
+from sie_server.adapters.sglang.cuda13 import SGLangCuda13Adapter, SGLangStrictThinkingAdapter
+from sie_server.adapters.sglang.gemma import SGLangGemmaAdapter
from sie_server.adapters.sglang.generation import (
SGLangGenerationAdapter,
_chunk_from_sglang_event,
_encode_image_data,
- _mamba_scheduler_strategy_value,
+ _mamba_strategy_value,
_p_unsafe_from_verdict_logprobs,
_parse_sglang_generate_response,
_raise_for_sglang_event_error,
@@ -98,31 +99,33 @@ def test_load_required_memory_bytes_uses_mem_fraction_static() -> None:
assert adapter.load_required_memory_bytes(device_type="cpu", device_total_bytes=10 * gb) is None
[email protected]("flag", ["--mamba-scheduler-strategy", "--mamba-radix-cache-strategy"])
@pytest.mark.parametrize(
("args", "expected"),
[
# two-token form (Qwen3.5-4B YAML shape) → exact value
- (["--mamba-scheduler-strategy", "extra_buffer"], "extra_buffer"),
- (["--mamba-scheduler-strategy", "default"], "default"),
+ (["FLAG", "extra_buffer"], "extra_buffer"),
+ (["FLAG", "default"], "default"),
# flag=value form
- (["--mamba-scheduler-strategy=extra_buffer"], "extra_buffer"),
- (["--mamba-scheduler-strategy=default"], "default"),
+ (["FLAG=extra_buffer"], "extra_buffer"),
+ (["FLAG=default"], "default"),
# absent → None
(["--disable-overlap-schedule"], None),
([], None),
# trailing flag with no value → None (no crash)
- (["--mamba-scheduler-strategy"], None),
+ (["FLAG"], None),
# a stray ``extra_buffer`` token elsewhere must NOT be read as the value
- (["--some-other-flag", "extra_buffer", "--mamba-scheduler-strategy", "default"], "default"),
+ (["--some-other-flag", "extra_buffer", "FLAG", "default"], "default"),
# last occurrence wins (argparse semantics)
- (
- ["--mamba-scheduler-strategy", "default", "--mamba-scheduler-strategy", "extra_buffer"],
- "extra_buffer",
- ),
+ (["FLAG", "default", "FLAG", "extra_buffer"], "extra_buffer"),
],
)
-def test_mamba_scheduler_strategy_value(args: list[str], expected: str | None) -> None:
- assert _mamba_scheduler_strategy_value(args) == expected
+def test_mamba_strategy_value(flag: str, args: list[str], expected: str | None) -> None:
+ assert _mamba_strategy_value([arg.replace("FLAG", flag) for arg in args], flag) == expected
+
+
+def test_mamba_strategy_value_ignores_the_other_engines_spelling() -> None:
+ assert _mamba_strategy_value(["--mamba-scheduler-strategy", "extra_buffer"], "--mamba-radix-cache-strategy") is None
def test_speculative_launch_args_support_qwen_eagle_and_gemma_assistant() -> None:
@@ -2878,7 +2881,9 @@ async def test_duplicate_event_keys_raise_typed_error_before_output(adapter, n,
assert "secret" not in str(error.value)
-def _tp_adapter(**overrides: Any) -> SGLangGenerationAdapter:
+def _tp_adapter(
+ adapter_class: type[SGLangGenerationAdapter] = SGLangGenerationAdapter, **overrides: Any
+) -> SGLangGenerationAdapter:
kwargs: dict[str, Any] = {
"model_name_or_path": "Qwen/Qwen3-4B-Instruct",
"max_seq_length": 32768,
@@ -2893,7 +2898,7 @@ def _tp_adapter(**overrides: Any) -> SGLangGenerationAdapter:
kwargs["request_read_timeout_s"] = 120.0
kwargs["startup_timeout_s"] = 600.0
kwargs.update(overrides)
- return SGLangGenerationAdapter(**kwargs)
+ return adapter_class(**kwargs)
def _launch(adapter: SGLangGenerationAdapter, mock_popen: MagicMock, device: str = "cuda:0") -> tuple[list[str], dict]:
@@ -3011,6 +3016,106 @@ def test_capture_path_can_be_re_enabled_explicitly(
assert "--disable-piecewise-cuda-graph" not in cmd
[email protected]("adapter_class", [SGLangCuda13Adapter, SGLangStrictThinkingAdapter, SGLangGemmaAdapter])
+@patch("sie_server.adapters.sglang._server.subprocess.Popen")
+@patch("sie_server.adapters.sglang._server.requests.get")
+@patch("sie_server.adapters.sglang._server.find_free_port")
+def test_cuda13_adapters_turn_off_the_prefill_capture_path_by_its_current_name(
+ mock_find_port: MagicMock,
+ mock_requests_get: MagicMock,
+ mock_popen: MagicMock,
+ adapter_class: type[SGLangGenerationAdapter],
+) -> None:
+ """The CUDA 13 engine removed the piecewise flag; its prefill-phase flag replaces it."""
+ mock_find_port.return_value = 30005
+ mock_popen.return_value = MagicMock(poll=MagicMock(return_value=None))
+ mock_requests_get.return_value = MagicMock(status_code=200)
+
+ cmd, _env = _launch(_tp_adapter(adapter_class, tensor_parallel_size=4), mock_popen)
+
+ assert "--disable-prefill-cuda-graph" in cmd
+ assert "--disable-piecewise-cuda-graph" not in cmd
+
+
[email protected]("adapter_class", [SGLangCuda13Adapter, SGLangStrictThinkingAdapter, SGLangGemmaAdapter])
+ ("overrides", "expected"),
+ [
+ ({}, True),
+ ({"disable_piecewise_cuda_graph": False}, False),
+ ({"disable_cuda_graph": True}, False),
+ ],
+)
+@patch("sie_server.adapters.sglang._server.subprocess.Popen")
+@patch("sie_server.adapters.sglang._server.requests.get")
+@patch("sie_server.adapters.sglang._server.find_free_port")
+def test_cuda13_adapters_keep_the_prefill_graph_off_at_width_one(
+ mock_find_port: MagicMock,
+ mock_requests_get: MagicMock,
+ mock_popen: MagicMock,
+ overrides: dict[str, Any],
+ expected: bool,
+ adapter_class: type[SGLangGenerationAdapter],
+) -> None:
+ """Every CUDA 13 profile was sized on an engine that never captured this graph.
+
+ A profile may opt back in, and turning all CUDA graphs off needs no second flag.
+ """
+ mock_find_port.return_value = 30005
+ mock_popen.return_value = MagicMock(poll=MagicMock(return_value=None))
+ mock_requests_get.return_value = MagicMock(status_code=200)
+
+ cmd, _env = _launch(_tp_adapter(adapter_class, **overrides), mock_popen)
+
+ assert cmd[cmd.index("--tensor-parallel-size") + 1] == "1"
+ assert ("--disable-prefill-cuda-graph" in cmd) is expected
+
+
+@patch("sie_server.adapters.sglang._server.subprocess.Popen")
+@patch("sie_server.adapters.sglang._server.requests.get")
+@patch("sie_server.adapters.sglang._server.find_free_port")
+def test_cuda13_speculative_guard_accepts_the_renamed_mamba_flag(
+ mock_find_port: MagicMock,
+ mock_requests_get: MagicMock,
+ mock_popen: MagicMock,
+) -> None:
+ mock_find_port.return_value = 30005
+ mock_popen.return_value = MagicMock(poll=MagicMock(return_value=None))
+ mock_requests_get.return_value = MagicMock(status_code=200)
+
+ cmd, env = _launch(
+ _tp_adapter(
+ SGLangCuda13Adapter,
+ speculative={"enabled": True, "algorithm": "eagle"},
+ extra_launch_args=["--mamba-radix-cache-strategy", "extra_buffer"],
+ ),
+ mock_popen,
+ )
+
+ assert cmd[cmd.index("--mamba-radix-cache-strategy") + 1] == "extra_buffer"
+ assert env["SGLANG_ENABLE_SPEC_V2"] == "1"
+
+
+@patch("sie_server.adapters.sglang._server.subprocess.Popen")
+@patch("sie_server.adapters.sglang._server.find_free_port")
+def test_cuda13_speculative_guard_rejects_the_retired_mamba_flag(
+ mock_find_port: MagicMock,
+ mock_popen: MagicMock,
+) -> None:
+ """The CUDA 13 engine no longer declares the old spelling, so it cannot satisfy the guard."""
+ mock_find_port.return_value = 30007
+ adapter = _tp_adapter(
+ SGLangCuda13Adapter,
+ speculative={"enabled": True, "algorithm": "eagle"},
+ extra_launch_args=["--mamba-scheduler-strategy", "extra_buffer"],
+ )
+
+ with pytest.raises(RuntimeError, match="'--mamba-radix-cache-strategy extra_buffer'"):
+ adapter.load("cuda:0")
+
+ mock_popen.assert_not_called()
+
+
@pytest.mark.parametrize("bad", [0, -1, 9, 2.0, "4", True, None])
def test_invalid_width_is_refused_at_construction(bad: Any) -> None:
"""A bad width fails where it is declared, not as an engine crash later."""
diff --git a/packages/sie_server/tests/adapters/test_sglang_launch_flags.py b/packages/sie_server/tests/adapters/test_sglang_launch_flags.py
index 5607ca607..569f4f7c6 100644
--- a/packages/sie_server/tests/adapters/test_sglang_launch_flags.py
+++ b/packages/sie_server/tests/adapters/test_sglang_launch_flags.py
@@ -10,14 +10,18 @@ The list below is the contract. It is deliberately explicit rather than derived
at run time, because the engine is only importable inside a GPU bundle and this
check has to run in an ordinary unit suite. Adding a flag means adding it here,
which is the moment to confirm the engine declares it in **every** pinned
-version that loads the adapter emitting it.
-
-Verified against both pinned engines by reading ``sglang/srt/server_args.py``:
-``0.5.10.post1`` (the ``sglang`` and ``sglang-embedding`` bundles) from the
-published sdist, 364 declared flags, and ``0.5.13`` (the ``sglang-cu130``
-bundle) from the installed package inside a GPU container, 417 declared flags.
-Neither declares ``--tp``. No flag recorded below is a strict prefix of another
-declared flag in either version.
+version that loads the adapter emitting it. Moving a bundle to a new engine
+version means confirming every recorded flag again, including the flags model
+profiles routed to that bundle pass through ``extra_launch_args``.
+
+Verified against both pinned engines: ``0.5.10.post1`` (the ``sglang`` and
+``sglang-embedding`` bundles) by reading ``sglang/srt/server_args.py`` from the
+published sdist, 364 declared flags, and ``0.5.20`` (the ``sglang-cu130``
+bundle) by building the engine's own parser inside a GPU container, 515
+declared flags. Neither declares ``--tp``. In 0.5.20, ``--disable-cuda-graph``,
+``--enable-lora`` and ``--log-level`` are strict prefixes of other declared
+flags; each is declared itself, and argparse takes an exact match before any
+prefix, so none of them is ambiguous.
"""
from __future__ import annotations
@@ -26,23 +30,24 @@ import re
from pathlib import Path
import pytest
+import yaml
+from sie_server.core.loader import load_model_configs
-_ADAPTER_DIR = Path(__file__).resolve().parents[2] / "src/sie_server/adapters/sglang"
+_PACKAGE_DIR = Path(__file__).resolve().parents[2]
+_ADAPTER_DIR = _PACKAGE_DIR / "src/sie_server/adapters/sglang"
-# Flags confirmed present in sglang 0.5.10.post1's declared argument set.
+# Flags confirmed present in both pinned engines' declared argument sets.
_DECLARED_IN_PINNED_ENGINE = frozenset(
{
"--attention-backend",
"--context-length",
"--disable-cuda-graph",
- "--disable-piecewise-cuda-graph",
"--dtype",
"--enable-lora",
"--grammar-backend",
"--is-embedding",
"--log-level",
"--lora-paths",
- "--mamba-scheduler-strategy",
"--max-loras-per-batch",
"--mem-fraction-static",
"--model-path",
@@ -65,10 +70,40 @@ _DECLARED_IN_PINNED_ENGINE = frozenset(
)
# Emitted only by adapters whose bundle pins the newer engine. Absent from
-# 0.5.10.post1 and present in 0.5.13, which is the bundle that loads them.
+# 0.5.10.post1 and present in 0.5.20, which is the bundle that loads them.
_NEWER_ENGINE_ONLY = frozenset(
{
+ "--disable-prefill-cuda-graph", # cuda13.py and gemma.py, sglang-cu130 bundle
"--enable-strict-thinking", # cuda13.py, sglang-cu130 bundle
+ "--mamba-radix-cache-strategy", # cuda13.py and gemma.py, sglang-cu130 bundle
+ }
+)
+
+# Emitted only by adapters whose bundle pins 0.5.10.post1, which declares them.
+# 0.5.20 renamed both, and the sglang-cu130 adapters override the spelling.
+_OLDER_ENGINE_ONLY = frozenset(
+ {
+ "--disable-piecewise-cuda-graph",
+ "--mamba-scheduler-strategy",
+ }
+)
+
+# Flags that profiles routed to the ``sglang-cu130`` bundle pass through
+# ``extra_launch_args``, each confirmed declared by that bundle's engine (0.5.20).
+_CU130_PROFILE_FLAGS = frozenset(
+ {
+ "--chunked-prefill-size",
+ "--cuda-graph-max-bs-decode",
+ "--disable-overlap-schedule",
+ "--enable-strict-thinking",
+ "--kv-cache-dtype",
+ "--mamba-radix-cache-strategy",
+ "--mamba-ssm-dtype",
+ "--max-prefill-tokens",
+ "--max-running-requests",
+ "--mm-process-config",
+ "--page-size",
+ "--quantization",
}
)
@@ -92,7 +127,7 @@ def _emitted_flags() -> dict[str, set[Path]]:
def test_no_emitted_flag_is_outside_the_verified_contract() -> None:
"""A new flag must be added to this module, which is where it gets checked."""
- known = _DECLARED_IN_PINNED_ENGINE | _NEWER_ENGINE_ONLY | _KNOWN_UNDECLARED
+ known = _DECLARED_IN_PINNED_ENGINE | _NEWER_ENGINE_ONLY | _OLDER_ENGINE_ONLY | _KNOWN_UNDECLARED
emitted = _emitted_flags()
# "--tp" survives as comment text explaining why it is not emitted.
unexpected = {
@@ -136,3 +171,30 @@ def test_no_parallelism_abbreviation_is_emitted(abbreviation: str) -> None:
assert not emitting, (
f"{path.relative_to(_ADAPTER_DIR)} emits the abbreviated parallelism flag {abbreviation!r}: {emitting}"
)
+
+
+def _cu130_profile_flags() -> dict[str, set[str]]:
+ """Return every ``--flag`` that sglang-cu130 profiles pass in ``extra_launch_args``, by profile."""
+ bundle = yaml.safe_load((_PACKAGE_DIR / "bundles/sglang-cu130.yaml").read_text(encoding="utf-8"))
+ modules = set(bundle["adapters"])
+ found: dict[str, set[str]] = {}
+ for name, config in load_model_configs(_PACKAGE_DIR / "models").items():
+ profile = config.resolve_profile("default")
+ if (profile.adapter_path or "").partition(":")[0] not in modules:
+ continue
+ for arg in profile.loadtime.get("extra_launch_args") or []:
+ if isinstance(arg, str) and arg.startswith("--"):
+ found.setdefault(arg.partition("=")[0], set()).add(name)
+ return found
+
+
+def test_cu130_profile_launch_args_are_declared_by_the_bundle_engine() -> None:
+ """A flag the engine renamed fails here rather than when the model loads."""
+ flags = _cu130_profile_flags()
+ unexpected = {flag: sorted(names) for flag, names in flags.items() if flag not in _CU130_PROFILE_FLAGS}
+
+ assert flags, "no sglang-cu130 profile passes extra_launch_args; the catalog walk found nothing"
+ assert not unexpected, (
+ f"sglang-cu130 profiles pass engine flag(s) not recorded in this module: {unexpected}. "
+ "Confirm the bundle's engine declares each one, then add it to _CU130_PROFILE_FLAGS."
+ )
diff --git a/packages/sie_server/tests/config/test_qwen38_generation_profiles.py b/packages/sie_server/tests/config/test_qwen38_generation_profiles.py
index 38d486b39..86df47880 100644
--- a/packages/sie_server/tests/config/test_qwen38_generation_profiles.py
+++ b/packages/sie_server/tests/config/test_qwen38_generation_profiles.py
@@ -144,11 +144,11 @@ def test_qwen38_hardware_launches_keep_fp8_weights_with_tuned_state_precision()
assert "--quantization" not in args
assert args[args.index("--kv-cache-dtype") + 1] == "bfloat16"
assert args[args.index("--mamba-ssm-dtype") + 1] == "bfloat16"
- assert args[args.index("--mamba-scheduler-strategy") + 1] == "extra_buffer"
+ assert args[args.index("--mamba-radix-cache-strategy") + 1] == "extra_buffer"
assert args.count("--disable-overlap-schedule") == 1
assert args[args.index("--page-size") + 1] == "64"
assert args[args.index("--max-running-requests") + 1] == "1"
- assert args[args.index("--cuda-graph-max-bs") + 1] == "1"
+ assert args[args.index("--cuda-graph-max-bs-decode") + 1] == "1"
assert profile.loadtime["extra_env"] == {"SGLANG_JIT_DEEPGEMM_FAST_WARMUP": "1"}
for profile_name in (
diff --git a/packages/sie_server/tests/config/test_qwen_generation_profiles.py b/packages/sie_server/tests/config/test_qwen_generation_profiles.py
index 657181aaa..df95be2d0 100644
--- a/packages/sie_server/tests/config/test_qwen_generation_profiles.py
+++ b/packages/sie_server/tests/config/test_qwen_generation_profiles.py
@@ -231,7 +231,7 @@ def test_qwen36_native_window_uses_measured_cuda13_eagle_shape() -> None:
*_MM_PROCESS_CONFIG_ARGS,
"--quantization",
"fp8",
- "--mamba-scheduler-strategy",
+ "--mamba-radix-cache-strategy",
"extra_buffer",
"--page-size",
"64",
@@ -253,7 +253,7 @@ def test_qwen36_thinking_native_window_uses_measured_cuda13_shape() -> None:
*_MM_PROCESS_CONFIG_ARGS,
"--quantization",
"fp8",
- "--mamba-scheduler-strategy",
+ "--mamba-radix-cache-strategy",
"extra_buffer",
"--page-size",
"64",
diff --git a/tools/ci/cuda13_image_smoke.py b/tools/ci/cuda13_image_smoke.py
index 487b97b95..ecfdab01c 100644
--- a/tools/ci/cuda13_image_smoke.py
+++ b/tools/ci/cuda13_image_smoke.py
@@ -16,7 +16,6 @@ import sie_server
import torch
import transformers
-assert torch.__version__.split("+", 1)[0] == "2.11.0", torch.__version__
assert torch.version.cuda and torch.version.cuda.startswith("13."), torch.version.cuda
"""
@@ -25,17 +24,18 @@ import tvm_ffi
import xgrammar
from sie_server.adapters.sglang import cuda13, gemma, generation
+assert torch.__version__.split("+", 1)[0] == "2.13.0", torch.__version__
expected = {
- "sglang": "0.5.13",
- "transformers": "5.8.1",
+ "sglang": "0.5.20",
+ "transformers": "5.12.1",
"kernels": "0.14.1",
- "flashinfer-python": "0.6.12",
+ "flashinfer-python": "0.6.18",
"xgrammar": "0.2.1",
- "apache-tvm-ffi": "0.1.9",
+ "apache-tvm-ffi": "0.1.11",
}
for distribution, version in expected.items():
assert importlib.metadata.version(distribution) == version, distribution
-for distribution, upstream in (("sgl-deep-gemm", "0.1.2"), ("sglang-kernel", "0.4.3")):
+for distribution, upstream in (("sgl-deep-gemm", "0.2.0"), ("sglang-kernel", "0.4.7")):
actual_upstream, separator, variant = importlib.metadata.version(distribution).partition("+")
assert (actual_upstream, separator, variant) == (upstream, "+", "cu130"), distribution
assert importlib.metadata.distribution("sglang").files
@@ -48,6 +48,7 @@ from pathlib import Path
from sie_server.adapters.tensorrt_llm import _server, compat, generation
+assert torch.__version__.split("+", 1)[0] == "2.11.0", torch.__version__
expected = {
"tensorrt-llm": "1.3.0rc24",
"transformers": "5.5.4",
diff --git a/tools/ci/tests/test_cuda13_image_smoke.py b/tools/ci/tests/test_cuda13_image_smoke.py
index 795656cc3..2576912cb 100644
--- a/tools/ci/tests/test_cuda13_image_smoke.py
+++ b/tools/ci/tests/test_cuda13_image_smoke.py
@@ -36,11 +36,27 @@ def test_sglang_check_uses_safe_distribution_and_adapter_surfaces():
def test_sglang_native_wheels_require_exact_cu130_local_variants():
script = cuda13_image_smoke.validation_script("sglang-cu130")
- assert '(("sgl-deep-gemm", "0.1.2"), ("sglang-kernel", "0.4.3"))' in script
+ assert '(("sgl-deep-gemm", "0.2.0"), ("sglang-kernel", "0.4.7"))' in script
assert '.partition("+")' in script
assert '(upstream, "+", "cu130")' in script
+ ("bundle", "torch_version"),
+ [("sglang-cu130", "2.13.0"), ("tensorrt-llm", "2.11.0")],
+)
+def test_each_engine_pins_its_own_torch(bundle, torch_version):
+ """The two bundles ship different torch builds, so a point version cannot be shared."""
+ script = cuda13_image_smoke.validation_script(bundle)
+ assert f'torch.__version__.split("+", 1)[0] == "{torch_version}"' in script
+ assert script.count("torch.__version__.split") == 1
+
+
+def test_common_checks_pin_only_the_cuda_family():
+ assert 'torch.version.cuda.startswith("13.")' in cuda13_image_smoke.COMMON_CHECKS
+ assert "torch.__version__" not in cuda13_image_smoke.COMMON_CHECKS
+
+
def test_tensorrt_check_locates_engine_and_verifies_qualified_sources():
script = cuda13_image_smoke.validation_script("tensorrt-llm")
assert 'find_spec("tensorrt_llm")' in script