-
Notifications
You must be signed in to change notification settings - Fork 295
feat: Support for nano-v2 #1514
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
9462df9
nano-v2 support
yfw bb99fd4
Set model parallel cuda manual seed for mamba mixer
yfw 92c40c1
Add nano-v2 tests to nightlies
yfw cc70215
Set context_parallel_size when importing model
yfw 2cd85c5
lint
yfw 847d8cc
Fix typo
yfw 608cf6d
Address coderabbit comment
yfw 8656e81
Add comments about mamba sequence packing
yfw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Submodule Megatron-Bridge
updated
48 files
34 changes: 34 additions & 0 deletions
34
examples/configs/recipes/llm/grpo-nano-v2-12b-1n8g-megatron.yaml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| defaults: ../../grpo_math_1B.yaml | ||
| grpo: | ||
| max_num_steps: 30 | ||
| checkpointing: | ||
| checkpoint_dir: results/grpo-nano-v2-12b-1n8g-megatron | ||
| policy: | ||
| model_name: nvidia/NVIDIA-Nemotron-Nano-12B-v2 | ||
| tokenizer: | ||
| name: nvidia/NVIDIA-Nemotron-Nano-12B-v2 | ||
| optimizer: null | ||
| megatron_cfg: | ||
| enabled: true | ||
| bias_activation_fusion: false | ||
| tensor_model_parallel_size: 8 | ||
| dtensor_cfg: | ||
| enabled: false | ||
| make_sequence_length_divisible_by: 1 | ||
| generation: | ||
| max_new_tokens: 512 | ||
| vllm_cfg: | ||
| max_model_len: 512 | ||
| sequence_packing: | ||
| enabled: false | ||
| data: | ||
| max_input_seq_length: 512 | ||
| logger: | ||
| log_dir: logs/grpo-nano-v2-12b-1n8g-megatron | ||
| wandb_enabled: true | ||
| tensorboard_enabled: true | ||
| wandb: | ||
| project: nemo-rl | ||
| name: grpo-nano-v2-12b-1n8g-megatron | ||
| cluster: | ||
| gpus_per_node: 8 |
44 changes: 44 additions & 0 deletions
44
examples/configs/recipes/llm/grpo-nano-v2-12b-2n8g-fsdp2tp1.yaml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| defaults: ../../grpo_math_1B.yaml | ||
| grpo: | ||
| max_num_steps: 30 | ||
| checkpointing: | ||
| checkpoint_dir: results/grpo-nano-v2-12b-2n8g-fsdp2tp1 | ||
| policy: | ||
| model_name: nvidia/NVIDIA-Nemotron-Nano-12B-v2 | ||
| tokenizer: | ||
| name: nvidia/NVIDIA-Nemotron-Nano-12B-v2 | ||
| dtensor_cfg: | ||
| cpu_offload: true | ||
| activation_checkpointing: true | ||
| dynamic_batching: | ||
| enabled: true | ||
| sequence_packing: | ||
| enabled: false | ||
| make_sequence_length_divisible_by: 1 | ||
| generation: | ||
| max_new_tokens: 512 | ||
| vllm_cfg: | ||
| max_model_len: 512 | ||
| scheduler: | ||
| - name: "torch.optim.lr_scheduler.LinearLR" | ||
| kwargs: | ||
| start_factor: 0.1 | ||
| end_factor: 1.0 | ||
| total_iters: 13 | ||
| - name: "torch.optim.lr_scheduler.ConstantLR" | ||
| kwargs: | ||
| factor: 1.0 | ||
| total_iters: 10000000000 | ||
| - milestones: [13] | ||
| data: | ||
| max_input_seq_length: 512 | ||
| logger: | ||
| log_dir: logs/grpo-nano-v2-12b-2n8g-fsdp2tp1 | ||
| wandb_enabled: true | ||
| tensorboard_enabled: true | ||
| wandb: | ||
| project: nemo-rl | ||
| name: grpo-nano-v2-12b-2n8g-fsdp2tp1 | ||
| cluster: | ||
| gpus_per_node: 8 | ||
| num_nodes: 2 |
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| #!/bin/bash | ||
| SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd) | ||
| source $SCRIPT_DIR/common.env | ||
|
|
||
| # ===== BEGIN CONFIG ===== | ||
| NUM_NODES=1 | ||
| STEPS_PER_RUN=30 | ||
| MAX_STEPS=30 | ||
| NUM_RUNS=$(( (MAX_STEPS + STEPS_PER_RUN - 1) / STEPS_PER_RUN )) # Round up | ||
| NUM_MINUTES=60 | ||
| # ===== END CONFIG ===== | ||
|
|
||
| exit_if_max_steps_reached | ||
|
|
||
| # Run the experiment | ||
| cd $PROJECT_ROOT | ||
| uv run examples/run_grpo_math.py \ | ||
| --config $CONFIG_PATH \ | ||
| grpo.max_num_steps=$MAX_STEPS \ | ||
| logger.log_dir=$LOG_DIR \ | ||
| logger.wandb_enabled=True \ | ||
| logger.wandb.project=nemo-rl \ | ||
| logger.wandb.name=$EXP_NAME \ | ||
| logger.monitor_gpus=True \ | ||
| logger.tensorboard_enabled=True \ | ||
| checkpointing.enabled=True \ | ||
| checkpointing.checkpoint_dir=$CKPT_DIR \ | ||
| $@ \ | ||
| 2>&1 | tee $RUN_LOG | ||
|
|
||
| # Convert tensorboard logs to json | ||
| uv run tests/json_dump_tb_logs.py $LOG_DIR --output_path $JSON_METRICS | ||
|
|
||
| # Only run metrics if the target step is reached | ||
| if [[ $(jq 'to_entries | .[] | select(.key == "train/loss") | .value | keys | map(tonumber) | max' $JSON_METRICS) -ge $MAX_STEPS ]]; then | ||
| uv run tests/check_metrics.py $JSON_METRICS \ | ||
| 'mean(data["train/token_mult_prob_error"]) < 1.05' \ | ||
| 'data["train/token_mult_prob_error"]["30"] < 1.05' \ | ||
| 'data["train/reward"]["30"] > 0.4' \ | ||
| 'mean(data["timing/train/total_step_time"], -6, -1) < 80' | ||
| fi |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| #!/bin/bash | ||
| SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd) | ||
| source $SCRIPT_DIR/common.env | ||
|
|
||
| # ===== BEGIN CONFIG ===== | ||
| NUM_NODES=2 | ||
| STEPS_PER_RUN=30 | ||
| MAX_STEPS=30 | ||
| NUM_RUNS=$(( (MAX_STEPS + STEPS_PER_RUN - 1) / STEPS_PER_RUN )) # Round up | ||
| NUM_MINUTES=60 | ||
| # ===== END CONFIG ===== | ||
|
|
||
| exit_if_max_steps_reached | ||
|
|
||
| # Run the experiment | ||
| cd $PROJECT_ROOT | ||
| uv run examples/run_grpo_math.py \ | ||
| --config $CONFIG_PATH \ | ||
| grpo.max_num_steps=$MAX_STEPS \ | ||
| logger.log_dir=$LOG_DIR \ | ||
| logger.wandb_enabled=True \ | ||
| logger.wandb.project=nemo-rl \ | ||
| logger.wandb.name=$EXP_NAME \ | ||
| logger.monitor_gpus=True \ | ||
| logger.tensorboard_enabled=True \ | ||
| checkpointing.enabled=True \ | ||
| checkpointing.checkpoint_dir=$CKPT_DIR \ | ||
| $@ \ | ||
| 2>&1 | tee $RUN_LOG | ||
|
|
||
| # Convert tensorboard logs to json | ||
| uv run tests/json_dump_tb_logs.py $LOG_DIR --output_path $JSON_METRICS | ||
|
|
||
| # Only run metrics if the target step is reached | ||
| if [[ $(jq 'to_entries | .[] | select(.key == "train/loss") | .value | keys | map(tonumber) | max' $JSON_METRICS) -ge $MAX_STEPS ]]; then | ||
| uv run tests/check_metrics.py $JSON_METRICS \ | ||
| 'mean(data["train/token_mult_prob_error"]) < 1.05' \ | ||
| 'data["train/token_mult_prob_error"]["30"] < 1.05' \ | ||
| 'data["train/reward"]["30"] > 0.4' \ | ||
| 'mean(data["timing/train/total_step_time"], -6, -1) < 60' | ||
| fi |
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.