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