Skip to content

CUDA on GB10: the memory budget is at most CUDA's free memory, after the checkpoint's cached pages are dropped - #3192

Merged
ashhart merged 5 commits into
mainfrom
lead/gb10-admission-card-free
Nov 21, 2026
Merged

ashhart merged 5 commits into
mainfrom
lead/gb10-admission-card-free

Conversation

@ashhart

@ashhart ashhart commented Nov 13, 2026

Copy link
Copy Markdown
Owner

On a GB10 (unified memory, Linux), the CUDA start-up budget came from /proc/meminfo alone. MemAvailable counts the page cache, and CUDA can't allocate those pages until the kernel reclaims them. After one 60 GB checkpoint read, CUDA reported 60.17 GiB free and MemAvailable was 115.85 GiB. Admission granted 103.44 GiB, 43.27 GiB more than CUDA's free figure.

What changes on unified Linux

  • Both CUDA admission readers now take the smaller of the host figure (MemAvailable plus the per-CPU free pages) and the free memory CUDA reports, then subtract the same reserve as before (a tenth of RAM, at least 4 GiB, or TENSORFOLD_MEMORY_RESERVE_GIB). The second reader serves the Qwen3 embedding and reranker engine and the speech engine.
  • Before the weights check, the server advises POSIX_FADV_DONTNEED on the checkpoint's own shards: the files its weight map names inside the model folder, or model*.safetensors when there's no index. Without this, a checkpoint that was just downloaded or read could be refused because of its own cached pages. Only clean cached pages are dropped; no file's bytes change. An index naming a file outside the folder drops nothing, and other files and the rest of the page cache are left alone. The advice goes through the same path as the existing post-load release, so it waits while a tensor-parallel load is in flight.
  • There is no second drop after loading. Each loader already releases its load-only pages and keeps the ranges it reads while serving (CUDA: every loader drops its checkpoint from the page cache after load (part of #1868) #1884).
  • The docs' description of the unified-memory budget is updated to match.

What stays the same

  • Discrete cards and Windows keep their own counts exactly. The bound passes their figure through unchanged, and the drop only runs on an integrated device under Linux. Metal and HIP don't use this code.
  • Replies keep their tokens. Admission only decides how many streams and how much cache fit; it never touches arithmetic.

Tests (host, no GPU)

  • The 6 Nov figures are replayed: MemAvailable 115.85 GiB, CUDA 60.17 GiB free, the 12.41 GiB reserve that the 103.44 GiB grant implies. The pool's free is now CUDA's 60.17 GiB and its room is 47.76 GiB.
  • A discrete card's free is taken as reported on Linux and Windows, and /proc is never read.
  • The per-CPU parked share only counts the part that lies within CUDA's free.
  • The shard drop advises each named shard once and leaves its bytes unchanged. It skips a stray file and passes over a missing shard, and an index that points outside the folder advises nothing.
  • Linux CUDA host and device-test compiles are clean.

Still owed: a GB10 device check. It should reproduce the cached state (read a checkpoint's shards, then serve) and confirm that the budget stays at or below CUDA's free less the reserve, and that the page cache drops by about the checkpoint's size before the load. After a fresh boot, the budget should be compared with main's. It should also confirm that greedy token_sha256 equals main's and compare load time.

Part of #1857. Thanks to @mimeding for the 19-job series and the pre-launch release-and-check approach that this follows.

  • Synthena (Ash's Agent)

… 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
ashhart force-pushed the lead/gb10-admission-card-free branch from 0662546 to 6ffb177 Compare November 21, 2026 06:19
@ashhart
ashhart merged commit 97ce314 into main Nov 21, 2026
2 of 11 checks passed
@ashhart
ashhart deleted the lead/gb10-admission-card-free branch November 21, 2026 06:19
ashhart added a commit that referenced this pull request Nov 21, 2026
ashhart added a commit to Bizuayeu/TensorFold that referenced this pull request Nov 21, 2026
ashhart added a commit to Bizuayeu/TensorFold that referenced this pull request Nov 21, 2026
ashhart added a commit to Ch0mpaa/TensorFold that referenced this pull request Nov 21, 2026
ashhart added a commit to Ch0mpaa/TensorFold that referenced this pull request Nov 21, 2026
ashhart added a commit that referenced this pull request Nov 21, 2026
ashhart added a commit that referenced this pull request Nov 21, 2026
#3192 caps a GB10's start-up budget at CUDA's reported free memory and
drops the checkpoint's shards from the page cache before the load. On a
GB10 with Flash Next NVFP4, 1.3.3 then refuses --parallel 8 at a 73,728-token
window (needs 19.94 GiB, budget 18.14 GiB) that 1.3.2 serves, and its first
cold 32K prompt is 5.4% slower. It stays on main for a fix.
ashhart added a commit that referenced this pull request Nov 21, 2026
ashhart added a commit that referenced this pull request Nov 22, 2026
Unreleased: the five (#N) placeholders get their PR numbers, the two (#PR)
duplicates go, #3192's line goes (#4427 replaced that behaviour on main and
its line refs #3192), #3960 is named as the PR that landed #2799, and the
penalty under --instruct-sampling card; ?token= Web addresses and pull's
digest and size checks).

Sixteen PRs merged 20-21 Nov with no line anywhere: a blank lines file
replaced each PR's own line at landing. #4321 and #4322 go under
Unreleased, the twelve that shipped in 1.3.3 under 1.3.3, and the two
1.3.1 lines that carried no PR number get #3941 and #4022.

docs/environment.md: Flash Next checks 37 settings, and TF_GLM_INDEX_SPLIT
(registered by #4510) gets its row.
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