Repository navigation
Conversation
Adds an "nccl" option for `refit_backend` alongside the existing "gloo" and "nvshmem" copy services when transferring training weights to the Megatron generation engine in non-colocated setups. Megatron-Core already ships an `NCCLCopyService` (moves weight bytes via CUDA-tensor `batch_isend_irecv`), but NeMo-RL only wired up gloo/nvshmem. The nccl path registers an NCCL/CUDA backend on the cross-world refit ProcessGroup (in addition to the GLOO/CPU backend that the object collectives in `prepare_swap_model_weights` rely on) so the CUDA P2P sends/recvs dispatch to NCCL. Motivation: on the nano-3.5 30B-A3B MoE, the nvshmem copy service's per-step refit is slow and degrades step-over-step (~95s climbing to 135s+), whereas nccl refit stays flat at ~16-19s per step and needs no NVSHMEM_MAX_TEAMS tuning. Signed-off-by: shanmugamr1992 <[email protected]> (cherry picked from commit e41568a) Signed-off-by: Anil Thomas <[email protected]>
Signed-off-by: Teodor-Dumitru Ene <[email protected]> (cherry picked from commit 34c41e9) Signed-off-by: Anil Thomas <[email protected]>
Colocated MegatronGeneration returned from __init__ without starting the engine, leaving dp_openai_server_base_urls empty; NeMo-Gym's policy_model then had zero clients (ZeroDivisionError per rollout). Offload buffers, start the engine, and collect worker URLs like the non-colocated path.
Build the colocated model as transformer_impl=inference_optimized: dual-mode layers run fast decode kernels under InferenceMode and fall back to the trainable TE path for training, so one model trains and generates fast (no second model, no weight sync). Closes the colocated rollout-speed gap. Relax the training guard behind allow_inference_optimized_training, register InferenceColumnParallelLinear with the Megatron->HF exporter, and set inference_optimized + moe_pad=false + activation_checkpointing in the config. Co-Authored-By: Claude Opus 4.8 <[email protected]> Signed-off-by: Anil Thomas <[email protected]>
Graph the decode block (cuda_graph_impl=local, scope=block) so MoE decode is fast enough to overlap training, and sync at the engine suspend/resume boundary to keep the shared communicator in step across cycles.
The suspend/resume drain used torch.cuda.synchronize() with no device arg on the Ray caller thread, which never set its device and so drained device 0 for every worker. Target the explicit LOCAL_RANK device instead, drain on the inference thread before suspending, and fence before resuming decode.
async_grpo_train saved distributed checkpoints while colocated generation was live, so the checkpoint's world-group collectives raced the engine's decode collectives on the shared GPUs and deadlocked. Pause the collector and engine before save_checkpoint and resume after finalize.
Assert the pause/resume helpers order collector drain, engine pause, checkpoint collectives, engine resume, and collector resume.
Report samples/hour and the exposed-generation lull share for colocated vs non-colocated runs from wandb per-step _runtime. samples/hour = steps/hour x train_global_batch_size keeps mixed-batch runs comparable. Defaults to the CMP=1 runs; run IDs/project overridable. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Add validate_all_checkpoints.sh (offline-val every step_N checkpoint and log one wandb reward curve) plus the CMP=1 launch preset that reproduces the colocated-vs- non-colocated comparison runs. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
… runs Log train/consumed_samples for async GRPO indexed by wall-clock elapsed time (via a define_metric step_metric) rather than step, since the async step cadence is uneven (buffer-empty waits) and a vs-step curve misstates throughput. Also log ray/mean_gpu_util, the mean utilization over the whole GPU pool, as one chart. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
SEQ_LEN (default 16384) matches the checkpoint's training seq, and override_opt_param_scheduler skips the checkpoint-vs-config warmup assertion (val-only run builds no usable scheduler). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
run_megatron_eval.py loads a checkpoint into a dedicated non-colocated MegatronGeneration (init_optimizer=False), generates on the val set, scores via the env, and reuses grpo.validate() to report accuracy -- no optimizer or scheduler. Extracts the _spinup_nemo_gym closure to a module-level spinup_nemo_gym so the entrypoint builds the same env actor without a training Policy. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Offline-val each checkpoint via the inference-only run_megatron_eval.py (dedicated non-colocated MegatronGeneration, no optimizer/scheduler) on a 4-node interactive cluster. The eval config is the 2nd positional arg; keeps the per-step Accuracy scrape and the single-wandb-run reward curve. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Signed-off-by: Anil Thomas <[email protected]>
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Signed-off-by: Anil Thomas <[email protected]>
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Signed-off-by: Anil Thomas <[email protected]>
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Signed-off-by: Anil Thomas <[email protected]>
Concurrent workers importing megatron off lustre hit a PEP-420 namespace resolution race, and ray.sub launched Ray even when SETUP_COMMAND had failed. Add tools/retry_import.sh to retry the import in fresh processes on every node before Ray starts, and make ray.sub treat a failing SETUP_COMMAND as a failed attempt so it retries. Signed-off-by: Anil Thomas <[email protected]>
The async trajectory collector could saturate its Ray actor pool with rollout work, leaving no slot for the main loop's control calls (pause, prepare_for_refit, size queries), which stalls the training step. Signed-off-by: Anil Thomas <[email protected]>
The wandb `_runtime` staircase conflates startup with training, and steps/hour cannot compare runs whose global batch differs. Read `train/consumed_samples` against `train/elapsed_time_s` and report samples/hour, generated tokens/s and mean generation length alongside sec/step. Both series are logged at step + 1, so --warmup-steps must be at least 1. Signed-off-by: Anil Thomas <[email protected]>
launch_experiment.sh special-cased every model/env combination because the config families were built opposite ways round: the nano-v3 family defaulted to gym and overrode to math, so a math-native model meant another branch. Factor the environment into model-agnostic env_gym.yaml / env_math.yaml layers whose data/env blocks are _override_, collect the harness under examples/configs/async/ in four tiers (<model>_base, <model>_<topology>, env_<env>, and the leaf), and resolve the config by formula in the launcher. Also fixes: TIMEOUT_MIN was documented but unwired; the wandb run name was built in four inconsistent places and could disagree with the slurm job name; WANDB_PROJECT / WANDB_ENTITY / MAX_STEPS were plumbed on one branch only; CMP=1 hardcoded nano-v3 sequence length and checkpoint cadence. MATH=1 and --smoke are replaced by ENV=gym|math. Signed-off-by: Anil Thomas <[email protected]>
A 2-node dense analog of the nano-v3 colocated-vs-non-colocated comparison on either env, at about an hour per arm instead of two. Qwen3 satisfies the asserts of Megatron's transformer_impl=inference_optimized (RMSNorm, no add_bias_linear, no add_qkv_bias), so the colocated arm carries the same graphed-decode setup as nanov3_colocated.yaml rather than silently decoding with training kernels; the MoE-only knobs are omitted. It also offloads the KV cache during the training pause like nano-v3, which is graph-safe because a non-persist mode makes megatron_worker.py request static_kv_memory_pointers -- so the launcher installs torch_memory_saver for every colocated arm. Both arms see 32 samples per learner GPU, so the comparison isolates topology rather than batch size. Signed-off-by: Anil Thomas <[email protected]>
…eration `mcore_generation_config` is merged into `megatron_cfg` only when MegatronGeneration stands up its own inference Policy; the colocated branch returns before that merge because it reuses the training Policy as-is. So parallelism set under mcore_generation_config was dropped with no assert and no warning, and generation silently inherited the training layout. Raise for the weight-sharding axes (TP/PP/EP/ETP), which a colocated run cannot apply because it shares one set of shards. Context parallelism only shards activations, so a separate generation value is meaningful in principle; the colocated engine still takes its process groups from the training model, so warn that it is ignored rather than rejecting the config. Signed-off-by: Anil Thomas <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
draft pull request to inspect diffs