mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #1269] [CLOSED] [Engine] restore a session file without holding its K/V in RAM #3348
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#3348
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/1269
Author: @pspranger-throw
Created: 10/6/2026
Status: ❌ Closed
Base:
main← Head:pr/streaming-restore📝 Commits (1)
2b3d2feserve: restore a session file without holding its K/V in RAM📊 Changes
8 files changed (+561 additions, -50 deletions)
View changed files
📝
docs/DETAILS.md(+13 -4)📝
include/strata/core/conversation_file.hpp(+28 -0)📝
include/strata/core/conversation_snapshot.hpp(+30 -0)📝
src/core/conversation_file.cpp(+227 -32)📝
src/core/conversation_file_test.cpp(+122 -0)📝
src/core/conversation_snapshot.cpp(+61 -0)📝
src/core/conversation_state.cpp(+17 -2)📝
src/program/generate.cpp(+63 -12)📄 Description
Problem and result
The RESTORE path reads the whole snapshot into host memory before it writes anything, so its peak is about the size of the file. On a machine that is also serving the model, a deep session is larger than the RAM left free: a 198,830-token IQ3_S session is a 3.05 GiB file, with roughly 5 GiB available while the model is loaded, and the server answers 503 ("when the RAM to read the file is not there", DETAILS.md). Shallow sessions restore fine, which makes the limit easy to miss.
After this change the restore is two passes over the same file, format v1 unchanged: the read pass validates the whole file without materializing the K/V, and the apply pass re-reads it and copies the K/V into the authoritative pools in blocks of at most 16 MiB. Peak RAM is two 16 MiB buffers plus the running-state metadata, so a session of any depth restores under the same floor.
Related discussion
PR #1269. Niko, 2026-10-17: "It avoids the 503 on deep sessions by restoring in blocks, which is a memory fix and not a speed change, so it is outside this round. It needs a rebase and we would take it as a fix."
The branch is rebased onto
main(e88ee39d, head69fb7912) and retested on 0.2.0-beta. Rebase-only: the diff is unchanged from the reviewed patch (8 files, 561 insertions / 50 deletions).Approach
ConversationKvTarget. It is bound to the read pass: a file whose K/V layer count or any part size differs is refused before that layer or part is applied. The payload hash is recomputed and compared to the trailer at the end.kv_stream_reset/kv_ring_restore); without it the modes that keep K/V in VRAM read stale slots.session_file_readis untouched, so callers that hold the K/V in RAM behave exactly as before.Validation
Passed:
main(e88ee39d), CUDA 13.4, archs 75;86 (368 targets).conversation_file_test: 223/223 checks. All 8 conversation suites pass underctest: conversation_cache, conversation_split_failure, conversation_memory, conversation_file, session_save_reclaim, conversation_snapshot, conversation_validation, conversation_transfer.--peer-device 1, 153K session, direct server on loopback:SERR, noFATAL, no refusals. Peer tier active throughout: 3,339 experts / 6.34 GiB on the RTX 2060S.Failed:
Not run:
--session-restore-at-start) is a separate, unopened change and is not part of this PR.Limits
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.