{"record":{"id":"e23cfab1b9ae9fde","repo":"tensorflow/models","slug":"looping-until-exhausted-is-not-supported-if-optio","errorCode":null,"errorMessage":"Looping until exhausted is not supported if `options.use_tf_while_loop` is `True`","messagePattern":"Looping until exhausted is not supported if `options\\.use_tf_while_loop` is `True`","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"orbit/standard_runner.py","lineNumber":325,"sourceCode":"    return loop_fn\n\n  def evaluate(self, num_steps: tf.Tensor) -> Optional[runner.Output]:\n    \"\"\"Implements `num_steps` steps of evaluation.\n\n    Args:\n      num_steps: The number of evaluation steps to run. When this is -1,\n        evaluation proceeds until a call to `eval_step` raises a `StopIteration`\n        or `tf.errors.OutOfRangeError`.\n\n    Returns:\n      The output of `self.eval_end()`.\n\n    Raises:\n      ValueError: If `options.use_tf_while_loop` is `True` and `num_steps` is\n        unspecified.\n    \"\"\"\n    if self._eval_options.use_tf_while_loop and num_steps == -1:\n      raise ValueError(\"Looping until exhausted is not supported if \"\n                       \"`options.use_tf_while_loop` is `True`\")\n\n    outputs = self.eval_begin()  # pylint: disable=assignment-from-no-return\n\n    has_state = outputs is not None\n    if self._eval_loop_fn is None:\n      self._eval_loop_fn = self.create_eval_loop_fn(has_state)\n\n    # If `recreate_iterator_for_each_eval` is `True`, `self._eval_iter` is\n    # always None.\n    if self._eval_iter is None:\n      eval_iter = tf.nest.map_structure(iter, self.eval_dataset)\n      if not self._eval_options.recreate_iterator_for_each_eval:\n        self._eval_iter = eval_iter\n    else:\n      eval_iter = self._eval_iter\n\n    if self._eval_options.use_tf_while_loop and not has_state:","sourceCodeStart":307,"sourceCodeEnd":343,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/orbit/standard_runner.py#L307-L343","documentation":"Error \"Looping until exhausted is not supported if `options.use_tf_while_loop` is `True`\" thrown in tensorflow/models.","triggerScenarios":"Thrown at orbit/standard_runner.py:325 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass a finite steps count instead of -1 when use_tf_while_loop is True.","Disable use_tf_while_loop to loop until the dataset is exhausted."],"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"}