Skip to content

CUDA: every loader drops its checkpoint from the page cache after load (part of #1868) - #1884

Merged
ashhart merged 2 commits into
mainfrom
lead/cuda-drop-load-cache
Nov 2, 2026
Merged

ashhart merged 2 commits into
mainfrom
lead/cuda-drop-load-cache

Conversation

@ashhart

@ashhart ashhart commented Nov 2, 2026 •

Copy link
Copy Markdown
Owner

Part of #1868.

1.2.1 fixed Flash Next: a loaded server left its checkpoint in the page cache, which on a GB10 is the GPU's memory too. Every other CUDA loader did the same: a served Qwen3.8-27B keeps its whole 15 GiB checkpoint cached. Each family now releases its checkpoint's pages at its existing close boundary, after the last read: drafters, MTP heads, vision towers, tensor-parallel ranks and learners included. Files read at runtime are kept: Flash Next's PLE rows, DeepSeek's Engram tables and MOSS-Image's mapping. Heap copies are skipped, so no live reader can lose bytes; nothing else changes, so tokens can't.

An independent review found it safe to land. Two gaps follow in their own PR: Qwen4 dense on CUDA, and tensor-parallel ranks on one machine that share a page cache.

Release each temporary checkpoint at its existing close boundary, including
separate vision, MTP and draft weights. Drop completed DeepSeek pack and
prepared reads, retaining the live PLE files and mixed PLE shards.

Add host checks for family cleanup scopes, release order, explicit shard
lists and runtime file exclusions. GPU arithmetic and runtime readers are
unchanged.
@ashhart
ashhart force-pushed the lead/cuda-drop-load-cache branch from 68598da to ee6985b Compare November 2, 2026 01:57
@ashhart
ashhart merged commit 7cf02bd into main Nov 2, 2026
13 checks passed
@ashhart
ashhart deleted the lead/cuda-drop-load-cache branch November 10, 2026 16:34
ashhart added a commit that referenced this pull request Nov 18, 2026
… checkpoint leaves the page cache

On a GB10 the memory admission read /proc/meminfo alone. MemAvailable counts the page cache, which CUDA can't
allocate until the kernel reclaims it: after one 60 GB checkpoint read CUDA reported 60.17 GiB free against
MemAvailable's 115.85 GiB, and admission granted 103.44 GiB, 43.27 GiB above CUDA's figure (#1857).

Both admission readers, poolFor and readPool (the Qwen3 embedding and reranker engine, the speech engine's limit),
now take the smaller of the host figure and CUDA's free (cuda_memory.boundFree), less the same reserve. The parked
share is the part of that free above MemAvailable, so its debug line stays true.

Before the weights check, the CUDA open on an integrated device advises POSIX_FADV_DONTNEED on the shards core's
loader opens (checkpoint.shardFiles: the weight map's files inside the model folder, else model*.safetensors)
through checkpoint_cache.drop, so a checkpoint just downloaded or read is not refused for its own cached pages.
Only clean cached pages go; no file's bytes change, and an index naming a file outside the folder drops nothing.
After the load no second drop runs: each loader's own release (#1884) has dropped its load-only pages already and
keeps the ranges it reads at run time, such as Flash Next's n-gram rows.

Discrete cards and Windows keep their counts (boundFree passes them through and the drop never runs off an
integrated Linux device); Metal and HIP don't reach this code. Admission sizes streams and caches only, so
replies keep their tokens. The docs' unified-memory budget says the same. Host tests replay the 6 Nov figures;
a GB10 device check is owed.
ashhart added a commit that referenced this pull request Nov 19, 2026
… checkpoint leaves the page cache

On a GB10 the memory admission read /proc/meminfo alone. MemAvailable counts the page cache, which CUDA can't
allocate until the kernel reclaims it: after one 60 GB checkpoint read CUDA reported 60.17 GiB free against
MemAvailable's 115.85 GiB, and admission granted 103.44 GiB, 43.27 GiB above CUDA's figure (#1857).

Both admission readers, poolFor and readPool (the Qwen3 embedding and reranker engine, the speech engine's limit),
now take the smaller of the host figure and CUDA's free (cuda_memory.boundFree), less the same reserve. The parked
share is the part of that free above MemAvailable, so its debug line stays true.

Before the weights check, the CUDA open on an integrated device advises POSIX_FADV_DONTNEED on the shards core's
loader opens (checkpoint.shardFiles: the weight map's files inside the model folder, else model*.safetensors)
through checkpoint_cache.drop, so a checkpoint just downloaded or read is not refused for its own cached pages.
Only clean cached pages go; no file's bytes change, and an index naming a file outside the folder drops nothing.
After the load no second drop runs: each loader's own release (#1884) has dropped its load-only pages already and
keeps the ranges it reads at run time, such as Flash Next's n-gram rows.

Discrete cards and Windows keep their counts (boundFree passes them through and the drop never runs off an
integrated Linux device); Metal and HIP don't reach this code. Admission sizes streams and caches only, so
replies keep their tokens. The docs' unified-memory budget says the same. Host tests replay the 6 Nov figures;
a GB10 device check is owed.
ashhart added a commit that referenced this pull request Nov 21, 2026
… checkpoint leaves the page cache

On a GB10 the memory admission read /proc/meminfo alone. MemAvailable counts the page cache, which CUDA can't
allocate until the kernel reclaims it: after one 60 GB checkpoint read CUDA reported 60.17 GiB free against
MemAvailable's 115.85 GiB, and admission granted 103.44 GiB, 43.27 GiB above CUDA's figure (#1857).

Both admission readers, poolFor and readPool (the Qwen3 embedding and reranker engine, the speech engine's limit),
now take the smaller of the host figure and CUDA's free (cuda_memory.boundFree), less the same reserve. The parked
share is the part of that free above MemAvailable, so its debug line stays true.

Before the weights check, the CUDA open on an integrated device advises POSIX_FADV_DONTNEED on the shards core's
loader opens (checkpoint.shardFiles: the weight map's files inside the model folder, else model*.safetensors)
through checkpoint_cache.drop, so a checkpoint just downloaded or read is not refused for its own cached pages.
Only clean cached pages go; no file's bytes change, and an index naming a file outside the folder drops nothing.
After the load no second drop runs: each loader's own release (#1884) has dropped its load-only pages already and
keeps the ranges it reads at run time, such as Flash Next's n-gram rows.

Discrete cards and Windows keep their counts (boundFree passes them through and the drop never runs off an
integrated Linux device); Metal and HIP don't reach this code. Admission sizes streams and caches only, so
replies keep their tokens. The docs' unified-memory budget says the same. Host tests replay the 6 Nov figures;
a GB10 device check is owed.
ashhart added a commit that referenced this pull request Nov 21, 2026
… checkpoint leaves the page cache

On a GB10 the memory admission read /proc/meminfo alone. MemAvailable counts the page cache, which CUDA can't
allocate until the kernel reclaims it: after one 60 GB checkpoint read CUDA reported 60.17 GiB free against
MemAvailable's 115.85 GiB, and admission granted 103.44 GiB, 43.27 GiB above CUDA's figure (#1857).

Both admission readers, poolFor and readPool (the Qwen3 embedding and reranker engine, the speech engine's limit),
now take the smaller of the host figure and CUDA's free (cuda_memory.boundFree), less the same reserve. The parked
share is the part of that free above MemAvailable, so its debug line stays true.

Before the weights check, the CUDA open on an integrated device advises POSIX_FADV_DONTNEED on the shards core's
loader opens (checkpoint.shardFiles: the weight map's files inside the model folder, else model*.safetensors)
through checkpoint_cache.drop, so a checkpoint just downloaded or read is not refused for its own cached pages.
Only clean cached pages go; no file's bytes change, and an index naming a file outside the folder drops nothing.
After the load no second drop runs: each loader's own release (#1884) has dropped its load-only pages already and
keeps the ranges it reads at run time, such as Flash Next's n-gram rows.

Discrete cards and Windows keep their counts (boundFree passes them through and the drop never runs off an
integrated Linux device); Metal and HIP don't reach this code. Admission sizes streams and caches only, so
replies keep their tokens. The docs' unified-memory budget says the same. Host tests replay the 6 Nov figures;
a GB10 device check is owed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant