mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[GH-ISSUE #4144] [Engine] Mac: conversation cache never parks (no macOS RAM reading; Metal checkpoints fail validation) #1815
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#1815
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?
Originally created by @swhite1122 on GitHub (Oct 25, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/4144
Area
Engine
Desktop app, Terminal or source?
Source (git clone,
./setup.sh, engine built by setup)What happened
On the Mac, the conversation cache never parks anything, so an agent that alternates conversations re-reads its whole prompt on every switch.
Client: Codex CLI 0.164 over
/v1/responses. With Codex's memories feature on, Codex runs its memory-consolidation thread alongside the main task, and the two take turns on the server. One short lookup took 14 minutes: 16 requests, 862 s, of which 661 s were full prompt reads of 16K-36K tokens. The last two requests, after the second thread finished, reused the cache and read in 2-3 s.The same Codex setup on Windows (RTX 5080, engine 0.1.50) parks fine:
conversation cache: parked 445 tokens in 68.8 ms; parked=2 ....There are two gaps on Metal.
1.
sample_host_memory()has no macOS branch. Insrc/core/conversation_memory.cppit only handles_WIN32and__linux__and returns{}otherwise, so every Mac start prints:I tried a local branch using the same rule as
arena_avail()inmetal/src/engine/arena_budget.h:With that, the guard reads the RAM and the cache is sized:
2. Then every park fails validation. Two alternating conversations (12K and 7K tokens, three turns each) gave, five times:
conversation_checkpoint_validate()(src/core/conversation_state.cpp) checksgdn,ple,tails,deadandblock_posagainst theSessionStatelayout, but underSTRATA_GPU_METALconversation_checkpoint_save()goes towindow_checkpoint_save(), whose running state comes from the Metal decode window and does not match those sizes. I did not force it past the check, because a mismatched restore would silently corrupt answers, and I reverted the local change. Both gaps are still inmainas of4b9e05a.Expected: on a Mac, conversations park and restore as they do on Windows and Linux, so an agent's alternating threads keep their prompt cache.
Smallest steps or command that reproduce it
conversation cache off.skip parking (conversation snapshot: invalid checkpoint running-state payload)on every switch.Reproduction status
Reproduces every time
Strata version
Source v0.2.3.1 (commit
7ddc17a), Metal engine 0.1.48. Both code paths above are unchanged inmain(4b9e05a).Graphics card, memory and system
MacBook Pro, Apple M5 Pro, 48 GB unified memory, macOS 26.7.1.
Model, size and settings
Qwen3.8-Flash-Next ISTA IQ3_XXS, experts streamed from the SSD (
STRATA_METAL_ARENA_GB=20, the experts' copy),--spec 2 --suffix-draft 0 --prefill auto, context 262,144, vision on (GPU reader).Logs
The log lines are quoted above.
@stalker1211 commented on GitHub (Oct 30, 2026):
Same here on Terminal 0.1.54 / engine 0.1.54-macos-arm64-metal (M5 Pro 48 GB, Q2_0, 128K, STRATA_METAL_STREAM=1). Claude Code does side requests for title / recap ~4-5K which invalidate the main conversation cache and re-reads 45–56K tokens.
--set memory-limit-mib=49152 gets past the RAM guard, and conversation-cache-min-tokens works as described:
strata serve: conversation cache: skip parking (5361 tokens, below the 10000 minimum; parked=0)
strata serve: conversation cache: skip parking (conversation snapshot: invalid checkpoint running-state payload)
The second line shows up for every large conversation (>10000 in my settings).
Workaround (for claude) is
"CLAUDE_CODE_DISABLE_TERMINAL_TITLE": "1"
"awaySummaryEnabled": false
@hyspace commented on GitHub (Nov 2, 2026):
Confirming on a second Mac setup, with a source-level explanation that matches the issue text.
Environment: Strata Terminal 0.1.55, engine
0.1.55-macos-arm64-metal, Apple M5 Ultra 96 GB (Darwin 27.2), Qwen3.8-Flash-Next IQ3_S,--mtp --spec 2 --kv k8v4 --mmap-experts --max-context 262144 --conversation-cache-mib 8192, run asstrata serve.Workload: Hermes agent as the main chat, plus the Hindsight memory server (retain / consolidation) as a second client on the same engine. Same pattern as the Codex memory-consolidation thread in the description: two clients with different prompts take turns, and every switch re-reads the whole prompt (37-41K tokens for the main chat, about 15 s).
What the log says (every start, and after every request):
Controlled test (
/v1/chat/completions, ~12K-token prompts, conversation A grows by one assistant reply plus one user turn, B is unrelated):Adding
--memory-limit-mib 90000 --conversation-cache-min-free-mib 0changes nothing: the "cannot be read" line still prints and the park still fails with the payload error. So the two gaps in the description are independent, and fixing only the first one is not enough.(Note for anyone reproducing: a test where A2 only changes the last user sentence is not valid. The hybrid recurrent state can only resume at a checkpoint boundary, so it shows 0 reuse even when nothing is wrong.)
Source reading (not instrumented on our build, so no new measurements beyond #4730):
sample_host_memory()insrc/core/conversation_memory.cpphas_WIN32and__linux__branches and#else return {}.conversation_checkpoint_validate()comparesgdn / ple / tails / dead / block_possizes with the CUDA layout.Window::checkpoint_save()writes the Metal ring (ts = 4 * 4 * 128per layer) and ends withc.block_pos.clear(). UnderSTRATA_GPU_METALthe normal checkpoint restore returns before the validator, but the park path (view_validate) does not.Things we tried that do not work around it:
--parallel 2("parallel": 2, 3.85 GB per slot on Metal): a request that arrives alone takes the solo path ingenerate_batched(alone and left > 1) and never looks at slot prefixes, so sequential alternation still reuses 0. Overlapping requests do use slot prefixes (one reused 12,137 tokens), but we also sawstrata batch: restoring slot 0 failed (metal window: a slot copy with a fold pending); reading the prompttwice.--slot-save-path): not tested, but from the source they go through the same checkpoint save/restore code, so they probably hit the same validation.PR #3231 looks like the right fix for both gaps. It is currently marked as conflicting with
main, so the 0.1.55 engine does not include it.@hyspace commented on GitHub (Nov 3, 2026):
Follow-up and a correction to my comment above: I said PR #3231 looked like the fix and that the engine did not include it yet. I had not checked
main, which already had the maintainer's fix ind01b1817("Metal: conversations park and restore (#4730, #4144)"). That fix shipped in 0.2.10 / engine 0.1.56.Verified on engine
0.1.56-macos-arm64-metal(same machine and flags as above: M5 Ultra 96 GB, Qwen3.8-Flash-Next IQ3_S,--mtp --spec 2 --kv k8v4 --mmap-experts --conversation-cache-mib 8192):memory guard: limit 96.0 GiB (source: meminfo), current 27.2 GiB, ... available 68.8 GiBNo
invalid checkpoint running-state payloadlines any more. Each ~12K-token snapshot took 420-540 MB of RAM. From our side this issue looks resolved by 0.1.56.