Adjust the global batch size by increasing or decreasing the number of micro-batches (i.e., gradient accumulation steps). The size of each micro-batch (i.e., ``train_micro_batch_size_per_gpu``) is not changed. Args: train_batch_size (int): The new global batch siz
(self, train_batch_size)
| 409 | ) |
| 410 | |
| 411 | def set_train_batch_size(self, train_batch_size): |
| 412 | """Adjust the global batch size by increasing or decreasing the number of |
| 413 | micro-batches (i.e., gradient accumulation steps). The size of each micro-batch |
| 414 | (i.e., ``train_micro_batch_size_per_gpu``) is not changed. |
| 415 | Args: |
| 416 | train_batch_size (int): The new global batch size for training. |
| 417 | Raises: |
| 418 | ValueError: if ``train_batch_size`` is not divisible by the |
| 419 | configured micro-batch size and data parallelism. |
| 420 | """ |
| 421 | if train_batch_size % (self.train_micro_batch_size_per_gpu() * self.dp_world_size) != 0: |
| 422 | #print(f'{train_batch_size=} {self.train_micro_batch_size_per_gpu()=} {self.dp_world_size=}') |
| 423 | raise ValueError(f'Train batch size must be divisible by micro-batch data parallelism') |
| 424 | new_gas = train_batch_size // (self.train_micro_batch_size_per_gpu() * self.dp_world_size) |
| 425 | # overwrite config |
| 426 | self._config.train_batch_size = train_batch_size |
| 427 | self._config.gradient_accumulation_steps = new_gas |
| 428 | |
| 429 | def set_data_post_process_func(self, post_process_func): |
| 430 | if self.training_dataloader is not None: |
nothing calls this directly
no test coverage detected