Skip to content

armgit / sie

Public Imported from GitHub
0

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

fix(server)!: refuse listener flags in extra_launch_args (#304)

Krisztian Gajdar7a68262a0f05
diff --git a/deploy/helm/sie-cluster/README.md b/deploy/helm/sie-cluster/README.md
index 8ab5dc586..66ae15e94 100644
--- a/deploy/helm/sie-cluster/README.md
+++ b/deploy/helm/sie-cluster/README.md
@@ -667,7 +667,12 @@ workers:
zero is refused when the model loads rather than replaced by a default.
- Width and placement are declared only through `tensor_parallel_size`. Engine
placement flags in `extra_launch_args` (including abbreviations such as
- `--tp`) and device-visibility variables in `extra_env` are refused.
+ `--tp`) and device-visibility variables in `extra_env` are refused. So are the
+ flags that decide where the engine listens: `--nccl-port`, which has the
+ `loadtime.nccl_port` option instead, and `--host` and `--port`, which the
+ server passes for the engine's own HTTP listener and then talks to. They are
+ not this pod's `--host`/`--port`, which the chart sets on the worker
+ container.
- `gpu.deviceGroup` requires `gpu.count >= 2`. `SIE_GPU_COUNT` and the cluster
health `gpu_count` count serving slots, so a device-group pod reports one
slot however many GPUs it holds.
diff --git a/packages/sie_config/src/sie_config/model_registry.py b/packages/sie_config/src/sie_config/model_registry.py
index b48876717..d854621a4 100644
--- a/packages/sie_config/src/sie_config/model_registry.py
+++ b/packages/sie_config/src/sie_config/model_registry.py
@@ -147,9 +147,9 @@ def _validate_profile_name(profile_name: str) -> None:
_IMMUTABLE_REVISION_RE = re.compile(r"^[0-9a-f]{40}$")
-# Mirror of sie_server's placement rules (config/model.py). A worker refuses a
-# snapshot containing a profile that breaks them, so the config service refuses
-# the write that would put one there.
+# Mirror of sie_server's placement and listener rules (config/model.py). A
+# worker refuses a snapshot containing a profile that breaks them, so the config
+# service refuses the write that would put one there.
_MAX_TENSOR_PARALLEL_SIZE = 8
_PLACEMENT_LAUNCH_FLAGS = frozenset(
{
@@ -170,6 +170,8 @@ _PLACEMENT_LAUNCH_FLAGS = frozenset(
"--gpu-id-step",
}
)
+_LISTENER_LAUNCH_FLAGS = frozenset({"--host", "--nccl-port", "--port"})
+_REFUSED_LAUNCH_FLAGS = _PLACEMENT_LAUNCH_FLAGS | _LISTENER_LAUNCH_FLAGS
_PLACEMENT_ENV_VARS = frozenset({"CUDA_VISIBLE_DEVICES", "NVIDIA_VISIBLE_DEVICES", "ROCR_VISIBLE_DEVICES"})
@@ -196,13 +198,25 @@ def _validate_profile_placement(profiles: dict) -> None:
flag = str(entry).split("=", 1)[0].strip()
if not flag.startswith("--") or len(flag) <= len("--"):
continue
- refused = next((f for f in sorted(_PLACEMENT_LAUNCH_FLAGS) if f.startswith(flag)), None)
- if refused is not None:
+ refused = next((f for f in sorted(_REFUSED_LAUNCH_FLAGS) if f.startswith(flag)), None)
+ if refused is None:
+ continue
+ if refused in _LISTENER_LAUNCH_FLAGS:
+ remedy = (
+ "Declare loadtime.nccl_port instead."
+ if refused == "--nccl-port"
+ else "The worker passes the host and port of the engine's HTTP listener and talks to it."
+ )
+ msg = (
+ f"Profile '{profile_name}': extra_launch_args carries {flag!r}, which sets the "
+ f"listener flag {refused!r}. {remedy}"
+ )
+ else:
msg = (
f"Profile '{profile_name}': extra_launch_args carries {flag!r}, which sets the "
f"placement flag {refused!r}. Declare loadtime.tensor_parallel_size instead."
)
- raise ValueError(msg)
+ raise ValueError(msg)
raw_env = loadtime.get("extra_env") or {}
if isinstance(raw_env, dict):
for key in raw_env:
diff --git a/packages/sie_config/tests/test_model_registry.py b/packages/sie_config/tests/test_model_registry.py
index bccb95b50..fc7c4ce07 100644
--- a/packages/sie_config/tests/test_model_registry.py
+++ b/packages/sie_config/tests/test_model_registry.py
@@ -1020,6 +1020,23 @@ class TestProfilePlacement:
with pytest.raises(ValueError, match="placement flag"):
model_registry._validate_profile_placement(self._profiles(extra_launch_args=args))
+ @pytest.mark.parametrize(
+ "args",
+ [
+ ["--nccl-port", "30411"],
+ ["--nccl-port=30411"],
+ ["--nccl-po", "30411"],
+ ["--host", "127.0.0.1"],
+ ["--port=8000"],
+ ],
+ )
+ def test_a_listener_flag_is_refused_however_it_is_spelled(self, args: list[str]) -> None:
+ with pytest.raises(ValueError, match="listener flag"):
+ model_registry._validate_profile_placement(self._profiles(extra_launch_args=args))
+
+ def test_the_sanctioned_rendezvous_option_still_passes(self) -> None:
+ model_registry._validate_profile_placement(self._profiles(tensor_parallel_size=2, nccl_port=30411))
+
def test_a_device_visibility_variable_is_refused(self) -> None:
with pytest.raises(ValueError, match="CUDA_VISIBLE_DEVICES"):
model_registry._validate_profile_placement(self._profiles(extra_env={"CUDA_VISIBLE_DEVICES": "0"}))
@@ -1034,5 +1051,7 @@ class TestProfilePlacement:
groups = pytest.importorskip("sie_server.config.device_groups")
assert model_registry._PLACEMENT_LAUNCH_FLAGS == server._PLACEMENT_LAUNCH_FLAGS
+ assert model_registry._LISTENER_LAUNCH_FLAGS == server._LISTENER_LAUNCH_FLAGS
+ assert model_registry._REFUSED_LAUNCH_FLAGS == server._REFUSED_LAUNCH_FLAGS
assert model_registry._PLACEMENT_ENV_VARS == server._PLACEMENT_ENV_VARS
assert model_registry._MAX_TENSOR_PARALLEL_SIZE == groups.MAX_TENSOR_PARALLEL_SIZE
diff --git a/packages/sie_server/src/sie_server/config/model.py b/packages/sie_server/src/sie_server/config/model.py
index d5553fa78..02b07c268 100644
--- a/packages/sie_server/src/sie_server/config/model.py
+++ b/packages/sie_server/src/sie_server/config/model.py
@@ -319,8 +319,23 @@ would serve on devices nothing reserved.
"""
-def _refused_placement_flag(token: object) -> str | None:
- """The placement flag a launch-argument token spells, abbreviations included.
+_LISTENER_LAUNCH_FLAGS = frozenset({"--host", "--nccl-port", "--port"})
+"""Launch flags that decide where the engine listens.
+
+Each one is refused inside ``extra_launch_args`` because the server owns both
+listeners: the adapter passes the HTTP host and port it then talks to, and it
+reserves the tensor-parallel rendezvous port before passing ``--nccl-port``.
+The passthrough is appended after the flags the adapter builds and the engine's
+parser keeps the last spelling of a flag, so one set here would move the HTTP
+listener away from the one the adapter reaches, or rendezvous a group on a port
+nothing reserved.
+"""
+
+_REFUSED_LAUNCH_FLAGS = _PLACEMENT_LAUNCH_FLAGS | _LISTENER_LAUNCH_FLAGS
+
+
+def _refused_launch_flag(token: object) -> str | None:
+ """The refused flag a launch-argument token spells, abbreviations included.
SGLang's parser accepts any unambiguous prefix of a long option, so
``--tensor-parallel 4`` reaches ``--tensor-parallel-size`` exactly as the
@@ -329,7 +344,7 @@ def _refused_placement_flag(token: object) -> str | None:
flag = str(token).split("=", 1)[0].strip()
if not flag.startswith("--") or len(flag) <= len("--"):
return None
- for refused in sorted(_PLACEMENT_LAUNCH_FLAGS):
+ for refused in sorted(_REFUSED_LAUNCH_FLAGS):
if refused.startswith(flag):
return refused
return None
@@ -430,6 +445,10 @@ class AdapterOptions(BaseModel):
because the launcher writes the device mask last, so a mask set there
would be silently discarded rather than honoured.
+ Where the engine listens is reserved the same way, so the flags that
+ move a listener are refused too: the rendezvous port has an option of
+ its own, and the HTTP listener belongs to the adapter that talks to it.
+
Requirements that belong to one engine, such as a read cap for a
group, are enforced by that engine's adapter, since a width is valid
for any adapter that accepts one.
@@ -443,14 +462,24 @@ class AdapterOptions(BaseModel):
raw_args = self.loadtime.get("extra_launch_args") or []
if isinstance(raw_args, list):
for entry in raw_args:
- refused = _refused_placement_flag(entry)
- if refused is not None:
+ refused = _refused_launch_flag(entry)
+ if refused is None:
+ continue
+ spelled = str(entry).split("=", 1)[0].strip()
+ if refused in _LISTENER_LAUNCH_FLAGS:
+ remedy = (
+ "Declare loadtime.nccl_port instead, so the group rendezvouses on the port SIE reserved."
+ if refused == "--nccl-port"
+ else "The server passes the host and port of the engine's HTTP listener and talks to it."
+ )
+ msg = f"extra_launch_args carries {spelled!r}, which sets the listener flag {refused!r}. {remedy}"
+ else:
msg = (
- f"extra_launch_args carries {str(entry).split('=', 1)[0].strip()!r}, which sets the "
+ f"extra_launch_args carries {spelled!r}, which sets the "
f"placement flag {refused!r}. Declare the width as "
"loadtime.tensor_parallel_size instead, so the registry can reserve the devices."
)
- raise ValueError(msg)
+ raise ValueError(msg)
raw_env = self.loadtime.get("extra_env") or {}
if isinstance(raw_env, dict):
diff --git a/packages/sie_server/tests/config/test_tensor_parallel_options.py b/packages/sie_server/tests/config/test_tensor_parallel_options.py
index 90a604449..b0e4c3529 100644
--- a/packages/sie_server/tests/config/test_tensor_parallel_options.py
+++ b/packages/sie_server/tests/config/test_tensor_parallel_options.py
@@ -3,7 +3,10 @@
Each rule exists because the failure it prevents is silent. A placement flag
passed straight to the engine serves on devices the registry never reserved,
and a mistyped width is dropped rather than rejected, so the model serves on
-one card while the profile declares several.
+one card while the profile declares several. A flag that moves a listener is
+the same class: the passthrough is appended after the flags the adapter builds
+and the engine keeps the last spelling, so the engine ends up somewhere other
+than where SIE reserved and expects it.
"""
from __future__ import annotations
@@ -11,7 +14,14 @@ from __future__ import annotations
from typing import Any
import pytest
-from sie_server.config.model import AdapterOptions
+from sie_server.config.model import (
+ AdapterOptions,
+ EmbeddingDim,
+ EncodeTask,
+ ModelConfig,
+ ProfileConfig,
+ Tasks,
+)
def _options(**loadtime: Any) -> AdapterOptions:
@@ -88,3 +98,62 @@ class TestPlacementIsNotSmuggled:
)
assert options.loadtime["extra_launch_args"] == ["--mamba-scheduler-strategy", "extra_buffer"]
+
+
+class TestListenersAreNotSmuggled:
+ @pytest.mark.parametrize("flag", ["--nccl-port", "--host", "--port"])
+ def test_a_listener_flag_in_the_raw_passthrough_is_refused(self, flag: str) -> None:
+ with pytest.raises(ValueError, match="listener flag"):
+ _options(extra_launch_args=[flag, "30411"])
+
+ @pytest.mark.parametrize(
+ ("spelling", "flag"),
+ [
+ ("--nccl-po", "--nccl-port"),
+ ("--nccl-port=30411", "--nccl-port"),
+ ("--po", "--port"),
+ ("--port=8000", "--port"),
+ ("--ho", "--host"),
+ ("--host=0.0.0.0", "--host"),
+ ],
+ )
+ def test_an_abbreviated_or_inline_listener_flag_is_refused(self, spelling: str, flag: str) -> None:
+ with pytest.raises(ValueError, match=flag):
+ _options(extra_launch_args=[spelling])
+
+ def test_the_rendezvous_refusal_names_the_sanctioned_option(self) -> None:
+ with pytest.raises(ValueError, match=r"loadtime\.nccl_port"):
+ _options(extra_launch_args=["--nccl-port", "30411"])
+
+ @pytest.mark.parametrize("flag", ["--host", "--port"])
+ def test_the_http_refusal_names_the_engine_listener(self, flag: str) -> None:
+ """The refused flags are the engine's, not the worker container's own."""
+ with pytest.raises(ValueError, match="engine's HTTP listener"):
+ _options(extra_launch_args=[flag, "8000"])
+
+ @pytest.mark.parametrize("flag", ["--page-size", "--hicache-ratio", "--num-continuous-decode-steps"])
+ def test_a_flag_that_only_shares_a_prefix_region_still_passes(self, flag: str) -> None:
+ """Only an abbreviation of a refused flag is refused, not a neighbour of one."""
+ assert _options(extra_launch_args=[flag, "1"]).loadtime["extra_launch_args"] == [flag, "1"]
+
+ def test_the_sanctioned_rendezvous_option_still_loads(self) -> None:
+ options = _options(tensor_parallel_size=2, nccl_port=30411)
+
+ assert options.loadtime["nccl_port"] == 30411
+
+ def test_a_profile_declaring_the_sanctioned_option_still_loads(self) -> None:
+ config = ModelConfig(
+ sie_id="tp-embedding",
+ hf_id="org/model",
+ tasks=Tasks(encode=EncodeTask(dense=EmbeddingDim(dim=768))),
+ profiles={
+ "default": ProfileConfig(
+ adapter_path="sie_server.adapters.sglang.embedding:SGLangEmbeddingAdapter",
+ max_batch_tokens=8192,
+ adapter_options=AdapterOptions(loadtime={"tensor_parallel_size": 2, "nccl_port": 30411}),
+ )
+ },
+ )
+
+ loadtime = config.profiles["default"].adapter_options.loadtime
+ assert (loadtime["tensor_parallel_size"], loadtime["nccl_port"]) == (2, 30411)