mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #2728] [CLOSED] STRATA_SLOT_COPY_DIRECT=1 (opt-in, CUDA): main session <-> batch slot copies go state to state, without a host image #4233
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#4233
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/2728
Author: @andyhrc
Created: 10/16/2026
Status: ❌ Closed
Base:
main← Head:pr/slot-copy-direct📝 Commits (1)
4efd2c4batch: STRATA_SLOT_COPY_DIRECT=1 - main session <-> slot copies go state to state, without a host image📊 Changes
6 files changed (+206 additions, -26 deletions)
View changed files
📝
docs/BATCHING.md(+7 -0)📝
include/strata/core/conversation_snapshot.hpp(+11 -0)📝
src/core/conversation_snapshot.cpp(+36 -9)📝
src/core/conversation_snapshot_test.cpp(+71 -0)📝
src/core/conversation_state.cpp(+33 -0)📝
src/program/generate.cpp(+48 -17)📄 Description
Summary
Every --batch admission reads its prompt on the main session and copies it into its slot (copy_to_slot); a slot
that holds the start of a prompt is copied back first (copy_from_slot); a read that gives way and park= use the same
copy. Each one saves a host image of every layer's K/V and of the running state and restores it: the K/V leaves its
authoritative pool (VRAM, or the pinned host pool with --kv-resident) for pageable memory allocated for the purpose
and goes back, with a device sync per layer. On a 3 x RTX A4000 layer split (--batch 6, --kv-resident 32768,
200K context) the engine log of one profile counts 1,346 copies into a slot (0.75 s on average, 89K tokens) and 969
copies back (0.80 s, 98K tokens): 30 minutes beside 6.1 hours of prompt reading, and no batch window runs meanwhile.
Change (opt-in, CUDA)
With STRATA_SLOT_COPY_DIRECT=1 the same bytes go from one session's state straight to the other's:
states' layouts at
uptomust be equal (nothing is written otherwise), the target's resident pages are theninvalidated (streamed K/V) or refilled (the draft ring) by the code restore used (now restore_residency());
and PLE window a restore rebuilds; refused before any write when the two sessions do not own the same state.
copy_to_slot / copy_from_slot (and their draft K/V) use them; a slot checkpoint restore (copy_from_slot's
at) isunchanged. Unset, every path is the one before. CUDA (src/); SYCL keeps its own copies and is not touched.
Results
Measured on our production build (this change with #2527 and #2528; 3 x RTX A4000, Qwen3.8-Flash-Next IQ3_S,
0.1.44.1, --batch 6 in 3 groups), the same binary off / on, one filler request keeping batch mode on:
A 117K conversation's next turn spent 1,751 ms before decoding, 444 ms with the variable. Single user 64.6 / 63.1
tok/s, 6 concurrent x 2048 176.7 / 178.1 tok/s (tools/serve_load.py).
How it was checked
Exactness: conversation_snapshot_test (4,670 checks, GPU): every K/V format and mode at 9 lengths equals save +
restore byte for byte, resident pages as a restore leaves them, another layout refused with nothing written; a whole
session's running state the same. With docs/BATCHING.md's exactness settings (STRATA_IQ_MT_MIN=1, --pcie-frac 0,
--adapt-every 1000000, --no-prefill-borrow) the replies of both turns at 8.7K / 46K / 117K tokens in batch mode are
the same tokens off and on; a park and restore gives the identical greedy reply either way.
Built natively on CUDA (sm_86, Linux): the engine and
conversation_snapshot_test. Not built here: HIP (it sharessrc/with CUDA; the new code uses only the calls these files already use) and SYCL (not touched: it keeps its owncopies of these functions).
Extra Notes
Independent of #2527 / #2528:
copy_to_slot/copy_from_slotare upstream code that every--batchadmissionruns. We run it in production with those two on the machine above since 2026-10-16.
🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.