8000 fix grpo rank by hjh0119 · Pull Request #3687 · modelscope/ms-swift · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix grpo rank #3687

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 1 commit into from
Mar 27, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions swift/trainers/rlhf_trainer/grpo_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,8 @@ def infer_rank(self):
for _vllm_rank in range(self.args.num_infer_workers):
if local_rank == _vllm_rank:
return get_node_setting()[0] * self.args.num_infer_workers + _vllm_rank

if local_rank == -1:
return 0
return -1

@property
Expand All @@ -418,7 +419,8 @@ def infer_rank_tp_0(self):
if local_rank == _vllm_rank and _vllm_rank % self.args.tensor_parallel_size == 0:
return (get_node_setting()[0] * self.args.num_infer_workers
+ _vllm_rank // self.args.tensor_parallel_size)

if local_rank == -1:
return 0
return -1

@property
Expand Down Expand Up @@ -1119,7 +1121,7 @@ def _queue(self):
def set_multi_turn_engine_default_max_tokens(self):
# Reset max_model_len to ensure that the total length during multi-turn generation
# does not exceed max_tokens, i.e., max_completion_length
if self.multi_turn_func:
if self.multi_turn_func and self.infer_rank >= 0:
origin_set_default_max_tokens = self.engine.set_default_max_tokens

def new_set_default_max_tokens(_self, request_config: RequestConfig, inputs: Dict[str, Any]) -> None:
Expand Down
Loading
0