Repository navigation
serve: reclaim host caches and wait for SAVE memory admission - #1573
Closed
tuandat3019 wants to merge 2 commits into
Closed
tuandat3019 wants to merge 2 commits into
tuandat3019 wants to merge 2 commits into
Conversation
tuandat3019
marked this pull request as ready for review
October 8, 2026 14:47
Owner
|
Ported into v0.1.42 with your commits. Reviewed and tested: the refusal reproduces without the flag, and with --session-save-reclaim the SAVE succeeds after the engine freed two parked conversations; SAVE then RESTORE gives the same token ids as continuing live. Thank you. |
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.
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.