Repository navigation
Conversation
…non-blocking streams read the table Every upload of the expert residency table (host_res -> d_res, and each stage's) was a plain cudaMemcpy: a pageable copy on the legacy stream, which may return before its DMA has landed, while the kernels that read the table run on streams created cudaStreamNonBlocking, which do not wait for the legacy stream. A kernel enqueued right after could read a table half old, half new: an expert computed by both the GPU and the CPU, or by neither. The ~100 KB copy lands in microseconds, so this rarely fires, but nothing ordered it. The uploads now go through res_put(), which waits for the copy on the current device's legacy stream only. Same values, same output. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VZy1yKaDDiA8a7svdwaHio
slovx2
added a commit
to slovx2/Strata
that referenced
this pull request
Oct 3, 2026
Port the functional synchronization fix from upstream Niko1221#463, residency uploads from Niko1221#550, and the all-layer fused layout guard from Niko1221#546. Keep the existing engine and defaults otherwise. Co-authored-by: multica-agent <github@multica.ai>
Contributor
Author
|
Reopened as #1043, the same branch and commit. GitHub closed this one when my fork was made private by mistake, which took it out of the fork network. |
Niko1221
added a commit
that referenced
this pull request
Oct 6, 2026
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This was referenced Oct 6, 2026
Owner
|
Merged for 0.1.40 with one change: HIP has no cudaStreamLegacy, so the wait is on stream 0 (the same stream on both CUDA and HIP). Thank you. |
Niko1221
added a commit
that referenced
this pull request
Oct 6, 2026
anon761
pushed a commit
to anon761/Strata-upstream
that referenced
this pull request
Oct 6, 2026
sskver
pushed a commit
to sskver/Strata
that referenced
this pull request
Oct 7, 2026
Niko1221
pushed a commit
that referenced
this pull request
Oct 10, 2026
…ts for the copy kvg_trim refilled the slots the K/V gave back and then uploaded host_res with a plain cudaMemcpy from pageable memory. That returns once the table is staged, before its DMA lands, and nothing after it waited for stream 0: the next request's session_zero syncs main_stream only, and a prompt part of --short-read tokens or fewer goes straight to ver.run, whose graph reads hits_.d_res on the verifier's cudaStreamNonBlocking stream. res_put (#550) is the upload every other residency change uses: the same copy, then cudaStreamSynchronize(nullptr). kvg_ensure's upload needs nothing: qsa_kv_elastic_grow ends in cudaDeviceSynchronize before anything reads the table. Only --kv-grow (opt-in) runs kvg_trim, so the default path is unchanged.
giridhart
pushed a commit
to giridhart/Strata
that referenced
this pull request
Oct 15, 2026
…ts for the copy kvg_trim refilled the slots the K/V gave back and then uploaded host_res with a plain cudaMemcpy from pageable memory. That returns once the table is staged, before its DMA lands, and nothing after it waited for stream 0: the next request's session_zero syncs main_stream only, and a prompt part of --short-read tokens or fewer goes straight to ver.run, whose graph reads hits_.d_res on the verifier's cudaStreamNonBlocking stream. res_put (Niko1221#550) is the upload every other residency change uses: the same copy, then cudaStreamSynchronize(nullptr). kvg_ensure's upload needs nothing: qsa_kv_elastic_grow ends in cudaDeviceSynchronize before anything reads the table. Only --kv-grow (opt-in) runs kvg_trim, so the default path is unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Every upload of the expert residency table, host_res to
d_resand each stage's, is a plaincudaMemcpy(src/program/generate.cpp, 9 call sites). The kernels that read the table run on streams createdcudaStreamNonBlocking.cudaMemcpymay return once the data is staged, before its DMA has landed.So nothing orders a kernel enqueued right after an upload (the next verify window after an adaptive swap, a trim, a refill) behind the copy. That kernel could read a table half old, half new: an expert computed by both the GPU and the CPU, or by neither.
The table is ~100 KB and usually lands in microseconds, so this rarely fires. It is the same class as #532 and #536, where the tests' uploads raced their non-blocking streams. Ours made one of those tests fail in 6 of 20 runs.
Fix: the uploads go through
res_put(), which waits for the copy on the current device's legacy stream (cudaStreamSynchronize(cudaStreamLegacy)): that copy only, not the device.Measured on an RTX 5090, IQ2_XS (ISTA),
--expert-cache 14900, v0.1.37 against this PR:--stop-eos), 6 interleaved pairs: 15.82 ms a round against 15.93 (+0.7%, within noise). One more pair is left out: 19.80 ms on a different token path, a desktop stall.🤖 Generated with Claude Code
https://claude.ai/code/session_01VZy1yKaDDiA8a7svdwaHio