pytorch/torch/csrc/cuda
Shivam Raikundalia 6b5b69a468 [Memory Snapshot] Fix RecordFunction Callback Handling (#153839)
Fixes #153571
Summary:
1. Set annotation callback to global to include all threads
2. Only init callbacks when enable == true and callbacks are empty under mutex
3. When enable == false, check if callbacks are present and if so remove them and set handle to 0 under mutex

We don't expect memory snapshots to be called from several different threads (almost always called just from main) but we make sure to add thread safety in the off case that users do want to call it from different points of entry

Test Plan: Ran basic snapshot and saw that the callbacks were registered properly

Reviewed By: ngimel

Differential Revision: D74771491

Pull Request resolved: https://github.com/pytorch/pytorch/pull/153839
Approved by: https://github.com/ngimel, https://github.com/Skylion007
2025-05-20 17:01:00 +00:00
..
shared API change for new enum in cusparseltsplitkmode-t for cusparseLT 0.7.0+ (#150536) 2025-05-14 23:36:53 +00:00
comm.cpp
comm.h
CUDAPluggableAllocator.cpp [GPU Snapshot] Add Clear History Flag (#149352) 2025-03-19 21:44:20 +00:00
CUDAPluggableAllocator.h [ROCm] Update CUDAPluggableAllocator.h (#1984) (#150010) 2025-04-01 16:49:03 +00:00
device_set.h
Event.cpp [Easy] The event_id of torch.cuda.Event and torch.xpu.Event always is 0 (#151226) 2025-04-26 14:18:22 +00:00
Event.h
GdsFile.cpp Fix initGdsBindings declaration (#152277) 2025-04-27 17:04:56 +00:00
GdsFile.h Fix initGdsBindings declaration (#152277) 2025-04-27 17:04:56 +00:00
Graph.cpp Revert "Implement cuda graphs implementation of torch.cond and torch.while_loop (#140979)" 2025-02-13 18:04:26 +00:00
memory_snapshot.cpp [Memory Snapshot] Fix RecordFunction Callback Handling (#153839) 2025-05-20 17:01:00 +00:00
memory_snapshot.h [Memento] Add PT2 to Memory Snapshot (#152707) 2025-05-12 21:12:51 +00:00
MemPool.cpp Add option to use mempool on OOM (#151487) 2025-04-26 04:04:57 +00:00
Module.cpp [Memento] Add PT2 to Memory Snapshot (#152707) 2025-05-12 21:12:51 +00:00
Module.h
nccl.cpp [Environment Variable][7/N] Use thread-safe getenv functions (#140211) 2025-04-24 01:06:29 +00:00
nccl.h
python_comm.cpp
python_comm.h
python_nccl.cpp Fix minor typo in python_nccl (#148088) 2025-02-28 00:47:09 +00:00
python_nccl.h
Stream.cpp
Stream.h
THCP.h Make torch/csrc/utils.h to be device-agnostic (#152521) 2025-05-04 07:15:11 +00:00
utils.cpp Remove unnecessary condition compilation macro (#152512) 2025-04-30 16:48:25 +00:00
utils.h Make torch/csrc/utils.h to be device-agnostic (#152521) 2025-05-04 07:15:11 +00:00