Skip to content

[Fix] ppo rollout engins for distribute - #394

Merged
zhuzilin merged 15 commits into
THUDM:mainfrom
lilei199908:ppo_updates
Sep 28, 2025
Merged

[Fix] ppo rollout engins for distribute#394
zhuzilin merged 15 commits into
THUDM:mainfrom
lilei199908:ppo_updates

Conversation

@lilei199908

Copy link
Copy Markdown
Collaborator

No description provided.

args,
values: Optional[list[torch.Tensor]] = None,
log_probs: Optional[list[torch.Tensor]] = None,
ref_log_probs: Optional[list[torch.Tensor]] = None,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can pass only one argument and use for example if "values" in rollout_data to check whether this is critic or actor

k *= -args.kl_coef
k[-1] += reward
if k.numel() > 0:
k[-1] += reward

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when enabling cp, we need to add the reward only to the last position

Comment thread slime/backends/megatron_utils/model.py Outdated

if args.use_wandb:
log_dict["train/step"] = accumulated_step_id
log_dict[f"train/{role_tag}step"] = accumulated_step_id

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm.. not sure why we need to change this?

self.quantization_config = quantization_config
self.param_info_buckets = get_param_info_buckets(self.args, self.model)
self.weight_version = 0
self.use_distribute = self.args.use_critic

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can use the number of rollout engines to judge whether we need to use distributed.

rank=0,
group_name=self._group_name,
)
ray.get(refs)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please try to reuse the code from class UpdateFromDistributed

if dist.get_rank() == self._ipc_gather_src:
refs.extend(self._update_converted_params_from_tensor(converted_named_tensors))
else:
self._update_converted_params_from_tensor(converted_named_tensors)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you also need to syn the refs for the non ipc_src ranks.

Comment thread slime/utils/arguments.py Outdated
)
args.rollout_num_gpus = args.actor_num_gpus_per_node * args.actor_num_nodes
if not args.use_critic:
args.rollout_num_gpus = args.actor_num_gpus_per_node * args.actor_num_nodes

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need to change this line?

Comment thread slime/utils/ppo_utils.py Outdated
from megatron.core import mpu

cp_size = mpu.get_context_parallel_world_size()
if cp_size > 0:

@zhuzilin zhuzilin Sep 28, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cp_size > 1

@zhuzilin zhuzilin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zhuzilin
zhuzilin merged commit 371c030 into THUDM:main Sep 28, 2025
3 of 4 checks passed
llltttwww pushed a commit to llltttwww/slime that referenced this pull request Nov 30, 2025
* [fix] fix ppo value_loss problem and add kl_coef to reward

* [fix] ppo update_weights form distribute

* [fix] ppo cp bugs

* [Fix] ppo update_from_distribute
Yangruipis pushed a commit to redai-studio/slime that referenced this pull request Feb 28, 2026
* [fix] fix ppo value_loss problem and add kl_coef to reward

* [fix] ppo update_weights form distribute

* [fix] ppo cp bugs

* [Fix] ppo update_from_distribute
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants