Skip to content

Commit 71c1c70

Browse files
committed
Merge branch 'save' into support_vllm_dp
2 parents ad114f0 + 501cd12 commit 71c1c70

58 files changed

Lines changed: 1121 additions & 77 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/fp8.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ FP8 generations are recommended to be configured with the following settings:
5353
num_first_layers_in_bf16: 0
5454
# Use FP32 scaling factors. Rounding scaling factors to the nearest pow2 may improve quantization
5555
# fidelity however this feature is still under research.
56-
use_weight_pow2_scale: False
57-
use_activation_pow2_scale: False
56+
pow2_weight_scaling_factors: False
57+
pow2_activation_scaling_factors: False
5858
```
5959

6060
To train with FP8, you need to set the Megatron path and configure it using the following settings:

docs/guides/dapo.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ This document focuses on DAPO-specific features: Dynamic Sampling and Overlong R
1313

1414
## Quickstart: Launch a DAPO Run
1515

16-
To get started quickly, use the example configuration [examples/configs/recipes/llm/dapo-qwen2.5-7b.yaml](../../examples/configs/recipes/llm/dapo-qwen2.5-7b.yaml). You can launch this using the same script as GRPO:
16+
To get started quickly, use the example configuration [examples/configs/recipes/llm/dapo-qwen2.5-7b.v2.yaml](../../examples/configs/recipes/llm/dapo-qwen2.5-7b.v2.yaml). You can launch this using the same script as GRPO:
1717

1818
```bash
19-
uv run examples/run_grpo.py --config examples/configs/recipes/llm/dapo-qwen2.5-7b.yaml {overrides}
19+
uv run examples/run_grpo.py --config examples/configs/recipes/llm/dapo-qwen2.5-7b.v2.yaml {overrides}
2020
```
2121

2222
**Reminder**: Don't forget to set your HF_HOME, WANDB_API_KEY, and HF_DATASETS_CACHE (if needed). You'll need to do a `huggingface-cli login` as well for LLaMA models.
@@ -85,10 +85,10 @@ grpo:
8585
> - Set `ratio_clip_max` to enable Clip-Higher (e.g., `ratio_clip_max: 0.28`)
8686
> - Set `token_level_loss: true` to enable Token-Level Policy Gradient Loss
8787
>
88-
> See the full [DAPO example config](../../examples/configs/recipes/llm/dapo-qwen2.5-7b.yaml) for reference.
88+
> See the full [DAPO example config](../../examples/configs/recipes/llm/dapo-qwen2.5-7b.v2.yaml) for reference.
8989

9090
## Example Training Results
91-
Using the [DAPO example config](../../examples/configs/recipes/llm/dapo-qwen2.5-7b.yaml), you can expect to see intermediate plots such as the training reward curve and validation accuracy on AIME24 for Qwen/Qwen2.5-Math-7B. These plots serve as reference outputs to help verify reproducibility. They are not intended to reflect the best accuracy that can be achieved using DAPO for this model.
91+
Using the [DAPO example config](../../examples/configs/recipes/llm/dapo-qwen2.5-7b.v2.yaml), you can expect to see intermediate plots such as the training reward curve and validation accuracy on AIME24 for Qwen/Qwen2.5-Math-7B. These plots serve as reference outputs to help verify reproducibility. They are not intended to reflect the best accuracy that can be achieved using DAPO for this model.
9292

9393
![DAPO Qwen2.5-7B Training Reward](../assets/dapo_train_reward.png)
9494
![DAPO Qwen2.5-7B Validation Accuracy](../assets/dapo_val_acc.png)

docs/guides/muon-optimizer.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ The command to generate the Muon results is:
132132

133133
```bash
134134
uv run examples/run_grpo_math.py \
135-
--config examples/configs/recipes/llm/dapo-qwen2.5-7b.yaml \
135+
--config examples/configs/recipes/llm/dapo-qwen2.5-7b.v2.yaml \
136136
policy.megatron_cfg.enabled=true \
137137
policy.dtensor_cfg.enabled=false \
138138
++policy.megatron_cfg.optimizer.optimizer=dist_muon \

docs/guides/prorlv2.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# An In-Depth Walkthrough of ProRLv2 in NeMo RL
22

3-
This guide covers the ProRLv2 configuration pattern in NeMo RL, based on the example config [`examples/configs/prorlv2.yaml`](../../examples/configs/prorlv2.yaml).
3+
This guide covers the ProRLv2 configuration pattern in NeMo RL, based on the example config [`examples/configs/prorlv2.v2.yaml`](../../examples/configs/prorlv2.v2.yaml).
44

55
ProRLv2 is best thought of as **GRPO plus a bundle of stability/efficiency techniques** commonly used for long-horizon RL fine-tuning:
66

@@ -15,13 +15,13 @@ This document focuses on ProRLv2-specific knobs and gotchas. For foundational co
1515

1616
## Quickstart: Launch a ProRLv2 Run
1717

18-
Use the example configuration [`examples/configs/prorlv2.yaml`](../../examples/configs/prorlv2.yaml):
18+
Use the example configuration [`examples/configs/prorlv2.v2.yaml`](../../examples/configs/prorlv2.v2.yaml):
1919

2020
```bash
21-
uv run examples/run_grpo_math.py --config examples/configs/prorlv2.yaml {overrides}
21+
uv run examples/run_grpo_math.py --config examples/configs/prorlv2.v2.yaml {overrides}
2222
```
2323

24-
`prorlv2.yaml` inherits from [`examples/configs/grpo_math_1B.yaml`](../../examples/configs/grpo_math_1B.yaml) and only overrides a small set of fields under `grpo` and `loss_fn`, plus output directories.
24+
`prorlv2.v2.yaml` inherits from [`examples/configs/grpo_math_1B.yaml`](../../examples/configs/grpo_math_1B.yaml) and only overrides a small set of fields under `grpo` and `loss_fn`, plus output directories.
2525

2626
**Reminder**: Don't forget to set your `HF_HOME`, `WANDB_API_KEY`, and `HF_DATASETS_CACHE` (if needed). You'll need to do a `huggingface-cli login` as well for gated models.
2727

@@ -47,7 +47,7 @@ Quick intuition:
4747
Computation (as implemented in this repo, with the ProRLv2 example defaults):
4848

4949
```text
50-
Defaults in examples/configs/prorlv2.yaml:
50+
Defaults in examples/configs/prorlv2.v2.yaml:
5151
grpo.adv_estimator.minus_baseline = true
5252
loss_fn.use_kl_in_reward = false
5353
@@ -204,26 +204,26 @@ Under Pure Online training (single update per rollout), the PPO policy ratio is
204204
- **Seq-mask-tis** — sequence-level filtering instead of token-level ICE-POP.
205205
- **No DAPO dynamic sampling** (`use_dynamic_sampling: false`).
206206

207-
Use [`examples/configs/prorlv2_1_moe.yaml`](../../examples/configs/prorlv2_1_moe.yaml) directly. See the [ProRL v2.1 blog post](https://developer.nvidia.com/blog/scaling-llm-reinforcement-learning-with-prolonged-training-using-prorl-v2/) for the full motivation.
207+
Use [`examples/configs/prorlv2_1_moe.v2.yaml`](../../examples/configs/prorlv2_1_moe.v2.yaml) directly. See the [ProRL v2.1 blog post](https://developer.nvidia.com/blog/scaling-llm-reinforcement-learning-with-prolonged-training-using-prorl-v2/) for the full motivation.
208208
:::
209209

210210
```bash
211211
# Launch ProRL v2.1 for MoE models
212-
uv run examples/run_grpo_math.py --config examples/configs/prorlv2_1_moe.yaml {overrides}
212+
uv run examples/run_grpo_math.py --config examples/configs/prorlv2_1_moe.v2.yaml {overrides}
213213
```
214214

215215
## Full Example Configs
216216

217-
- **ProRLv2** (ICE-POP, DAPO, clipping): [`examples/configs/prorlv2.yaml`](../../examples/configs/prorlv2.yaml) — inherits from [`grpo_math_1B.yaml`](../../examples/configs/grpo_math_1B.yaml)
218-
- **ProRL v2.1** (seq-mask-tis, pure online, MoE): [`examples/configs/prorlv2_1_moe.yaml`](../../examples/configs/prorlv2_1_moe.yaml) — inherits from `prorlv2.yaml`, adds `force_on_policy_ratio`, switches to seq-mask-tis, disables dynamic sampling
217+
- **ProRLv2** (ICE-POP, DAPO, clipping): [`examples/configs/prorlv2.v2.yaml`](../../examples/configs/prorlv2.v2.yaml) — inherits from [`grpo_math_1B.yaml`](../../examples/configs/grpo_math_1B.yaml)
218+
- **ProRL v2.1** (seq-mask-tis, pure online, MoE): [`examples/configs/prorlv2_1_moe.v2.yaml`](../../examples/configs/prorlv2_1_moe.v2.yaml) — inherits from `prorlv2.v2.yaml`, adds `force_on_policy_ratio`, switches to seq-mask-tis, disables dynamic sampling
219219

220220
## Practical Overrides
221221

222222
A few common overrides when launching:
223223

224224
```bash
225225
uv run examples/run_grpo_math.py \
226-
--config examples/configs/prorlv2.yaml \
226+
--config examples/configs/prorlv2.v2.yaml \
227227
policy.model_name="Qwen/Qwen2.5-1.5B" \
228228
logger.wandb_enabled=true \
229229
logger.wandb.project="prorlv2-dev" \
@@ -235,7 +235,7 @@ If you want to enable DAPO overlong reward shaping instead of stop-properly:
235235

236236
```bash
237237
uv run examples/run_grpo_math.py \
238-
--config examples/configs/prorlv2.yaml \
238+
--config examples/configs/prorlv2.v2.yaml \
239239
grpo.reward_shaping.stop_properly_penalty_coef=null \
240240
grpo.reward_shaping.overlong_buffer_length=4096 \
241241
grpo.reward_shaping.overlong_buffer_penalty=1.0 \

docs/guides/quantization-aware-rl.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ The following workflow + quantization recipe combinations have been validated en
1515
| Workflow | Quantization | Recipe | Status | Example Config |
1616
|---|---|---|---|---|
1717
| QA-Distillation | W4A4 | `NVFP4_DEFAULT_CFG` (NVFP4 weights + NVFP4 activations) | ✅ Converges | `examples/modelopt/qa_distillation_math_megatron.yaml` |
18-
| QA-GRPO | W4A16 | `examples/modelopt/quant_configs/nvfp4_a16.yaml` (NVFP4 weights, native-dtype activations) | ✅ Converges | `examples/modelopt/qa_grpo_llama8b_megatron.yaml` |
18+
| QA-GRPO | W4A16 | `examples/modelopt/quant_configs/nvfp4_a16.yaml` (NVFP4 weights, native-dtype activations) | ✅ Converges | `examples/modelopt/qa_grpo_llama8b_megatron.v2.yaml` |
1919
| QA-GRPO | W4A4 | `NVFP4_DEFAULT_CFG` | ⚠️ Known convergence issue | `examples/modelopt/qa_grpo_math_megatron.yaml` |
2020

2121
The `nvfp4_a16.yaml` custom YAML enables NVFP4 e2m1 weight quantization (with dynamic e4m3 micro-block scales) and leaves activations unquantized; weights are still exercised through both Megatron training and vLLM generation.
@@ -27,7 +27,7 @@ The `nvfp4_a16.yaml` custom YAML enables NVFP4 e2m1 weight quantization (with dy
2727
The QA-GRPO config extends the standard Megatron GRPO config by adding quantization parameters. See [Verified Configurations](#verified-configurations) for the status of W4A4 vs W4A16 on GRPO.
2828

2929
```yaml
30-
# examples/modelopt/qa_grpo_llama8b_megatron.yaml
30+
# examples/modelopt/qa_grpo_llama8b_megatron.v2.yaml
3131
defaults: "../configs/grpo_math_8B_megatron.yaml"
3232

3333
policy:
@@ -47,15 +47,15 @@ policy:
4747
4848
```bash
4949
uv run examples/run_grpo.py \
50-
--config examples/modelopt/qa_grpo_llama8b_megatron.yaml \
50+
--config examples/modelopt/qa_grpo_llama8b_megatron.v2.yaml \
5151
policy.model_name=meta-llama/Llama-3.1-8B-Instruct
5252
```
5353

5454
**Via Slurm:**
5555

5656
```bash
5757
COMMAND="uv run examples/run_grpo.py \
58-
--config examples/modelopt/qa_grpo_llama8b_megatron.yaml \
58+
--config examples/modelopt/qa_grpo_llama8b_megatron.v2.yaml \
5959
policy.model_name=meta-llama/Llama-3.1-8B-Instruct \
6060
checkpointing.checkpoint_dir=results/qa_grpo" \
6161
CONTAINER=YOUR_CONTAINER \

examples/configs/distillation_math.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,17 @@ policy: &POLICY_BASE
9090
force_reconvert_from_hf: False # Set to True to force reconvert of the model from Hugging Face
9191
empty_unused_memory_level: 0
9292
activation_checkpointing: false
93+
# recompute_granularity controls activation checkpointing depth.
94+
# "full": recompute all activations (default, max memory savings).
95+
# "selective": recompute only specific modules (see recompute_modules).
96+
# Only takes effect when activation_checkpointing: true.
97+
recompute_granularity: "full"
98+
# Modules to selectively recompute when recompute_granularity="selective".
99+
# MCore options: ["core_attn", "moe_act", "layernorm", "mla_up_proj", "mlp", "moe", "shared_experts"].
100+
# Null defaults to ["core_attn"]. Full list and per-module constraints:
101+
# https://github.com/NVIDIA/Megatron-LM/blob/d30c3ae5469fe3f6a64d4fd2e63b6e7f7844ea81/megatron/core/transformer/transformer_config.py#L483
102+
# Use ["moe"] for MoE models to recompute expert activations only.
103+
recompute_modules: null
93104
converter_type: "Qwen3ForCausalLM"
94105
tensor_model_parallel_size: 2
95106
expert_tensor_parallel_size: 1

examples/configs/distillation_math_megatron.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,17 @@ policy: &POLICY_BASE
3939
enabled: true
4040
empty_unused_memory_level: 0
4141
activation_checkpointing: false
42+
# recompute_granularity controls activation checkpointing depth.
43+
# "full": recompute all activations (default, max memory savings).
44+
# "selective": recompute only specific modules (see recompute_modules).
45+
# Only takes effect when activation_checkpointing: true.
46+
recompute_granularity: "full"
47+
# Modules to selectively recompute when recompute_granularity="selective".
48+
# MCore options: ["core_attn", "moe_act", "layernorm", "mla_up_proj", "mlp", "moe", "shared_experts"].
49+
# Null defaults to ["core_attn"]. Full list and per-module constraints:
50+
# https://github.com/NVIDIA/Megatron-LM/blob/d30c3ae5469fe3f6a64d4fd2e63b6e7f7844ea81/megatron/core/transformer/transformer_config.py#L483
51+
# Use ["moe"] for MoE models to recompute expert activations only.
52+
recompute_modules: null
4253
converter_type: "Qwen3ForCausalLM"
4354
tensor_model_parallel_size: 2
4455
expert_tensor_parallel_size: 1

examples/configs/dpo.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,17 @@ policy:
129129
force_reconvert_from_hf: False # Set to True to force reconvert of the model from Hugging Face
130130
empty_unused_memory_level: 1
131131
activation_checkpointing: false
132+
# recompute_granularity controls activation checkpointing depth.
133+
# "full": recompute all activations (default, max memory savings).
134+
# "selective": recompute only specific modules (see recompute_modules).
135+
# Only takes effect when activation_checkpointing: true.
136+
recompute_granularity: "full"
137+
# Modules to selectively recompute when recompute_granularity="selective".
138+
# MCore options: ["core_attn", "moe_act", "layernorm", "mla_up_proj", "mlp", "moe", "shared_experts"].
139+
# Null defaults to ["core_attn"]. Full list and per-module constraints:
140+
# https://github.com/NVIDIA/Megatron-LM/blob/d30c3ae5469fe3f6a64d4fd2e63b6e7f7844ea81/megatron/core/transformer/transformer_config.py#L483
141+
# Use ["moe"] for MoE models to recompute expert activations only.
142+
recompute_modules: null
132143
tensor_model_parallel_size: 2
133144
expert_tensor_parallel_size: 1
134145
expert_model_parallel_size: 1

examples/configs/grpo_math_1B.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,17 @@ policy:
134134
force_reconvert_from_hf: False # Set to True to force reconvert of the model from Hugging Face
135135
empty_unused_memory_level: 1 # 1 is the minimum recommendation for RL since we almost always need to offload before beginning generation. Setting to 0 is faster, but you are more likely to run out of GPU memory.
136136
activation_checkpointing: false
137+
# recompute_granularity controls activation checkpointing depth.
138+
# "full": recompute all activations (default, max memory savings).
139+
# "selective": recompute only specific modules (see recompute_modules).
140+
# Only takes effect when activation_checkpointing: true.
141+
recompute_granularity: "full"
142+
# Modules to selectively recompute when recompute_granularity="selective".
143+
# MCore options: ["core_attn", "moe_act", "layernorm", "mla_up_proj", "mlp", "moe", "shared_experts"].
144+
# Null defaults to ["core_attn"]. Full list and per-module constraints:
145+
# https://github.com/NVIDIA/Megatron-LM/blob/d30c3ae5469fe3f6a64d4fd2e63b6e7f7844ea81/megatron/core/transformer/transformer_config.py#L483
146+
# Use ["moe"] for MoE models to recompute expert activations only.
147+
recompute_modules: null
137148
converter_type: "Qwen2ForCausalLM"
138149
tensor_model_parallel_size: 1
139150
expert_tensor_parallel_size: 1

examples/configs/grpo_math_1B_megatron.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,17 @@ policy:
8686
force_reconvert_from_hf: False # Set to True to force reconvert of the model from Hugging Face
8787
empty_unused_memory_level: 1 # 1 is the minimum recommendation for RL since we almost always need to offload before beginning generation. Setting to 0 is faster, but you are more likely to run out of GPU memory.
8888
activation_checkpointing: false
89+
# recompute_granularity controls activation checkpointing depth.
90+
# "full": recompute all activations (default, max memory savings).
91+
# "selective": recompute only specific modules (see recompute_modules).
92+
# Only takes effect when activation_checkpointing: true.
93+
recompute_granularity: "full"
94+
# Modules to selectively recompute when recompute_granularity="selective".
95+
# MCore options: ["core_attn", "moe_act", "layernorm", "mla_up_proj", "mlp", "moe", "shared_experts"].
96+
# Null defaults to ["core_attn"]. Full list and per-module constraints:
97+
# https://github.com/NVIDIA/Megatron-LM/blob/d30c3ae5469fe3f6a64d4fd2e63b6e7f7844ea81/megatron/core/transformer/transformer_config.py#L483
98+
# Use ["moe"] for MoE models to recompute expert activations only.
99+
recompute_modules: null
89100
converter_type: "Qwen2ForCausalLM"
90101
tensor_model_parallel_size: 1
91102
expert_tensor_parallel_size: 1

0 commit comments

Comments
 (0)