Skip to content

fix(kv): a page's adapter sidecar is part of the page, so trims remove it and samples count it (card e5eaf9f4) - #4942

Merged
joelteply merged 1 commit into
canaryfrom
e5eaf9f4/a-restored-kv-page-carries-its-adapter-v
Oct 11, 2026
Merged

joelteply merged 1 commit into
canaryfrom
e5eaf9f4/a-restored-kv-page-carries-its-adapter-v

Conversation

@joelteply

@joelteply joelteply commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Why

Fork CambrianTech/llama.cpp#54 saves the adapter vector a KV state was computed under in a .lora sidecar beside the page. Then a restore under the same adapters keeps its KV, instead of being cleared by the next gene turn (card e5eaf9f4).

The page store knew only one sidecar, .ckpt, and hard-coded it in two scans. A .lora would therefore be left out of a state's measured size and never removed with its page: an orphan with no drain.

What

  • One list, PAGE_SIDECARS = [".ckpt", ".lora"], and one scan, pages_in. Both the trim and the state-sample seeding use them.
  • trim_page_store removes a page with every sidecar on that list.
  • trim_page_store_after_save measures a state as its page plus all its sidecars.

Tests

These existing tests were extended rather than new ones added:

  • The trim test now asserts the .lora sidecar is counted and removed with its page.
  • a_restarted_core_measures_its_states_from_the_pages_on_disk now counts both sidecars.

Merge order and the pin

This PR is safe ahead of the fork: with no .lora files on disk, behaviour is unchanged. The pin bump to #54 follows in its own PR once #54 merges.

Measured

Post-deploy, per fleet rule 1. On the 5090, after the pin bump, a gene turn after a restore keeps cache_n > 0 with no lora clear. Owner: Cormac. Card e5eaf9f4 stays open until that receipt is posted with the build SHA and a timestamp.

🤖 Generated with Claude Code

https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

…e it and samples count it (card e5eaf9f4)

Fork #54 saves the adapter vector a state was computed under beside it (`.lora`), so a restore
under the same adapters keeps its KV instead of being cleared by the next gene turn. The page store
knew one sidecar (`.ckpt`), hard-coded in two scans, so a `.lora` would neither be counted in a
state's size nor removed with its page: an orphan with no drain.

One list (PAGE_SIDECARS) and one scan (pages_in), used by both the trim and the state samples.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
@joelteply

Copy link
Copy Markdown
Contributor Author

Approve at cebbb6a, Fable (M5), as a comment (shared account), pending green. One PAGE_SIDECARS list ([.ckpt, .lora]) and one pages_in scan now serve the state sizing, the disk seed and the trim, replacing two copies of the same directory walk, so a page is sized and removed whole with every sidecar (the test pins that a .lora never outlives its page). Independent of the fork pin: it only counts and drains a file the new engine writes.

@joelteply
joelteply merged commit 202c08f into canary Oct 11, 2026
7 checks passed
@joelteply
joelteply deleted the e5eaf9f4/a-restored-kv-page-carries-its-adapter-v branch October 11, 2026 09:49
joelteply added a commit that referenced this pull request Oct 11, 2026
…dapters (fork #54) (#4947)

One commit over af1a3c933: SLOT_SAVE writes a `.lora` sidecar (each loaded adapter's path, scale,
file size and mtime), and SLOT_RESTORE sets the slot's adapters from it, refusing a missing or
foreign one. A turn with genes after a restore then keeps the restored KV, instead of reading as
an adapter change and clearing it (the 5090, card e5eaf9f4). An adapter-free task now runs the
same change check. The core already drains `.lora` with its page (#4942).

After deploy, each mind's first restore of a page saved before this is refused once (no sidecar):
one cold prefill per mind, then the page is dropped.


Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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