(config)
| 109 | |
| 110 | @ray.remote |
| 111 | def main_task(config): |
| 112 | # print initial config |
| 113 | from pprint import pprint |
| 114 | |
| 115 | from omegaconf import OmegaConf |
| 116 | |
| 117 | from verl.utils.fs import copy_to_local |
| 118 | |
| 119 | pprint(OmegaConf.to_container(config, resolve=True)) # resolve=True will eval symbol values |
| 120 | OmegaConf.resolve(config) |
| 121 | |
| 122 | # download the checkpoint from hdfs |
| 123 | local_path = copy_to_local(config.actor_rollout_ref.model.path) |
| 124 | |
| 125 | # instantiate tokenizer |
| 126 | from verl.utils import hf_tokenizer |
| 127 | |
| 128 | tokenizer = hf_tokenizer(local_path) |
| 129 | |
| 130 | # define worker classes |
| 131 | if config.actor_rollout_ref.actor.strategy in {"fsdp", "fsdp2"}: |
| 132 | assert config.critic.strategy in {"fsdp", "fsdp2"} |
| 133 | from verl.single_controller.ray import RayWorkerGroup |
| 134 | from verl.workers.fsdp_workers import ActorRolloutRefWorker, CriticWorker |
| 135 | |
| 136 | ray_worker_group_cls = RayWorkerGroup |
| 137 | |
| 138 | elif config.actor_rollout_ref.actor.strategy == "megatron": |
| 139 | assert config.actor_rollout_ref.actor.strategy == config.critic.strategy |
| 140 | from verl.single_controller.ray import RayWorkerGroup |
| 141 | from verl.workers.megatron_workers import ActorRolloutRefWorker, CriticWorker |
| 142 | |
| 143 | ray_worker_group_cls = RayWorkerGroup |
| 144 | |
| 145 | else: |
| 146 | raise NotImplementedError |
| 147 | |
| 148 | from verl.trainer.ppo.ray_trainer import ResourcePoolManager, Role |
| 149 | |
| 150 | role_worker_mapping = { |
| 151 | Role.ActorRollout: ray.remote(ActorRolloutRefWorker), |
| 152 | Role.Critic: ray.remote(CriticWorker), |
| 153 | } |
| 154 | |
| 155 | # NOTE: initialze two resource pool |
| 156 | actor_rollout_ref_pool_id = "actor_rollout_ref_pool" |
| 157 | critic_pool_id = "critic_pool" |
| 158 | if config.trainer.nnodes // 2 == 0 and config.trainer.n_gpus_per_node // 2 > 0: |
| 159 | resource_pool_spec = { |
| 160 | actor_rollout_ref_pool_id: [config.trainer.n_gpus_per_node // 2] * config.trainer.nnodes, |
| 161 | critic_pool_id: [config.trainer.n_gpus_per_node // 2] * config.trainer.nnodes, |
| 162 | } |
| 163 | else: |
| 164 | resource_pool_spec = { |
| 165 | actor_rollout_ref_pool_id: [config.trainer.n_gpus_per_node] * (config.trainer.nnodes // 2), |
| 166 | critic_pool_id: [config.trainer.n_gpus_per_node] * (config.trainer.nnodes // 2), |
| 167 | } |
| 168 | print(f"resource_pool_spec: {resource_pool_spec}") |
nothing calls this directly
no test coverage detected