mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
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#3737
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/1887
Author: @lask3802
Created: 10/10/2026
Status: ❌ Closed
Base:
main← Head:remote-stage-ckpt📝 Commits (10+)
6946676Remote stage: run the later layers of a layer split on another PC over TCP2ba81afRemote stage tools: a node agent, a layer shipper and a split tuner5657d79Remote stage docs and measurements: two and three PCs, two modelsf6241bastage_ship: pieces in flight at once; the agent checks each piece's sha256fecb3c7Remote stage: follow 0.1.43's decode defaults on both PCs9822a07Remote stage: images (--vision) - the worker's layers get the main's positions6efea4aRemote stage docs: images, and the checks after the rebase onto 0.1.43ef046e0Remote stage: a stuck worker ends as a stuck main process does; parking turned off, not refusedae6634fRemote stage: a worker's agent starts an ended worker again8aeb39eRemote stage: the main process connects again, a new main takes a silent worker over📊 Changes
29 files changed (+9889 additions, -325 deletions)
View changed files
📝
CMakeLists.txt(+16 -1)📝
docs/MULTI_GPU.md(+14 -1)➕
docs/REMOTE_STAGE.md(+608 -0)➕
docs/remote-stage/CHECKPOINTS.md(+412 -0)➕
docs/remote-stage/ENGINEERING.md(+836 -0)📝
include/strata/core/conversation_cache.hpp(+3 -0)📝
include/strata/core/conversation_snapshot.hpp(+7 -0)📝
include/strata/core/expert_source.hpp(+12 -1)📝
include/strata/core/verify.hpp(+42 -0)➕
include/strata/net/stage_ckpt_store.hpp(+87 -0)➕
include/strata/net/stage_link.hpp(+275 -0)📝
include/strata/prefill/prefill.hpp(+28 -0)📝
metal/CMakeLists.txt(+1 -1)📝
serve/server.py(+21 -1)📝
serve/test_server.py(+84 -1)📝
src/core/conversation_copy.hpp(+1 -0)📝
src/core/conversation_state.cpp(+51 -24)📝
src/core/conversation_validation_test.cpp(+45 -0)📝
src/core/expert_source.cpp(+58 -38)📝
src/core/verify.cpp(+126 -12)...and 9 more files
📄 Description
Stacked on #1748. The first nineteen commits are #1748's; this PR adds the last six: the feature, its docs, what
#1748's recovery (the main process connecting again) needs from them, the
--pipeline-windows 2case, and the notesof the rebase. Both PRs are on
main8183c6b6(v0.2.4.1 and one docs commit, engine 0.1.49.1; see "Rebased onto 0.2.4.1" underApproach); the measurements below were taken on
e88ee39d(0.2.0-beta).Problem and result
With
--remote-stage, every prompt was read from token 0. A conversation checkpoint holds only the running state ofthe process's own layers, so the main process could not restore the worker's. A chat client sends the whole
conversation every turn, so every turn of a long chat waited for the whole prompt again: about 15 s at 16K tokens on
the test pair below.
With
--prompt-cache Ngiven explicitly on the main process, the worker keeps its layers' part of each checkpointunder an id the main process hands it, and the chain works as on one GPU at the prompt's synchronous cut points. On
this head (0.2.0-beta), an RTX 2080 Ti main + RTX 3080 worker, the later turns' median time to the first token is
0.38 s with
--prompt-cache 6against 12.83 s without (Validation). On an RTX 3080 + RTX 2080 Ti pair (engine 0.1.43,earlier heads), time to the first token at the served flags, thinking on, 400 tokens:
--prompt-cache 6A turn read from 0 was 0.7-1.3 s slower with checkpoints on 0.1.41 and 0.1.42, and not slower in this run. The prompt
is read in parts that end at its cut points, and a checkpoint is saved at each. With
--prompt-cache, answers need notbe byte-identical to a run without it, because the read order differs; the repeated-turn check is the exactness test.
Measured on earlier heads
Every check in this subsection ran again on this head with the cards swapped (Validation), except the "before"
column of the fault table and the adaptive overlap on the worker (Not run).
An RTX 3080 main (layers 0-25, the head, the drafter) and an RTX 2080 Ti worker (layers 26-47) over 10 GbE, RVN
IQ3_S, Linux, engine 0.1.43; #1748's build is the base. The replay is two chats of four turns on one shared system
prompt of about 16,000 tokens, greedy. Exact flags:
--pcie-frac 0 --adapt-every 0 --adapt-swaps 0on both PCs,--mtp-max-t 1 --suffix-draft 0on the main, andSTRATA_IQ_MT_MIN=1 STRATA_PREFILL_CPU_SHARE=0on both.--prompt-cache, exact flags) vs #1748, one run of each--visionon both PCs): two turns, the second sent twice--prompt-cache!. Without the settle, on an earlier build with the same load: about 4 in 10In these runs the worker's adaptive overlap was on (#1748's build then followed upstream's default on the worker
too). #1748 has since made it opt-in on a worker (
STRATA_ADAPT_OVERLAP=1), since it measured no faster there; aworker without it takes the path of the 0.1.42 runs, where the same live-continuation check gave 161 requests and
0 replies of
!. The same checks on 0.1.41 and 0.1.42 gave the same results: 8 of 8 on each repeated-turn line, 53restores, no
!reply, and later turns in 0.28-0.54 s. On 0.1.42 the default path against #1748 did not repeat fromrun to run (8 of 8 in 2 of 6 pairs), as 0.1.42 did not on one GPU either; on 0.1.43 it did.
With
--pipeline-windows 2on the main process (same PCs and model, exact flags,--expert-cache 1951,STRATA_ROUTE_TAIL_SKIP=0on the main process): repeated turns 8 of 8 byte-identical with 15 restores on both sidesand 0 errors, the same with thinking on and with cancellation; a forced restore miss (
STRATA_REMOTE_CKPT_DROP=1)read from 0 and finished. The numbers are in
docs/remote-stage/CHECKPOINTS.md.Faults between two turns. On the same pair with this branch's build, #1748's agent and server,
--prompt-cache 6and pictures allowed (served flags). Each conversation's second turn asks for something only its first turn holds (a
code word, or the first word of the previous answer), greedy. The worker was killed with SIGKILL between the turns,
and its agent started it again. "Before" is the docs commit; "after" is the reconnect commit ("checkpoints and the
live session after a reconnect") before its worker-error texts and take-over check, which none of these runs reach.
The same session on 0.1.43.1 gave every second turn right (worker killed: 45.2 s text, 52.2 s picture, 61.1 s another
chat's checkpoint; main engine killed: 38.1 s), and again on top of #1748's open-points commit (45.1 / 52.1 / 61.0 s;
11.8 s).
Related discussion
rebased onto
maine88ee39don top of #1748's rebase. No maintainer agreement on scope yet.--prompt-cache.Approach
CkptSave/CkptRestorecarry an id, a position and the list of ids to keep,and
Resetcarries that list too.process works out the chain a new checkpoint leaves before the worker stores its part, with the same eviction it
applies after (
--prompt-cache-spreadincluded), so both PCs drop the same checkpoint.or any part when it cannot read its RAM (as the engine's own RAM guard refuses parking then). A main process that
takes a worker over (#1748) is held to the same limits as one that connects to a free worker. Checkpoint lists are
bounded (at most
kStageCkptMaxids, checked before the read).start is made again (below); any other error ends the engine as before. When the error is the link's or the
worker's, the
ERRline starts with it, so the server answers 503 with Retry-After, not 400. A failed imageposition table (#1748's
Positions) outlives aCkptRestoreas it outlives aReset, because it belongs to therequest being started.
take-over) holds no session and no checkpoint. So at each request's start the main process checks the idle link
with nothing sent (
StageClient::alive: a 0 ms poll, then a 1-byte peek; the worker never sends unasked) andconnects again there if it is lost. Whenever the link is made again in a request (that check, its positions, its
Reset, its
CkptRestore), the main process drops its live session and every checkpoint, and the request reads fromtoken 0 with a Reset that keeps nothing. A reconnect cancelled at these request-start paths ends that request, and
the engine stays.
last Commit and for the adaptive tier's swaps in flight before it lends cache slots to the prompt (
hs.prefill), asa Reset and a restore do. Without that, a loan could hand the prompt path slots that a swap was still writing, and
the reply degenerated into
!.--pipeline-windows 2. No checkpoint is saved, and the live session is not continued, after a pipelined drainthat failed.
Following upstream. The rebase onto 0.2.0-beta met upstream's checkpoint chain changes:
--prompt-cache-spread(its eviction now goes through the same function on both of the main process's paths, above), and
STRATA_CKPT_POOL/STRATA_CKPT_THREADS, which act on the main process's own part only (a remote main has noin-process stage; the worker keeps its part by id). 0.1.44's Metal backend hands the checkpoint save and restore to
its decode window; the range-taking overloads this branch adds stay on the session's buffers, and a remote stage is
refused on Metal (#1748). Upstream's
copy_checkpoint_beating(the parked conversation's copies, #2049) copies acheckpoint's
remote_idtoo. Details:docs/remote-stage/CHECKPOINTS.md, "After the rebase onto 0.2.0-beta".What it leaves alone.
--prompt-cache, a remote main keepsprompt_cacheat 0: no new message is sent,the prompt is not split, and a Reset is the same header-only message. One-GPU and in-process splits see two
mechanical refactors only (the eviction loop and the zero-and-reset at request start moved into lambdas, the same
calls in the same order). On one GPU with the conversation cache, upstream
main's, #1748's and this branch'sbuilds gave byte-identical answers on 0.1.42; that was not run again since.
--prompt-cache-every,--prompt-cache-tail) and parking (--conversation-cache-mib) stayoff with a remote stage; session files are refused. A config with
--conversation-cache-mibstarts, and the mainprocess says in its log that parking is off.
CkptSaveandCkptRestoreare watched by the engine's stall watchdog as its other messages are.so the next worker checks the real ckpt_max (read from the code and unit-tested, not run on GPUs).
Files:
include/strata/net/stage_ckpt_store.hppandsrc/net/stage_ckpt_store_test.cpp(new: the worker's store),include/strata/net/stage_link.hppandsrc/net/stage_link.cpp(the messages),src/net/stage_link_test.cpp,src/program/generate.cpp(the main process's chain and the worker's side),include/strata/core/verify.hpp(acomment),
src/core/conversation_state.cpp,conversation_copy.hpp,conversation_cache.hpp,conversation_snapshot.hpp(a checkpoint for a layer range and its
remote_id),src/core/conversation_validation_test.cpp,CMakeLists.txt,and the docs (
docs/remote-stage/CHECKPOINTS.md, new;docs/REMOTE_STAGE.md,docs/remote-stage/ENGINEERING.md).Rebased onto 0.2.4.1 (2026-10-24)
This head is #1748's rebase onto
main8183c6b6(v0.2.4.1 and one docs commit, engine 0.1.49.1) plus this PR's sixcommits. The rebase applied with no conflicts, and
git range-diffagainst the 0.2.3 head (8ef01676) shows every commit as thesame patch.
Checked on this head (Linux, the build of the runs below): the build,
stage_ckpt_store_test,stage_link_testandfive CPU tests (
conv_cache_test,spec_prob_test,batch_rows_test,conversation_validation_test,conversation_transfer_test) passed. Not run on this head: the Windows build and ctest.GPU runs on this head (2026-10-24). The same two PCs, model and runs as in the 0.2.3 section below (the 2080 Ti
main, the 3080 worker, 10 GbE, K=26,
--max-context 131072), this head's build on both. The CI container on themain PC's host used 0 cores during every run. In the 0.2.3 section below, "this head" means the 0.2.3 head (8ef01676).
--prompt-cache, exact flags): the same answer--pipeline-windows 2--prompt-cache, exact flags: five greedy prompts on the split against #1748's headRebased onto 0.2.3 (2026-10-23)
This head is #1748's rebase onto
main5c8dd322(v0.2.3, engine 0.1.48) plus this PR's six commits. Git stopped atone conflict, in
Optionsof generate.cpp:prompt_cache_explicitnow sits next to upstream's new defaultconversation_cache_mib = -1, which means "sized from the free RAM under--serve". A remote stage still sets--conversation-cache-mibto 0 before that sizing, so on a remote stage the checkpoints stay the only prompt reuse.No checkpoint code changed in the rebase.
Checked on this head (Windows, MSVC 19.44 + CUDA 13.0,
-DSTRATA_BUILD_CONVERSATION_TESTS=ON):hc_persist_parity)stage_ckpt_store_test,stage_link_test, the 7 conversation testsThe other 5 fail the same way on v0.2.3 itself in the same environment (see #1748).
GPU runs on this head (2026-10-23). The same two PCs and model as in Validation (the 2080 Ti main, the 3080
worker, 10 GbE, K=26,
--max-context 131072), this head's build on both. In the older sections below, "this head"means the 0.2.0-beta head (8ee568ff).
--prompt-cache, exact flags): the same answer--pipeline-windows 2--prompt-cache, exact flags: five greedy prompts on the split against #1748's headValidation
Revision: this head, 8ee568ff (#1748's a3e15682 plus six commits, on
maine88ee39d) (the builds and tests below ran on it before a last wording fix in ENGINEERING.md;git diffoutsidedocs/is empty). The upstream baseline for thePython suites is
e88ee39ditself, run the same way in the same environment.Passed:
Windows 11, MSVC 2022 (19.44.35229) + CUDA 13.0.88, Ninja, Release, sm_86:
cmake --build build --target strata stage_link_test stage_ckpt_store_test conv_cache_test draft_kv_plan_test split_ring_test message_boundary_test coupled_draft_test spec_prob_test bf16_bits_test batch_rows_test batch_groups_test conversation_cache_test conversation_validation_test, rc 0,strata.exelinked.The same build, the CPU tests with
CUDA_VISIBLE_DEVICES=-1, each rc 0:stage_link_test(all passed),stage_ckpt_store_test(all passed),conv_cache_test,draft_kv_plan_test,split_ring_test(23 checks),message_boundary_test(21),coupled_draft_test,spec_prob_test(72 cases),bf16_bits_test,batch_rows_test,batch_groups_test,conversation_cache_test(4772 checks),conversation_validation_test(1020 host-only checks; #1748's head: 972).
Linux (Ubuntu 24.04 container), GCC 13.3 + CUDA 13.0.88, sm_75 + sm_86, Ninja, Release, from a clean build
directory:
ninja strata stage_link_test stage_ckpt_store_test conversation_validation_test conversation_transfer_test, rc 0; withCUDA_VISIBLE_DEVICES=-1,stage_link_testandstage_ckpt_store_testpass,
conversation_validation_test1020 host-only checks andconversation_transfer_test1908 pass.g++ -std=c++20 -O2 -Wall -Wextra -cofsrc/net/stage_link.cpp,src/net/stage_link_test.cppandsrc/net/stage_ckpt_store_test.cpp(GCC 13.3): no warning.python -m unittest tools.test_stage_nodeon Linux (Python 3.12.3): 48 tests OK;python -m pytest tools/test_stage_node.pyon Windows (Python 3.10.8, pytest 9.0.2): 48 passed.python -m pytest serveon Windows (Python 3.10.8): 867 passed, 17 skipped (maine88ee39d: 864 passed, 17 skipped; the three more are #1748's server tests;this PR changes no Python file).
python -m pytest tools/test_setup_*.pyon Windows: 681 passed, 2 skipped, and the same 22 failures asmain(below).
GPUs, this head's Linux build on both PCs (protocol 6), #1748's head as the reference: the main process on an RTX
2080 Ti 11 GB (PCIe 3.0 x16) + Ryzen 9 5900XT, the worker on an RTX 3080 10 GB + Ryzen 9 5900X, 10 GbE, Linux; an
IQ3_S of Qwen3.8-Flash-Next, K=26,
--prefill 5888,--max-context 131072. The replay is two chats of four turnson one shared system prompt of about 16,000 tokens, greedy; "exact flags" are
--pcie-frac 0 --adapt-every 0 --adapt-swaps 0on both PCs,--mtp-max-t 1 --suffix-draft 0on the main, andSTRATA_IQ_MT_MIN=1 STRATA_PREFILL_CPU_SHARE=0on both.--prompt-cache 6--pipeline-windows 2andSTRATA_ROUTE_TAIL_SKIP=0on the main--prompt-cache, exact flags, five greedy prompts on the split, this head against #1748's head--prompt-cache 6--pipeline-windows 2(STRATA_ROUTE_TAIL_SKIP=0)STRATA_REMOTE_CKPT_DROP=1on the worker), without and with--pipeline-windows 2--prompt-cache 6(the worker's adaptive overlap off, #1748's default)!--visionon both PCs), exact flags: two pictures, two questions each, the second sent twice; the split with--prompt-cache 6, the split without it, and one 2080 TiTime to the first token, the served flags,
--think, 400 tokens, one server per arm (the first turn reads from 0in both):
--prompt-cache--prompt-cache 6Faults between two turns, on one held split (served flags,
--prompt-cache 6, text only), the turn-2 questionasking for a code word only turn 1 holds; #1748's agent restarting the worker:
kill -9)--visionon both PCs)No 400 in any of them.
Failed:
python -m pytest tools/test_setup_*.pyon Windows (Python 3.10.8): 22 failures (test_setup_download'sparallel download, two of
test_setup_engine_hash's refusal tests, and 19 subtests oftest_setup_golden).maine88ee39dfails the same 22 in the same environment, test for test; none touches a file of this branch.Not run:
STRATA_ADAPT_OVERLAP=1,no longer the worker's default), and the "before" column of the fault table (the docs commit's build). The
conflict resolutions around
--prompt-cache-spreadandSTRATA_CKPT_POOL/STRATA_CKPT_THREADSare read fromthe code and covered by the CPU tests and the runs above only.
Limits
alive until TCP keepalive notices it, about a minute, and a request in that time finds the loss at its first
message and ends the engine; a loss between the check and the request's first window is found at that window, and
the engine ends; with a relay the check sees only the main process's own link, and a next worker that restarted
while the main process was idle is found by the relay at the request's first message to it, an error that ends the
engine (read from the code; relays were not run).
CkptRestore's own fallback and the newERRtexts were not reached on GPUs (read from the code). A wrong answerwithout an error (a link made again at a request's positions, then the live session continued) was read from the
code and not seen.
--prompt-cacheanswers are not meant toequal a run without it.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.