-
Notifications
You must be signed in to change notification settings - Fork 2.4k
[recipe, hardware] feat: Add GRPO with full weight updates for 1.5B models on a single GPU #3747
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
KabakaWilliam
wants to merge
5
commits into
volcengine:main
Choose a base branch
from
KabakaWilliam:feat/grpo-math500-single-gpu
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 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
4ca6dcd
examples: add single-GPU GRPO example (Qwen2.5-Math-1.5B, MATH500, ~7…
KabakaWilliam fd967e0
[recipe, hardware] feat: Add GRPO with full weight updates for 1.5B m…
KabakaWilliam 2ca15a2
Revert PR template to default
KabakaWilliam 55cfe6c
Fix formatting issues in tuning script
KabakaWilliam 1dfea06
removed training curve image from tuning dir
KabakaWilliam 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,40 +1,27 @@ | ||
| ### What does this PR do? | ||
|
|
||
| > Add **concise** overview of what this PR aims to achieve or accomplish. Reference related GitHub issues and PRs that help with the review. | ||
| > Adds a new recipe to perform GRPO with full weight-updates on 1.5B models. | ||
| ### Checklist Before Starting | ||
|
|
||
| - [ ] Search for similar PRs. Paste at least one query link here: ... | ||
| - [ ] Format the PR title as `[{modules}] {type}: {description}` (This will be checked by the CI) | ||
| - `{modules}` include `fsdp`, `megatron`, `sglang`, `vllm`, `rollout`, `trainer`, `ci`, `training_utils`, `recipe`, `hardware`, `deployment`, `ray`, `worker`, `single_controller`, `misc`, `perf`, `model`, `algo`, `env`, `tool`, `ckpt`, `doc`, `data` | ||
| - If this PR involves multiple modules, separate them with `,` like `[megatron, fsdp, doc]` | ||
| - `{type}` is in `feat`, `fix`, `refactor`, `chore`, `test` | ||
| - If this PR breaks any API (CLI arguments, config, function signature, etc.), add `[BREAKING]` to the beginning of the title. | ||
| - Example: `[BREAKING][fsdp, megatron] feat: dynamic batching` | ||
| - [X] Search for similar PRs. Paste at least one query link here: https://github.com/volcengine/verl/pull/3029 | ||
| - [X] Format the PR title as `[recipe, hardware] feat: Add GRPO with full weight updates for 1.5B models on a single GPU ` (This will be checked by the CI) | ||
| - `{modules}`: `recipe`, `hardware` | ||
| - `{type}`: `feat` | ||
| - No breaking API changes | ||
|
|
||
| ### Test | ||
|
|
||
| > For changes that can not be tested by CI (e.g., algorithm implementation, new model support), validate by experiment(s) and show results like training curve plots, evaluation results, etc. | ||
| ### API and Usage Example | ||
|
|
||
| > Demonstrate how the API changes if any, and provide usage example(s) if possible. | ||
|
|
||
| ```python | ||
| # Add code snippet or script demonstrating how to use this | ||
| ``` | ||
|
|
||
| ### Design & Code Changes | ||
|
|
||
| > Demonstrate the high-level design if this PR is complex, and list the specific changes. | ||
| ### Test | ||
|  | ||
| > Pass@1 for MATH500: 77.8 | ||
| ### Checklist Before Submitting | ||
|
|
||
| > [!IMPORTANT] | ||
| > Please check all the following items before requesting a review, otherwise the reviewer might deprioritize this PR for review. | ||
| - [ ] Read the [Contribute Guide](https://github.com/volcengine/verl/blob/main/CONTRIBUTING.md). | ||
| - [ ] Apply [pre-commit checks](https://github.com/volcengine/verl/blob/main/CONTRIBUTING.md#code-linting-and-formatting): `pre-commit install && pre-commit run --all-files --show-diff-on-failure --color=always` | ||
| - [ ] Add / Update [the documentation](https://github.com/volcengine/verl/tree/main/docs). | ||
| - [ ] Add unit or end-to-end test(s) to [the CI workflow](https://github.com/volcengine/verl/tree/main/.github/workflows) to cover all the code. If not feasible, explain why: ... | ||
| - [ ] Once your PR is ready for CI, send a message in [the `ci-request` channel](https://verl-project.slack.com/archives/C091TCESWB1) in [the `verl` Slack workspace](https://join.slack.com/t/verl-project/shared_invite/zt-3855yhg8g-CTkqXu~hKojPCmo7k_yXTQ). (If not accessible, please try [the Feishu group (飞书群)](https://applink.larkoffice.com/client/chat/chatter/add_by_link?link_token=772jd4f1-cd91-441e-a820-498c6614126a).) | ||
| - [X] Read the [Contribute Guide](https://github.com/volcengine/verl/blob/main/CONTRIBUTING.md). | ||
| - [X] Apply [pre-commit checks](https://github.com/volcengine/verl/blob/main/CONTRIBUTING.md#code-linting-and-formatting): `pre-commit install && pre-commit run --all-files --show-diff-on-failure --color=always` | ||
| - [X] Add / Update [the documentation](https://github.com/volcengine/verl/tree/main/docs). | ||
| - [X] Add unit or end-to-end test(s) to [the CI workflow](https://github.com/volcengine/verl/tree/main/.github/workflows) to cover all the code. If not feasible, explain why: ... | ||
| - [X] Once your PR is ready for CI, send a message in [the `ci-request` channel](https://verl-project.slack.com/archives/C091TCESWB1) in [the `verl` Slack workspace](https://join.slack.com/t/verl-project/shared_invite/zt-3855yhg8g-CTkqXu~hKojPCmo7k_yXTQ). (If not accessible, please try [the Feishu group (飞书群)](https://applink.larkoffice.com/client/chat/chatter/add_by_link?link_token=772jd4f1-cd91-441e-a820-498c6614126a).) | ||
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
59 changes: 59 additions & 0 deletions
59
examples/tuning/1.5b/qwen2.5math-1.5b_grpo_1_h100_fsdp_vllm.sh
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,59 @@ | ||
| PROJECT_NAME=qwen2.5_Math_1.5b_dr_grpo | ||
| LR=1e-5 | ||
| MODEL_NAME=Qwen/Qwen2.5-Math-1.5B | ||
| MAX_NEW_TOKENS=3000 | ||
| MAX_PROMPT_LENGTH=1024 #1024 #512 | ||
| MODEL_ALIAS=${MODEL_NAME##*/} | ||
| GROUP_SIZE=8 | ||
| CHOSEN_DEVICE=0 #0,1 | ||
| TOTAL_EPOCHS=2 | ||
| LOG_N_VAL_GENERATIONS=40 | ||
| ADVANTAGE_ESTIMATOR="grpo" | ||
|
|
||
|
|
||
| TIMESTAMP=$(date +"%Y%m%d_%H%M%S") | ||
| RUN_NAME=${MODEL_ALIAS}_${LR}_${GROUP_SIZE}_${MAX_NEW_TOKENS}_${ADVANTAGE_ESTIMATOR}_${TIMESTAMP} | ||
|
|
||
| CUDA_VISIBLE_DEVICES=$CHOSEN_DEVICE python3 -m verl.trainer.main_ppo \ | ||
| algorithm.adv_estimator=$ADVANTAGE_ESTIMATOR \ | ||
| data.train_files=data/MATH/train.parquet \ | ||
| data.val_files=data/MATH/test.parquet \ | ||
| data.train_batch_size=256 \ | ||
| data.max_prompt_length=$MAX_PROMPT_LENGTH \ | ||
| data.max_response_length=$MAX_NEW_TOKENS \ | ||
| data.filter_overlong_prompts=True \ | ||
| data.truncation='error' \ | ||
| actor_rollout_ref.model.path=$MODEL_NAME \ | ||
| actor_rollout_ref.actor.optim.lr=$LR \ | ||
| actor_rollout_ref.actor.loss_agg_mode=seq-mean-token-sum-norm \ | ||
| actor_rollout_ref.model.use_remove_padding=True \ | ||
| actor_rollout_ref.actor.ppo_mini_batch_size=256 \ | ||
| actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=4 \ | ||
| actor_rollout_ref.actor.use_kl_loss=False \ | ||
| actor_rollout_ref.actor.kl_loss_coef=0.001 \ | ||
| actor_rollout_ref.actor.kl_loss_type=low_var_kl \ | ||
| actor_rollout_ref.actor.entropy_coeff=0 \ | ||
| actor_rollout_ref.model.enable_gradient_checkpointing=True \ | ||
| actor_rollout_ref.actor.fsdp_config.param_offload=False \ | ||
| actor_rollout_ref.actor.fsdp_config.optimizer_offload=False \ | ||
| actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=4 \ | ||
| actor_rollout_ref.rollout.tensor_model_parallel_size=1 \ | ||
| actor_rollout_ref.rollout.name=vllm \ | ||
| actor_rollout_ref.rollout.gpu_memory_utilization=0.4 \ | ||
| actor_rollout_ref.rollout.n=$GROUP_SIZE \ | ||
| actor_rollout_ref.ref.log_prob_micro_batch_size_per_gpu=4 \ | ||
| actor_rollout_ref.ref.fsdp_config.param_offload=True \ | ||
| actor_rollout_ref.rollout.temperature=1.0 \ | ||
| actor_rollout_ref.rollout.top_p=1.0 \ | ||
| algorithm.use_kl_in_reward=False \ | ||
| algorithm.norm_adv_by_std_in_grpo=False\ | ||
KabakaWilliam marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| trainer.critic_warmup=0 \ | ||
| trainer.logger='["console","wandb"]' \ | ||
| trainer.n_gpus_per_node=1 \ | ||
| trainer.log_val_generations=$LOG_N_VAL_GENERATIONS\ | ||
KabakaWilliam marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| trainer.nnodes=1 \ | ||
| trainer.save_freq=20 \ | ||
| trainer.test_freq=1 \ | ||
| trainer.project_name=$PROJECT_NAME \ | ||
| trainer.experiment_name=$RUN_NAME \ | ||
| trainer.total_epochs=$TOTAL_EPOCHS \ | ||
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.