Skip to content

Gate checkpoint-time GPU memory reclaim behind --ckpt-release-gpu-memory - #1

Closed
deepakn94 wants to merge 5 commits into
shurkat-nvidia:remove-torch-cuda-empty-cachefrom
deepakn94:dnarayanan/ckpt_free_memory
Closed

deepakn94 wants to merge 5 commits into
shurkat-nvidia:remove-torch-cuda-empty-cachefrom
deepakn94:dnarayanan/ckpt_free_memory

Conversation

@deepakn94

@deepakn94 deepakn94 commented Aug 10, 2026 •

Copy link
Copy Markdown

Stacked on top of NVIDIA#5678 (targets shurkat-nvidia:remove-torch-cuda-empty-cache).

What does this PR do?

Rather than dropping the checkpoint-time memory reclaim outright, this hides both free_overlap_buffers() and torch.cuda.empty_cache() in save_checkpoint_and_time() behind a new --ckpt-release-gpu-memory argument that defaults to off. Nobody pays the multi-second cost per save by default, but runs that depend on the extra GPU headroom for the async checkpoint worker (the reason NVIDIA#5170 was reverted by NVIDIA#5366) can opt back in without a code change.

The two Nemotron3 Super GB200 release configs set --ckpt-release-gpu-memory: true, so they keep today's behavior and the PYTORCH_ALLOC_CONF override is reverted to its previous commented-out state. The --async-strategy: nvrx / --async-ckpt-use-cpu-shm: true additions from NVIDIA#5678 are kept.

Changes

  • megatron/training/config/training_config.py: new ckpt_release_gpu_memory field on CheckpointConfig (default False), with a pointer to allocator tuning as the cheaper alternative.
  • megatron/training/training.py: gate the two calls on args.ckpt_release_gpu_memory.
  • tests/functional_tests/test_cases/nemotron/nemotron3_super_release_gb200{,_sm}/model_config.yaml: set --ckpt-release-gpu-memory: true, revert PYTORCH_ALLOC_CONF.

Pre-checks

  • (N/A) I have added relevant unit tests
  • (N/A) I have added relevant functional tests
  • I have added proper typing to my code
  • I have added relevant documentation (argument docstring)

shurkat-nvidia and others added 5 commits July 6, 2026 11:53
torch.cuda.empty_cache() was added as a workaround for out-of-memory
errors on some models. With async-shm checkpointing, some of the memory
pressure is reduced. Remaining memory fragmentation and pressure can be
reduced by properly configuring the torch allocator.

Signed-off-by: Skand Hurkat <shurkat@nvidia.com>
 - Update checkpointing to use nvrx with shm.

 - Provide PYTORCH_ALLOC_CONF environment variable to initiate garbage
   collection. Use larger blocks to avoid fragmentation due to
   splitting.

Signed-off-by: Skand Hurkat <shurkat@nvidia.com>
Instead of removing the checkpoint-time free_overlap_buffers() and
torch.cuda.empty_cache() calls outright, put both behind a new
--ckpt-free-memory argument that defaults to off, so runs that rely on the
extra GPU headroom for the async checkpoint worker can opt back in. The two
Nemotron3 Super GB200 release configs set the flag and therefore no longer
need the PYTORCH_ALLOC_CONF override, which is reverted to its previous
commented-out state.

Signed-off-by: Deepak Narayanan <dnarayanan@nvidia.com>
The previous name parsed as a noun phrase, so it read like it described an
amount of free memory rather than an action. Release is unambiguously a verb
and gpu says which memory is reclaimed.

Signed-off-by: Deepak Narayanan <dnarayanan@nvidia.com>
@deepakn94 deepakn94 changed the title Gate checkpoint-time GPU memory reclaim behind --ckpt-free-memory Gate checkpoint-time GPU memory reclaim behind --ckpt-release-gpu-memory Aug 10, 2026
@shurkat-nvidia
shurkat-nvidia force-pushed the remove-torch-cuda-empty-cache branch from debb98a to c7830f1 Compare August 10, 2026 21:01
@deepakn94 deepakn94 closed this Aug 10, 2026
@deepakn94
deepakn94 deleted the dnarayanan/ckpt_free_memory branch August 10, 2026 21:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants