mirror of
https://github.com/deepseek-ai/DeepEP.git
synced 2026-11-05 00:47:32 +00:00
[GH-ISSUE #497] [Question] Is there undefined behavior between the calls to cudaFree and cudaIpcCloseMemHandle? #322
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
deepseek-ai/DeepEP#322
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 @hexclover on GitHub (Nov 18, 2025).
Original GitHub issue: https://github.com/deepseek-ai/DeepEP/issues/497
In
Buffer::destroy, each rank first closes the 7 external memory handles, thencudaFrees the local buffer.However, the docs for
cudaIpcOpenMemHandlesays it is undefined behavior tocudaFreethe exported memory region before the call tocudaIpcCloseMemHandle.So in an extreme situation (actually I think this may be common) it is possible for rank 2 to close the handle exported from rank 1 long after rank 1 has freed that buffer. This should be technically considered undefined behavior, although I haven't been able to construct a test that exhibits clearly erroneous behavior, e. g. crashes.
Basically I am wondering about the robustness of this code: is it UB? Does it just happen to work? Or it is guaranteed to work given the current CUDA implementations?
@alpha-baby commented on GitHub (Dec 18, 2025):
maybe you are right!
we should add
intranode::barrierbetweencudaIpcCloseMemHandleandcudaFree