Feature/amem nccl rl - #2979
Conversation
|
The changes in |
bcb49bf to
96cec4d
Compare
|
Hey @HaochenYuan, I have made the relevant changes. Please tell me if anything else has to be changed. Thank you for the review!! Also i have made a follow-up pr for the rest of the changes #2988 please review that as well. |
| toggle_cuda_graphs(lang_module, 'none', reset_cuda_graphs=reset_cuda_graphs) | ||
|
|
||
| # Restore NCCL memory after inference if AMem is enabled | ||
| if use_amem and amem_offload_during_rollout: |
There was a problem hiding this comment.
Where is use_amem defined?
| # Offload NCCL memory before inference if AMem is enabled | ||
| if use_amem and amem_offload_during_rollout: | ||
| with nvtx_range("amem-nccl-pause-before-inference"): | ||
| if amem_nccl.nccl_pause(): | ||
| logger.info(f"[{dist.get_rank()}:DP] Successfully offloaded NCCL memory") | ||
| else: | ||
| logger.warning(f"[{dist.get_rank()}:DP] Failed to offload NCCL memory") | ||
|
|
There was a problem hiding this comment.
The inference process seems to be the same as training's, if you offload nccl memory before inference while the inference process also needs the comm groups, there may be runtime error.
| - Model parameters can be temporarily offloaded without performance penalty | ||
|
|
||
| AMem enables: | ||
| - Offloading idle model parameters during rollout |
There was a problem hiding this comment.
Amem cannot offload parameters, it can only offload memory used by nccl.
|
Before proceeding, could you confirm if you have tested this change with a compiled amem library? During some earlier beta testing, I observed that amem is currently only able to release NCCL memory for communication groups that are created via the loaded To better evaluate this PR, it would be very helpful if you could share:
Thx! |
- Move nv-grouped-gemm from dev/lts extras to new moe extra - Users can now install megatron-core[dev] without build failures - Add comprehensive error messages with installation instructions - Update README with MoE dependencies documentation This resolves the installation failure when nv-grouped-gemm cannot build due to missing CUTLASS headers. Users who need MoE with grouped GEMM can now explicitly install it with megatron-core[moe], while others can install dev/lts extras without encountering build errors. Fixes NVIDIA#2541
…r RL workflows. Fixed imports, ensured native RL loop support, and validated no errors in touched files. Ready for review and CI on supported platforms.
…lag, gate all logic on --rl-amem-offload-during-rollout, encapsulate env setup, and update docs/examples per review
Add comprehensive design document explaining: - When AMem hooks are enabled (RL rollout phase) - Why RL workloads benefit from memory offloading - What memory is offloaded (model params, optimizer states) - Implementation architecture across core, RL, and training modules - Non-goals and future optimization opportunities This document will accompany the AMem NCCL integration PR to provide reviewers with context on the feature's intent and scope.
|
@HaochenYuan — thanks for the detailed feedback. I've tested the fallback Given your point about torch.distributed.new_group comm groups potentially I'll fix the design doc regardless — AMem offloads NCCL memory, not model Sorry for being late. |
96cec4d to
094628e
Compare
Hi @CodersAcademy006, since NCCL v2.29.7 release has supported dynamic memory offload, the Amem integration maybe not be necessary now. Thx for your contribution! |
|
@HaochenYuan thanks for your explanation and review. If there is any other issue to work on, i would be happy to take that. Thank You. |
RL: Optional AMem NCCL offload support for memory-efficient rollouts
Motivation
Reinforcement learning workflows in Megatron-LM often alternate between training and inference-heavy rollout phases. During rollout, a significant amount of GPU memory can be consumed by NCCL-allocated buffers that are idle from a compute perspective but cannot be reclaimed.
This PR introduces optional support for the AMem NCCL plugin to allow NCCL-allocated GPU memory to be transparently offloaded during RL rollout phases and restored when needed. The goal is to reduce peak GPU memory pressure during inference-dominated steps without changing model semantics or training behavior.
What this PR does
perform-rl-step).Design principles
Expected impact
Scope limitations
Testing