tensorflow/models · error · ValueError

`use_tpu_summary_optimization=True` and `use_tf_while_loop=F

Error message

`use_tpu_summary_optimization=True` and `use_tf_while_loop=False` is not supported

What it means

Error "`use_tpu_summary_optimization=True` and `use_tf_while_loop=False` is not supported" thrown in tensorflow/models.

Source

Thrown at orbit/standard_runner.py:101

  `tf.function`, as determined by the `options` passed to `__init__`.
  """

  def __init__(self,
               train_dataset,
               options: Optional[StandardTrainerOptions] = None):
    """Initializes the `StandardTrainer` instance.

    Args:
      train_dataset: A `tf.nest`-compatible structure of `tf.data.Dataset` or
        `DistributedDataset`.
      options: An `orbit.StandardTrainerOptions` instance.
    """
    options = options or StandardTrainerOptions()
    if options.use_tf_while_loop and not options.use_tf_function:
      raise ValueError("`use_tf_while_loop=True` and `use_tf_function=False` "
                       "is not supported")
    if options.use_tpu_summary_optimization and not options.use_tf_while_loop:
      raise ValueError("`use_tpu_summary_optimization=True` and "
                       "`use_tf_while_loop=False` is not supported")

    self._train_options = options
    self._train_dataset = train_dataset
    self._train_iter = None
    self._train_loop_fn = None

  def create_train_loop_fn(self):
    """Creates a training loop from the current step function and options.

    Returns:
      The train loop function, i.e. wrapper of multiple train steps.
    """
    train_step_fn = self.train_step
    if self._train_options.use_tf_while_loop:
      loop_fn = loop_fns.create_tf_while_loop_fn(train_step_fn)
      if self._train_options.use_tpu_summary_optimization:
        loop_fn = loop_fns.LoopFnWithSummaries(loop_fn)

View on GitHub (pinned to e006f5f0d5)

Solutions

  1. Set use_tf_while_loop=True together with use_tpu_summary_optimization=True.
  2. Disable use_tpu_summary_optimization when not using a tf.while_loop.

When it happens

Trigger: Thrown at orbit/standard_runner.py:101 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of tensorflow/models@e006f5f0d5 (2026-08-24). Data as JSON: /api/errors/adf4c48ab3cb34ca. Report an issue: GitHub.