mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #3286] [Engine] session: support multi-GPU layer-split save/restore (format v3) #4546
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#4546
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/3286
Author: @LuckyKo
Created: 10/19/2026
Status: 🔄 Open
Base:
main← Head:feature/multigpu-session-save📝 Commits (1)
170e1a3session: support multi-GPU layer-split save/restore (format v3)📊 Changes
9 files changed (+566 additions, -76 deletions)
View changed files
📝
docs/DETAILS.md(+10 -3)📝
include/strata/core/conversation_cache.hpp(+1 -1)📝
include/strata/core/conversation_file.hpp(+24 -3)📝
include/strata/core/conversation_snapshot.hpp(+10 -0)📝
src/core/conversation_file.cpp(+124 -25)📝
src/core/conversation_file_test.cpp(+185 -3)📝
src/core/conversation_snapshot_test.cpp(+19 -0)📝
src/core/conversation_state.cpp(+48 -18)📝
src/program/generate.cpp(+145 -23)📄 Description
Problem and result
When running Strata with
--layer-split autoacross multiple GPUs,POST /slots/0?action=saveanswers 400: "session files do not support --layer-split". The save was either refused or produced an incomplete file that couldn't be restored. This made--slot-save-pathunusable for the most common multi-GPU configuration, which is exactly where long-context session persistence matters most (the RAM cost of re-reading a 30K+ token prompt).After this PR: save and restore work on multi-GPU layer splits. A 94K-token session saves in ~5.5 s and restores in ~3.7 s after an engine restart (vs. 147 s to re-read the prompt from scratch).
Related discussion
none
Approach
Introduce format v3 for session files that carries per-stage data. Version 2 is reserved for PR #2247's BF16 state codec; this build rejects it explicitly at the version gate.
put_payloadserializes stage 0 (as before), then — only whenstage_imagesis non-empty — a count followed by one block per later stage. Each block holds that stage's running state, K/V parts, and checkpoint. The file header version is set tokVersionStages = 3.get_payloadreads stage 0 identically to v1, then checks the version. For v3 files it reads the stage count (bounded bylimits.max_stages) and each subsequent stage block, validating geometry and layer range per stage. A v1 file has no stage section; a v2 file is refused at the version gate (not silently misparsed as v1).conversation_checkpoints_splitroutes any checkpoint tocs.rest(incomplete for the split), the save is refused rather than silently dropping it.SessionReadLimitsgainsmax_stagesand a per-stagestage_limitsvector. The serve loop populates these from the live engine's stage carves before callingsession_file_read, so a file from a different split is refused before any allocation.Supersedes #2590 (closed by mass-cleanup, same branch).
Validation
Passed:
build-win-cuda13\conversation_file_test.exe— 209 checks (revf22b66ef, CUDA 13.4, Windows 11, 2× RTX 5060 Ti sm_120)build-win-cuda13\conversation_snapshot_test.exe— 4321 checksbuild-win-cuda13\conversation_cache_test.exe— 4842 checksbuild-win-cuda13\conversation_memory_test.exe— 33 checksbuild-win-cuda13\conversation_split_failure_test.exe— 36 allocation-failure cases (stages 1–3)build-win-cuda13\session_save_reclaim_test.exe— 119 checksstrata_aba_test.py, dual-GPU q2_0 + 27B dflash2 sibling): A 36-msg prefill → save → sibling evict → restore → A+ hit 99.1% cache (34979/35293 prompt tokens, 2.8 s)75e7df6b)Failed:
Not run:
--batch/ parallel slots (no multi-slot test harness)Limits
--batch(parallel slots) — the stage layout is per-slot and the save format assumes a single active slot.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.