-
Notifications
You must be signed in to change notification settings - Fork 260
feat: async grpo + nemo gym #1985
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
Open
terrykong
wants to merge
6
commits into
main
Choose a base branch
from
tk/async-gym
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
4ea3217
FROM 72e87b1bcff34bc1c2a67f352202d3a2cdbb3b84 async+gym (but missing …
HeyyyyyyG 4e2f0a4
add genrm rlhf to gym (just the non genrm things)
HeyyyyyyG e925ca6
Revert "add genrm rlhf to gym (just the non genrm things)"
terrykong 8e2952f
fix a lot of logging stuff and add functional
terrykong e82518a
add workplace download
terrykong affd793
log data in async path
HeyyyyyyG 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
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
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,87 @@ | ||
| #!/bin/bash | ||
|
|
||
| SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd) | ||
| PROJECT_ROOT=$(realpath $SCRIPT_DIR/../..) | ||
| # Mark the current repo as safe, since wandb fetches metadata about the repo | ||
| git config --global --add safe.directory $PROJECT_ROOT | ||
|
|
||
| set -eou pipefail | ||
|
|
||
| EXP_NAME=$(basename $0 .sh) | ||
| EXP_DIR=$SCRIPT_DIR/$EXP_NAME | ||
| LOG_DIR=$EXP_DIR/logs | ||
| JSON_METRICS=$EXP_DIR/metrics.json | ||
| RUN_LOG=$EXP_DIR/run.log | ||
| CHECKPOINT_DIR=$EXP_DIR/checkpoints | ||
| DATA_DIR=$EXP_DIR/data | ||
| export PYTHONPATH=${PROJECT_ROOT}:${PYTHONPATH:-} | ||
|
|
||
| rm -rf $EXP_DIR $LOG_DIR | ||
| mkdir -p $EXP_DIR $LOG_DIR $CHECKPOINT_DIR $DATA_DIR | ||
|
|
||
| cd $PROJECT_ROOT | ||
|
|
||
| # Follow nemo-gym instructions here to get this data: | ||
| # https://docs.nvidia.com/nemo/gym/0.1.0/tutorials/nemo-rl-grpo/setup.html#training-nemo-rl-grpo-setup | ||
| cd 3rdparty/Gym-workspace/Gym | ||
| config_paths="responses_api_models/vllm_model/configs/vllm_model_for_training.yaml,\ | ||
| resources_servers/workplace_assistant/configs/workplace_assistant.yaml" | ||
|
|
||
| uv run ng_prepare_data "+config_paths=[${config_paths}]" \ | ||
| +output_dirpath=data/workplace_assistant \ | ||
| +mode=train_preparation \ | ||
| +should_download=true \ | ||
| +data_source=huggingface | ||
| cd - | ||
|
|
||
| # This trimming of the workplace assistant dataset is necessary b/c with all the tools the first prompt is >4000 tokens | ||
| # which will cause vllm to return nothing on the first prompt and crash RL. Since we want to keep this test short to | ||
| # smoke test, we trim all but the first tool | ||
| TRAIN_PATH=$DATA_DIR/workplace_assistant_train.jsonl | ||
| VALIDATION_PATH=$DATA_DIR/workplace_assistant_validation.jsonl | ||
| jq -c '.responses_create_params.tools |= (.[0:1])' 3rdparty/Gym-workspace/Gym/data/workplace_assistant/train.jsonl > $TRAIN_PATH | ||
| jq -c '.responses_create_params.tools |= (.[0:1])' 3rdparty/Gym-workspace/Gym/data/workplace_assistant/validation.jsonl > $VALIDATION_PATH | ||
|
|
||
| uv run coverage run -a --data-file=$PROJECT_ROOT/tests/.coverage --source=$PROJECT_ROOT/nemo_rl \ | ||
| $PROJECT_ROOT/examples/nemo_gym/run_grpo_nemo_gym.py \ | ||
| --config $PROJECT_ROOT/examples/nemo_gym/grpo_qwen3_30ba3b_instruct.yaml \ | ||
| policy.model_name=Qwen/Qwen3-0.6B \ | ||
| policy.dtensor_cfg.enabled=false \ | ||
| policy.megatron_cfg.enabled=true \ | ||
| policy.megatron_cfg.tensor_model_parallel_size=1 \ | ||
| policy.megatron_cfg.pipeline_model_parallel_size=1 \ | ||
| policy.megatron_cfg.expert_model_parallel_size=1 \ | ||
| policy.megatron_cfg.context_parallel_size=1 \ | ||
| policy.megatron_cfg.sequence_parallel=false \ | ||
| policy.generation.vllm_cfg.tensor_parallel_size=1 \ | ||
| policy.generation.vllm_cfg.async_engine=true \ | ||
| policy.max_total_sequence_length=512 \ | ||
| policy.generation.colocated.enabled=false \ | ||
| policy.generation.colocated.resources.num_nodes=1 \ | ||
| policy.generation.colocated.resources.gpus_per_node=1 \ | ||
| grpo.num_prompts_per_step=4 \ | ||
| grpo.num_generations_per_prompt=2 \ | ||
| grpo.max_num_steps=10 \ | ||
| grpo.async_grpo.enabled=true \ | ||
| grpo.async_grpo.max_trajectory_age_steps=1 \ | ||
| grpo.async_grpo.in_flight_weight_updates=true \ | ||
| policy.train_global_batch_size=4 \ | ||
| policy.train_micro_batch_size=1 \ | ||
| cluster.gpus_per_node=2 \ | ||
| loss_fn.use_importance_sampling_correction=true \ | ||
| logger.tensorboard_enabled=true \ | ||
| logger.log_dir=$LOG_DIR \ | ||
| logger.wandb_enabled=false \ | ||
| logger.monitor_gpus=true \ | ||
| checkpointing.enabled=false \ | ||
| checkpointing.checkpoint_dir=$CHECKPOINT_DIR \ | ||
| data.train.data_path=$TRAIN_PATH \ | ||
| data.validation.data_path=$VALIDATION_PATH \ | ||
| $@ \ | ||
| 2>&1 | tee $RUN_LOG | ||
|
|
||
| uv run tests/json_dump_tb_logs.py $LOG_DIR --output_path $JSON_METRICS | ||
|
|
||
| # Observed to be between 0.8-1.3 | ||
| uv run tests/check_metrics.py $JSON_METRICS \ | ||
| 'median(data["train/gen_kl_error"]) < 1.3' |
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.