Skip to content

Flash Next on CUDA: drop the checkpoint from the page cache after load (fixes #1868) - #1880

Merged
ashhart merged 1 commit into
mainfrom
lead/fn-drop-load-cache
Nov 1, 2026
Merged

ashhart merged 1 commit into
mainfrom
lead/fn-drop-load-cache

Conversation

@ashhart

@ashhart ashhart commented Nov 1, 2026 •

Copy link
Copy Markdown
Owner

Fixes #1868.

On a GB10 the GPU's memory is the system's. A loaded Flash Next CUDA server kept about 36 GiB of its safetensors shards in the page cache (the last layers' shards in full) beside the weights on the GPU, leaving under 1 GiB free. Under that pressure, the kernel's reclaim and compaction made long prompts drop to about 0.73x from some point in a server's life until a restart, with the same tokens. 1.2.0 does this too.

  • Each shard releases its pages when its mapping closes (core.safetensors.File.release, which skips heap copies, so no live reader's bytes can be zeroed).
  • Once the weights and the MTP head are on the GPU, every shard file's pages are dropped (dropPageCache). Nothing reads them after load; a later read would fault them back in.

Measured on a GB10 with Qwen3.8-Flash-Next MLX 4-bit + MTP, one stream, 32K and 64K prompts:

  • Without the drop, servers went slow in 5 of 6 and 3 of 5 runs (64K prefill about 1,200 to 1,340 tok/s instead of about 1,720).
  • With the checkpoint's pages evicted (compaction, or the same drop done outside the server): 12 of 12 normal (1,716 to 1,723 tok/s).
  • This change against main, balanced six runs: GREEN, every cell within 0.5%, the same prompt tokens.

Host checks: test-flashnext-cleanup-host, test-flashnext-memory-host, test-flashnext-buffer-plan-host and check-native-cuda-host pass; the light gate passes. An independent review found it safe to land. The same drop for the other CUDA loaders is a follow-up (a Qwen3.8-27B server keeps its whole 15 GiB checkpoint cached).

… load (#1868)

On a GB10 the device's memory is the system's. A loaded Flash Next server kept about 36 GiB of its
safetensors shards in the page cache (the last layers' shards in full) beside the weights on the device,
leaving under 1 GiB free; under that pressure long prompts dropped to about 0.73x from some point in a
server's life on, with the same tokens. Every shard now leaves the cache when its mapping closes, and once
the weights and the MTP head are on the device every shard file's pages are dropped. Nothing reads them
after load; a later read would fault the bytes back in.
@ashhart
ashhart merged commit 73f0f5c into main Nov 1, 2026
1 of 13 checks passed
@ashhart
ashhart deleted the lead/fn-drop-load-cache 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.

Flash Next on a GB10: long-prompt prefill sometimes drops to about 0.73x and stays there until restart

1 participant