Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions aten/src/ATen/cuda/CUDAGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,25 @@ void CUDAGraph::capture_end() {
TORCH_CHECK(stream.stream() == capture_stream_.stream(),
"Capture must end on the same stream it began on.");

<<<<<<< HEAD
AT_CUDA_CHECK(cudaStreamEndCapture(capture_stream_, &graph_));
=======
// Capture is over once cudaStreamEndCapture returns (success or failure).
// Clear bookkeeping before propagating the return status so watchdog-side
// checks cannot observe stale "capture active" state on error paths.
cudaError_t endCaptureErr = cudaStreamEndCapture(capture_stream_, &graph_);
{
std::unique_lock<std::mutex> lock(_currently_capturing_graphs_mutex);
TORCH_CHECK(
_currently_capturing_graphs.count(capture_id_),
"capture_end() called before capture_begin().");
_currently_capturing_graphs.erase(capture_id_);
}
>>>>>>> 08b5c324de0 ([release/2.12] fix leak in CUDAGraph::capture_end (#180395) (#3357))

c10::cuda::CUDACachingAllocator::endAllocateToPool(capture_dev_, mempool_id_);
at::getHostAllocator(at::kCUDA)->end_allocate_to_pool(mempool_id_);
AT_CUDA_CHECK(endCaptureErr);

TORCH_CHECK(graph_ != nullptr, "Invalid capture.");

Expand Down