From efd0061a0af160b41b31b0d59b4e75e060682a04 Mon Sep 17 00:00:00 2001 From: Guangming Sheng Date: Wed, 26 Feb 2025 10:07:52 +0800 Subject: [PATCH] =?UTF-8?q?[misc]=20add=20assertion=20for=20normalized=20p?= =?UTF-8?q?po=20mini=5Fbatch=5Fsize=20and=20ppo=20micro=E2=80=A6=20(#382)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - As titled --- verl/workers/fsdp_workers.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/verl/workers/fsdp_workers.py b/verl/workers/fsdp_workers.py index 1660bd06..c3079373 100644 --- a/verl/workers/fsdp_workers.py +++ b/verl/workers/fsdp_workers.py @@ -123,7 +123,11 @@ def __init__(self, config: DictConfig, role: str): self.config.actor.ppo_micro_batch_size //= (self.device_mesh.shape[0] // self.ulysses_sequence_parallel_size) self.config.actor.ppo_micro_batch_size_per_gpu = self.config.actor.ppo_micro_batch_size - assert self.config.actor.ppo_mini_batch_size % self.config.actor.ppo_micro_batch_size_per_gpu == 0 + assert self.config.actor.ppo_mini_batch_size % self.config.actor.ppo_micro_batch_size_per_gpu == 0, \ + f'normalized ppo_mini_batch_size {self.config.actor.ppo_mini_batch_size} should be divisible by ppo_micro_batch_size_per_gpu {self.config.actor.ppo_micro_batch_size_per_gpu}' + assert self.config.actor.ppo_mini_batch_size // self.config.actor.ppo_micro_batch_size_per_gpu > 0, \ + f'normalized ppo_mini_batch_size {self.config.actor.ppo_mini_batch_size} should be larger than ppo_micro_batch_size_per_gpu {self.config.actor.ppo_micro_batch_size_per_gpu}' + # normalize rollout config if self._is_rollout and self.config.rollout.log_prob_micro_batch_size is not None: self.config.rollout.log_prob_micro_batch_size //= (self.device_mesh.shape[0] // @@ -612,7 +616,10 @@ def __init__(self, config): self.ulysses_sequence_parallel_size) self.config.ppo_micro_batch_size_per_gpu = self.config.ppo_micro_batch_size self.config.forward_micro_batch_size_per_gpu = self.config.forward_micro_batch_size - assert self.config.ppo_mini_batch_size % self.config.ppo_micro_batch_size_per_gpu == 0 + assert self.config.ppo_mini_batch_size % self.config.ppo_micro_batch_size_per_gpu == 0, \ + f'normalized ppo_mini_batch_size {self.config.ppo_mini_batch_size} should be divisible by ppo_micro_batch_size_per_gpu {self.config.ppo_micro_batch_size_per_gpu}' + assert self.config.ppo_mini_batch_size // self.config.ppo_micro_batch_size_per_gpu > 0, \ + f'normalized ppo_mini_batch_size {self.config.ppo_mini_batch_size} should be larger than ppo_micro_batch_size_per_gpu {self.config.ppo_micro_batch_size_per_gpu}' def _build_critic_model_optimizer(self, config): # the following line is necessary