Skip to content

Commit ea2ea84

Browse files
committed
(fix): fix rlvr reward num_nodes infer.
1 parent ebc5fe4 commit ea2ea84

1 file changed

Lines changed: 24 additions & 1 deletion

File tree

roll/pipeline/rlvr/rlvr_config.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ class RLVRConfig(BaseConfig):
128128
metadata={"help": "Path to pretrain model directory for the reward model, if available."}
129129
)
130130
validation: WorkerConfig = field(
131-
default_factory=WorkerConfig,
131+
default=None,
132132
metadata={"help": "Configuration for the validation."}
133133
)
134134
actor_train: WorkerConfig = field(
@@ -289,6 +289,29 @@ def __post_init__(self):
289289
self.tag_2_domain = {
290290
tag: key for key, worker_config in self.rewards.items() for tag in worker_config.tag_included
291291
}
292+
if self.actor_infer:
293+
self.actor_infer.generating_args.max_new_tokens = self.sequence_length - self.prompt_length
294+
logger.warning(f"rewrite actor_infer max_new_tokens: {self.actor_infer.generating_args.max_new_tokens}")
295+
if self.validation:
296+
self.validation.generating_args.max_new_tokens = self.val_sequence_length - self.val_prompt_length
297+
logger.warning(f"rewrite validation max_new_tokens: {self.validation.generating_args.max_new_tokens}")
298+
299+
# infer the required num nodes
300+
total_devices = []
301+
for attribute_name in dir(self):
302+
attribute = getattr(self, attribute_name)
303+
if isinstance(attribute, WorkerConfig):
304+
if attribute.device_mapping is not None:
305+
total_devices.extend(attribute.device_mapping)
306+
for worker_config in self.rewards.values():
307+
if worker_config.device_mapping is not None:
308+
total_devices.extend(worker_config.device_mapping)
309+
if len(total_devices) > 0:
310+
max_gpu_num = max(total_devices) + 1
311+
if max_gpu_num <= self.num_gpus_per_node:
312+
self.num_nodes = 1
313+
else:
314+
self.num_nodes = (max_gpu_num + self.num_gpus_per_node - 1) // self.num_gpus_per_node
292315

293316
def set_max_steps(self, max_steps: int):
294317
actor_backward_batch_size = (

0 commit comments

Comments
 (0)