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)
| 1351 | ) |
| 1352 | |
| 1353 | def set_train_batch_size(self, train_batch_size): |
| 1354 | """Adjust the global batch size by increasing or decreasing the number of |
| 1355 | micro-batches (i.e., gradient accumulation steps). The size of each micro-batch |
| 1356 | (i.e., ``train_micro_batch_size_per_gpu``) is not changed. |
| 1357 | Args: |
| 1358 | train_batch_size (int): The new global batch size for training. |
| 1359 | Raises: |
| 1360 | ValueError: if ``train_batch_size`` is not divisible by the |
| 1361 | configured micro-batch size and data parallelism. |
| 1362 | """ |
| 1363 | if train_batch_size % (self.train_micro_batch_size_per_gpu() * self.dp_world_size) != 0: |
| 1364 | raise ValueError('Train batch size must be divisible by micro-batch data parallelism') |
| 1365 | new_gas = train_batch_size // (self.train_micro_batch_size_per_gpu() * self.dp_world_size) |
| 1366 | # overwrite config |
| 1367 | self._config.train_batch_size = train_batch_size |
| 1368 | self._config.gradient_accumulation_steps = new_gas |
| 1369 | |
| 1370 | def set_train_micro_batch_size(self, micro_batch_size): |
| 1371 | """Adjust the micro batch size(i.e., the micro batch size in every data parallel group), |
nothing calls this directly
no test coverage detected