2noise/ChatTTS · error · ValueError

min_p must be in [0, 1], got {self.min_p}.

Error message

min_p must be in [0, 1], got {self.min_p}.

What it means

SamplingParams._verify_args enforces min_p in the inclusive range [0, 1]. min_p filters tokens whose probability is below min_p times the probability of the most likely token, so it is a ratio and must lie in [0, 1].

Source

Thrown at ChatTTS/model/velocity/sampling_params.py:212

                "frequency_penalty must be in [-2, 2], got "
                f"{self.frequency_penalty}."
            )
        if not 0.0 < self.repetition_penalty <= 2.0:
            raise ValueError(
                "repetition_penalty must be in (0, 2], got "
                f"{self.repetition_penalty}."
            )
        # if self.temperature < 0.0:
        #     raise ValueError(
        #         f"temperature must be non-negative, got {self.temperature}.")
        if not 0.0 < self.top_p <= 1.0:
            raise ValueError(f"top_p must be in (0, 1], got {self.top_p}.")
        if self.top_k < -1 or self.top_k == 0:
            raise ValueError(
                f"top_k must be -1 (disable), or at least 1, " f"got {self.top_k}."
            )
        if not 0.0 <= self.min_p <= 1.0:
            raise ValueError("min_p must be in [0, 1], got " f"{self.min_p}.")
        if self.max_tokens < 1:
            raise ValueError(f"max_tokens must be at least 1, got {self.max_tokens}.")
        if self.logprobs is not None and self.logprobs < 0:
            raise ValueError(f"logprobs must be non-negative, got {self.logprobs}.")
        if self.prompt_logprobs is not None and self.prompt_logprobs < 0:
            raise ValueError(
                f"prompt_logprobs must be non-negative, got " f"{self.prompt_logprobs}."
            )

    def _verify_beam_search(self) -> None:
        if self.best_of == 1:
            raise ValueError(
                "best_of must be greater than 1 when using beam "
                f"search. Got {self.best_of}."
            )
        if self.temperature > _SAMPLING_EPS:
            raise ValueError("temperature must be 0 when using beam search.")
        if self.top_p < 1.0 - _SAMPLING_EPS:

View on GitHub (pinned to 77b89ee281)

Solutions

  1. Keep min_p in [0, 1]; 0 disables min_p filtering
  2. Clamp or validate the value before constructing SamplingParams

Example fix

# before
params = SamplingParams(min_p=1.2)

# after
params = SamplingParams(min_p=0.05)
Defensive patterns

Strategy: validation

Validate before calling

def clamp_min_p(v: float) -> float:
    return min(max(float(v), 0.0), 1.0)

Type guard

def is_valid_min_p(v) -> bool:
    return isinstance(v, (int, float)) and 0.0 <= v <= 1.0

Prevention

When it happens

Trigger: Constructing SamplingParams with min_p < 0 or min_p > 1.0 (e.g. 1.2 or -0.1 from user input).

Common situations: Confusing min_p with an absolute probability threshold; unvalidated request payloads; porting a min_p value tuned against another implementation.

Related errors


AI-assisted analysis of 2noise/ChatTTS@77b89ee281 (2026-08-26). Data as JSON: /api/errors/3f61585150c46a1f. Report an issue: GitHub.