Repository navigation
Conversation
Revert csrc/cumem_allocator.cpp to main. The C++ fix that skips unmapping an allocation freed while asleep is now split out as vllm-project#59228; this PR depends on it and keeps no Python remap before the free. Signed-off-by: aoshen02 <aoshen@inferact.ai> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
This pull request has merge conflicts that must be resolved before it can be |
my_free() always unmapped and released the handle returned by the Python free callback, but sleep() has already done both for an asleep allocation. Freeing a cuMem pool tensor while asleep (engine teardown, or a tensor freed during sleep) therefore double-unmapped it, and the stale error_code made the next create_and_map (e.g. wake_up) fail. unmap_and_release() now zeroes the released handle and my_free() skips a zero handle, only freeing the address reservation, as the ROCm path already does. Signed-off-by: aoshen02 <aoshen@inferact.ai> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
49b5f1a to
85eac2a
Compare
|
Independent H20 verification of the current patch: we applied the diff from
For comparison, our prior run on the same pinned main without the fix failed in the first native-probe round with This verifies the current patch applied to the pinned base, not the entire current PR-head checkout or complete engine shutdown. The scope is the allocator free path; we did not need to rerun the large-model matrix to establish this result. |
Purpose
my_free()incsrc/cumem_allocator.cppalways callsunmap_and_release()on the handle returned by the Python free callback. For an allocation that is asleep,sleep()has already unmapped it and released the physical handle, so freeing a cuMem-pool tensor while asleep double-unmaps it. The driver error is left in the globalerror_code, so the nextcreate_and_map(e.g.wake_up()) or cuMem allocation fails with that stale error. This happens on engine teardown while asleep, or when a pool tensor is freed during sleep. It becomes more frequent once CUDA graph pools are cuMem-backed (#59160).Fix (CUDA path only; the ROCm path already skips an asleep allocation via an empty chunk list):
unmap_and_release()sets*p_memHandle = 0after a successful release;my_free()skipsunmap_and_release()for a zero handle and only frees the address reservation.No Python change is needed:
_python_free_callbackalready pops the entry, drops the CPU backup and returns the handle. The Python-only alternative, remapping physical memory before the free so the C++ unmap succeeds, can OOM when a colocated trainer holds the VRAM freed by sleep.Related:
my_freeon allocations already released bysleep().Test Plan
New
test_free_while_asleepintests/basic_correctness/memory/cumem/test_cumem.py(discard and offload variants): sleep, free a pool tensor while asleep by releasing the pools withrelease_pools()(as engine shutdown does), then check that the pointer is untracked, the CPU backup is dropped, no memory is remapped, andwake_up()succeeds with the other tensors intact.Test Result
GB300, torch 2.13.0+cu130, extension rebuilt from this branch:
test_cumem.py: 14/14 pass, includingtest_free_while_asleep[discard]and[offload].release_pools()test change: the 7 non-LLM tests pass on this branch, and the 9 non-LLM tests pass with this PR applied on top of [Feature] Release WorkspaceManager scratch on sleep #59156, which stores a list of pools per tag. With the unpatched extension both new cases still fail with the same error. The test no longer depends on the layout ofallocator_and_pools.wake_up()withCUDA Error: invalid argument at csrc/cumem_allocator.cpp:258, from the staleerror_codeleft by the double unmap.--shutdown-timeout 60).CUDA Error: invalid argument.out of memory.AI assistance was used to prepare this change; I reviewed the diff.
Re-check on current main (
bdd31c31d), GB300 (rebased; test-only conflict intest_cumem.pyresolved by keeping both sides)Re-checked on main bdd31c3 (rebased: the only conflict was the insertion point in
test_cumem.py next to the new #59156/#59158/#59160 tests; both kept), 4x GB300,
torch 2.13.0+cu130, extension rebuilt from this branch:
from main's csrc) both test_free_while_asleep cases fail at wake_up() with
"CUDA Error: invalid argument at csrc/cumem_allocator.cpp:258".
asleep gives 4x "CUDA Error: invalid argument at cumem_allocator.cpp:258" (one per
worker) on main in all 3 launches and 0 with this PR. Asleep memory (11321 MiB/GPU),
wake time (1.26-1.34 s) and outputs (3 sleep/wake cycles, 28/28 greedy and 28/28
seeded top-k/top-p identical to the awake reference) are unchanged.
🤖 Generated with Claude Code