-
Notifications
You must be signed in to change notification settings - Fork 55
feat: add RAFT alfworld example with reflection support #174
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
7 commits
Select commit
Hold shift + click to select a range
586c3ed
feat: add RAFT alfworld example with reflection support
765fbec
Merge branch 'modelscope:main' into main
shiweijiezero 2597f62
update comments of RAFTAlgorithm
9571b2e
adjust default parameter with enable_prefix_caching (true) and balanc…
ce6ef2d
Merge branch 'main' into main
shiweijiezero ba90ac4
simplify the implementation of RAFT, and add utils files to make code…
b505135
Rebuild code structure and make it concise by inheritance.
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,75 @@ | ||
| project: "Trinity-RFT-RAFT-alfworld" | ||
| name: "qwen2.5-7B-RAFT-alfworld" | ||
| mode: both | ||
| checkpoint_root_dir: /PATH/TO/CHECKPOINT/RAFT_ALFWORLD/ | ||
| algorithm: | ||
| algorithm_type: raft | ||
| repeat_times: 1 | ||
| model: | ||
| model_path: /PATH/TO/MODEL/ | ||
| max_response_tokens: 4096 | ||
| max_model_len: 20480 | ||
| cluster: | ||
| node_num: 1 | ||
| gpu_per_node: 8 | ||
| buffer: | ||
| total_epochs: 30 | ||
| batch_size: 80 | ||
| max_retry_times: 1 | ||
| max_retry_interval: 1 | ||
| explorer_input: | ||
| taskset: | ||
| name: alfworld-train | ||
| storage_type: file | ||
| path: '/PATH/TO/ALFWORLD_DATA/' | ||
| split: 'train' | ||
| format: | ||
| prompt_key: 'game_file' | ||
| response_key: 'task_desc' | ||
| rollout_args: | ||
| temperature: 0.85 | ||
| top_k: 25 | ||
| top_p: 0.95 | ||
| eval_tasksets: | ||
| - name: alfworld-eval | ||
| storage_type: file | ||
| path: '/PATH/TO/ALFWORLD_DATA/' | ||
| split: 'test' | ||
| format: | ||
| prompt_key: 'game_file' | ||
| response_key: 'task_desc' | ||
| rollout_args: | ||
| temperature: 0.85 | ||
| top_k: 25 | ||
| top_p: 0.95 | ||
| default_workflow_type: 'RAFT_alfworld_workflow' | ||
| trainer_input: | ||
| experience_buffer: | ||
| name: RAFT_buffer | ||
| storage_type: queue | ||
| path: 'sqlite:///RAFT_alfworld.db' | ||
| explorer: | ||
| eval_interval: 30 | ||
| runner_num: 100 | ||
| max_timeout: 3000 # Increased timeout for alfworld environment interactions | ||
| max_retry_times: 2 | ||
| rollout_model: | ||
| engine_type: vllm_async | ||
| engine_num: 4 | ||
| tensor_parallel_size: 1 | ||
| enable_prefix_caching: true | ||
| enforce_eager: false | ||
| dtype: bfloat16 | ||
| gpu_memory_utilization: 0.86 | ||
| seed: 42 | ||
| synchronizer: | ||
| sync_style: dynamic_by_explorer | ||
| sync_method: 'nccl' | ||
| sync_interval: 4 | ||
| sync_timeout: 1200 | ||
| trainer: | ||
| trainer_type: 'verl' | ||
| trainer_config_path: 'examples/RAFT_alfworld/train_alfworld.yaml' | ||
| save_interval: 100000 | ||
| monitor: | ||
| monitor_type: wandb |
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,75 @@ | ||
| project: "Trinity-RFT-RAFT-reflect-alfworld" | ||
| name: "qwen2.5-7B-RAFT-reflect-alfworld" | ||
| mode: both | ||
| checkpoint_root_dir: /PATH/TO/CHECKPOINT/RAFT_REFLECT_ALFWORLD/ | ||
| algorithm: | ||
| algorithm_type: raft | ||
| repeat_times: 1 | ||
| model: | ||
| model_path: /PATH/TO/MODEL/ | ||
| max_response_tokens: 4096 | ||
| max_model_len: 20480 | ||
| cluster: | ||
| node_num: 1 | ||
| gpu_per_node: 8 | ||
| buffer: | ||
| total_epochs: 30 | ||
| batch_size: 80 | ||
| max_retry_times: 1 | ||
| max_retry_interval: 1 | ||
| explorer_input: | ||
| taskset: | ||
| name: alfworld-train | ||
| storage_type: file | ||
| path: '/PATH/TO/ALFWORLD_DATA/' | ||
| split: 'train' | ||
| format: | ||
| prompt_key: 'game_file' | ||
| response_key: 'task_desc' | ||
| rollout_args: | ||
| temperature: 0.85 | ||
| top_k: 25 | ||
| top_p: 0.95 | ||
| eval_tasksets: | ||
| - name: alfworld-eval | ||
| storage_type: file | ||
| path: '/PATH/TO/ALFWORLD_DATA/' | ||
| split: 'test' | ||
| format: | ||
| prompt_key: 'game_file' | ||
| response_key: 'task_desc' | ||
| rollout_args: | ||
| temperature: 0.85 | ||
| top_k: 25 | ||
| top_p: 0.95 | ||
| default_workflow_type: 'RAFT_reflect_alfworld_workflow' | ||
| trainer_input: | ||
| experience_buffer: | ||
| name: RAFT_buffer | ||
| storage_type: queue | ||
| path: 'sqlite:///RAFT_reflect_alfworld.db' | ||
| explorer: | ||
| eval_interval: 30 | ||
| runner_num: 100 | ||
| max_timeout: 3000 # Increased timeout for alfworld environment interactions | ||
| max_retry_times: 2 | ||
| rollout_model: | ||
| engine_type: vllm_async | ||
| engine_num: 4 | ||
| tensor_parallel_size: 1 | ||
| enable_prefix_caching: false | ||
| enforce_eager: false | ||
| dtype: bfloat16 | ||
| gpu_memory_utilization: 0.86 | ||
| seed: 42 | ||
| synchronizer: | ||
| sync_style: dynamic_by_explorer | ||
| sync_method: 'nccl' | ||
| sync_interval: 4 | ||
| sync_timeout: 1200 | ||
| trainer: | ||
| trainer_type: 'verl' | ||
| trainer_config_path: 'examples/RAFT_alfworld/train_alfworld.yaml' | ||
| save_interval: 100000 | ||
| monitor: | ||
| monitor_type: wandb |
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,33 @@ | ||
| # RAFT on ALFWorld Dataset | ||
|
|
||
| This example shows the usage of RAFT on the ALFWorld dataset, with both standard and reflection-enhanced variants. | ||
|
|
||
|  | ||
|
|
||
| ## Variants | ||
|
|
||
| ### Standard RAFT | ||
| The config files are located in [`RAFT_alfworld_7B.yaml`](RAFT_alfworld_7B.yaml) and [`train_alfworld.yaml`](train_alfworld.yaml). | ||
|
|
||
| ### RAFT with Reflection | ||
| The config files are located in [`RAFT_reflect_alfworld_7B.yaml`](RAFT_reflect_alfworld_7B.yaml) and [`train_alfworld.yaml`](train_alfworld.yaml). | ||
|
|
||
| ## Setup | ||
|
|
||
| ### Data Preparation | ||
| To prepare the ALFWorld dataset, run: | ||
| ```bash | ||
| python examples/grpo_alfworld/get_alfworld_data.py | ||
| ``` | ||
|
|
||
| ### Configuration | ||
| Before running, make sure to update the following paths in the YAML files: | ||
| - `model.model_path`: Replace with your model path (e.g., `/PATH/TO/MODEL/`) | ||
| - `buffer.explorer_input.taskset.path`: Replace with your alfworld dataset path | ||
| - `buffer.explorer_input.eval_tasksets[0].path`: Replace with your alfworld dataset path | ||
| - `checkpoint_root_dir`: Replace with your desired checkpoint directory | ||
|
|
||
| ## Implementation | ||
| The workflow implementations are located in: | ||
| - Standard RAFT: [`trinity/common/workflows/envs/alfworld/RAFT_alfworld_workflow.py`](../../trinity/common/workflows/envs/alfworld/RAFT_alfworld_workflow.py) | ||
| - RAFT with Reflection: [`trinity/common/workflows/envs/alfworld/RAFT_reflect_alfworld_workflow.py`](../../trinity/common/workflows/envs/alfworld/RAFT_reflect_alfworld_workflow.py) | ||
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,45 @@ | ||
| actor_rollout_ref: | ||
| hybrid_engine: True | ||
| model: | ||
| external_lib: null | ||
| override_config: { } | ||
| enable_gradient_checkpointing: True | ||
| use_remove_padding: True | ||
| actor: | ||
| strategy: fsdp | ||
| ppo_mini_batch_size: 16 | ||
| ppo_micro_batch_size_per_gpu: 1 | ||
| use_dynamic_bsz: True | ||
| ppo_max_token_len_per_gpu: 20000 # Adjusted for alfworld longer sequences | ||
| grad_clip: 1.0 | ||
| clip_ratio: 0.2 | ||
| ppo_epochs: 1 | ||
| shuffle: False | ||
| ulysses_sequence_parallel_size: 1 | ||
| optim: | ||
| lr: 1e-6 | ||
| lr_warmup_steps_ratio: 0. | ||
| total_training_steps: -1 # Will be overridden by program | ||
| fsdp_config: | ||
| wrap_policy: | ||
| min_num_params: 0 | ||
| param_offload: False | ||
| optimizer_offload: False | ||
| fsdp_size: -1 | ||
| ref: | ||
| fsdp_config: | ||
| param_offload: False | ||
| wrap_policy: | ||
| min_num_params: 0 | ||
| log_prob_micro_batch_size_per_gpu: 8 | ||
| log_prob_use_dynamic_bsz: ${actor_rollout_ref.actor.use_dynamic_bsz} | ||
| log_prob_max_token_len_per_gpu: ${actor_rollout_ref.actor.ppo_max_token_len_per_gpu} | ||
| ulysses_sequence_parallel_size: ${actor_rollout_ref.actor.ulysses_sequence_parallel_size} | ||
|
|
||
| trainer: | ||
| balance_batch: True | ||
| resume_mode: disable | ||
| default_hdfs_dir: null | ||
| remove_previous_ckpt_in_save: True | ||
| del_local_ckpt_after_load: False | ||
| val_before_train: False |
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
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.