Repository navigation
Conversation
yuweih205
force-pushed
the
fix/deferred-epilogue-multistream-wait
branch
from
October 17, 2026 08:10
3dd1c67 to
ebaaab5
Compare
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.
Summary
Retain a completion event after a successfully executed
EventOverlaphook, solater waits on other CUDA streams also depend on the work enqueued by that hook.
The event returned by the communication operation precedes its deferred epilogue.
The first wait runs the hook on its current stream and clears the hook; another
stream currently waits only for the original communication event. It can then
read tensors before the epilogue's GPU work is complete. The same issue applies
to deterministic sorting registered as an after-wait hook.
The fix keeps the original event and its retained tensors alive, records a
separate native
EventHandleafter the hook succeeds, and includes it in laterwaits. Explicit
release_handle=Truereleases both event handles. Hooks stillrun once and only the first wait returns their result. A failing hook remains
retryable. The ordinary no-hook path records no additional CUDA event. No
host/device synchronization is added.
Regression coverage
The current diff includes a standalone two-function CUDA regression in
tests/utils/test_event.py:original-event negative control, repeated waits, single-hook execution and
explicit event-handle release. The test requires the delayed write to still
be pending when the negative control completes; an ineffective window fails.
event is recorded.
Run it in an installed/built checkout:
Historical extended harness
The earlier standalone CUDA regression harness, retained in the tested commit
e15813d, checks:with and without explicit release.
Its eager race tests require the delayed write to still be pending before the
reader is queued. Otherwise they fail as an ineffective race test. They drain
both streams even if an assertion fails. This historical five-method harness
is not the current two-function regression.
Validation
Current polished revision
Head:
ebaaab5f4b58d3fd96ccbc9ba66481ba41cd1703, based on public mainb5a33eefda39485f438dc764695b71ba7b9249b6.Both current CUDA regression functions passed on H200 with PyTorch
2.13.0+cu132, CUDA 13.2 and NCCL 2.32.3. This run covers the currenttwo-function regression, not a rerun of the extended historical harness or
its CUDA Graph cases. The production wrapper's Python AST matches the
previously published fixed implementation.
Historical extended validation
Validated on eight H200 141GB GPUs, PyTorch 2.13.0+cu132, CUDA 13.2 and NCCL
2.32.3. Base: public main
93eb6eb238127e96c6d7a4a625a6dad158348509; pinnedDeepJIT
cba802df081985141eeee36803685775c183a047. The_Cextension was builtfrom those unmodified native sources. Only the Python event wrapper differs
between the original/fixed regression arms.
both explicit-reader release cases and the context-manager case. The CUDA
Graph case also reproduces stale reads in all 24 suites.
no skipped tests. Each Graph test verifies three replays.
deferred-epilogue configurations and all 72 non-deferred configurations pass.
This covers fresh/cached, compact/expanded, BF16/FP8 dispatch and combine,
bias variants, previous-event and allocation-stream settings, and repeated
deterministic dispatch checks.
These results belong to the earlier extended harness and functional-suite
validation. That larger harness is not included in the current diff; the
two-function CUDA regression above is included.
Re-run the upstream EP8 functional suite in an installed/built checkout:
The first historical build attempt stopped before tests because the image
lacked the DeepJIT dependency
elfutils/libdwfl.h. Reusing the availablelibdw/libelf development headers allowed the frozen source/test payload to
build and pass.
This is a stream-ordering correctness change, not a performance claim or a
full-model/training/backward validation.