{"record":{"id":"5053f6f6ecb669d0","repo":"tensorflow/models","slug":"keras-model-fit-on-tpus-is-not-implemented","errorCode":null,"errorMessage":"Keras model.fit on TPUs is not implemented.","messagePattern":"Keras model\\.fit on TPUs is not implemented\\.","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"official/legacy/transformer/transformer_main.py","lineNumber":335,"sourceCode":"\n          if params[\"enable_tensorboard\"]:\n            for metric_obj in train_metrics:\n              tf.summary.scalar(metric_obj.name, metric_obj.result(),\n                                current_step)\n              summary_writer.flush()\n\n        for cb in callbacks:\n          cb.on_train_end()\n\n        if flags_obj.enable_checkpointing:\n          # avoid check-pointing when running for benchmarking.\n          checkpoint_name = checkpoint.save(\n              os.path.join(flags_obj.model_dir,\n                           \"ctl_step_{}.ckpt\".format(current_step)))\n          logging.info(\"Saved checkpoint to %s\", checkpoint_name)\n      else:\n        if self.use_tpu:\n          raise NotImplementedError(\n              \"Keras model.fit on TPUs is not implemented.\")\n        history = model.fit(\n            train_ds,\n            initial_epoch=current_iteration,\n            epochs=current_iteration + 1,\n            steps_per_epoch=train_steps_per_eval,\n            callbacks=callbacks,\n            # If TimeHistory is enabled, progress bar would be messy. Increase\n            # the verbose level to get rid of it.\n            verbose=(2 if flags_obj.enable_time_history else 1))\n        current_step += train_steps_per_eval\n        logging.info(\"Train history: {}\".format(history.history))\n\n      logging.info(\"End train iteration at global step:{}\".format(current_step))\n\n      if (flags_obj.bleu_source and flags_obj.bleu_ref):\n        uncased_score, cased_score = self.eval()\n        cased_score_history.append([current_iteration + 1, cased_score])","sourceCodeStart":317,"sourceCodeEnd":353,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/legacy/transformer/transformer_main.py#L317-L353","documentation":"Error \"Keras model.fit on TPUs is not implemented.\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/legacy/transformer/transformer_main.py:335 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"}