From 369e2ea7876406389ec66e16550a2d59835b9a0b Mon Sep 17 00:00:00 2001 From: Haibin Lin Date: Mon, 2 Dec 2024 23:06:10 -0800 Subject: [PATCH] fix lint --- verl/trainer/ppo/ray_trainer.py | 16 +++++++++++----- verl/trainer/ppo/workers/fsdp_workers.py | 18 ++++++++++++------ verl/trainer/ppo/workers/megatron_workers.py | 18 ++++++++++++------ 3 files changed, 35 insertions(+), 17 deletions(-) diff --git a/verl/trainer/ppo/ray_trainer.py b/verl/trainer/ppo/ray_trainer.py index 776c0fb..9569eaf 100644 --- a/verl/trainer/ppo/ray_trainer.py +++ b/verl/trainer/ppo/ray_trainer.py @@ -293,11 +293,17 @@ def _validate(self): test_gen_batch = test_batch.pop(['input_ids', 'attention_mask', 'position_ids']) test_gen_batch.meta_info = { - 'eos_token_id': self.tokenizer.eos_token_id, - 'pad_token_id': self.tokenizer.pad_token_id if self.tokenizer.pad_token_id is not None else self.tokenizer.eos_token_id, - 'recompute_log_prob': False, - 'do_sample': False, - 'validate': True, + 'eos_token_id': + self.tokenizer.eos_token_id, + 'pad_token_id': + self.tokenizer.pad_token_id + if self.tokenizer.pad_token_id is not None else self.tokenizer.eos_token_id, + 'recompute_log_prob': + False, + 'do_sample': + False, + 'validate': + True, } test_output_gen_batch = self.actor_rollout_wg.generate_sequences(test_gen_batch) diff --git a/verl/trainer/ppo/workers/fsdp_workers.py b/verl/trainer/ppo/workers/fsdp_workers.py index 4f4de81..4e94439 100644 --- a/verl/trainer/ppo/workers/fsdp_workers.py +++ b/verl/trainer/ppo/workers/fsdp_workers.py @@ -117,9 +117,12 @@ def _build_model_optimizer(self, actor_model_config = AutoConfig.from_pretrained(local_path, trust_remote_code=trust_remote_code) override_config_kwargs = { - 'bos_token_id': self.tokenizer.bos_token_id, - 'eos_token_id': self.tokenizer.eos_token_id, - 'pad_token_id': self.tokenizer.pad_token_id if self.tokenizer.pad_token_id is not None else self.tokenizer.eos_token_id, + 'bos_token_id': + self.tokenizer.bos_token_id, + 'eos_token_id': + self.tokenizer.eos_token_id, + 'pad_token_id': + self.tokenizer.pad_token_id if self.tokenizer.pad_token_id is not None else self.tokenizer.eos_token_id, } override_config_kwargs.update(override_model_config) update_model_config(actor_model_config, override_config_kwargs=override_config_kwargs) @@ -471,9 +474,12 @@ def _build_critic_model_optimizer(self, config): from omegaconf import OmegaConf override_config = OmegaConf.to_container(self.config.model.get('override_config', OmegaConf.create())) override_config_kwargs = { - 'bos_token_id': self.tokenizer.bos_token_id, - 'eos_token_id': self.tokenizer.eos_token_id, - 'pad_token_id': self.tokenizer.pad_token_id if self.tokenizer.pad_token_id is not None else self.tokenizer.eos_token_id, + 'bos_token_id': + self.tokenizer.bos_token_id, + 'eos_token_id': + self.tokenizer.eos_token_id, + 'pad_token_id': + self.tokenizer.pad_token_id if self.tokenizer.pad_token_id is not None else self.tokenizer.eos_token_id, } override_config_kwargs.update(override_config) if self.rank == 0: diff --git a/verl/trainer/ppo/workers/megatron_workers.py b/verl/trainer/ppo/workers/megatron_workers.py index 2dd1005..7fc46a0 100644 --- a/verl/trainer/ppo/workers/megatron_workers.py +++ b/verl/trainer/ppo/workers/megatron_workers.py @@ -465,9 +465,12 @@ def _build_critic_model_optimizer(self, critic_model_config = AutoConfig.from_pretrained(local_path) override_config_kwargs = { - 'bos_token_id': self.tokenizer.bos_token_id, - 'eos_token_id': self.tokenizer.eos_token_id, - 'pad_token_id': self.tokenizer.pad_token_id if self.tokenizer.pad_token_id is not None else self.tokenizer.eos_token_id, + 'bos_token_id': + self.tokenizer.bos_token_id, + 'eos_token_id': + self.tokenizer.eos_token_id, + 'pad_token_id': + self.tokenizer.pad_token_id if self.tokenizer.pad_token_id is not None else self.tokenizer.eos_token_id, } override_config_kwargs.update(override_model_config) update_model_config(critic_model_config, override_config_kwargs=override_config_kwargs) @@ -628,9 +631,12 @@ def _build_rm_model(self, model_path, megatron_config: ModelParallelConfig, over rm_model_config = AutoConfig.from_pretrained(local_path) override_config_kwargs = { - 'bos_token_id': self.tokenizer.bos_token_id, - 'eos_token_id': self.tokenizer.eos_token_id, - 'pad_token_id': self.tokenizer.pad_token_id if self.tokenizer.pad_token_id is not None else self.tokenizer.eos_token_id, + 'bos_token_id': + self.tokenizer.bos_token_id, + 'eos_token_id': + self.tokenizer.eos_token_id, + 'pad_token_id': + self.tokenizer.pad_token_id if self.tokenizer.pad_token_id is not None else self.tokenizer.eos_token_id, } override_config_kwargs.update(override_model_config) update_model_config(rm_model_config, override_config_kwargs=override_config_kwargs)