{"record":{"id":"4f6e1c60c50e3ea8","repo":"tensorflow/models","slug":"global-step-not-found-in-checkpoint-if-you-wan","errorCode":null,"errorMessage":"global_step not found in checkpoint {}. If you want to run finetune eval jobs, you need to make sure that your pretrain model writes global_step in its checkpoints.","messagePattern":"global_step not found in checkpoint (.+?)\\. If you want to run finetune eval jobs, you need to make sure that your pretrain model writes global_step in its checkpoints\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/core/train_utils.py","lineNumber":445,"sourceCode":"      model_dir, 'operative_config.{}.gin'.format(filename_suffix))\n  logging.info('Saving gin configurations to %s', gin_save_path)\n  tf.io.gfile.makedirs(model_dir)\n  with tf.io.gfile.GFile(gin_save_path, 'w') as f:\n    f.write(gin.operative_config_str())\n\n\ndef read_global_step_from_checkpoint(ckpt_file_path):\n  \"\"\"Read global step from checkpoint, or get global step from its filename.\"\"\"\n  global_step = tf.Variable(-1, dtype=tf.int64)\n  ckpt = tf.train.Checkpoint(global_step=global_step)\n  try:\n    ckpt.restore(ckpt_file_path).expect_partial()\n    global_step_maybe_restored = global_step.numpy()\n  except tf.errors.InvalidArgumentError:\n    global_step_maybe_restored = -1\n\n  if global_step_maybe_restored == -1:\n    raise ValueError('global_step not found in checkpoint {}. '\n                     'If you want to run finetune eval jobs, you need to '\n                     'make sure that your pretrain model writes '\n                     'global_step in its checkpoints.'.format(ckpt_file_path))\n  global_step_restored = global_step.numpy()\n  logging.info('get global_step %d from checkpoint %s', global_step_restored,\n               ckpt_file_path)\n  return global_step_restored\n\n\ndef write_json_summary(log_dir, global_step, eval_metrics):\n  \"\"\"Dump evaluation metrics to json file.\"\"\"\n  serializable_dict = {}\n  for name, value in eval_metrics.items():\n    if hasattr(value, 'numpy'):\n      serializable_dict[name] = str(value.numpy())\n    else:\n      serializable_dict[name] = str(value)\n  output_json = os.path.join(log_dir, 'metrics-{}.json'.format(global_step))","sourceCodeStart":427,"sourceCodeEnd":463,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/core/train_utils.py#L427-L463","documentation":"Error \"global_step not found in checkpoint {}. If you want to run finetune eval jobs, you need to make sure that your pretrain model writes global_step in its checkpoints.\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/core/train_utils.py:445 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"}