mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #2962] [Engine] conversation cache: parked dialogs give RAM back when available RAM falls below --conversation-cache-min-free-mib #4362
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#4362
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/2962
Author: @sergqwer
Created: 10/17/2026
Status: 🔄 Open
Base:
main← Head:pr/conv-pressure📝 Commits (1)
5df5db2conversation cache: parked dialogs give RAM back when available RAM falls below --conversation-cache-min-free-mib📊 Changes
5 files changed (+405 additions, -2 deletions)
View changed files
📝
CMakeLists.txt(+4 -0)📝
docs/DETAILS.md(+11 -0)➕
include/strata/core/conversation_pressure.hpp(+85 -0)➕
src/core/conversation_pressure_test.cpp(+194 -0)📝
src/program/generate.cpp(+111 -2)📄 Description
Problem and result
--conversation-cache-min-free-mib(default 2560) is checked when a conversation is parked, saved or restored. Once parked, a conversation stays in RAM until a later park or restore evicts it, also when the host runs short in between (another program opened, or the engine's own memory grew).Related discussion
None beyond this PR. It was #2962 before the 0.2.0-beta tracker reset, unchanged except for the rebase. It changes no default: the cache is off unless
--conversation-cache-mibis set (setup only prints it as a tip), and the floor's default is unchanged.Approach
STRATA_CONV_PRESSURE_MS(2000 ms; 0 = off) while the engine is idle (the stdin wait wakes in 2 s slices for it), and between batch windows.sample_host_memory(): on Windows the smaller of available physical memory and commit room; on Linux MemAvailable, the cgroup limits and--memory-limit-mib). An unknown reading releases nothing, as the park gate fails closed.STRATA_CONV_PRESSURE_HYST_MIB(1024) is available: the retained K/V; then the parked conversations, least recently active first, through the cache's ownevict_oldest()(pinned shared prefixes and a guarded donor stay; a client that comes back has its prompt read again); then the idle--batchslots' host checkpoints (their K/V and ids in VRAM stay; a partial read keeps its own). After each step it reads again; glibc getsmalloc_trimfirst.conversation cache: RAM below the floor: released 2 dialogs, 2180 MiB (dropped) in 84 ms; idle: 29694 -> 31899 MiB available, floor 30720 MiB + 1024; parked=1. An event with nothing left to release is said once.include/strata/core/conversation_pressure.hpp), tested without a GPU;generate.cpponly wires it in.Validation
Revision: this branch, one commit
5df5db29onmaine88ee39d(v0.2.0-beta + 12 commits), against a build ofmaine88ee39d. RTX 5090, Ryzen 9 9950X3D, 128 GB, Windows 11; MSVC 2022 17.14, CUDA 13.3, release configure (-DSTRATA_PORTABLE=ON,75-real;86-real;89-real;120-real, ggml at the pinned 3cf03257). Model: the NVFP4 GPTQ pack (Maximilian228/Qwen3.8-Flash-Next-NVFP4-GPTQ-Strata, upstream setup's--family nvfp4 --model NVFP4files).Passed:
Identity.
strata --servewith setup's model files plus--expert-cache 3000 --prefill auto --spec 6 --spec-min-p 0.7 --max-context 262144 --kv int8 --gpu 0 --pcie-frac 0 --adapt-every 1000000, envSTRATA_PREFILL_CPU_SHARE=0 STRATA_PCIE_BALANCE=0 STRATA_IQ_MT_MIN=1 STRATA_DUMP_FIRST_LOGITS=<file>; a 2,100-token and a 32,037-token prompt, 32 greedy tokens each:maine88ee39d1e9c612c...f5b2872c...--conversation-cache-mib 8192 --conversation-cache-slots 4(the 2K dialog parked when the 32K one came, no pressure)Under pressure (one server run, 78 s). Config:
--expert-cache auto --spec 4 --spec-min-p 0.5 --max-context 262144 --kv int8 --kv-resident 32768plus--conversation-cache-mib 8192 --conversation-cache-slots 4 --conversation-cache-min-free-mib 30720. The floor is set high so that a small ballast crosses it (this PC's RAM is shared with other work).conversation cache: RAM below the floor: released 2 dialogs, 2180 MiB (dropped) in 84 ms; idle: 29694 -> 31899 MiB available, floor 30720 MiB + 1024; parked=1. The oldest two went (B, A); E stayed. Engine private bytes 107,532 -> 105,383 MiB (-2,149) at once. One line only while the ballast was held.32092 tokens = 2998 reused + 29094 read, TTFT 5.5 s, its own codename in the answer. E (still parked)64047 reused + 46 read, restored in 75 ms, TTFT 0.49 s, its own codename. 4 s idle after: no release line.Unit tests (CPU, from the repo root).
conversation_pressure_test(new, 63 checks: nothing at or above the floor or inside the band; below it the oldest go until floor + hysteresis; settle-only recovery; retained K/V first; pinned prefixes stay; unknown readings; the bound; and one real 256 MiB release that leaves the process):/std:c++20 /W4: 0 warnings, 63 passed (Windows private bytes 257 -> 0 MiB, twice).-std=c++20 -Wall -Wextra: 0 warnings, 63 passed.-Wall -Wextra: 0 warnings, 63 passed (RSS 299 -> 3 MiB and 259 -> 3 MiB).conversation_cache_test4,772 checks,conversation_file_test183,conversation_memory_test25,conversation_split_failure_test16 cases,session_save_reclaim_test119, all passed (conversation_cache_testalso on the Linux box).Failed: none observed.
Not run:
generate.cpp; no ROCm or Mac here.sycl/src/program/generate.cppis not changed, so a SYCL engine keeps the old behaviour.--batchunder pressure on this revision (the slots' checkpoints): measured only on our fork's 0.1.44 code, where with--batch 2the parked images went first and then the slots' checkpoints (2,180 MiB together), and the slots still reused 32K/48K tokens afterwards.Limits
--prompt-cache, ~118 MB each), which is the active conversation, andSTRATA_CKPT_POOL's at most two kept checkpoints.ConvCacheLog) reads park, restore and "dropped ... superseded" lines; the release line is not parsed there, so the Monitor shows the old count until the next park or restore.🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.