mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #3541] [Engine] Session files on the Mac: the drafter's GGUF in the fingerprint, and no draft layer without a drafter #4677
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#4677
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/3541
Author: @oceanio
Created: 10/21/2026
Status: 🔄 Open
Base:
main← Head:pr/metal-window-snapshots-solo📝 Commits (3)
3d226dcmetal: a session file's model fingerprint reads the MTP GGUF the window loadsf21ee3asession files: an engine without a drafter saves and restores them without a draft layer6a5e562tools: session_restart_test.py and metal_snapshot_test.py; parking_test.py reads the engine's own log📊 Changes
8 files changed (+272 additions, -12 deletions)
View changed files
📝
include/strata/core/conversation_snapshot.hpp(+9 -0)📝
metal/src/engine/window.cpp(+2 -0)📝
src/core/conversation_snapshot_test.cpp(+12 -0)📝
src/core/conversation_state.cpp(+18 -6)📝
src/program/generate.cpp(+18 -5)➕
tools/metal_snapshot_test.py(+112 -0)📝
tools/parking_test.py(+1 -1)➕
tools/session_restart_test.py(+100 -0)📄 Description
Problem and result
On the Mac (Metal) engine of 0.2.10, parking works, but a session file cannot be saved, with or without MTP:
--mtp, SAVE and RESTORE answerSERR io 0 session fingerprint: mtp <rt>/dense.bin: No such file or directory. The model fingerprint samples the drafter's CUDA pack files (<rt>/dense.bin,dense.txt,experts.bin). A Mac install's rt directory holds onlydraft_vocab.bin, because the window loads the drafter from the MTP GGUF beside it (window.cppmtp_load:<rt>/../mtp-q2_0.gguf, orSTRATA_METAL_MTP_GGUF). The same refusal was there on 0.2.6 through 0.2.9.SERR io 0 conversation snapshot: invalid K/V extent. The file's K/V sources always end with the drafter's layer, and with no drafter its state is empty (Mtp::st_ = QsaState{},max_cells0), so the extent check refuses any conversation. Parking does not hit this, because its context passes no draft state when there is no drafter.With this PR a session file is saved and restored in a new engine process, with or without MTP. Measured on an M5 Max with Qwen3.8-Flash-Next IQ3_S: a 28,785-token conversation is a 676 MB file, saved in 0.12 s and restored in 0.12 s. Its follow-up decodes the same 95 tokens as the conversation that never left.
Related discussion
Approach
metal/src/engine/window.cpp:mtp_gguf_path()returns the GGUF path thatmtp_loadkeeps.src/program/generate.cpp, the session identity: underSTRATA_GPU_METAL, the drafter's model input is that GGUF, and the pack'sdense.txtandexperts.binare not asked for.draft_vocab.binstays (optional, as before). Other backends are unchanged.src/core/conversation_state.cppandconversation_snapshot.hpp:conversation_snapshot_sourcesandconversation_session_read_limitstakedraft == nullptr, which means no draft layer (the read limits allow one layer fewer). The reference forms keep their meaning. This matches what the header already describes for snapshots ("an image is validated and restored with the same kind of call it was saved with").src/program/generate.cpp, SAVE and RESTORE: they passuse_mtp ? &mtp.kv_state() : nullptr, as the park context does. The SAVE RAM preflight counts the draft layer only when there is one.--mtpcan now save a session file instead of being refused. An engine with a drafter writes and reads exactly what it did before.mtp_windowis -1 without--mtp), then by the K/V layer count. The reverse is refused the same way.conversation_snapshot_test.cpp: the no-drafter sources, the file round trip and the validation, with and without a draft state.tools/metal_snapshot_test.pyandtools/session_restart_test.pyare new.tools/parking_test.pyreads the engine's own log undertempfile.gettempdir(); on macOS/tmpis not the temp folder, so it read a stale file there.Validation
Environment: Apple M5 Max (128 GB), macOS 26.7.1. Revision: this branch,
6a5e562a= 0.2.10 (ffa80d73) + 3 commits, engine 0.1.56-metal. Model: Qwen3.8-Flash-Next GSQ-RCO IQ3_S (SC117's abliterated build), resident,--expert-cache 64 --prefill auto --mmap-experts. "MTP" is--spec 2 --mtp <rt>; "no MTP" is the same config without--specand--mtp. The tools drive the engine directly (--serveprotocol), greedy.Passed:
Metal build: 0 errors, the same warnings as 0.2.10. The first commit also builds alone.
metal_snapshot_test.py(8K context), with MTP and without: the cache parks; SAVE writes a file; RESTORE of a non-session file answersSERR invalidand the engine stays in step; RESTORE of the saved file restores it. 0.2.10 fails 4 of these checks with MTP and 3 without, for the two reasons above.session_restart_test.py(64K context). One engine saves the conversation, and a new engine process restores it and decodes the follow-up:parking_test.pyat 28,692 tokens, with MTP and without: the follow-up after A, B, A is identical to the one that never parked (95/95), as on 0.2.10.The same checks on #3536 + these two commits: all pass, with the same file sizes.
Failed:
None observed.
Not run:
conversation_snapshot_testwith the new checks: it is a CUDA test (STRATA_BUILD_CONVERSATION_TESTS). It compiles against the Metal runtime, but stops at an entry point the Metal build does not have (kv_stream_reset).QsaState{}reaches the same extent check there.--batch): session files are refused there, unchanged.Limits
--batch,--layer-splitand--peer-device, as before.🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.