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)
| 1432 | ) |
| 1433 | |
| 1434 | def set_train_batch_size(self, train_batch_size): |
| 1435 | """Adjust the global batch size by increasing or decreasing the number of |
| 1436 | micro-batches (i.e., gradient accumulation steps). The size of each micro-batch |
| 1437 | (i.e., ``train_micro_batch_size_per_gpu``) is not changed. |
| 1438 | Args: |
| 1439 | train_batch_size (int): The new global batch size for training. |
| 1440 | Raises: |
| 1441 | ValueError: if ``train_batch_size`` is not divisible by the |
| 1442 | configured micro-batch size and data parallelism. |
| 1443 | """ |
| 1444 | if train_batch_size % (self.train_micro_batch_size_per_gpu() * self.dp_world_size) != 0: |
| 1445 | raise ValueError('Train batch size must be divisible by micro-batch data parallelism') |
| 1446 | new_gas = train_batch_size // (self.train_micro_batch_size_per_gpu() * self.dp_world_size) |
| 1447 | # overwrite config |
| 1448 | self._config.train_batch_size = train_batch_size |
| 1449 | self._config.gradient_accumulation_steps = new_gas |
| 1450 | |
| 1451 | def set_train_micro_batch_size(self, micro_batch_size): |
| 1452 | """Adjust the micro batch size(i.e., the micro batch size in every data parallel group), |
nothing calls this directly
no test coverage detected