mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #2590] [CLOSED] [Engine] session: support multi-GPU layer-split save/restore (format v3) #4150
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#4150
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/2590
Author: @LuckyKo
Created: 10/15/2026
Status: ❌ Closed
Base:
main← Head:feature/multigpu-session-save📝 Commits (1)
5e1ec82session: support multi-GPU layer-split save/restore (format v3)📊 Changes
7 files changed (+520 additions, -62 deletions)
View changed files
📝
include/strata/core/conversation_file.hpp(+21 -0)📝
include/strata/core/conversation_snapshot.hpp(+10 -0)📝
src/core/conversation_file.cpp(+112 -20)📝
src/core/conversation_file_test.cpp(+166 -3)📝
src/core/conversation_snapshot_test.cpp(+19 -0)📝
src/core/conversation_state.cpp(+48 -18)📝
src/program/generate.cpp(+144 -21)📄 Description
Problem
When running Strata with
--layer-split autoacross multiple GPUs, the engine divides model layers into stages (one per GPU). The existing session save/restore (--slot-save-path) only handled a single-stage (single-GPU) layout: it saved/restored one set of running state and K/V. On a multi-GPU 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).Solution
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.Read-limit hardening
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 (wrong stage count, wrong layer range, oversized K/V) is refused before any allocation — not after a partial read.Changes by file
include/strata/core/conversation_file.hppkVersionStages = 3,SessionReadLimits::max_stages,stage_limits,SessionStageLimitsstructinclude/strata/core/conversation_snapshot.hppconversation_stage_read_limits()declarationsrc/core/conversation_file.cppput_payload), v3 read (get_payload), per-stage validation, explicit v2 rejectionsrc/core/conversation_state.cppconversation_stage_read_limits()implementation,conversation_session_read_limitsupdated to carry stage boundssrc/program/generate.cppstage_limitsfrom live stages, setmax_stages, pass through to read; save path collects per-stage K/V sources;cs.restguard;draft_stage_kvhelpersrc/core/conversation_file_test.cppsrc/core/conversation_snapshot_test.cppconversation_stage_read_limitsunit testsEnvironment
Strata built from source, CUDA 13.4, Windows 11 / Debian 13
2× NVIDIA RTX 5060 Ti (16 GB) or 2× NVIDIA A2 (16 GB), 64 GB system RAM
Qwen3.8-Flash-Next Coder IQ3_XXS / UD-Q4_K_XL, up to 128K context
Validation
Revision:
94f55cd6(rebased onto maine88ee39d, 0.2.0-beta)Environment: CUDA 13.4, Windows 11, 2× NVIDIA RTX 5060 Ti 16 GB (sm_120), 64 GB RAM
Commands:
Passed:
Failed: none
Not run:
--batch/ parallel slots🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.