mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[GH-ISSUE #548] decode_cluster_parity: graph replays race their input upload (pageable cudaMemcpy + non-blocking stream) #260
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#260
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?
Originally created by @xenodeve on GitHub (Oct 2, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/548
At v0.1.37,
decode_cluster_parity --selftestfails 5 of its 6 graph replays on an RTX 5060 Ti (sm_120). Each failing replay differs in one argmax token. The kernels look fine: the test's input upload races the graph launch, and with one synchronization after the upload the test passes every time.Environment
db4f91a), unmodified; built locally with CUDA 13.3, MSVC 19.44,-DCMAKE_CUDA_ARCHITECTURES=89;120; only thedecode_cluster_paritytargetMeasurements
Three consecutive runs all failed 5 of 6 replays and exited with 1 (an earlier run failed 4 of 6). This is one of them:
With only the one-line fix below added to the same source and rebuilt, three runs out of three passed all 6 replays and exited with 0:
Likely cause
Not proven; it fits everything above:
run_graph_caseuploads each replay's inputs withDev::put, a synchronouscudaMemcpyfrom a pageablestd::vector(src/kernels/decode_cluster_parity.cpp:60). It then launches the graph oncs(:279), which is acudaStreamNonBlockingstream (:247).cudaMemcpymay return once the data is staged, before the DMA reaches the device. A non-blocking stream is also not ordered behind the legacy stream. So the graph can start before the last upload has landed. The referencesample_tokenslaunch (:283) runs after the graph, so it reads the new logits.:278). The QSA inputs go up first and never differ.cudaGraphLaunchalso uploads the executable graph, which may delay the kernels long enough for the copy to land.Suggested fix
Synchronize in
Dev::put:This also covers
bench(), which has the same pattern (d_l.put(l)at:359, then work on its own non-blocking stream). Other options arecudaMemcpyAsynconcsfrom pinned buffers, or a sync beforecudaGraphLaunch.I have not checked whether any engine path uploads from pageable memory right before a launch on a non-blocking stream. As far as this test shows, the kernels are bitwise identical and the failure comes from the test itself.
@xenodeve commented on GitHub (Oct 2, 2026):
I missed that PR #536 already fixes this (it waits for the uploads in the same test) - sorry for the duplicate. The data above may still help it land: on this sm_120 card under Windows the failure is not occasional but 5 of 6 replays in every run (3/3), and a sync after the upload in
Dev::putalone made it pass 3/3. Feel free to close this in favour of #536.@Niko1221 commented on GitHub (Oct 3, 2026):
Thanks, and the sm_120 numbers helped: 5 of 6 replays in every run makes it clear this isn't a rare flake. Fixed in 0.1.38 the way you suggested:
Dev::putnow waits for the copy to land, which covers the graph replays andbench(). This was test-only. The engine feeds these kernels from kernels on the same stream, so its output was never affected.