You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 462a4af
Browse filesBrowse the repository at this point in the historyBrowse files
CUDA backend: fix GPU tensor leak in execute() with RAII cleanup (pytorch#18674)
Built on top of pytorch#18673
Same bug as the Metal backend: execute() pre-creates GPU output tensors,
but AOTI's run() replaces them with its own handles. The pre-created
SlimTensors were orphaned — 1 leak per execute() call. Unlike Metal
(where orphans accumulated in a global tracking set causing O(n)
progressive slowdown), CUDA's orphans are a pure GPU memory leak since
SlimTensor uses plain new/delete without global tracking.
Fix: delete orphaned pre-created outputs immediately after run() (before
the error check, so orphans are cleaned even if run() fails). A
ScopeGuard (from backends/aoti/utils.h) provides RAII cleanup for
gpu_outputs on any early-return error path — normal paths null entries
as they take ownership, so the guard is a no-op on success.
Also removes the redundant delete_slimtensor_vector(gpu_inputs) on the
happy path, since run() steals inputs via internal RAII
0 commit comments