mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #203] [CLOSED] serve: prompt checkpoints copied out asynchronously (pinned staging on the prompt stream + a thread) #2504
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#2504
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/203
Author: @q8atnight
Created: 9/30/2026
Status: ❌ Closed
Base:
main← Head:pr/async-checkpoint📝 Commits (2)
3bf3b14serve: prompt checkpoints copied out asynchronously (pinned staging on the prompt stream + a thread; STRATA_CK_SYNC=1 = old)3b6100cserve: async checkpoint - the pinned staging buffer and its event are freed at teardown (and on a failed allocation) (review)📊 Changes
1 file changed (+100 additions, -1 deletions)
View changed files
📝
src/program/generate.cpp(+100 -1)📄 Description
Summary
A mid-prompt checkpoint (every
--prompt-cache-everytokens, default 16K) currently stops the GPU:cudaDeviceSynchronize()plus pageablecudaMemcpys into fresh vectors - ~370 ms of GPU idle per checkpoint onour box. This copies the same bytes out asynchronously: the running state goes to a pinned staging buffer through
stream-ordered
cudaMemcpyAsyncs on the prompt stream (ordered after the chunk that produced the state, beforethe next chunk overwrites it; ~10 ms of copy engine), and a thread moves it into the checkpoint's own vectors
while the next chunk runs. The checkpoint joins
checksat the next checkpoint, at a turn/root checkpoint, oronce the prompt is read. One commit on top of 0.1.27 (
a790805).Measured
2x RTX 3090, IQ3_S, developed in the 0.1.24 + dual-GPU engine: the synchronous copy-out held the GPU idle
~370 ms per mid-prompt checkpoint; async it overlaps the next chunk, so the prompt path does not wait for it.
With
--prompt-cache-every 16384a 128K prompt takes ~7 checkpoints, so up to ~2.6 s of GPU idle (7 x ~370 ms, arithmetic, not separately measured).Correctness
The checkpoint contents are unchanged - the same bytes, only copied later. The copy is stream-ordered between the
chunk that wrote the running state and the chunk that overwrites it, so no sync is needed on the prompt path.
A layer split keeps upstream's path untouched: its checkpoints are assembled from the stages' own parts, saved on
their own streams, and a per-stage pinned staging does not obviously fit there - say so if you want it extended.
Switch
STRATA_CK_SYNC=1= the old synchronous path.STRATA_PREFILL_TIMING=1traces the staging allocation and theenqueue time of each async checkpoint.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.