-
Notifications
You must be signed in to change notification settings - Fork 438
feat: add async RL support #1098
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 24 commits
Commits
Show all changes
42 commits
Select commit
Hold shift + click to select a range
7f0a931
WIP init commit
parthchadha 01e8887
Add checks to prevent cuda oom
parthchadha 15364fc
Merge remote-tracking branch 'origin/main' into pchadha/async-basic
parthchadha c1160d5
Merge remote-tracking branch 'origin/main' into pchadha/async-basic
parthchadha f66f4c0
Default max_trajectory_age_steps=1 by default
parthchadha 509312a
debug implementation
parthchadha 621a1fa
fix lock for writing into dict
parthchadha c196790
Fix stalls
parthchadha 653e4f5
More fixes
parthchadha 718c332
Add stronger check for stall
parthchadha 722fae8
Fix more stalling issues and wrong batch data use
parthchadha 160a350
Fix incorrect clearning of inflight generation targets
parthchadha 01f1cd6
Add stall on refit and log avg age of samples
parthchadha 0b7c8f9
Save the state of dataloader from the collector
parthchadha 987bdfe
Merge remote-tracking branch 'origin/main' into faster-strictfifo
parthchadha ff52010
Fix incorrect passing of gbs args which reduced async experiments to …
parthchadha 81fc3a5
Add assertion when async grpo is used with sync vllm engine
parthchadha 7ca538d
fix: Decouple exposed_generation time from weight_sync time (#1052)
youngeunkwon0405 a1f35cb
fix: issue where generation_weight_version isn't correct after refit …
RahulSChand ca84567
Merge remote-tracking branch 'origin/main' into faster-strictfifo
parthchadha 07bcd9a
Merge remote-tracking branch 'origin/faster-strictfifo' into faster-s…
parthchadha b321181
Merge remote-tracking branch 'origin/main' into faster-strictfifo
parthchadha 576634c
Add more detailed comments about async
parthchadha 6868407
Add more comments; resolve review feedback
parthchadha c8ee01f
Merge remote-tracking branch 'origin/main' into faster-strictfifo
parthchadha 62eec29
Move async config to grpo/, remove async config examples, clean up code
parthchadha d7e1e29
Add async grpo docs
parthchadha 4ace692
Add functional L1 test
parthchadha 215e7a9
Merge remote-tracking branch 'origin/main' into faster-strictfifo
parthchadha 7f90b60
Update configs with async_grpo flag
parthchadha 79944bf
Add diagram in docs
parthchadha c1bbe8b
Apply suggestions from code review
parthchadha c0a144a
Merge remote-tracking branch 'origin/main' into faster-strictfifo
parthchadha ad42ecf
Merge remote-tracking branch 'origin/main' into faster-strictfifo
parthchadha 3a7ca57
fix doc failure
parthchadha bf5a6d7
feat: async RL
terrykong b534850
Add missing async unit tests
parthchadha a7f12d5
Merge remote-tracking branch 'origin/faster-strictfifo' into faster-s…
parthchadha 8eb7c93
Add missing grpo config in vlm yaml
parthchadha 2c7a922
Merge remote-tracking branch 'origin/main' into faster-strictfifo
parthchadha 7ed8a90
Raise error if ReplayBuffer created with <= 0 size
parthchadha c10f034
Add missing pragma no cover to ray remote async class
parthchadha 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 |
|---|---|---|
| @@ -0,0 +1,109 @@ | ||
| # Async GRPO Algorithm Configuration | ||
| defaults: "grpo_math_1B.yaml" | ||
|
|
||
| # Async-specific settings | ||
| async_grpo: | ||
| enabled: true # Enable async training | ||
| max_trajectory_age_steps: 1 # Allow trajectories from the last 4 training steps | ||
|
|
||
| grpo: | ||
| num_prompts_per_step: 32 | ||
| num_generations_per_prompt: 16 | ||
| max_rollout_turns: 1 | ||
| max_num_steps: 1000 | ||
| normalize_rewards: true | ||
| use_leave_one_out_baseline: true | ||
| val_period: 10 | ||
| val_at_start: false | ||
| max_val_samples: 256 | ||
| val_batch_size: 256 | ||
|
|
||
| policy: | ||
| model_name: "Qwen/Qwen2.5-1.5B" | ||
| tokenizer: | ||
| name: ${policy.model_name} | ||
| train_global_batch_size: 512 | ||
| train_micro_batch_size: 4 | ||
| generation_batch_size: 32 | ||
| logprob_batch_size: 4 | ||
| max_total_sequence_length: 512 | ||
| precision: "bfloat16" | ||
| fsdp_offload_enabled: false | ||
| activation_checkpointing_enabled: false | ||
|
|
||
| dtensor_cfg: | ||
| enabled: true | ||
| cpu_offload: False | ||
| sequence_parallel: false | ||
| activation_checkpointing: false | ||
| tensor_parallel_size: 1 | ||
| context_parallel_size: 1 | ||
| custom_parallel_plan: null | ||
|
|
||
| dynamic_batching: | ||
| enabled: True | ||
|
|
||
| sequence_packing: | ||
| enabled: False | ||
|
|
||
| generation: | ||
| backend: "vllm" | ||
| max_new_tokens: ${policy.max_total_sequence_length} | ||
| temperature: 1.0 | ||
| top_p: 1.0 | ||
| top_k: null | ||
| stop_token_ids: null | ||
| stop_strings: null | ||
| vllm_cfg: | ||
| # Enable async engine for better concurrency | ||
| async_engine: true | ||
| tensor_parallel_size: 1 | ||
| gpu_memory_utilization: 0.8 | ||
| max_model_len: ${policy.max_total_sequence_length} | ||
| enforce_eager: False | ||
| colocated: | ||
| enabled: false | ||
| resources: | ||
| gpus_per_node: 1 | ||
| num_nodes: 1 | ||
|
|
||
| # Data configuration | ||
| data: | ||
| dataset_name: "OpenMathInstruct-2" | ||
| subset: "train" | ||
| limit: 1000 # For faster testing | ||
| val_limit: 100 | ||
| val_subset: "test" | ||
| max_input_seq_length: ${policy.max_total_sequence_length} | ||
| prompt_file: "examples/prompts/cot.txt" | ||
| system_prompt_file: null | ||
| add_system_prompt: false | ||
|
|
||
| # Environment configuration | ||
| env: | ||
| math: | ||
| cfg: | ||
| num_workers: 4 | ||
|
|
||
| checkpointing: | ||
| enabled: true | ||
| checkpoint_dir: "results/async_grpo_importance_sampling" | ||
| metric_name: "val_reward" | ||
| higher_is_better: true | ||
| keep_top_k: 3 | ||
| save_period: 10 | ||
|
|
||
| logger: | ||
| log_dir: "logs" | ||
| num_val_samples_to_print: 3 | ||
| wandb_enabled: true | ||
| tensorboard_enabled: false | ||
| monitor_gpus: true | ||
| wandb: | ||
| project: "async-grpo-dev" | ||
| name: "async-grpo-math" | ||
| tensorboard: {} | ||
| gpu_monitoring: | ||
| collection_interval: 10 | ||
| flush_interval: 10 | ||
|
|
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,98 @@ | ||
| # Async GRPO Algorithm Configuration | ||
| defaults: "grpo_math_1B.yaml" | ||
|
|
||
| # Async-specific settings | ||
| async_grpo: | ||
| enabled: true # Enable async training | ||
| max_trajectory_age_steps: 1 # Allow trajectories from the last 1 training steps | ||
|
|
||
| grpo: | ||
| num_prompts_per_step: 64 | ||
| num_generations_per_prompt: 32 | ||
|
|
||
| # Use async-friendly backend | ||
| policy: | ||
| model_name: "meta-llama/Llama-3.1-8B-Instruct" | ||
| tokenizer: | ||
| name: ${policy.model_name} ## specify if you'd like to use a tokenizer different from the model's default | ||
| train_global_batch_size: 512 | ||
| train_micro_batch_size: 1 | ||
| generation_batch_size: 32 # Only used when generating using HF backend | ||
| logprob_batch_size: 2 | ||
| max_total_sequence_length: 4096 | ||
| precision: "bfloat16" | ||
| fsdp_offload_enabled: false | ||
| activation_checkpointing_enabled: false | ||
|
|
||
| dtensor_cfg: | ||
| enabled: true | ||
| cpu_offload: False | ||
| sequence_parallel: false | ||
| activation_checkpointing: false | ||
| tensor_parallel_size: 1 | ||
| context_parallel_size: 1 | ||
| custom_parallel_plan: null | ||
|
|
||
| dynamic_batching: | ||
| enabled: False | ||
|
|
||
| optimizer: | ||
| name: "torch.optim.AdamW" | ||
| kwargs: | ||
| lr: 3.0e-7 | ||
| weight_decay: 0.01 | ||
| betas: [0.9, 0.999] | ||
| eps: 1e-8 | ||
|
|
||
| scheduler: | ||
| - name: "torch.optim.lr_scheduler.LinearLR" | ||
| kwargs: | ||
| start_factor: 0.1 | ||
| end_factor: 1.0 | ||
| # The scheduler iteration is per GPRO step and is decoupled with the optimizer step (may be >=1 per GPRO step) | ||
| total_iters: 13 | ||
| - name: "torch.optim.lr_scheduler.ConstantLR" | ||
| kwargs: | ||
| factor: 1.0 | ||
| total_iters: 10000000000 | ||
| - milestones: [13] | ||
|
|
||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
|
||
| generation: | ||
| backend: "vllm" | ||
| max_new_tokens: ${policy.max_total_sequence_length} | ||
| temperature: 1.0 | ||
| top_p: 1.0 | ||
| top_k: null | ||
| stop_token_ids: null | ||
| stop_strings: null | ||
| vllm_cfg: | ||
| # Enable async engine for better concurrency | ||
| async_engine: true | ||
| tensor_parallel_size: 1 | ||
| gpu_memory_utilization: 0.8 | ||
| max_model_len: ${policy.max_total_sequence_length} | ||
| enforce_eager: False | ||
| colocated: | ||
| enabled: false | ||
| resources: | ||
| gpus_per_node: 1 | ||
| num_nodes: 1 | ||
|
|
||
| cluster: | ||
| gpus_per_node: 8 | ||
| num_nodes: 1 | ||
|
|
||
| logger: | ||
| log_dir: "logs" | ||
| num_val_samples_to_print: 3 | ||
| wandb_enabled: true | ||
| tensorboard_enabled: false | ||
| monitor_gpus: true | ||
| wandb: | ||
| project: "async-grpo-dev" | ||
| name: "async-grpo-math" | ||
| tensorboard: {} | ||
| gpu_monitoring: | ||
| collection_interval: 10 | ||
| flush_interval: 10 | ||
|
|
||
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.