mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #1573] [CLOSED] serve: reclaim host caches and wait for SAVE memory admission #3539
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#3539
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/1573
Author: @tuandat3019
Created: 10/8/2026
Status: ❌ Closed
Base:
main← Head:codex/session-save-reclaim📝 Commits (2)
1881e82serve: optionally reclaim host caches before SAVE admission6863febserve: wait for measured RAM before retrying reclaimed SAVE📊 Changes
9 files changed (+519 additions, -1 deletions)
View changed files
📝
CMakeLists.txt(+3 -0)📝
docs/DETAILS.md(+20 -0)➕
include/strata/core/session_save_reclaim.hpp(+55 -0)📝
serve/server.py(+6 -1)➕
serve/session_save_retry.py(+84 -0)➕
serve/test_session_save_retry.py(+192 -0)📝
src/core/conversation_file_test.cpp(+27 -0)➕
src/core/session_save_reclaim_test.cpp(+115 -0)📝
src/program/generate.cpp(+17 -0)📄 Description
Summary
Closes #1572.
SAVE can fail its physical-RAM preflight while auxiliary caches hold memory that the session file will not contain, or while the OS has not yet reported released memory as available. Add
--session-save-reclaimto release those caches under measured pressure and let the HTTP server wait briefly for measured headroom before retrying SAVE on the same engine. The flag is off by default.Backend validation:
generate.cppis shared by CUDA and HIP. HIP builds and runs here; CUDA cannot be built on this machine. No review request is added with this update. SYCL is not changed or validated. The follow-up commit changes only Python server handling, tests and documentation; it does not change engine code.What changed
session_deepest_checkpoint, and that checkpoint's existing storage. Run this beforesession_save_checkpointstakes its pointer. Clear a tail-checkpoint marker only if its checkpoint was removed.save_ms.The default branch through SAVE, session format, RESTORE, memory floor and live tokens/images/device state are unchanged. Evictions trade future prefix-cache hits for headroom and remain in effect if a later admission or I/O check fails. This does not guarantee SAVE under arbitrary memory pressure. No Windows-specific trimming, application integration or hardware-specific setting is included.
Extra Notes
Validation on Windows, RX 6800 16 GiB, 32 GiB system RAM, HIP gfx1030 / Clang 24.0.0, against main
fb58e0dbc8399662c0e47c76578c6e878b14f6cf(0.1.41):stratabuild succeeded.STRATA_BUILD_CONVERSATION_TESTS=ON; CTest cache, split-failure, memory, file and new reclaim targets: 5/5 passed.STRATA_SESSION_BUFFERED=1. New cases compare complete file bytes with/without reclamation (pinned and ordinary selection), then inject ENOSPC and verify the old file/live state survive and no temporary remains.conversation_snapshot_test: 3,901 checks passed on RX 6800. This is the existing device-state fixture, not a long-context model benchmark.python -m unittest serve.test_session_save_retry serve.test_slots serve.test_security: 66 run, 1 skipped, no failures on 2026-10-09. Mock engines and a fake clock cover delayed RAM, persistent pressure, changed estimates, retry limits, unknown telemetry, process death/replacement and published/non-memory failures. HTTP checks verify default response equality, unchanged success fields and SAVE/RESTORE FIFO ordering. No model or GPU was used for this follow-up suite. The Windows symlink test is skipped because it needs privileges.2ceba30fdadb437e98bfb01f3cf05e3100fdc3cfcb3a6d2e9014b99858fab4b4.--conversation-cache-min-free-mib 100000000rather than consuming system RAM. After three turns, SAVE released 2 checkpoints / 236,134,612 host bytes, then correctly returnedSERR memorybecause the floor remained impossible. The prior file was unchanged; the next request answeredREADY, reusing 1,096 tokens. Successful admission after pressure is covered with injected telemetry in CPU tests, not claimed as a real-memory recovery measurement.Reproduce the CPU suite:
For a live check, add
--session-save-reclaimto the engine config'sargs, keep--slot-save-pathenabled, and use the existing/slots/0?action=save|restoreAPI. An impossible RAM floor safely exercises refusal without allocating a large pressure buffer. Restore the usual floor for real use.Not tested: CUDA build/runtime, Linux/macOS, SYCL, real OS memory-accounting delay for the new Python retry, or performance at long context on this upstream revision. Earlier local long-session results are deliberately not attributed to this PR. Developed and tested with an AI coding assistant.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.