[GH-ISSUE #1444] can kvcache be saved and reused on disk? #580

Closed
opened 2026-11-04 01:44:14 +07:00 by bsakaguchi · 5 comments
Owner

Originally created by @badelon on GitHub (Oct 7, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/1444

2. KV cache to disk — wired up, but the engine's writer is broken on this pack

Good news: the plumbing is correct.

[strata] slot save/restore on: /home/jo/Strata/strata-sessions
POST /slots/0?action=restore {"filename":"nope.bin"}
  -> 404 "no saved session named nope.bin"     <- right behaviour

Bad news: save always fails:

strata serve: session save .../chat1.bin: conversation snapshot: invalid K/V extent
{"error":{"code":500,"kind":"io"}}

It was isolated rather than guessed — it is not any of these:

  • --kv-resident streaming on -> fails
  • streaming off -> fails
  • --kv int8 -> fails
  • default fp16 KV -> fails

It fails identically in all four, so it is not a config error. The error comes from
src/core/conversation_snapshot.cpp:21-24, where valid_extent() rejects when the token count
exceeds the state's max_cells. docs/DETAILS.md:774-814 documents this working (a 63,025-token
save, 1.2 GB), but that example is a standard setup-installed pack — ours is a hand-packed native
--compat-bf16 Q6_K pack, and the snapshot writer appears not to handle that geometry in 0.1.40.
This looks like an upstream bug, and it cannot be fixed without patching the engine's snapshot
code.

slot_save_path was left in place, since restore works and costs nothing.

What was suggested instead

The RAM-side conversation cache gets the same reuse benefit and is a different code path that
upstream verified with native packs:

--conversation-cache-mib 32768 --conversation-cache-slots 8

Upstream: a 9,276-token conversation restored in 51 ms. With 503 GB RAM, 32 GiB is conservative.
It needs no restart-persistence though — it does not survive a restart (only the session files
do, and those are what is broken).

Also worth knowing

That self-match bug

pgrep -f "serve.server --engine strata" matches its own bash -c command line, so kill was
killing the agent's own shell — the source of every "Killed by SIGTERM/SIGKILL" and every failed
bind. Fixed in /home/jo/restart-strata.sh, which excludes $$/$PPID/bash wrappers and waits
for the processes to be gone.

Originally created by @badelon on GitHub (Oct 7, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/1444 ## 2. KV cache to disk — wired up, but the engine's writer is broken on this pack Good news: the plumbing is correct. ``` [strata] slot save/restore on: /home/jo/Strata/strata-sessions POST /slots/0?action=restore {"filename":"nope.bin"} -> 404 "no saved session named nope.bin" <- right behaviour ``` Bad news: **save** always fails: ``` strata serve: session save .../chat1.bin: conversation snapshot: invalid K/V extent {"error":{"code":500,"kind":"io"}} ``` It was isolated rather than guessed — it is **not** any of these: - `--kv-resident` streaming on -> fails - streaming off -> fails - `--kv int8` -> fails - default fp16 KV -> fails It fails identically in all four, so it is not a config error. The error comes from `src/core/conversation_snapshot.cpp:21-24`, where `valid_extent()` rejects when the token count exceeds the state's `max_cells`. `docs/DETAILS.md:774-814` documents this working (a 63,025-token save, 1.2 GB), but that example is a standard setup-installed pack — ours is a hand-packed native `--compat-bf16` Q6_K pack, and the snapshot writer appears not to handle that geometry in 0.1.40. **This looks like an upstream bug**, and it cannot be fixed without patching the engine's snapshot code. `slot_save_path` was left in place, since restore works and costs nothing. ## What was suggested instead The RAM-side conversation cache gets the same *reuse* benefit and is a different code path that upstream verified with native packs: ``` --conversation-cache-mib 32768 --conversation-cache-slots 8 ``` Upstream: a 9,276-token conversation restored in **51 ms**. With 503 GB RAM, 32 GiB is conservative. It needs no restart-persistence though — it does **not** survive a restart (only the session files do, and those are what is broken). ## Also worth knowing ### That self-match bug `pgrep -f "serve.server --engine strata"` matches *its own* `bash -c` command line, so `kill` was killing the agent's own shell — the source of every "Killed by SIGTERM/SIGKILL" and every failed bind. Fixed in `/home/jo/restart-strata.sh`, which excludes `$$`/`$PPID`/`bash` wrappers and waits for the processes to be gone.
Author
Owner

@Momoyeyu commented on GitHub (Oct 8, 2026):

I found a path on current main that produces this exact error when --mtp is omitted: SAVE unconditionally passes the unloaded drafter state (max_cells = 0) to conversation_snapshot_sources. The in-memory cache already handles an absent drafter, but the session-file path does not. I reproduced this with the existing host-transfer test and have a local fix for that path; hardware validation is still pending.

Was your Q6_K run started without --mtp? Could you share the engine arguments and the GGUF source/revision? I have not reproduced your specific pack, so I do not yet know whether this explains your report.

<!-- gh-comment-id:6052020000 --> @Momoyeyu commented on GitHub (Oct 8, 2026): I found a path on current main that produces this exact error when --mtp is omitted: SAVE unconditionally passes the unloaded drafter state (max_cells = 0) to conversation_snapshot_sources. The in-memory cache already handles an absent drafter, but the session-file path does not. I reproduced this with the existing host-transfer test and have a local fix for that path; hardware validation is still pending. Was your Q6_K run started without --mtp? Could you share the engine arguments and the GGUF source/revision? I have not reproduced your specific pack, so I do not yet know whether this explains your report.
Author
Owner

@Niko1221 commented on GitHub (Oct 8, 2026):

Saving a conversation to disk exists: --slot-save-path with the /slots/N?action=save|restore calls (docs/DETAILS.md), and the RAM-side --conversation-cache-mib you found is the faster route that does not survive a restart. The error you got on save, conversation snapshot: invalid K/V extent, comes from valid_extent() in src/core/conversation_snapshot.cpp rejecting a token count above the KV state's max_cells. We have not reproduced it, and we do not know yet why a native --compat-bf16 Q6_K pack would differ. If you can post the engine log from the start (the max-context and KV cell lines) and the number of tokens in the conversation when the save failed, we can check whether max_cells is smaller than the context for that pack.

<!-- gh-comment-id:6059704544 --> @Niko1221 commented on GitHub (Oct 8, 2026): Saving a conversation to disk exists: `--slot-save-path` with the `/slots/N?action=save|restore` calls (docs/DETAILS.md), and the RAM-side `--conversation-cache-mib` you found is the faster route that does not survive a restart. The error you got on save, `conversation snapshot: invalid K/V extent`, comes from `valid_extent()` in src/core/conversation_snapshot.cpp rejecting a token count above the KV state's `max_cells`. We have not reproduced it, and we do not know yet why a native `--compat-bf16` Q6_K pack would differ. If you can post the engine log from the start (the `max-context` and KV cell lines) and the number of tokens in the conversation when the save failed, we can check whether `max_cells` is smaller than the context for that pack.
Author
Owner

@Momoyeyu commented on GitHub (Oct 8, 2026):

An update on the no-MTP case from my earlier comment: #1492 fixes that path. With no drafter loaded, SAVE still passed its KV state with max_cells == 0, so any nonempty conversation failed the extent check. The host-transfer regression reproduced this before the fix; after the fix the host-only tests pass, and conversation_snapshot_test passed 4,055 checks on an RTX 4090 D, including the no-MTP disk round trip.

These tests use synthetic session state, not the reported Q6_K pack. I have not reproduced that configuration and cannot supply its startup log or failing token count. We still need the reporter to confirm whether --mtp was omitted and provide the requested logs. The PR deliberately leaves this issue open.

<!-- gh-comment-id:6061027035 --> @Momoyeyu commented on GitHub (Oct 8, 2026): An update on the no-MTP case from my earlier comment: #1492 fixes that path. With no drafter loaded, SAVE still passed its KV state with max_cells == 0, so any nonempty conversation failed the extent check. The host-transfer regression reproduced this before the fix; after the fix the host-only tests pass, and conversation_snapshot_test passed 4,055 checks on an RTX 4090 D, including the no-MTP disk round trip. These tests use synthetic session state, not the reported Q6_K pack. I have not reproduced that configuration and cannot supply its startup log or failing token count. We still need the reporter to confirm whether --mtp was omitted and provide the requested logs. The PR deliberately leaves this issue open.
Author
Owner

@Niko1221 commented on GitHub (Oct 10, 2026):

Saving a conversation to disk exists: start with --slot-save-path DIR and use the /slots/0?action=save and restore calls (docs/DETAILS.md, the slot section). The RAM-side --conversation-cache-mib is faster but does not survive a restart. For the save error "invalid K/V extent": PR #1492 has a fix for the case where no drafter is loaded (--mtp left out) and the save passed a zero extent. If your pack was started without --mtp, that is the likely cause; please say whether it was, and post the engine arguments and start-up log if the error continues.

<!-- gh-comment-id:6099593927 --> @Niko1221 commented on GitHub (Oct 10, 2026): Saving a conversation to disk exists: start with --slot-save-path DIR and use the /slots/0?action=save and restore calls (docs/DETAILS.md, the slot section). The RAM-side --conversation-cache-mib is faster but does not survive a restart. For the save error "invalid K/V extent": PR #1492 has a fix for the case where no drafter is loaded (--mtp left out) and the save passed a zero extent. If your pack was started without --mtp, that is the likely cause; please say whether it was, and post the engine arguments and start-up log if the error continues.
Author
Owner

@Niko1221 commented on GitHub (Oct 13, 2026):

Thanks for the report. To keep the tracker current we are closing issues older than three days: 0.1.44 is out with a long list of fixes, and many older reports are covered by it or by 0.1.43.1.

If this still happens on 0.1.44, please leave a comment here with your engine log (and the version line it prints), and we will reopen it. A new issue that links this one works too.

<!-- gh-comment-id:6156097226 --> @Niko1221 commented on GitHub (Oct 13, 2026): Thanks for the report. To keep the tracker current we are closing issues older than three days: [0.1.44](https://github.com/Niko1221/Strata/releases/tag/v0.1.44) is out with a long list of fixes, and many older reports are covered by it or by 0.1.43.1. If this still happens on 0.1.44, please leave a comment here with your engine log (and the version line it prints), and we will reopen it. A new issue that links this one works too.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#580
No description provided.