Repository navigation
Description
Native HF checkpoint prefetch uses host-wide available memory. A load rejected by rank-striped read-ahead because of its cgroup memory budget can enter native fallback and start full-checkpoint prefetch using the larger host budget.
System Info
- Source:
mainat1e84796dd310a3ee199a73a500f389b5fe08acbe. - Controlled source-decision reproduction:
a40d97aa57446ad014f4be5c8d857502bd8fce36;weight_loader.pyandrank_striped_read_ahead.pyare unchanged at the current commit above. - Reproduction environment: macOS, arm64, Python standard-library source execution with controlled memory observations and MPI/I/O callbacks.
- Injected values: host available memory 256 GiB, cgroup available memory 32 GiB, checkpoint logical size 64 GiB. These are controlled inputs. The checkpoint file was sparse, with zero allocated payload bytes.
- GPU, driver, CUDA, TensorRT and container versions: N/A for the source-decision reproduction. Full installed-runtime and real Linux cgroup validation remain pending.
Who can help?
Checkpoint loading maintainers.
Information
- My own modified scripts
Tasks
- My own task or dataset (give details below)
Controlled HF checkpoint prefetch admission and native fallback reproduction.
Reproduction
The relevant paths are:
effective_available_host_memory()combines host availability with the tightest remaining cgroup limit, including ancestors andmemory.high.- Rank-striped preflight and admission use that value. An ineligible load enters
_fallback_to_native(). - Native loading and prefetch call
_get_local_available_host_memory(), which readspsutil.virtual_memory().availabledirectly.
This short replay requires TensorRT-LLM and its dependencies installed at the cited revision. It calls the two availability getters and prints the admission predicates with TLLM_OVERRIDE_LAYER_NUM=0. The full installed-runtime replay remains pending; the controlled source execution produced the values in the table below.
from types import SimpleNamespace
from unittest.mock import patch
from tensorrt_llm._torch.models.checkpoints.hf import rank_striped_read_ahead as read_ahead
from tensorrt_llm._torch.models.checkpoints.hf import weight_loader
GiB = 1 << 30
checkpoint_bytes = 64 * GiB
with (
patch.object(weight_loader, "ENABLE_MULTI_DEVICE", False),
patch.object(
read_ahead.psutil,
"virtual_memory",
return_value=SimpleNamespace(available=256 * GiB),
),
patch.object(read_ahead, "cgroup_available_host_memory", return_value=32 * GiB),
):
effective = read_ahead.effective_available_host_memory()
native = weight_loader.HfWeightLoader._get_local_available_host_memory()
admitted, headroom = read_ahead.memory_admission(checkpoint_bytes, effective)
print("effective available GiB:", effective / GiB)
print("native available GiB:", native / GiB)
print("rank-striped admitted:", admitted)
print("rank-striped headroom GiB:", headroom / GiB)
print("native prefetch enabled:", checkpoint_bytes < native * 0.9)Expected behavior
Native prefetch should use the existing cgroup-aware availability helper, including after rank-striped fallback. With the controlled 32 GiB cgroup availability and 64 GiB checkpoint, native prefetch should be skipped and normal weight loading should continue. The existing native 90% threshold, local MPI.MIN, barrier ordering and cache-hit collective mirroring should remain unchanged.
Actual behavior
| Controlled source decision | Result |
|---|---|
| Effective available memory | 32 GiB |
| Rank-striped startup headroom | 16 GiB |
| Rank-striped admission | Rejected |
| Native available memory | 256 GiB |
| Native prefetch condition | 64 < 0.9 * 256, enabled |
Executing the current native and fallback methods with the sparse checkpoint and controlled I/O callbacks recorded one prefetch call for each path. Substituting the existing effective_available_host_memory() call in the native getter reduced that count to zero for both paths; the subsequent load callback ran in both versions. Controlled communicator scenarios retained the MIN reduction followed by the barrier, including cache-hit mirroring.
Additional notes
The observed issue is the prefetch admission decision. Real cgroup pressure, reclaim activity, OOM behavior, payload loading and startup latency have not been measured. Eager SafeTensors loading is the affected path; model-specific lazy SafeTensors loading bypasses this prefetch gate.
The bounded-buffer prefetch work in #17430 and #15711 addresses temporary anonymous allocations. This report concerns the availability value used before prefetch begins.
Could a TensorRT-LLM engineer approve a focused fix that reuses effective_available_host_memory() inside _get_local_available_host_memory()? The proposed scope preserves the native threshold and MPI/cache contracts and leaves rank-striped memory_admission() policy unchanged.
Activity
[None][fix] Add native prefetch cgroup-budget regression test and doc…