Skip to content

CUDA: Qwen4 and tensor-parallel loaders drop the checkpoint's pages after every rank is ready - #1887

Merged
ashhart merged 4 commits into
mainfrom
lead/s179-tp-drop
Nov 4, 2026
Merged

ashhart merged 4 commits into
mainfrom
lead/s179-tp-drop

Conversation

@ashhart

@ashhart ashhart commented Nov 2, 2026

Copy link
Copy Markdown
Owner

Follow-up to #1884 for #1868, closing the two gaps an independent review of #1884's change found.

What changes

  • Qwen4 on CUDA now drops its load-only checkpoint shards from the page cache after placement and metadata, as the other CUDA families do since CUDA: every loader drops its checkpoint from the page cache after load (part of #1868) #1884. It keeps the CPU embedding and PLE lookup shards, mixed shards and aliases, since those stay in use while serving.
  • Tensor parallel. All five TP loaders (Flash Next, DeepSeek-V4.1, GLM, MiniMax and Nemotron) now drop their pages only after every rank reports its load ready. Before, a rank that finished first could drop pages another rank on the same host was still reading through the shared page cache.

A failed start can't hang on this. The drop never waits on its own: the waits are the existing bounded exchanges, and a rank that fails closes without dropping anything.

Checks

  • Host: the loader tests and the lean check (424 problems before and after).
  • An independent review of every changed loader: LAND after a TP device run.
  • Device: a TP=2 load on two GB10s, comparing free memory after load and replies against main. Results will be posted here before this lands.

Replies stay the same tokens; only page-cache advice changes.

@cwschroeder

Copy link
Copy Markdown
Contributor

The Windows job on c60da330fd19c0a3238ab4b622f086b0514c4888 fails to compile checkpoint_drop.zig: lines 69 and 75 pass the Windows *anyopaque file handle to linux.close and linux.fadvise, which require i32. The reference chain is Load.finish() → Queue.end() → those Linux helpers. finish() and deinit() only check the runtime active field, so they still instantiate this path on Windows even though begin() returns inactive there. An OS guard on those entry points should keep the Linux queue out of non-Linux builds; that fix still needs the Windows check.

Failed job and compiler diagnostics. This is from the CI log and pinned source; I have not run a local Windows build or the TP device test.

@ashhart

ashhart commented Nov 2, 2026

Copy link
Copy Markdown
Owner Author

Two-GB10 run in: GLM-5.3-Flash NVFP4 at TP=2, main against this head, base-new-new-base. GREEN: 52 of 52 token cells equal, speed flat (prompt within 0.1%, decode within 0.5%), and memory available after load up by about 0.6 to 1.4 GiB, since the checkpoint's pages are dropped once every rank has loaded. The Windows build is fixed in this branch (no Linux call on other OSes' handles). It lands next.

@cwschroeder

Copy link
Copy Markdown
Contributor

The rebased head cb5a652a24ea3f542f736bb294414004c9eca9e6 has a new compile blocker in both Linux and Windows CI: zig/src/families/qwen4/load_cache.zig:23 calls file.release() without the scratch allocator now required by safetensors.File.release.

Pass the checkpoint allocator (file.release(ck.gpa)) and update the local fake's release signature and fake checkpoint to match. The fake still accepts the old zero-argument call, so its test does not catch this API mismatch. The earlier OS guards in checkpoint_drop.zig are unchanged from 95d28e3.

Linux compiler diagnostics and Windows compiler diagnostics. This finding is from the CI logs and pinned source; I have not built the proposed fix or rerun the TP device check.

@ashhart

ashhart commented Nov 4, 2026

Copy link
Copy Markdown
Owner Author

Device run on two GB10s at TP=2 (GLM, base main vs this head, tree c26bd6f; order base, new, new, base): GREEN.

  • Tokens equal / unequal / unverified: 52 / 0 / 0, with 0 cells where streams differed.
  • Speed, new vs base: prefill 2k +0.4%, 8k +0.1%, 32k -0.1%; chat C1/C2 +0.0%; code C1 -0.3%, C2 -0.1%. That's flat, within run-to-run noise.

Dropping the checkpoint's pages after every rank is ready leaves output and speed unchanged. Queued to land.

@ashhart
ashhart force-pushed the lead/s179-tp-drop branch 2 times, most recently from 2716bb2 to 93de42d Compare November 4, 2026 01:35
Release Qwen4 load-only shards after placement and model metadata reads,
retaining CPU embedding and PLE lookup files, companions and inode aliases.

Queue original shard descriptors through every TP load-ready exchange,
including side heads and vision. Suppress intermediate hash/pack range
advice while loading, and close held descriptors without advice on failure.
@ashhart
ashhart merged commit e5df570 into main Nov 4, 2026
3 of 7 checks passed
@ashhart
ashhart deleted the lead/s179-tp-drop branch November 10, 2026 16:34
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.

2 participants