Skip to content

[HiCache] Fall back to host memory when no cgroup fs is mounted - #42120

Merged
merrymercy merged 1 commit into
sgl-project:mainfrom
raghotham:hicache-host-memory-no-cgroupfs
Oct 2, 2026
Merged

merrymercy merged 1 commit into
sgl-project:mainfrom
raghotham:hicache-host-memory-no-cgroupfs

Conversation

@raghotham

@raghotham raghotham commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

HiCache sizes its host pool from available_host_memory_bytes(), which bounds psutil's available memory by the process's cgroup headroom. If the process belongs to a cgroup but no cgroup/cgroup2 filesystem is mounted (for example, a container that shares the host cgroup namespace without mounting cgroupfs), discovery raises

RuntimeError: Cannot locate the process memory cgroup in mounted cgroup filesystems

and the server fails to start whenever a HiCache host pool is created. There was also no way to give the budget directly.

Modifications

  • mem_cache/host_memory.py
    • No cgroup filesystem mounted at all: no limit is visible, so log a one-time warning and size against host available memory instead of raising.
    • A cgroup filesystem is mounted but doesn't contain the process: still raise, since that may hide a real limit. The message now points to the override below.
    • SGLANG_HICACHE_HOST_MEMORY_BYTES: when set, available_host_memory_bytes() returns it and skips both cgroup and psutil discovery. The existing reserve and per-local-rank split in pool_host/base.py still apply. Values <= 0 raise ValueError.
  • environ.py: registers SGLANG_HICACHE_HOST_MEMORY_BYTES (EnvInt, default unset).

Behavior is unchanged when cgroup discovery succeeds, and when no cgroup membership is present.

Tests

test/registered/unit/mem_cache/test_host_memory.py drives available_host_memory_bytes() through the real discovery code over a synthetic procfs:

  • cgroup membership with no cgroupfs mounted (v1 and v2) returns host available memory;
  • the explicit budget is returned even in a layout where discovery would raise, and 0 is rejected;
  • a mounted but unmatched cgroup still raises, and the error names the variable.

These replace the old test that expected an empty mountinfo to raise. All three fail without the change.

Ran locally:

  • pytest test/registered/unit/mem_cache/test_host_memory.py: 9 passed (13 subtests).
  • ruff 0.15.1 check/format, isort 7.0.0 and codespell 2.4.1 on the changed files: clean.

GPU and e2e tests were not run locally.


CI States

Latest PR Test (Base): ✅ Run #36918037160
Latest PR Test (Extra): ❌ Run #36920089666
Latest PR Test (AMD ROCm 10): ❌ Run #36918036853

HiCache sizes its host pool from available_host_memory_bytes(), which
bounds psutil's available memory by the process's cgroup headroom. When
the process belongs to a cgroup but no cgroup or cgroup2 filesystem is
mounted (for example a container that shares the host cgroup namespace
without mounting cgroupfs), discovery raised "Cannot locate the process
memory cgroup in mounted cgroup filesystems" and the engine failed to
start.

- If no cgroup filesystem is mounted at all, no limit is visible: log a
  one-time warning and size against host available memory.
- A mounted cgroup filesystem that does not contain the process still
  raises, since it may hide a real limit; the error now names the
  override below.
- New SGLANG_HICACHE_HOST_MEMORY_BYTES sets the host memory budget
  directly and skips cgroup and psutil discovery. The existing reserve
  and per-local-rank split still apply. Values <= 0 are rejected.

Tests exercise available_host_memory_bytes() over a synthetic procfs:
no cgroupfs (v1 and v2), the explicit budget where discovery would
raise, and a mounted but unmatched cgroup.
@github-actions github-actions Bot added the hicache Hierarchical Caching for SGLang label Oct 1, 2026
@metamergebot metamergebot added the run-ci CI: run the baseline test suite on this PR label Oct 1, 2026
@metamergebot

metamergebot commented Oct 1, 2026 •

Copy link
Copy Markdown
Collaborator

This port clears our bar on 489a69413d2b6ca9311d14ffdc1f455787af5e42: every base-a and base-b job is green.
base-c and the accelerator suites are reported but not gated, because they run
on scarce hardware and upstream merges through them routinely.

gate 20✓✗6 lint✓ build✓ A✓ B✓ C 0/10⏳ other✓ · accel ✗amd,mlx,musa

@merrymercy @raghotham — could one of you take a look and merge it if you are happy? Nothing else is waiting on our side.

@merrymercy
merrymercy merged commit a64725d into sgl-project:main Oct 2, 2026
233 of 255 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hicache Hierarchical Caching for SGLang run-ci CI: run the baseline test suite on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants