Repository navigation
Conversation
Assisted-by: Codex
Adapt the slot save/restore checkpoint appendix from ggml-org#26004 to the shared_ptr checkpoint list and the common_state_data buffers. Assisted-by: Claude Opus 5.5
d133b80 to
d2d35a3
Compare
|
Would the shared references to the checkpoints also reduce the memory footprint of the prompt cache? If so, it might be useful to include numbers in the table. |
No, this patch uses |
I see. But just for clarification, the scenario I had in mind was when 2 prompts share the same prefix (eg. system prompt+tool schema) but different user messages. With this pr, do they share the same checkpoint object for the matching system prompt? I'm curious because if the original behaviour was a vector copy, it sounds like it's going to store the same checkpoint twice. |
|
Yes, sorry, you're right: If there are the same prefixes (a growing conversation), this saves (peak) RAM. It does not save RAM unrelated histories, even if they have the same input (there is no deduplication). Added the Memory table |
|
Sweet! I have only a few GB of RAM left once I load the model/prompt cache, so even a few hundred MB of savings would be meaningful to me. Looking forward to seeing this in mainline. |
Overview
llama-servercurrently creates and reuses context-checkpoints through a vector copy.Since the checkpoints are immutable by design, this patch introduces reference-counted sharing instead.
This PR includes 3 changes to the system:
std::shared_ptrfor the context checkpoints, allowing cheap (ref-counted) copiesstd::moveAdditional information
This applies mainly to the host-side copies. The effects become larger as context grows. The effects are most visible when queuing events, as they need to wait on the serialized cache-checkpoint copies.
Tested on 3x Arc Pro B60, Threadripper 1950X x399 platform, 128GB RAM, qwen3.8-flash-next:UD-IQ4XS, RAM prompt cache 8GB, 16 checkpoints, checkpoint spacing 8192 tokens, no MTP, running on the SYCL backend (but should not affect this code).
Memory savings:
Requirements