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(helm): make the worker /dev/shm size configurable per pool (#302)

Krisztian Gajdare20368263290
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 4a73269e3..ad928a2e0 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -79,7 +79,7 @@ jobs:
mise exec -- uv run --frozen --project . --no-sync ruff format --check tools/ci
mise exec -- uv run --frozen --project . --no-sync ruff check --select E,F,I,UP,B tools/ci
mise exec -- uv run --frozen --project . --no-sync ruff check --select E9,F63,F7,F82 tools/mise_tasks
- mise exec -- uv run --frozen --project . --no-sync pytest -q tools/ci/tests --ignore tools/ci/tests/test_required_ci.py --ignore tools/ci/tests/test_public_tree.py
+ mise exec -- uv run --frozen --project . --no-sync pytest -q tools/ci/tests --ignore tools/ci/tests/test_required_ci.py --ignore tools/ci/tests/test_public_tree.py --ignore tools/ci/tests/test_helm_render.py
typescript:
name: CI / TypeScript
@@ -186,6 +186,8 @@ jobs:
-f deploy/helm/sie-cluster/values-aws.yaml
-f deploy/helm/sie-cluster/values-ha.yaml
--set payloadStore.enabled=false >/dev/null
+ - name: Chart render tests
+ run: mise exec -- uv run --frozen --project . pytest -q tools/ci/tests/test_helm_render.py
- run: |
destination="$(mktemp -d)"
mise exec -- helm package deploy/helm/sie-cluster --destination "$destination"
diff --git a/deploy/helm/sie-cluster/README.md b/deploy/helm/sie-cluster/README.md
index aaf711971..fd23e3242 100644
--- a/deploy/helm/sie-cluster/README.md
+++ b/deploy/helm/sie-cluster/README.md
@@ -19,11 +19,13 @@ render with an explicit non-secret payload-store choice:
mise run helm -- dependencies
mise run helm -- lint --set payloadStore.enabled=false
mise run helm -- template --set payloadStore.enabled=false
+mise exec -- uv run --frozen --project . pytest -q tools/ci/tests/test_helm_render.py
```
The task temporarily stages the public model and bundle YAML files into the
chart and removes them after each render. Helm's generated `charts/` directory
-is ignored and must not be committed.
+is ignored and must not be committed. The render tests need that directory, so
+run them after `dependencies`.
## Architecture
@@ -621,15 +623,32 @@ profiles:
request_read_timeout_s: 600
```
+A complete device-group pool follows. Its CPU, memory, and shared-memory sizes
+are placeholders. Size them for the model and the node:
+
```yaml
workers:
pools:
l4-4x-group:
enabled: true
machineProfile: l4-4x
+ gpuType: nvidia-l4
gpu:
count: 4
+ product: NVIDIA-L4
deviceGroup: true
+ shmSize: 32Gi
+ resources:
+ requests:
+ cpu: "16"
+ memory: "64Gi"
+ limits:
+ cpu: "32"
+ memory: "128Gi"
+ bundles:
+ sglang:
+ minReplicas: 0
+ maxReplicas: 1
```
- The worker claims a contiguous block of `tensor_parallel_size` devices for
@@ -645,6 +664,13 @@ workers:
- `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.
+- Every worker pod mounts `/dev/shm` as an in-memory `emptyDir` whose size limit
+ is the pool's `shmSize`, or `workers.common.shmSize` (default `8Gi`) when the
+ pool sets none. Whatever the worker writes there counts against its container
+ memory limit. A tensor-parallel engine runs one process per GPU, and those
+ processes can exchange data through shared memory, so a device-group pool may
+ need a larger `shmSize`. Raise `resources.limits.memory` with it so the limit
+ covers both the engine processes and their shared memory.
- Splitting a model across GPUs on a node without a fast GPU interconnect adds
communication overhead. For a model that fits one GPU, fan-out children
serving replicas usually deliver more throughput for the same GPUs.
diff --git a/deploy/helm/sie-cluster/templates/worker-statefulset.yaml b/deploy/helm/sie-cluster/templates/worker-statefulset.yaml
index c48b1d8d9..293d31698 100644
--- a/deploy/helm/sie-cluster/templates/worker-statefulset.yaml
+++ b/deploy/helm/sie-cluster/templates/worker-statefulset.yaml
@@ -47,6 +47,10 @@ fast at render time.
{{- fail (printf "workers.pools.%s: missing required `bundles:` map. Define at least one bundle under the pool (e.g. `bundles: { default: { minReplicas: 0, maxReplicas: 1 } }`)." $poolName) }}
{{- end }}
{{- $platform := default $root.Values.workers.common.platform $pool.platform }}
+{{- $shmSize := default (dig "shmSize" "" $root.Values.workers.common) (dig "shmSize" "" $pool) | toString | trim }}
+{{- if eq $shmSize "" }}
+{{- fail (printf "workers.pools.%s: the /dev/shm size is empty. Set workers.pools.%s.shmSize or workers.common.shmSize to a Kubernetes quantity (e.g. 8Gi)." $poolName $poolName) }}
+{{- end }}
{{- $payloadStoreUrl := include "sie-cluster.payloadStoreUrl" $root }}
{{- range $bundleName, $bundleCfg := $pool.bundles }}
{{- if dig "enabled" true $bundleCfg }}
@@ -752,7 +756,7 @@ spec:
- name: shm
emptyDir:
medium: Memory
- sizeLimit: 8Gi
+ sizeLimit: {{ $shmSize }}
# Model cache (emptyDir - ephemeral, no zone-lock issues)
- name: model-cache
emptyDir:
diff --git a/deploy/helm/sie-cluster/values.yaml b/deploy/helm/sie-cluster/values.yaml
index 11f7dc631..3a0652b4e 100644
--- a/deploy/helm/sie-cluster/values.yaml
+++ b/deploy/helm/sie-cluster/values.yaml
@@ -506,6 +506,14 @@ workers:
# pressure mid-inference, long before this sizeLimit ever engages.
cacheStorageSize: 300Gi
+ # -- Size limit of the in-memory `/dev/shm` volume (an emptyDir with
+ # `medium: Memory`) mounted into worker containers. It caps the volume
+ # without reserving memory, but whatever a worker writes there counts
+ # against that container's memory limit, so raise a pool's
+ # `resources.limits.memory` together with it. Override per pool with
+ # `workers.pools.<name>.shmSize`. The resolved value must be non-empty.
+ shmSize: 8Gi
+
# -- Optional persistent cache for SGLang/FlashInfer/DeepGEMM/Triton
# compiled kernels. Disabled by default: workers remain cacheless-capable
# and no PVC is required for a normal install. When enabled, every worker
@@ -844,6 +852,12 @@ workers:
# Optional per-pool Rust Candle CUDA compute capability
# override. If omitted, the chart resolves it from
# workers.common.rust.image.computeCapabilityByMachineProfile.
+ # shmSize: Optional override of common.shmSize, the size limit of
+ # the in-memory /dev/shm volume. Writes there count against
+ # the worker container's memory limit. A gpu.deviceGroup
+ # engine runs one process per GPU, and those processes can
+ # exchange data through /dev/shm, so such a pool may need
+ # a larger size and a matching resources.limits.memory.
# tolerations: extra tolerations on top of the chart defaults.
#
# bundles: map keyed by bundle name (matches a bundle in sie_config;
diff --git a/tools/ci/tests/test_helm_render.py b/tools/ci/tests/test_helm_render.py
new file mode 100644
index 000000000..ca53decbf
--- /dev/null
+++ b/tools/ci/tests/test_helm_render.py
@@ -0,0 +1,111 @@
+from __future__ import annotations
+
+import re
+import subprocess
+from pathlib import Path
+
+import pytest
+import yaml
+
+from tools.mise_tasks import helm
+
+ROOT = Path(__file__).resolve().parents[3]
+WORKER_TEMPLATE = "templates/worker-statefulset.yaml"
+
+
+def render_workers(tmp_path: Path, values: dict) -> subprocess.CompletedProcess[str]:
+ values_file = tmp_path / "values.yaml"
+ values_file.write_text(yaml.safe_dump(values), encoding="utf-8")
+ return subprocess.run(
+ [
+ "mise",
+ "exec",
+ "--",
+ "helm",
+ "template",
+ "sie",
+ str(helm.CHART_DIR),
+ "--namespace",
+ "sie",
+ *helm.validation_args(["-f", str(values_file), "--show-only", WORKER_TEMPLATE]),
+ ],
+ cwd=ROOT,
+ capture_output=True,
+ text=True,
+ check=False,
+ )
+
+
+def worker_statefulsets(tmp_path: Path, values: dict) -> list[dict]:
+ result = render_workers(tmp_path, values)
+ assert result.returncode == 0, result.stderr
+ return [doc for doc in yaml.safe_load_all(result.stdout) if doc and doc["kind"] == "StatefulSet"]
+
+
+def shm_volume(statefulset: dict) -> dict:
+ (volume,) = [volume for volume in statefulset["spec"]["template"]["spec"]["volumes"] if volume["name"] == "shm"]
+ return volume["emptyDir"]
+
+
+def shm_size_limits(tmp_path: Path, values: dict) -> dict[str, str]:
+ limits = {}
+ for statefulset in worker_statefulsets(tmp_path, values):
+ volume = shm_volume(statefulset)
+ assert volume["medium"] == "Memory"
+ limits[statefulset["metadata"]["labels"]["sie.superlinked.com/pool"]] = volume["sizeLimit"]
+ return limits
+
+
+def readme_device_group_values() -> dict:
+ readme = (ROOT / helm.CHART_DIR / "README.md").read_text(encoding="utf-8")
+ section = readme.split("### Tensor-Parallel Device Groups\n", 1)[1].split("\n### ", 1)[0]
+ (pool_example,) = [
+ block for block in re.findall(r"```yaml\n(.*?)```", section, flags=re.DOTALL) if block.startswith("workers:")
+ ]
+ return yaml.safe_load(pool_example)
+
+
+def test_worker_shm_defaults_to_8gi(tmp_path: Path) -> None:
+ assert shm_size_limits(tmp_path, {"workers": {"pools": {"l4": {"enabled": True}}}}) == {"l4": "8Gi"}
+
+
+ ("common", "expected"),
+ [
+ ({}, {"l4": "32Gi", "cpu": "8Gi"}),
+ ({"shmSize": "16Gi"}, {"l4": "32Gi", "cpu": "16Gi"}),
+ ],
+)
+def test_pool_shm_size_overrides_the_common_size(tmp_path: Path, common: dict, expected: dict) -> None:
+ pools = {"l4": {"enabled": True, "shmSize": "32Gi"}, "cpu": {"enabled": True}}
+ assert shm_size_limits(tmp_path, {"workers": {"common": common, "pools": pools}}) == expected
+
+
+ "workers",
+ [
+ {"common": {"shmSize": ""}, "pools": {"l4": {"enabled": True}}},
+ {"common": {"shmSize": None}, "pools": {"l4": {"enabled": True}}},
+ {"common": {"shmSize": " "}, "pools": {"l4": {"enabled": True, "shmSize": ""}}},
+ {"pools": {"l4": {"enabled": True, "shmSize": " "}}},
+ ],
+)
+def test_empty_shm_size_fails_the_render(tmp_path: Path, workers: dict) -> None:
+ result = render_workers(tmp_path, {"workers": workers})
+ assert result.returncode != 0
+ assert "workers.pools.l4: the /dev/shm size is empty." in result.stderr
+
+
+def test_readme_device_group_example_renders(tmp_path: Path) -> None:
+ values = readme_device_group_values()
+ ((pool_name, pool),) = values["workers"]["pools"].items()
+ (statefulset,) = worker_statefulsets(tmp_path, values)
+ assert statefulset["metadata"]["labels"]["sie.superlinked.com/pool"] == pool_name
+ assert shm_volume(statefulset)["sizeLimit"] == pool["shmSize"]
+ (worker,) = [
+ container
+ for container in statefulset["spec"]["template"]["spec"]["containers"]
+ if container["name"] == "worker"
+ ]
+ assert worker["resources"]["limits"]["nvidia.com/gpu"] == str(pool["gpu"]["count"])
+ assert worker["resources"]["limits"]["memory"] == pool["resources"]["limits"]["memory"]
diff --git a/tools/ci/tests/test_required_ci.py b/tools/ci/tests/test_required_ci.py
index a5bb05716..c44c81cce 100644
--- a/tools/ci/tests/test_required_ci.py
+++ b/tools/ci/tests/test_required_ci.py
@@ -196,6 +196,15 @@ def test_helm_renders_each_cloud_overlay():
assert "--set payloadStore.enabled=false" in overlay_command
+def test_helm_render_tests_run_after_chart_dependencies():
+ workflow = yaml.safe_load((ROOT / ".github/workflows/ci.yml").read_text())
+ helm_commands = [step.get("run", "") for step in workflow["jobs"]["helm"]["steps"]]
+ render_tests = "mise exec -- uv run --frozen --project . pytest -q tools/ci/tests/test_helm_render.py"
+ assert helm_commands.index("mise run helm -- dependencies") < helm_commands.index(render_tests)
+ python_commands = [step.get("run", "") for step in workflow["jobs"]["python"]["steps"]]
+ assert any("--ignore tools/ci/tests/test_helm_render.py" in command for command in python_commands)
+
+
def test_cpu_lane_uses_cpu_stack_task():
workflow = yaml.safe_load((ROOT / ".github/workflows/ci.yml").read_text())
commands = [step.get("run") for step in workflow["jobs"]["cpu-stack"]["steps"] if "run" in step]