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)
| 1404 | ) |
| 1405 | |
| 1406 | def set_train_batch_size(self, train_batch_size): |
| 1407 | """Adjust the global batch size by increasing or decreasing the number of |
| 1408 | micro-batches (i.e., gradient accumulation steps). The size of each micro-batch |
| 1409 | (i.e., ``train_micro_batch_size_per_gpu``) is not changed. |
| 1410 | Args: |
| 1411 | train_batch_size (int): The new global batch size for training. |
| 1412 | Raises: |
| 1413 | ValueError: if ``train_batch_size`` is not divisible by the |
| 1414 | configured micro-batch size and data parallelism. |
| 1415 | """ |
| 1416 | if train_batch_size % (self.train_micro_batch_size_per_gpu() * self.dp_world_size) != 0: |
| 1417 | raise ValueError('Train batch size must be divisible by micro-batch data parallelism') |
| 1418 | new_gas = train_batch_size // (self.train_micro_batch_size_per_gpu() * self.dp_world_size) |
| 1419 | # overwrite config |
| 1420 | self._config.train_batch_size = train_batch_size |
| 1421 | self._config.gradient_accumulation_steps = new_gas |
| 1422 | |
| 1423 | def set_train_micro_batch_size(self, micro_batch_size): |
| 1424 | """Adjust the micro batch size(i.e., the micro batch size in every data parallel group), |
nothing calls this directly
no test coverage detected