Conversation
elibol
force-pushed
the
fix/cuda-graph-lifetimes
branch
from
September 7, 2026 05:02
2c38ce5 to
2bc0987
Compare
CudaGraph<'a, T> now mutably borrows every buffer its captured ops touch for as long as it lives: scope/capture bound the op or closure by 'a, the executable's baked-in device pointers can no longer outlive or alias their buffers, and outputs are reachable only after a completed replay (launch borrows the graph mutably; sync/sync_on/outputs synchronize first; into_inner consumes). take_output is removed; replay() and update_with() cover the sync-replay and graph-owned-input idioms. Compile-fail UI tests pin the rejected programs; GPU tests cover replays, async replay, and into_inner. Signed-off-by: Melih Elibol <elibol@users.noreply.github.com>
elibol
force-pushed
the
fix/cuda-graph-lifetimes
branch
from
September 7, 2026 05:13
2bc0987 to
676002f
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.
Breaking API changes (cuda-async):
CudaGraph<T>→CudaGraph<'a, T>: the graph mutably borrows every captured buffer for its lifetime, so dropping, moving, or writing one while the graph can still replay is now a compile error (previously a use-after-free / data race reachable in safe code).take_outputremoved: outputs are reachable only after a completed replay, viaoutputs(&mut self),into_inner(self), or the&mut Treturned byreplay()/GraphLaunch::sync.launchtakes&mut selfand returnsGraphLaunch<'_, 'a, T>; the oldgraph.launch().sync_on(graph.stream())idiom becomesgraph.replay().DeviceOp::graph/graph_ongained a lifetime parameter (where Self: 'a).New:
replay(),outputs(),into_inner(), andupdate_with()(refresh an input buffer the graph owns). Self-referential graph structs migrate by moving buffers into the scope closure and returning them asT(see the updatedcuda_graphsexample). Compile-fail UI tests pin the rejected programs; GPU tests cover sequential/async replays andinto_inner. cutile's public API is unchanged.