-
Notifications
You must be signed in to change notification settings - Fork 485
feat(sc): NeMo-Gym path #3267
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
yuki-97
wants to merge
13
commits into
yukih/sc-split-3
Choose a base branch
from
yukih/sc-split-4
base: yukih/sc-split-3
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
feat(sc): NeMo-Gym path #3267
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
8ab1f2a
feat(sc): wire NeMo-Gym integration into setup
yuki-97 bc6f033
feat(sc): NeMo-Gym path
yuki-97 8569746
Revert "refactor(sc): drop dead nemo-gym setup call from entrypoint"
yuki-97 40689b1
remove test_nemo_gym_not_supported
yuki-97 cfb990d
fix(sc): correct async_rl overrides in nemo-gym smoke test
yuki-97 f2a5a2e
fix(sc): configure vLLM for router_replay before generation build
yuki-97 83a0563
test(sc): cover nemo-gym env handle wiring and non-vllm backend guard
yuki-97 111e679
fix rebase
yuki-97 9dc761d
fix(sc): configure sampler in NeMo-Gym smoke test
RayenTian 51678d7
fix(sc): address NeMo-Gym review feedback
RayenTian b2bd34d
docs(sc): track deferred NeMo-Gym initialization
RayenTian d7dad8f
test(sc): add env to run_grpo_single_controller main_context fixture
terrykong 522ab8e
fix(sc): compute reference logprobs when KL penalty is set in nemo-gy…
terrykong 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,114 @@ | ||
| #!/bin/bash | ||
| # SingleController + NeMo-Gym e2e smoke. Mirrors grpo_async_gym.sh but | ||
|
RayenTian marked this conversation as resolved.
|
||
| # routes everything through the SC path (TransferQueue data plane + | ||
| # SingleControllerActor) instead of async_grpo_train. | ||
|
|
||
| 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 | ||
|
|
||
| # clean up checkpoint directory on exit | ||
| trap "rm -rf $CHECKPOINT_DIR" EXIT | ||
|
|
||
| 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 | ||
|
|
||
| # We need HF_TOKEN to download the data from huggingface | ||
| if [[ ! -f env.yaml ]]; then | ||
| if [[ -z "${HF_TOKEN:-}" ]]; then | ||
| echo "[ERROR] HF_TOKEN is not set" | ||
| exit 1 | ||
| fi | ||
| echo "hf_token: $HF_TOKEN" >> env.yaml | ||
| fi | ||
|
|
||
| uv run ng_prepare_data "+config_paths=[resources_servers/workplace_assistant/configs/workplace_assistant.yaml]" \ | ||
| +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/run_grpo_single_controller.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.val_period=-1 \ | ||
| grpo.val_at_start=false \ | ||
| policy.train_global_batch_size=8 \ | ||
| policy.train_micro_batch_size=1 \ | ||
| cluster.gpus_per_node=2 \ | ||
| loss_fn.reference_policy_kl_penalty=0.01 \ | ||
| grpo.skip_reference_policy_logprobs_calculation=false \ | ||
| 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 \ | ||
| data.train.data_path=$TRAIN_PATH \ | ||
| data.validation.data_path=$VALIDATION_PATH \ | ||
| ++data_plane.enabled=true \ | ||
| ++data_plane.impl=transfer_queue \ | ||
| ++data_plane.backend=simple \ | ||
| ++data_plane.storage_capacity=1000000 \ | ||
| ++data_plane.num_storage_units=2 \ | ||
| ++data_plane.claim_meta_poll_interval_s=0.5 \ | ||
| ++data_plane.global_segment_size=549755813888 \ | ||
| ++data_plane.local_buffer_size=68719476736 \ | ||
| ++async_rl.sampler.name=in_order \ | ||
| ++async_rl.sampler.max_lookahead_versions=0 \ | ||
| ++async_rl.min_groups_for_streaming_train=4 \ | ||
| ++async_rl.max_inflight_prompts=4 \ | ||
| ++async_rl.max_buffered_rollouts=4 \ | ||
| $@ \ | ||
| 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' \ | ||
| 'max(data["train/reward"]) > 0' | ||
|
RayenTian marked this conversation as resolved.
|
||
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.
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.