You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Bug]: 142 GiB/rank host memory leak (leading to host OOM if KV cache offloading is enabled) when serving Kimi-K2.6-NVFP4 TP4 on GB300 (aarch64), due to MetaInitException on aten.fill_.Scalar (nn.LayerNorm init) silently falling back to whole-model CPU construction #16086
Container: nvcr.io/nvidia/tensorrt-llm/release:1.3.0rc4 (also reproduces on current main — the relevant code is unchanged)
torch: 2.10 NGC build (CPU allocator = mimalloc v2.2.4 on aarch64, enabled by Enable mimalloc on non-Windows platforms and make default for AArch64 builds pytorch/pytorch#164741 — note that PR shows as Closed because pytorch merges via pytorchmergebot, and it was briefly reverted then relanded the same day 2025-10-09; current pytorch main still sets USE_MIMALLOC ON for CPU_AARCH64 in CMakeLists.txt, and the NGC build logs mimalloc: v2.2.4 under MIMALLOC_VERBOSE=1)
Model: nvidia/Kimi-K2.6-NVFP4 (≈554 GB checkpoint; any model whose modules construct stock nn.LayerNorm is affected)
Anyone familiar with the PyTorch-backend model loader / MetaInitMode (tensorrt_llm/_torch/models/modeling_utils.py).
Information
The official example scripts
My own modified scripts
Tasks
My own task or dataset (give details below)
Reproduction
Trigger (any platform, CPU-only, a few seconds):
importtorch.nnasnnfromtensorrt_llm._torch.models.modeling_utilsimportMetaInitModewithMetaInitMode():
nn.LayerNorm(64) # raises MetaInitException: Meta tensor used in unsupported function: aten.fill_.Scalar
Deployment-scale consequence (aarch64):
Serve a large checkpoint whose model constructs nn.LayerNorm in __init__ (e.g. Kimi-K2.6's vision tower) with the PyTorch backend on an aarch64 node.
Engine log shows, once per rank per start (at info level only): Fallback to regular model init: ... MetaInitException: Meta tensor used in unsupported function: aten.fill_.Scalar
After weights land on GPU, check grep RssAnon /proc/<rank_pid>/status (RssAnon = anonymous resident set size, the process's actual physical-RAM footprint from heap/allocator arenas): each rank retains a weight-shard-sized private-anonymous region for process lifetime (137-142 GiB/rank for the ≈554 GB TP4 checkpoint; ≈568 GiB/node, 54% of host RAM), invisible to allocator statistics.
Allocator discriminator proving the pages are freed-but-retained (no rebuild):
Meta init survives value-irrelevant in-place initializers (fill_/zero_) that stock torch modules run in __init__; the model constructs on the meta device; no CPU materialization of the weights; host memory after load is a few GiB per rank.
actual behavior
MetaInitMode raises on aten.fill_.Scalar / aten.zero_.default, the loader's broad except Exception silently constructs the ENTIRE model on CPU memory, and on aarch64 the freed CPU copy is retained by mimalloc for process lifetime:
142 GiB/rank of dead (freed-but-retained) host memory, ≈568 GiB per node, for the ≈554 GB TP4 checkpoint;
KvCacheConfig.host_cache_size cannot be raised beyond ≈30 GB/rank without host OOM, on a node that should support 150 GB+/rank;
load time also regresses on every platform (full CPU init instead of meta skeleton).
Root cause of the retention half is upstream of TensorRT-LLM (mimalloc v2.2.4 arena purge gate; same class as the open pytorch/pytorch#178726, proposed fix pytorch/pytorch#178851) — but TensorRT-LLM turns a benign in-place init into that trap by aborting meta init on ops whose results are never consumed.
additional notes
A fix PR is filed right after this issue (branch Weili-0234/TensorRT-LLM:fix-metainit-inplace-init-ops, will be auto-linked here): add a deterministic_init_ops pass-through (fill_.Scalar, fill_.Tensor, zero_.default) to MetaInitMode, plus regression tests (tests/unittest/_torch/models/test_meta_init_mode.py). Red/green verified on a GB300 node with the rc4 image: 3 failed + 1 passed before, 4 passed after.
Searchable log signatures for others hitting this: Fallback to regular model init, MetaInitException: Meta tensor used in unsupported function: aten.fill_.Scalar, unexplained per-rank physical memory (RssAnon) ≈ weight-shard size on Grace (GB200/GB300).
Suggested follow-up (not in the PR): log the whole-model CPU fallback at warning instead of info — at production log levels the fallback is currently invisible, which is why this took a full allocation-stack investigation to find.
System Info
nvcr.io/nvidia/tensorrt-llm/release:1.3.0rc4(also reproduces on currentmain— the relevant code is unchanged)mainstill setsUSE_MIMALLOC ONforCPU_AARCH64inCMakeLists.txt, and the NGC build logsmimalloc: v2.2.4underMIMALLOC_VERBOSE=1)nvidia/Kimi-K2.6-NVFP4(≈554 GB checkpoint; any model whose modules construct stocknn.LayerNormis affected)tensorrt_llm._torch), KV cache host offloading enabled (KvCacheConfig.host_cache_size)Who can help?
Anyone familiar with the PyTorch-backend model loader /
MetaInitMode(tensorrt_llm/_torch/models/modeling_utils.py).Information
Tasks
Reproduction
Trigger (any platform, CPU-only, a few seconds):
Deployment-scale consequence (aarch64):
nn.LayerNormin__init__(e.g. Kimi-K2.6's vision tower) with the PyTorch backend on an aarch64 node.infolevel only):Fallback to regular model init: ... MetaInitException: Meta tensor used in unsupported function: aten.fill_.Scalargrep RssAnon /proc/<rank_pid>/status(RssAnon = anonymous resident set size, the process's actual physical-RAM footprint from heap/allocator arenas): each rank retains a weight-shard-sized private-anonymous region for process lifetime (137-142 GiB/rank for the ≈554 GB TP4 checkpoint; ≈568 GiB/node, 54% of host RAM), invisible to allocator statistics.Expected behavior
Meta init survives value-irrelevant in-place initializers (
fill_/zero_) that stock torch modules run in__init__; the model constructs on the meta device; no CPU materialization of the weights; host memory after load is a few GiB per rank.actual behavior
MetaInitModeraises onaten.fill_.Scalar/aten.zero_.default, the loader's broadexcept Exceptionsilently constructs the ENTIRE model on CPU memory, and on aarch64 the freed CPU copy is retained by mimalloc for process lifetime:KvCacheConfig.host_cache_sizecannot be raised beyond ≈30 GB/rank without host OOM, on a node that should support 150 GB+/rank;Root cause of the retention half is upstream of TensorRT-LLM (mimalloc v2.2.4 arena purge gate; same class as the open pytorch/pytorch#178726, proposed fix pytorch/pytorch#178851) — but TensorRT-LLM turns a benign in-place init into that trap by aborting meta init on ops whose results are never consumed.
additional notes
Weili-0234/TensorRT-LLM:fix-metainit-inplace-init-ops, will be auto-linked here): add adeterministic_init_opspass-through (fill_.Scalar,fill_.Tensor,zero_.default) toMetaInitMode, plus regression tests (tests/unittest/_torch/models/test_meta_init_mode.py). Red/green verified on a GB300 node with the rc4 image: 3 failed + 1 passed before, 4 passed after.Fallback to regular model init,MetaInitException: Meta tensor used in unsupported function: aten.fill_.Scalar, unexplained per-rank physical memory (RssAnon) ≈ weight-shard size on Grace (GB200/GB300).warninginstead ofinfo— at production log levels the fallback is currently invisible, which is why this took a full allocation-stack investigation to find.