mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #4551] [Engine] session-file v3: incremental append saves under --session-save-append #5084
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#5084
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/4551
Author: @sakuumomo
Created: 10/28/2026
Status: 🔄 Open
Base:
main← Head:pr/engine-session-save-append📝 Commits (10+)
e05bf4aAdd an opt-in build that runs CUDA and HIP in one processf8e0e29A hybrid build follows 0.2.2's HIP rules for a HIP primary: the early PLE flag and side-thread launch rule, the queue priming, and the integrated-GPU cache reserveb17e8dcdocs: the hybrid CUDA+HIP build (opt-in), its devices and its probe commandcf3d713A hybrid build follows 0.2.3's drafter rules for a HIP primary too: the dflash2 stream priority and fork defaults, the Strix Halo window cap and the 12 GB card linebf40f37hip_compat: cover the CUDA usages main's drafter brings to the HIP copy8843b4ehip_compat: drop grid_constant on the HIP copy0d8075fhybrid: do not glob the dsv41 engine path into strata256cd07hybrid: keep the moe_ws family out of the HIP glob - upstream #3752 (GP100 weight-stationary experts) landed with the 0.2.7 rebase, after this file was written. The kernels are pure PTX (prmt/mad.wide/f16x2 asm): on the CUDA side they are strata_mmq sources only under STRATA_EXPERIMENTAL_SM60, gated at run time to machines whose every GPU is cc 6.0. A hip-src copy of them fails on 'invalid output constraint =f' / 'invalid instruction' in the gfx1150 pass, and could never dispatch on an AMD device - so they belong beside the gdn_chunk/mmq_nvfp4/mmq_kq_lib exclusions. moko flavor build was the witness: moe_ws_down/gu_iq2/gu_iq3 were the only FAILED targets.1b8fa69hybrid: speak CUDA 13's plain runtime API names9828162Let a HIP helper read pinned expert rows in place📊 Changes
58 files changed (+12173 additions, -222 deletions)
View changed files
📝
CMakeLists.txt(+53 -5)📝
bench/results/2026-10-10-community-2x-p40-iq3_s/README.md(+4 -2)➕
cmake/hip-host-tramp.py(+99 -0)➕
cmake/hybrid.cmake(+406 -0)➕
cmake/prefix-hip.py(+97 -0)📝
docs/AMD_HIP.md(+25 -1)📝
docs/DETAILS.md(+59 -6)📝
docs/MULTI_GPU.md(+2 -1)📝
docs/QUANTS.md(+2 -1)📝
include/strata/core/conversation_cache.hpp(+12 -1)📝
include/strata/core/conversation_file.hpp(+186 -5)📝
include/strata/core/conversation_snapshot.hpp(+33 -1)📝
include/strata/core/device.hpp(+3 -4)📝
include/strata/core/expert_cache.hpp(+1 -1)📝
include/strata/core/expert_source.hpp(+19 -0)📝
include/strata/core/layer.hpp(+7 -0)📝
include/strata/core/remote_experts.hpp(+22 -1)📝
include/strata/core/session.hpp(+42 -0)📝
include/strata/core/session_save_reclaim.hpp(+38 -9)📝
include/strata/hip_compat/cublas_v2.h(+4 -0)...and 38 more files
📄 Description
Problem and result: saves rewrite the whole conversation file every time — a 30k-token session costs ~1.1 GB written per save. This adds an opt-in incremental mode: with
--session-save-append, a save APPENDS its new generation group onto its own file instead of rewriting it, behind the trailer chain + digest authority cascade that already guards a torn tail. Flag-off behavior is unchanged: a flag-off save is byte-identical to v2 (pinned byconversation_file_test's golden fixture).On a live serve host (proof tables collapsible below): re-save with no request in between went from writing 1,109,307,968 bytes in 8.88 s to appending 237,226,496 bytes in 1.97 s; a second shape: 1,053,068,864 / 31.5 s → 237,210,624 / 2.11 s.
Related discussion: #4552 (the steady-state blocker: engine-internal mount/borrow watermarks dirtied from token 0 — fixed on this branch as of 2026-11-07: every proven-bytes resume now marks the restored prefix, see Approach and Limits). Stacks on #4310 — see Limits.
Approach:
session_save_gate+ the kv watermark M1–M7 inSessionState): a save may append only when the pool's first dirty cell, rounded to whole pages, is at or above the file's whole-page committed prefix. The whole-page rounding is load-bearing: comparing against the rawsaved_tokensmade every save at an unaligned boundary refuse its own next append — that bug was found by measurement on a live host (13 saves, 0 appends) and is pinned here with an unaligned gate matrix (conversation_append_test,session_watermark_test).bytes(appended-only SAVED field) so the serve-side ladder can recordappended/delta_bytesin its save ledger.size_twhile the reader'scount(uint64_t& …)binding needsuint64_t— identical types on Linux,unsigned longvsunsigned long longon macOS arm64, where the reference refuses to bind (metal-linkCI caught it). The count now follows the file's u64-counts convention; the other twelvecount()sites already did.conversation_kv_restore/conversation_kv_restore_prefix(M9) mark a COMPLETED restore atupto; a mid-transfer failure marks 0 (partial bytes landed); a refusal that wrote no pools marks nothing, so a rejected attempt cannot invalidate the watermark a previous save earned. The engine sites follow: the file restore (M3) at the restored conversation's whole cells, a park restore (M4) per carve against its own stage image, a prefix borrow (M4) at the borrowed count, a batch slot handing its conversation back (M5) at the tokens it returned; the zeroing sites (M2) keep marking 0 — there nothing was restored — and the checkpoint mount (M8) already marked at spare-row granularity, unchanged. On a layer split the save gate now consultssession_gate_watermark, the fold (most-dirty carve) over every carve — a stage rewritten below the committed boundary refuses the append, the file-corrupting direction of the same defect — and the post-save raise lifts every carve's watermark, so a split save stops refusing its own next append.Validation (branch tip
f1dbcea0— the append delta re-applied on the rebuilt 0.2.8 lineage; the v3 content is identical to the gate-verifiedd74bcec6tree; local NixOS x86_64, AMD gfx1030 / ROCm 7.2.3; model Qwen3.8-Flash-Next IQ3_XXS GGUF,--kv fp16 --max-context 262144 --kv-resident 32768 --layer-split 19):Passed:
cmake --build build && ctest --test-dir build -R 'conversation_(file|append|split_failure|cache|memory)_test|session_save_reclaim_test|session_watermark_test'(nix develop toolchain): 100 % tests passed out of 7. Running the binaries directly:conversation_append_test1969 checks,conversation_file_test263,session_watermark_test21.conversation_file_test+conversation_append_test— 0 warnings (1969 + 260 checks; 3 filesystem-shape file checks skip under the sanitizer).d74bcec6: the HIP/gfx1030 build and the CUDA build that also compiles the shared kernels for gfx1150 — rc=0.d74bcec6: Metal build (macOS arm64), Minimal serving runtime, Title area — all green; on the rebased tipf1dbcea0the Metal and title jobs are green again. Metal is compile-only here; no Metal execution claimed.dd4790a7build — the same lineage; the one commit on top is the macOS type binding above): the append/refusal/restoration behaviors in the collapsible tables below, from real saves against a running GPU engine, with the append delta round-tripping through the engine result into the serve-side save ledger.v0.2.8(870aedd9): the 16-commit append delta re-applied clean on the rebuilt chain of #4310 + #4306 + #4307 + #4411 + #3551/#3552/#3553 (nixos== branch tip; 85 signed commits on870aedd9). Gates re-run on the rebuilt tip: session test family 7/7 (append 1969, file 263, watermark 21), ThreadSanitizer 1969 + 260 checks 0 warnings, full serve suite 1386 passed / 17 skipped, HIP and CUDA+HIP hybrid flavor builds rc=0 with installCheck.Failed: none on the submitted tree. (The previous head
dd4790a7failed the macOSmetal-linkcompile — that failure is the compile fix above and the current head is green on the same job.)Not run: Windows builds; execution on NVIDIA hardware (the CUDA-flavor evidence is compile-only); Metal execution.
Update (2026-11-07): rebased onto upstream
v0.2.12(123bad4a, engine 0.1.58) with zero conflicts; the append delta re-applies 1:1 and the #4552 fix lands as described in Approach. The branch is fast-forwarded to the rebuilt train tipc3e4cdc4(93 signed commits: the seven other PR chains of this stack re-merged in order onto123bad4a, the append delta + #4552 fix riding the tip). Gates on that lineage: session test family 7/7 (conversation_append_test1969 checks,conversation_file_test263,session_watermark_test31 — the battery grew with the #4552 pins: completed-restore marking atupto, mid-transfer failure marks 0, refusal marks nothing, park/borrow/batch prefix pins, the split-gate fold, the post-save raise of every carve —,session_save_reclaim_test167); ThreadSanitizer 1969 + 260 checks, 0 warnings; full serve suite 1640 OK / 37 skipped; CUDA-13 nvcc (arch 89) compile ofstrata,conversation_snapshot_testandconversation_stage_split_testrc=0 (GPU execution stays with the validating CUDA hosts); HIP gfx1030 and CUDA+HIP hybrid (gfx1150, CUDA 13) flavor builds with installCheck. Engine identity across this pin (0.1.54 -> 0.1.58;SessionConfig::engine_versionis in the file's config fingerprint): the first save of each pre-existing session file is a full rewrite by construction.Limits:
session_watermark_testprefix pins). The remaining boundary is unchanged and remains correct: a resume that genuinely rewrites rows below the committed boundary (grow/trim churn) still refuses. A live-host re-measure of the steady state follows the owner's re-pin to the 0.2.12 lineage.mainthen. The merge lineage this branch sits on is fetchable atsakuumomo/Stratabranchnixos(the run-here lineage: #4310 + #4306 + #4307 + #4411 + #3551/#3552/#3553 re-merged in order onto123bad4a, the append delta + #4552 fix on the tip;nixos== this branch @c3e4cdc4; earlier lineage tips stay fetchable as tagspin-*).Live-host proof tables (click to expand)
Captured 2026-10-29 against the pre-#4552-fix build (engine 0.1.54 lineage
dd4790a7). The refusal rows are the real behavior of that build — Proof B rows 2–4 show exactly the defect the #4552 follow-up above fixes; a fresh capture against the 0.2.12 lineage follows the owner's re-pin.Proof A — chain-re-push shape (session
probe-app-e), engine flags--session-save-reclaim --session-save-append:save gate: full rewrite - no verified checkpoint chain for this file)n_written237,226,496 (delta), 1.97 s, log suffix(appended)pool rows at or below the file's saved boundary may differ from what it committed(the K/V grow/trim genuinely churns rows below the boundary)Proof B — short-increment shape (session
probe-app-f, 28,966 → 29,014 tokens, inside the resident window):Engine log excerpts (session-dir paths elided):
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.