[Bug]: KV cache estimation probe's V2 host tier is bounded by neither `kv_cache_config.host_cache_size` nor the cgroup limit (can be OOM-killed at startup under a 16 GiB cgroup limit)
System Info
- x86_64; 1× NVIDIA H200 (143771 MiB), driver 580.65.06
- Container
nvcr.io/nvidia/tensorrt-llm/release:1.3.0rc29(TensorRT-LLM 1.3.0rc29),trtllm-serve - Slurm job, cgroup v2
memory.max= 16 GiB,swap.max= 0
Who can help?
No response
Information
- [ ] The official example scripts
- [ ] My own modified scripts
Tasks
- [ ] An officially supported task in the
examplesfolder (such as GLUE/SQuAD, ...) - [ ] My own task or dataset (give details below)
Reproduction
1.3.0rc29 container, trtllm-serve Llama-3.1-8B-Instruct bf16, TP=1, 1× H200, under a cgroup v2 memory limit of 16 GiB with no swap (Slurm --mem=16G). Six interleaved starts per arm. Not every default-arm start is OOM-killed; see the last paragraph of actual behavior.
cfg.yaml:
kv_cache_config:
host_cache_size: 1073741824
Default arm (estimation on):
trtllm-serve serve <path/to/Llama-3.1-8B-Instruct> --host 127.0.0.1 --port <port> --log_level info --no-telemetry --config cfg.yaml
Skip-estimation arm: the same command with TRTLLM_SKIP_KV_CACHE_ESTIMATION=1 set in the environment.
Expected behavior
KV cache estimation should not cause a startup OOM when the configured host_cache_size fits within the cgroup limit, however much memory the rest of the node has free: here the same launch with estimation skipped came up 6/6 with a 1.00 GiB host tier. One option is to bound the probe's auto tier by host_cache_size when one is set; another is for the auto path to use the cgroup-aware effective_available_host_memory() in _torch/models/checkpoints/hf/rank_striped_read_ahead.py:183.
actual behavior
With KVCacheManagerV2, an explicit kv_cache_config.host_cache_size does not bound host memory during KV cache estimation. The estimation pass deliberately leaves the budget unset for its probe managers (_drop_explicit_offload_tier_budgets, added in https://github.com/NVIDIA/TensorRT-LLM/pull/17850 so that probes stop pinning the full configured host tier), so the probe falls back to the auto host tier, which it sizes and pins as min(probe device quota, SC_AVPHYS_PAGES × page size / local ranks / 2, memlock × 0.8) (kv_cache_manager_v2.py:425-432, :1656). Neither the configured budget nor the cgroup memory limit enters that bound. SC_AVPHYS_PAGES is node-wide free memory (it equalled MemFree on our nodes), so that term tracks what the whole node has free, not the cgroup's headroom.
In this run TRT-LLM logged 141.6–156.3 GiB of available host memory, so the device-quota term was the binding one (17.37 GiB; the SC_AVPHYS_PAGES term was 71–78 GiB):
| arm | probe host tier (log) | result |
|---|---|---|
| default (estimation on) | 17.37 GiB | 6/6 OOM-killed during profiling_kv_cache_allocation (cgroup oom_kill +1 each) |
TRTLLM_SKIP_KV_CACHE_ESTIMATION=1 |
no probe; host tier 1.00 GiB | 6/6 ready in 72–74 s, no OOM |
In a separate run with host_cache_size = 8 GiB under --mem=48G, all six starts came up, but every probe tier exceeded the budget: 11.3–17.4 GiB, with the SC_AVPHYS_PAGES term binding in two of them (11.32 and 16.84 GiB).
The OOM does not always happen. In a later job with the same container, model, config and 16 GiB cgroup, a default-arm start logged 14.22 GiB of available host memory, sized the probe tier at 7.11 GiB, and became ready in 88.9 s with no OOM kill. A start is OOM-killed when the auto tier does not fit in the cgroup's remaining headroom. To test this, we overrode only the SC_AVPHYS_PAGES value in the tier sizing, alternating starts in a separate job on one node: starts with a 17.00 GiB probe tier were OOM-killed 3/3, and starts with a 4.00 GiB tier came up 3/3. Here the tier is half of that value (node MemFree, as above) until it reaches the device quota, so whether a start is OOM-killed depends on node free memory at probe time.
additional notes
main fced9ff98 has the same code (_util.py:2829-2833, kv_cache_manager_v2.py:425-432, :1656; line numbers in this issue are from that commit); the runs were on rc29. Open #19650 changes when host-tier pages are committed; I have not tested it.
Before submitting a new issue...
- [X] Make sure you already searched for relevant issues, and checked the documentation and examples for answers to frequently asked questions.
Estimation clears the configured host_cache_size before V2 auto sizing, so the probe can exceed the explicit cap. The prepared fix retains the target/draft shares, uses min(existing_auto_quota, configured_share), and applies the existing fleet minimum. The same 94 CPU regressions give 27 failed / 67 passed before and 94 passed after.
This scope preserves existing automatic safety bounds and excludes cgroup-aware automatic sizing. It does not claim to reproduce the reported H200 startup failure. Would an engineer approve this explicit-cap scope for a PR?
Allocation edge cases, test coverage and environment limits
Zero shares participate in the reduction. If cache costs are unavailable, the estimation target retains the cap and the draft host tier is disabled, avoiding duplicate use of the budget. Host backing and resize behavior are unchanged.
Changed-file pre-commit passes. The broader three-module CPU run has 275 passes and nine failures: eight budget-fixture failures also occur on the original source, and an existing MPI-spawn test times out locally. Tests use actual checkout modules and normal initialization of official native wheel 1.4.0rc1.dev202610140007, Python 3.12 and PyTorch 2.14.0+cu132, with CUDA hidden. The wheel is 13 commits older than Python base 681cff123; intervening C++ changes are three CMake files. No GPU serving or successful multi-rank MPI result is claimed.
AI tools assisted implementation, testing, and documentation.