openai/whisper · error · ValueError

patience requires beam_size to be given

Error message

patience requires beam_size to be given

What it means

_verify_options() requires that patience (the beam-search patience factor that lets the search keep going when a better beam might still appear) only makes sense inside beam search. Specifying patience without beam_size is rejected because there is no beam to be patient with.

Source

Thrown at whisper/decoding.py:579

            max_initial_timestamp_index = None
            if options.max_initial_timestamp:
                max_initial_timestamp_index = round(
                    self.options.max_initial_timestamp / precision
                )
            self.logit_filters.append(
                ApplyTimestampRules(
                    tokenizer, self.sample_begin, max_initial_timestamp_index
                )
            )

    def _verify_options(self, options: DecodingOptions) -> DecodingOptions:
        if options.beam_size is not None and options.best_of is not None:
            raise ValueError("beam_size and best_of can't be given together")
        if options.temperature == 0:
            if options.best_of is not None:
                raise ValueError("best_of with greedy sampling (T=0) is not compatible")
        if options.patience is not None and options.beam_size is None:
            raise ValueError("patience requires beam_size to be given")
        if options.length_penalty is not None and not (
            0 <= options.length_penalty <= 1
        ):
            raise ValueError("length_penalty (alpha) should be a value between 0 and 1")

        return options

    def _get_initial_tokens(self) -> Tuple[int]:
        tokens = list(self.sot_sequence)

        if prefix := self.options.prefix:
            prefix_tokens = (
                self.tokenizer.encode(" " + prefix.strip())
                if isinstance(prefix, str)
                else prefix
            )
            if self.sample_len is not None:
                max_prefix_len = self.n_ctx // 2 - self.sample_len

View on GitHub (pinned to 5f86d1d863)

Solutions

  1. Set beam_size together with patience: DecodingOptions(beam_size=5, patience=1.5)
  2. Remove patience if you did not intend beam search

Example fix

# before
options = whisper.DecodingOptions(patience=2.0)  # ValueError

# after
options = whisper.DecodingOptions(beam_size=5, patience=2.0)
Defensive patterns

Strategy: validation

Validate before calling

def patience_ok(options) -> bool:
    return options.patience is None or options.beam_size is not None

Prevention

When it happens

Trigger: DecodingOptions(patience=1.5) with beam_size left at its default None; passing patience through a custom DecodingTask; enabling patience via a config dict that does not also set beam_size.

Common situations: Copying patience from the paper/repo examples (which always pair it with beam_size) into a partially-specified options object; config files shared across pipelines where beam_size is conditionally set.

Related errors


AI-assisted analysis of openai/whisper@5f86d1d863 (2026-08-14). Data as JSON: /api/errors/996b2743081543b6. Report an issue: GitHub.