Skip to content

DeepSeek-V4.1: --prompt-cache-gib bounds the whole prompt cache, the same on every rank - #1892

Closed
ashhart wants to merge 3 commits into
mainfrom
lead/s182-dsv41-prompt-cache
Closed

ashhart wants to merge 3 commits into
mainfrom
lead/s182-dsv41-prompt-cache

Conversation

@ashhart

@ashhart ashhart commented Nov 2, 2026

Copy link
Copy Markdown
Owner

Fixes #1625: DeepSeek-V4.1's --prompt-cache-gib now bounds everything the prompt cache keeps.

What changes

  • --prompt-cache-gib caps the retained KV pages, the host snapshots and the index records together, with LRU eviction after each save. Unset means 16 GiB, 0 turns RAM and disk reuse off and logs that at start-up, and a bad value is refused before the load.
  • Rank 0's cap is sent to every rank before boot. Retention charges each snapshot's agreed logical size, which is the same on every rank, so all ranks evict the same entries. Physical counters are kept as before.
  • Resume points are unchanged: the 16-row grid, with rings and carries restored. The reporter's 2,048-token observation came from a modified build; main already keeps 16-row cuts.

One behaviour to note: the combined cap counts logical bytes at one rank too, while one rank's RAM sub-limit still counts physical bytes. At TP=2 or more, the default 256 MiB RAM limit now counts logical bytes, so it may keep a few more snapshots.

Checks

  • Host: store, trim and boot-agreement tests, including world-2 and world-4 cases with unequal per-rank physical sizes. These fail on the first commit alone. The lean check shows 424 problems before and after.
  • Three independent reviews: LAND after a TP=2 run. Default replies are the same tokens.
  • Device: TP=2 on two GB10s, with the cache off, at default, and at a small cap, plus resumed prompts at 2,071 and 4,119 tokens against main. Results will be posted here before this lands.

Honor the native cache budget across tensor ranks and cap shared KV,
bounded snapshots and indexed token payload through the session store.
Keep existing 16-row snapshot alignment, with partial-page and eviction
regressions and runtime controls for coarse snapshots and ignored caps.
Track logical bounded bytes separately from physical residency and use
that charge for retention and multi-rank RAM trimming. Roll back and
release both totals with their owners, and log zero-cache startup.

Cover unequal rank sizes, LRU victims and failed publication custody.
@ashhart

ashhart commented Nov 3, 2026

Copy link
Copy Markdown
Owner Author

Closing in favour of #2056, which does #1625's fix with the default unchanged: --prompt-cache-gib sets the kept states' RAM limit, and every rank takes rank 0's value over the plan link. This PR also capped snapshots and index records and set an unset limit to 16 GiB, which changes the default for everyone. If we want those broader caps later, they can come as an opt-in on top of #2056.

@ashhart ashhart closed this Nov 3, 2026
@ashhart
ashhart deleted the lead/s182-dsv41-prompt-cache branch November 10, 2026 16:35
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.

DeepSeek-V4.1: prompt cache resumes only at 2,048-token boundaries and ignores --prompt-cache-gib

1 participant