{"record":{"id":"e3671d61d8b5d42d","repo":"tensorflow/models","slug":"global-batch-size-is-not-a-multiple-of-num-repl","errorCode":null,"errorMessage":"global_batch_size {} is not a multiple of num_replicas {}","messagePattern":"global_batch_size (.+?) is not a multiple of num_replicas (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/projects/pointpillars/tasks/pointpillars.py","lineNumber":51,"sourceCode":"\n\ndef pick_dataset_fn(file_type: str) -> Any:\n  if file_type == 'tfrecord':\n    return tf.data.TFRecordDataset\n  if file_type == 'tfrecord_compressed':\n    return functools.partial(tf.data.TFRecordDataset, compression_type='GZIP')\n  raise ValueError('Unrecognized file_type: {}'.format(file_type))\n\n\ndef get_batch_size_per_replica(global_batch_size: int) -> int:\n  \"\"\"Get batch size per accelerator replica.\"\"\"\n  num_replicas = tf.distribute.get_strategy().num_replicas_in_sync\n  if global_batch_size < num_replicas:\n    logging.warning('Global batch size is smaller than num replicas. '\n                    'Set batch size per replica to 1.')\n    return 1\n  if global_batch_size % num_replicas != 0:\n    raise ValueError(\n        'global_batch_size {} is not a multiple of num_replicas {}'\n        .format(global_batch_size, num_replicas))\n  batch_size = int(global_batch_size / num_replicas)\n  return batch_size\n\n\n@task_factory.register_task_cls(cfg.PointPillarsTask)\nclass PointPillarsTask(base_task.Task):\n  \"\"\"A single-replica view of training procedure.\"\"\"\n\n  def __init__(self,\n               params: cfg.PointPillarsTask,\n               logging_dir: Optional[str] = None,\n               name: Optional[str] = None):\n    super().__init__(params, logging_dir, name)\n    self._model = None\n    self._attribute_heads = self.task_config.model.head.attribute_heads\n","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/projects/pointpillars/tasks/pointpillars.py#L33-L69","documentation":"Error \"global_batch_size {} is not a multiple of num_replicas {}\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/projects/pointpillars/tasks/pointpillars.py:51 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e006f5f0d534913e49c1f1dae87364039fa607e2","analyzedAt":"2026-08-24T14:09:15.576Z","schemaVersion":2},"datasetVersion":"2026-08-24T17:17:21.512Z"}