-
Notifications
You must be signed in to change notification settings - Fork 967
[WIP][Exp]Support ray dpo #6395
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
tastelikefeet
wants to merge
19
commits into
modelscope:main
Choose a base branch
from
tastelikefeet:feat/dpo-ray
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
19 commits
Select commit
Hold shift + click to select a range
ccc0edd
wip
tastelikefeet 3d585fd
wip
tastelikefeet 2cf6194
fix
51fc512
Merge branch 'feat/dpo-ray' of github.com:tastelikefeet/swift into fe…
9156320
revert files
tastelikefeet c43ab45
Merge commit '07b7110201b654fcb7cd3b31f72b6697210688be' into feat/dpo…
tastelikefeet 3a9e575
wip
tastelikefeet c4439ed
wip
tastelikefeet 53f0327
wip
tastelikefeet cfd2433
Merge branch 'main' into feat/dpo-ray
tastelikefeet c303e1f
fix
tastelikefeet c9e1cb6
fix
01b4f66
lint
tastelikefeet 789b3c3
fix
0b46447
fix
1e98804
wip
tastelikefeet 746e533
fix
afd608b
fix
081fa47
fix doc
tastelikefeet 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| swift rlhf --config dpo.yaml |
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,39 @@ | ||
| rlhf_type: dpo | ||
| model: Qwen/Qwen2.5-VL-3B-Instruct | ||
| ref_model: Qwen/Qwen2.5-VL-3B-Instruct | ||
| train_type: full | ||
| dataset: swift/RLAIF-V-Dataset#1000 | ||
| load_from_cache_file: true | ||
| split_dataset_ratio: 0.01 | ||
| torch_dtype: bfloat16 | ||
| num_train_epochs: 1 | ||
| per_device_train_batch_size: 4 | ||
| per_device_eval_batch_size: 4 | ||
| learning_rate: 1e-4 | ||
| gradient_accumulation_steps: 2 | ||
| eval_steps: 1 | ||
| save_steps: 1 | ||
| save_total_limit: 2 | ||
| logging_steps: 5 | ||
| max_length: 2048 | ||
| output_dir: output | ||
| warmup_ratio: 0.05 | ||
| dataloader_num_workers: 4 | ||
| rpo_alpha: 0.1 | ||
| dataset_num_proc: 4 | ||
|
|
||
| use_ray: true | ||
|
|
||
| # Ranks of rlhf:default and ref must equal | ||
| device_groups: | ||
| nproc_per_node: 4 | ||
| sample_group: | ||
| device: GPU | ||
| ranks: list(range(0, 2)) | ||
| workers: | ||
| - rlhf:default | ||
| rm_group: | ||
| device: GPU | ||
| ranks: list(range(2, 4)) | ||
| workers: | ||
| - ref |
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 @@ | ||
| swift sft --config pt.yaml |
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 @@ | ||
| model: Qwen/Qwen2.5-7B | ||
| train_type: full | ||
| dataset: swift/chinese-c4#2000 | ||
| torch_dtype: bfloat16 | ||
| streaming: true | ||
| per_device_train_batch_size: 1 | ||
| per_device_eval_batch_size: 1 | ||
| learning_rate: 1e-5 | ||
| gradient_accumulation_steps: 2 | ||
| packing: true | ||
| eval_steps: 500 | ||
| save_steps: 500 | ||
| save_total_limit: 2 | ||
| logging_steps: 5 | ||
| deepspeed: zero3 | ||
| max_length: 8192 | ||
| max_steps: 10000 | ||
| warmup_ratio: 0.05 | ||
| dataloader_num_workers: 4 | ||
| dataset_num_proc: 8 | ||
| save_only_model: true | ||
| output_dir: output/Qwen2.5-7B | ||
| attn_impl: flash_attn | ||
|
|
||
| use_ray: true | ||
|
|
||
| device_groups: | ||
| nproc_per_node: 4 | ||
| default: | ||
| device: GPU | ||
| ranks: list(range(0, 4)) | ||
| workers: | ||
| - pt:default |
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 |
|---|---|---|
|
|
@@ -33,4 +33,4 @@ device_groups: | |
| device: GPU | ||
| ranks: list(range(0, 4)) | ||
| workers: | ||
| - default | ||
| - sft:default | ||
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,5 +1,7 @@ | ||
| # Copyright (c) Alibaba, Inc. and its affiliates. | ||
| from swift.llm import pt_main | ||
|
|
||
| if __name__ == '__main__': | ||
| from swift.ray import try_init_ray | ||
| try_init_ray() | ||
| from swift.llm import pt_main | ||
| pt_main() |
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,5 +1,7 @@ | ||
| # Copyright (c) Alibaba, Inc. and its affiliates. | ||
| from swift.llm import rlhf_main | ||
|
|
||
| if __name__ == '__main__': | ||
| from swift.ray import try_init_ray | ||
| try_init_ray() | ||
| from swift.llm import rlhf_main | ||
| rlhf_main() |
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.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The initialization of
self.reward_modelandself.reward_templatehappens aftersuper().__init__(args)is called. Thesuper().__init__call chain eventually triggers remote calls to methods like_prepare_reward_model, which attempt to use these attributes on the worker instances. Since they are not yet initialized on the workers when these remote methods are called, this will lead to anAttributeError.To fix this, these attributes should be initialized before the
super().__init__(args)call. Also, note thatself.argsis not available beforesuper().__init__, so you should use theargsfrom the__init__method signature for the conditional initialization ofself.reward_template.