sgl-project/sglang · error · ValueError

rollout_noise_level must be finite, got {noise!r}

Error message

rollout_noise_level must be finite, got {noise!r}

What it means

Validates that rollout_noise_level is a finite number: math.isfinite(float(noise)) must hold. NaN and +/-inf pass the isinstance(int, float) check but are rejected here because non-finite noise levels make SDE rollouts mathematically meaningless.

Source

Thrown at python/sglang/multimodal_gen/configs/post_training/rl_rollout.py:32

_VALID_ROLLOUT_SDE_TYPES = ("sde", "cps", "ode")


@dataclass
class RLRolloutArgs:
    """Rollout (log-prob trajectory) options used by SamplingParams and APIs."""

    rollout: bool = False
    rollout_sde_type: str = "sde"
    rollout_noise_level: float = 0.7
    rollout_log_prob_no_const: bool = False
    rollout_debug_mode: bool = False

    def validate(self) -> None:
        noise = self.rollout_noise_level
        if isinstance(noise, bool) or not isinstance(noise, (int, float)):
            raise ValueError(f"rollout_noise_level must be a number, got {noise!r}")
        if not math.isfinite(float(noise)):
            raise ValueError(f"rollout_noise_level must be finite, got {noise!r}")
        if float(noise) < 0.0:
            raise ValueError(f"rollout_noise_level must be non-negative, got {noise!r}")

        if self.rollout_sde_type not in _VALID_ROLLOUT_SDE_TYPES:
            raise ValueError(
                f"rollout_sde_type must be one of {_VALID_ROLLOUT_SDE_TYPES}, "
                f"got {self.rollout_sde_type!r}"
            )

    @classmethod
    def validate_sampling_params(cls, params: Any) -> None:
        """Validate rollout fields on a duck-typed object (e.g. ``SamplingParams``).

        Mirrors how ``ServerArgs`` runs ``NunchakuSVDQuantArgs.validate()`` from
        ``_adjust_quant_config`` instead of inlining checks in a large validator.
        """
        cls(
            rollout=params.rollout,

View on GitHub (pinned to 0132848349)

Solutions

  1. Fix the upstream computation so the noise level is finite; check for 0-denominator divisions or unset variables
  2. Clamp the value explicitly: min(max(noise, 0.0), some_max) and verify math.isfinite first
  3. Hard-set a sane finite value (e.g. 0.0 or 1.0) to confirm the rest of the config passes

Example fix

# before
noise = ratio / denominator  # denominator == 0 -> inf
params.rollout_noise_level = noise

# after
noise = ratio / denominator if denominator else 1.0
params.rollout_noise_level = float(min(max(noise, 0.0), 10.0))
Defensive patterns

Strategy: validation

Validate before calling

import math
assert math.isfinite(float(params.rollout_noise_level)), "rollout_noise_level must be finite"

Type guard

def is_finite_noise(v) -> bool:
    return isinstance(v, (int, float)) and not isinstance(v, bool) and math.isfinite(v)

Prevention

When it happens

Trigger: Setting rollout_noise_level to float('nan'), float('inf'), or a computed value that evaluated to NaN/inf (e.g. division by zero, 0/0 during hyperparameter derivation) before validate_sampling_params runs.

Common situations: Computing the noise level from a schedule or ratio that underflows/overflows; logging placeholders (nan) left in configs; math ops on uninitialized floats producing NaN.

Related errors


AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28). Data as JSON: /api/errors/acac9d1afd867baa. Report an issue: GitHub.