- A node with 8 GPUs (H100 / H200 / B-series).
- At least 500 GB of free disk.
- Docker with GPU access.
- Launch a GRPO run on Qwen3-4B and watch the reward climb!
Step 1: Start the container
On the host:/root/miles and
Megatron-LM at /root/Megatron-LM. Refresh the editable install so you run the
latest main:
Step 2: Download the model and data
Three downloads:Step 3: Convert to Megatron format
Megatron reads its own sharded checkpoint format, so convert the HuggingFace weights once:Step 4: Launch training
- Checkpoints land in
/root/shared_data/checkpointsevery 20 rollouts;--output-dirmoves them. - The policy is evaluated on AIME-2024 every 20 rollouts.
- If the run dies, relaunch the same command — training resumes from the last checkpoint.
rollout/raw_reward is the number to watch: the mean reward of the freshly scored
responses, drifting upward as the policy improves. You have a live RL run.
What’s happening
A Miles job combines two engines: SGLang generates responses from the current policy (the rollout), and Megatron-LM updates the policy from those responses (the training). In this recipe both share the same 8 GPUs, taking turns. Every iteration runs the same loop:- Sample a batch of prompts and let the SGLang engines generate several candidate responses per prompt.
- Score every response — the reward function checks each final answer against the dataset label.
- Compute the GRPO objective from the scores and step the optimizer.
- Sync the updated weights back into the SGLang engines, and go again.
The fine print 🔍
- The docker flags (Step 1).
--gpus allexposes the GPUs,--ipc=hostand--shm-size=32ggive NCCL and Ray the shared memory they need, and--network=hostlets you reach the Ray dashboard from the host. MODEL_ARGS(Step 3). The Megatron-side description of the architecture (layer count, hidden sizes, attention layout). The converter uses it to map the HuggingFace weights into a shardedtorch_distcheckpoint.- The launcher (Step 4).
scripts/run_qwen3_dense.pybuilds the flags it passes totrain.pyas one group per concern (checkpoint paths, rollout, GRPO, optimizer, performance, eval, SGLang) and is meant to be read and edited — it is the canonical place to change hyperparameters.--extra-argsappends flags without touching the file, and the same launcher covers Qwen3-32B and the Qwen3.5 / Qwen3.6 dense sizes through--model-name. - Colocation. The recipe sets
--colocate: four SGLang engines (2 GPUs each) and the Megatron trainer share the same 8 GPUs, alternating between generation and training. Sharing GPUs also makes the weight sync local — each rank gathers its shards over NCCL and hands them to its engine through IPC, no network involved. Disaggregated runs choose a transport with--update-weight-transfer-mode:broadcast(the default, over NCCL),p2p(point-to-point RDMA via Mooncake), ordisk-delta(versioned deltas through shared storage).p2panddisk-deltaare incompatible with--colocate. - The reward function.
--rm-type deepscaler— a rule-based verifier, no learned reward model. - KL regularization. The frozen reference model can add a KL term to the loss;
this recipe sets
--kl-loss-coef 0.00, so the term is off. - The metric lines (Step 4). The
stepline reports each optimizer step, and the twoperflines time the generation side (perf/rollout_time) and the training side (perf/actor_train_time) of each iteration.
Inspecting a run 📊
Next steps
- Core concepts — the model behind rollout / actor / reference.
- Launch script — what a launch script does when you run it, how it is structured, and the three ways to override a recipe.
- Training backends — Megatron vs FSDP.
- Customization — plug in custom rollout / reward.
- Models — recipes for Qwen3.5, GLM5.2, DeepSeek V4, Kimi K2.6, and more.

