mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #4310] [Engine] session files: format v2 with per-stage save/restore under --layer-split #4996
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#4996
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/4310
Author: @sakuumomo
Created: 10/27/2026
Status: 🔄 Open
Base:
main← Head:pr/session-files-layer-split📝 Commits (10+)
62519e7session-files: format v2 stage table (single-device saves byte-identical + 8)75db23asession-files: per-checkpoint stage parts in format v2c798fc5session-files: per-stage snapshot sources and read limits for splitsbdc4654session-files: per-stage validate and restore for split session files1525e35session-files: reclaim hook for RESTORE's read admitd5ef73fsession-files: SAVE works under --layer-split (per-stage capture and sources)cdd5a68session-files: review-focus regression battery2b318b6session-files: RESTORE works under --layer-split (per-stage limits, admit reclaim)82010c1session-files: document split save/restore and format v2cd27924session-files: capture and transfer each split stage on its own device📊 Changes
16 files changed (+1353 additions, -72 deletions)
View changed files
📝
CMakeLists.txt(+10 -0)📝
bench/results/2026-10-10-community-2x-p40-iq3_s/README.md(+4 -2)📝
docs/DETAILS.md(+36 -2)📝
include/strata/core/conversation_cache.hpp(+12 -1)📝
include/strata/core/conversation_file.hpp(+12 -3)📝
include/strata/core/conversation_snapshot.hpp(+33 -1)📝
include/strata/core/session_save_reclaim.hpp(+38 -9)📝
src/core/conversation_file.cpp(+85 -21)📝
src/core/conversation_file_test.cpp(+246 -13)📝
src/core/conversation_snapshot.cpp(+7 -2)➕
src/core/conversation_stage_split_test.cpp(+485 -0)📝
src/core/conversation_state.cpp(+241 -2)📝
src/core/session_save_reclaim_test.cpp(+67 -0)📝
src/program/generate.cpp(+67 -15)📝
sycl/src/core/conversation_snapshot.cpp(+4 -1)📝
sycl/src/core/conversation_state.cpp(+6 -0)📄 Description
Problem and result: Session SAVE/RESTORE works today, but a save of an engine running with
--layer-split(stages spread over devices) cannot capture or admit the split state: SAVE skipped stage ownership and RESTORE refused the file outright. After this change SAVE captures and transfers each split stage on its own device, RESTORE works under--layer-splitwith per-stage limits and the reclaim hook, and the on-disk format becomes v2 with an explicit stage table. Single-device saves carry a fixed +24-byte payload delta (8 B stage-table count + 8 B per checkpoint record; the 64-byte header is untouched apart from itsversionfield), and v1 files are not read: a v2 engine refuses them asunsupported version 1(typedinvalid), so slot files written by a pre-v2 engine are re-saved once after the upgrade. (Corrected 2026-11-07 per review; see the changes section.)Dependencies: none — this branch is
main+ 13 commits and stands on its own.Related discussion: none filed; this is the engine groundwork the serve session-ladder PR (#4306) builds on for multi-device hosts.
Approach: format v2 adds a stage table to each checkpoint, snapshot sources and read limits per stage, per-stage validate/restore, a reclaim hook for RESTORE's read admit, then the SAVE/RESTORE paths themselves, a review-driven regression battery, documentation, per-stage device capture/transfer, size-bound fixes, and the main carve following the engine's primary device. (The individual commit hashes of earlier lineages are dropped here on purpose; each rebase renumbered them.) Why a stage table: v1 assumed one device owns the whole conversation cache, so a split save silently lost per-stage ownership at restore. Compatibility (corrected 2026-11-07): v2 is a hard version bump. A v2 engine refuses v1 files (
unsupported version 1, typedinvalid— pinned by this PR's own test), and a v1 engine refuses v2; there is no migration path or format knob, so existing.binslot files are re-saved once after the upgrade. Single-device saves differ from v1 by +24 B of payload (8 B stage-table count + 8 B per checkpoint record); nothing is added to the 64-byte header, andversion,payload, and both hashes all change, so the files are not byte-identical in any sense.Validation:
Passed: engine compiles and the repo's session-save reclaim test target passes on the HIP build (RX 6900 XT, momo) on the owner's fleet tree carrying this exact content (deploy lineage
54d6c213era, and the currentnixosbranch rebuilt onto upstreamv0.2.8— where the session test family passes 7/7: append 1969 checks, file 263, watermark 21, plus a ThreadSanitizer run of 1969 + 260 checks with 0 warnings); live two-card SAVE/RESTORE battery on momo passed (M3 battery records, 2026-10-24: split save/restore round-trips verified end to end); the serve suite is green on the fleet tree containing these commits.Failed: none observed on the HIP build.
Not run: CUDA-only and SYCL builds of this exact rebased branch — the identical content compiles in the owner's hybrid CUDA+HIP fleet build (RTX 4060 + Radeon 890M), but a pure-CUDA CI build of this branch was not executed; hardware execution on NVIDIA-only hosts is not claimed.
Limits: v2 is exercised on AMD (HIP) and hybrid CUDA+HIP hosts only;
--layer-splitstage capture covers the devices the engine itself exposes, and per-stage bounds follow the existing state bounds (no new budget knob).Changes since the last update (2026-11-07)
v0.2.12(123bad4a, engine 0.1.58): zero conflicts, and the diffstat reproduces exactly (+1291/−69) — the same reproduction @nazerim reported from their independent 877-commit rebase. New tip6c91c00a(13 rebased commits + four review follow-ups below), mergeable, metal-link and title jobs green.version != 2, and this PR's own test pins that refusal.conversation_snapshot_sources_splitjoins the background GDN copy (opt-inSTRATA_CKPT_ASYNC) — once after the live capture, and per stage part before it moves into the record; the last part's copy used to be covered only by the next stage save's entry join, and with no next save a torn stage could land in a payload-hash-valid file. The battery's own three unjoined comparisons are joined too, theSTRATA_TEST_BIG_GDNgeometry hook is added, andconversation_stage_split_test_ckpt_asyncis registered as a ctest variant — reproducing the reviewer's finding and its proof independently.conversation_kv_sourcethe shared header declares (its 6-parameter definition left the port with an undefined symbol at link), and itsconversation_session_read_limitsengages an empty stage table withmax_stages = 0— closing the open read bound and restoring the stage-table comparison the PR claims. Not compiled here: no SYCL toolchain, and no SYCL CI job, which is how both halves survived.session_read_reclaimtakes(chain, cache, …)like its siblingsession_save_reclaim(engine call site and battery updated); the header note and the flag's docs line record that RESTORE's ladder runs before the stage-table comparison — a file written by another split spends retained K/V, unpinned parks and unpinned checkpoints, and is refused only afterwards. The re-validation fix (or a header-level split check before the RAM admit) remains open.--layer-split N, the K from the startup log'slayer split auto: K=…; a manual value also keeps the server's per-bootordered_gpusreorder from moving a stage to another card); the restore RAM peak on--kv-residenthosts (SERR memory 0 not enough RAM to read itnear the limit is the expected outcome, with the two-pass streamed read named as the unimplemented fix); placement continuity (fixed tier ⇒ byte-identical continuation after restore; adaptive-evicting tier ⇒ live and restored turns differ from each other while re-saved files stay byte-identical; plus the per-compute-capability arithmetic note and the device set being outside the file's fingerprint); and the stale "session files do not support --layer-split" quote inbench/results/2026-10-10-community-2x-p40-iq3_s/README.mdcorrected.cudaSetDevice/cudaGetDevicewrap-harness offer (§5) is accepted — to arrive as its own PR. Thedevices{0,0}battery limitation is real: this branch's per-stage device discipline is exactly what such a harness pins, and only a two-GPU host can prove it today.conversation_append_test1969 checks,conversation_file_test263,session_watermark_test31,session_save_reclaim_test167); ThreadSanitizer 1969 + 260 checks, 0 warnings; full serve suite 1640 OK / 37 skipped; CUDA 13 nvcc compile (arch 89) ofstrata,conversation_snapshot_testandconversation_stage_split_testrc=0; HIP gfx1030 flavor build green with installCheck, and the GPU conversation battery runs on a real gfx1030 (RX 6900 XT): all 12 targets build and 11 pass —conversation_snapshot_test(4377 checks), bothconversation_stage_split_testvariants (including the new_ckpt_async), and the seven core session tests. The lone failure isconversation_snapshot_test_ckpt_asyncat the six-restore free-memory pin:ckpt_async_on()is compiled OFF for HIP (and Metal), so on gfx1030 that variant runs the synchronous path with the battery's big-GDN geometry, and there each restore moves more than the card's 4 MiB slack — while the_ckpt_vram_slotsvariant at the same geometry passes and every restore/hash check before the pin passes in both variants. Logged as a HIP-lane follow-up, not a correctness failure. (The battery run also exposed an upstream CMake gap: the standalone conversation test targets register with-I includeonly, no hip_compat wiring, sosession.hpp's unconditional CUDA include cannot compile underSTRATA_ENABLE_HIPwithout a configure-time include — worked around at configure here, worth its own fix upstream.) The unlike-card hardware half remains with the validating reviewer.Commits were re-signed (GPG ed25519) on 2026-11-07 after rebasing onto upstream
v0.2.12(123bad4a); trees are unchanged from the originally validated work apart from the four review follow-ups (branch tip6c91c00a; pre-rebase tip62cdf9bcfetchable as an ancestor of the train tagpin-f6f00908).🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.