{"record":{"id":"33f5f90908cf2f43","repo":"tensorflow/models","slug":"evaluation-batch-size-must-be-divisible-by-time","errorCode":null,"errorMessage":"Evaluation batch size must be divisible by {} times {}","messagePattern":"Evaluation batch size must be divisible by (.+?) times (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/recommendation/ncf_input_pipeline.py","lineNumber":146,"sourceCode":"    strategy: Distribution strategy used for distributed training. If specified,\n      used to assert that evaluation batch size is correctly a multiple of total\n      number of devices used.\n\n  Returns:\n    (training dataset, evaluation dataset, train steps per epoch,\n    eval steps per epoch)\n\n  Raises:\n    ValueError: If data is being generated online for when using TPU's.\n  \"\"\"\n  # NCF evaluation metric calculation logic assumes that evaluation data\n  # sample size are in multiples of (1 + number of negative samples in\n  # evaluation) for each device. As so, evaluation batch size must be a\n  # multiple of (number of replicas * (1 + number of negative samples)).\n  num_devices = strategy.num_replicas_in_sync if strategy else 1\n  if (params[\"eval_batch_size\"] % (num_devices *\n                                   (1 + rconst.NUM_EVAL_NEGATIVES))):\n    raise ValueError(\"Evaluation batch size must be divisible by {} \"\n                     \"times {}\".format(num_devices,\n                                       (1 + rconst.NUM_EVAL_NEGATIVES)))\n\n  if params[\"train_dataset_path\"]:\n    assert params[\"eval_dataset_path\"]\n\n    train_dataset = create_dataset_from_tf_record_files(\n        params[\"train_dataset_path\"],\n        input_meta_data[\"train_prebatch_size\"],  # pyrefly: ignore[unsupported-operation]\n        params[\"batch_size\"],\n        is_training=True,\n        rebatch=False)\n\n    # Re-batch evaluation dataset for TPU Pods.\n    # TODO (b/162341937) remove once it's fixed.\n    eval_rebatch = (params[\"use_tpu\"] and strategy.num_replicas_in_sync > 8)  # pyrefly: ignore[missing-attribute]\n    eval_dataset = create_dataset_from_tf_record_files(\n        params[\"eval_dataset_path\"],","sourceCodeStart":128,"sourceCodeEnd":164,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/recommendation/ncf_input_pipeline.py#L128-L164","documentation":"Error \"Evaluation batch size must be divisible by {} times {}\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/recommendation/ncf_input_pipeline.py:146 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"}