Skip to content

llama-server: Avoids extra copying of existing checkpoints - #30683

Open
sarahwu185 wants to merge 2 commits into
ggml-org:masterfrom
sarahwu185:sarwu/cache_context
Open

sarahwu185 wants to merge 2 commits into
ggml-org:masterfrom
sarahwu185:sarwu/cache_context

Conversation

@sarahwu185

Copy link
Copy Markdown
Contributor

Overview

If an existing checkpoint already exist, reuse it instead of copying the state again.

Additional information

Will have merge conflicts with #30137

Profiling

Same long system prompt with a different user message per request vs. a growing multi-turn chat. Median GPU prompt time per request, RTX PRO 6000 Blackwell.

Model Checkpoint size Shared prefix, new user message (master → branch) Multi-turn chat (master → branch)
Gemma 3 1B Q4_K_M (SWA) 11 MiB 20 → 15.5 ms (−22%) unchanged, ~30 ms
Gemma 3 12B Q4_K_M (SWA) 320 MiB 216–230 → 114–130 ms (−45%) unchanged, ~275–314 ms
Qwen3.6-35B-A3B Q4_K_M (hybrid, MTP draft) 72 MiB 83 → 62 ms (−25%) unchanged, ~110–119 ms
lev (Qwen3.5-4B hybrid) Q4_K_M 50 MiB 48–49 → 35.5–36 ms (−27%) 70–72 → 57–59 ms (−18%)

Multi-turn chat benefits only when the next request goes back to a position that already has a checkpoint. lev restored a checkpoint on every turn, and all 48 re-copies became reuses. Qwen3.6 and Gemma just extended the cached prompt, so there was nothing to reuse.

Requirements

  • I have read and agree with the contributing guidelines
    Yes
  • AI usage disclosure: Yes, AI was used in identifying the problem as well as drafting the code change.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant