2626from verl .trainer .ppo .utils import Role
2727from verl .utils .device import auto_set_device
2828
29-
3029# -- Resource pool helpers ------------------------------------------------
3130
31+
3232def _create_resource_pool_manager (config , roles : list [Role ]) -> ResourcePoolManager :
3333 """Build separate resource pools for trainer vs. rollout roles."""
3434 resource_pool_spec = {}
@@ -74,6 +74,7 @@ def _create_role_worker_mapping(config):
7474
7575# -- AsyncTaskRunner ------------------------------------------------------
7676
77+
7778@ray .remote (num_cpus = 1 )
7879class AsyncTaskRunner :
7980 """Orchestrates async training: creates components, wires them, starts loops."""
@@ -93,8 +94,8 @@ def _initialize(self, config):
9394 pprint (OmegaConf .to_container (config , resolve = True ))
9495 OmegaConf .resolve (config )
9596
96- from verl .utils .fs import copy_to_local
9797 from verl .utils import hf_processor , hf_tokenizer
98+ from verl .utils .fs import copy_to_local
9899
99100 local_path = copy_to_local (
100101 config .actor_rollout_ref .model .path ,
@@ -103,7 +104,9 @@ def _initialize(self, config):
103104 trust_remote_code = config .data .get ("trust_remote_code" , False )
104105 tokenizer = hf_tokenizer (local_path , trust_remote_code = trust_remote_code )
105106 processor = hf_processor (
106- local_path , trust_remote_code = trust_remote_code , use_fast = True ,
107+ local_path ,
108+ trust_remote_code = trust_remote_code ,
109+ use_fast = True ,
107110 )
108111
109112 role_worker_mapping , ray_worker_group_cls = _create_role_worker_mapping (config )
@@ -139,7 +142,9 @@ def _initialize(self, config):
139142 max_queue_size = config .async_training .get ("max_queue_size" , None )
140143 data_pool_name = "data_pool"
141144 data_pool = DataPool .options (name = data_pool_name ).remote (
142- data_pool_config , verl_backend , max_queue_size = max_queue_size ,
145+ data_pool_config ,
146+ verl_backend ,
147+ max_queue_size = max_queue_size ,
143148 )
144149 self .components ["data_pool" ] = data_pool
145150 self .components ["data_pool_name" ] = data_pool_name
@@ -213,17 +218,12 @@ def _create_rollouter(self, config):
213218 def _create_trainer (self , config ):
214219 from claw_r1 .async_trainer import AsyncTrainer
215220
216- trainer_roles = [
217- role for role in self .components ["role_worker_mapping" ]
218- if role != Role .Rollout
219- ]
221+ trainer_roles = [role for role in self .components ["role_worker_mapping" ] if role != Role .Rollout ]
220222 trainer = AsyncTrainer .remote (
221223 config = config ,
222224 tokenizer = self .components ["tokenizer" ],
223225 role_worker_mapping = {
224- role : cls
225- for role , cls in self .components ["role_worker_mapping" ].items ()
226- if role != Role .Rollout
226+ role : cls for role , cls in self .components ["role_worker_mapping" ].items () if role != Role .Rollout
227227 },
228228 resource_pool_manager = _create_resource_pool_manager (config , trainer_roles ),
229229 ray_worker_group_cls = self .components ["ray_worker_group_cls" ],
@@ -266,6 +266,7 @@ def _run(self):
266266
267267# -- Hydra entry point ----------------------------------------------------
268268
269+
269270@hydra .main (config_path = "config" , config_name = "async_ppo_trainer" , version_base = None )
270271def main (config ):
271272 auto_set_device (config )
@@ -275,9 +276,7 @@ def main(config):
275276 ray_init_kwargs = config .ray_kwargs .get ("ray_init" , {})
276277 runtime_env_kwargs = ray_init_kwargs .get ("runtime_env" , {})
277278 runtime_env = OmegaConf .merge (default_runtime_env , runtime_env_kwargs )
278- ray_init_kwargs = OmegaConf .create (
279- {** ray_init_kwargs , "runtime_env" : runtime_env }
280- )
279+ ray_init_kwargs = OmegaConf .create ({** ray_init_kwargs , "runtime_env" : runtime_env })
281280 ray .init (namespace = "claw_r1_async" , ** OmegaConf .to_container (ray_init_kwargs ))
282281
283282 if not hasattr (config , "async_training" ):
0 commit comments