Repository navigation
feat(kv): the context switch — page KV to disk on eviction, restore on return - #2719
Merged
Merged
Conversation
…n questions The field's complaints (subagent context copies, 48GB vanishing, hand- configured vision models, 2-3x slow loops, dotfile setup) are symptoms of disposable sessions. Map each question their users actually ask to the mechanism that answers it structurally: warm KV slots instead of context copies, demand-derived serving instead of spawn-and-pray, sensory bridge instead of a vision checkbox, probed loop economics instead of vibes, configuration-as-activities instead of dotfiles. Honesty line: instrumented, not finished; beta re-measures. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…n return
The restore economy's designed tier, never wired: llama-server's slot
save/restore (measured ~0.1s at 20k tokens) requires --slot-save-path
at launch and explicit /slots/{id}?action=save|restore calls, and the
tree had ZERO references to either. So rotation on an oversubscribed
server — 5 residents, 2-3 citizen slots, all last night — cost a full
re-prefill per act: hit_rate 0.0 on every turn, 21-28k tokens and
35-45s each, prefill traffic starving every decode to 2-7 t/s.
The OS shape (Joel: 'many threads but one at a time … they page in and
out per persona; seamless like an os is with registers'):
- lane_args: --slot-save-path joins the unconditional spine — a lane
without it silently amputates the whole paging tier (pinned by test).
- llama_server: the dir is GEOMETRY-KEYED (model + per-slot ctx) so a
page can never restore into a mismatched slot; stale geometry
generations are swept at spawn (the class's eviction owner).
- slots.rs: the paging ledger — holders (who warmed each slot) + saved
(who has a page). lease_paged() names who to SAVE before the new
turn overwrites the slot and whether to RESTORE the returner's page;
warm same-holder re-leases do neither (the in-slot KV is fresher).
- openai_adapter: performs the switch around the Turn pin — save the
evictee, restore the returner, both ordered on the slot exactly like
the inference they bracket (the only FIFO; nothing else waits).
Probes: inference.kv_page.action {action, ok, ms}.
- disk_reporters + disk_eviction: kv-pages tracked, eviction decided
(spawn sweep owns stale geometries; broker pool deferred under #155).
Tests: slot_recycling_pages_the_evictee_out_and_the_returner_in,
slot_save_path_is_part_of_the_unconditional_spine. inference:: 378/378,
disk_eviction 11/11.
Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
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.
The designed tier that was never wired
The restore economy's whole premise — many personas context-switching over few slots like OS threads over registers, near-instant page-in/out — hinges on llama-server's slot save/restore. That needs
--slot-save-pathat launch and explicit/slots/{id}?action=save|restorecalls. The tree had zero references to either. Every rotation was a full re-prefill: last night's measured hit_rate 0.0 on every act, 35–45s prefill each, decodes starved to 2–7 t/s.What lands
--slot-save-pathin the unconditional lane spine, geometry-keyed dir (model + per-slot ctx) so pages can't restore into mismatched slots; stale generations swept at spawn.slots.rs:lease_paged()names the evictee to save and whether the returner restores; warm re-leases do neither.inference.kv_page.action.Companion to #2717 (re-home guard counts lanes). Together: plans actuate, and when residents still exceed slots, rotation costs ~0.1s instead of ~35s.
🤖 Generated with Claude Code
https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo