Repository navigation
Serving gives its host prompt cache back first when the authority reclaims memory (card 494c99f1) - #5969
Merged
Conversation
…laims memory (card 494c99f1) Under pressure, ServingConsumer::reclaim lowers the engine's host prompt-cache limit by the request's target through the fork's live route (POST /prompt-cache/limit, fork 9269444f6) before it tiers down or unloads. The engine's receipt is confirmed against the measured process drop; a refusal (no host cache, route missing, engine refusal), an unknown launch grant, or a cache at its floor falls through to the heavy levers unchanged. - engine: LlamaServerControl::set_prompt_cache_limit(NonZeroU64) with a typed PromptCacheLimit receipt and LlamaServerError::PromptCacheRefused(PromptCacheRefusal); the route is spoken in one file (prompt_cache_limit.rs), decoded straight into a typed reply. - serving: PromptCacheLever (serving_consumer/prompt_cache.rs) keeps the limit serving last set per engine incarnation and never raises it on a reclaim; the daemon wires it over its LlamaServerControl. - touched files end clean on unwrap justification. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…w of #5969) A limit far above the cache's contents freed nothing when lowered by the target (limit 9,369 MiB holding 2 GB, asked for 4 GB: the limit walked down 4 GB per ask, freed 0). The lever now keeps the last receipt's held bytes per engine incarnation and plans from min(limit, held). On an engine whose contents are not yet known, a first receipt that freed less than the target while the cache still holds more than the shortfall is followed by ONE more limit set from what it holds, in the same reclaim; the two receipts' freed bytes are summed. A refused second call keeps the first's result and is probed. Test: limit 9,369 MiB holding 2 GiB, target 1 GiB frees 1 GiB in one reclaim (two calls), and the next reclaim plans from what is held. The fake now models the fork's cache: held at most the limit, freed = held above the new limit. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
joelteply
added a commit
that referenced
this pull request
Nov 13, 2026
… live (#5970) * The engine pin moves to fork 9269444f6: the host prompt cache can be lowered and raised live (POST /prompt-cache/limit), and context_geometry reports the slot's capped window Fast-forward of 32 commits on codex/s4-per-mind-integration (316ad8b -> 9269444f6), including fork #110 and #111. #5969's reclaim lever needs the route; until this lands every engine answers 404 and the lever falls through to tier-down, as designed. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo * The recorded engine pin moves with the pointer: 9269444f6 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What it serves
The four resident minds on the M5. That machine has 64 GB and serves Qwen3.6-35B-A3B to four persistent minds, and it is memory-starved: 60 MB free, 34 GB in the OS compressor, swap at 8.6 of 10 GB, and prefill at 92 tok/s against ~190. The engine was launched with a fixed host prompt cache (
--cache-ram 9369MiB) that never gives memory back. Fork PR #110 (9269444f6 oncodex/s4-per-mind-integration) added a live route,POST /prompt-cache/limit, that resizes the cache on a running engine.This is card 494c99f1 slice 2, the core side, and it advances line 3b (one live engine, its memory moved by us, no relaunch).
The change
continuum-engine,llama_server):LlamaServerControl::set_prompt_cache_limit(NonZeroU64) -> Result<PromptCacheLimit, LlamaServerError>. The route's floor of 1 MiB is enforced by theNonZeroU64type.PromptCacheLimit { held_bytes, freed_bytes }receipt.LlamaServerError::PromptCacheRefused(PromptCacheRefusal)with three cases:Disabled(no host cache),RouteMissing(404/405: the engine predates 9269444f6), andRefused(word)(the engine named its own refusal).prompt_cache_limit.rs. It POSTs with the endpoint's client andPROBE_TIMEOUT, like its neighbours, and decodes the reply withresp.json::<LimitReply>()into a typedrefusalenum. There is noValuewalk.matchonLlamaServerErrorexists in the workspace. Every match site has a named arm or an error-forwarding arm, and none of the lifecycle paths (serve,idle, probes) can return the new variant.continuum-serving):ServingConsumer::with_prompt_cache(Arc<dyn PromptCacheControl>). The daemon wires it over its ownLlamaServerControl(serving_daemon/consumer.rs,EnginePromptCache).reclaim: after the kind check, the pending-landed check and the active-model check, and before tier-down or unload. It applies only underPressureand only when the host cache sits in serving's pool row. It then:Releasedwhen the freed bytes cover the target,Partialotherwise;detail.serving.reclaim.prompt_cacheprobe with the limit before and after, the target, the reported freed bytes and the measured drop.host_prompt_cache_mib). That is the spawn fact, or--cache-ramread off an adopted engine's argv. There is no guessed constant.EngineIncarnation(pid, start time, port).serving_consumer/prompt_cache.rs.unwrap_or_defaultis replaced byinto_iter().collect().Decisions
ShutdownandRebalanceskip the cache lever for the same reason they skip tier-down: both want the whole lease gone from this box.Tests
These extend the existing test module of
serving_consumer, as a nestedprompt_cache_firstmod.RouteMissing) falls through to the tier-down.Partial.current_limit: only a different engine starts again from its launch grant, and an unknown engine is never raised.Nothing was compiled locally: the M5 is serving live minds, so CI is the compiler.
Live receipt to take
After the engine pin includes fork 9269444f6, record on the M5 before and after: prefill and decode tok/s, free memory, compressor size, swap used, and median act time at four residents. Also record the
serving.reclaim.prompt_cacheprobes, showing limit before and after, reported against measured freed bytes.Next slice (not here)
Raise the cache back toward its launch grant when pressure clears.
🤖 Generated with Claude Code
https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo