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
Contributor
Author
|
Closing: this went into 0.1.40 from #550 (see the comment there). It was reopened here only because my old fork had gone private; thank you for taking it. |
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.
Replaces #550. GitHub closed it on 2026-10-05, when my fork was made private by mistake: that took the fork out of the network for good, so it can no longer open pull requests. This is the same branch and commit (
000f288), opened from a new fork; the discussion and the measurements are in #550.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