{"record":{"id":"acac9d1afd867baa","repo":"sgl-project/sglang","slug":"rollout-noise-level-must-be-finite-got-noise-r","errorCode":null,"errorMessage":"rollout_noise_level must be finite, got {noise!r}","messagePattern":"rollout_noise_level must be finite, got (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/configs/post_training/rl_rollout.py","lineNumber":32,"sourceCode":"_VALID_ROLLOUT_SDE_TYPES = (\"sde\", \"cps\", \"ode\")\n\n\n@dataclass\nclass RLRolloutArgs:\n    \"\"\"Rollout (log-prob trajectory) options used by SamplingParams and APIs.\"\"\"\n\n    rollout: bool = False\n    rollout_sde_type: str = \"sde\"\n    rollout_noise_level: float = 0.7\n    rollout_log_prob_no_const: bool = False\n    rollout_debug_mode: bool = False\n\n    def validate(self) -> None:\n        noise = self.rollout_noise_level\n        if isinstance(noise, bool) or not isinstance(noise, (int, float)):\n            raise ValueError(f\"rollout_noise_level must be a number, got {noise!r}\")\n        if not math.isfinite(float(noise)):\n            raise ValueError(f\"rollout_noise_level must be finite, got {noise!r}\")\n        if float(noise) < 0.0:\n            raise ValueError(f\"rollout_noise_level must be non-negative, got {noise!r}\")\n\n        if self.rollout_sde_type not in _VALID_ROLLOUT_SDE_TYPES:\n            raise ValueError(\n                f\"rollout_sde_type must be one of {_VALID_ROLLOUT_SDE_TYPES}, \"\n                f\"got {self.rollout_sde_type!r}\"\n            )\n\n    @classmethod\n    def validate_sampling_params(cls, params: Any) -> None:\n        \"\"\"Validate rollout fields on a duck-typed object (e.g. ``SamplingParams``).\n\n        Mirrors how ``ServerArgs`` runs ``NunchakuSVDQuantArgs.validate()`` from\n        ``_adjust_quant_config`` instead of inlining checks in a large validator.\n        \"\"\"\n        cls(\n            rollout=params.rollout,","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/configs/post_training/rl_rollout.py#L14-L50","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Fix the upstream computation so the noise level is finite; check for 0-denominator divisions or unset variables","Clamp the value explicitly: min(max(noise, 0.0), some_max) and verify math.isfinite first","Hard-set a sane finite value (e.g. 0.0 or 1.0) to confirm the rest of the config passes"],"exampleFix":"# before\nnoise = ratio / denominator  # denominator == 0 -> inf\nparams.rollout_noise_level = noise\n\n# after\nnoise = ratio / denominator if denominator else 1.0\nparams.rollout_noise_level = float(min(max(noise, 0.0), 10.0))","handlingStrategy":"validation","validationCode":"import math\nassert math.isfinite(float(params.rollout_noise_level)), \"rollout_noise_level must be finite\"","typeGuard":"def is_finite_noise(v) -> bool:\n    return isinstance(v, (int, float)) and not isinstance(v, bool) and math.isfinite(v)","tryCatchPattern":null,"preventionTips":["Guard divisions used to derive noise levels","Assert math.isfinite on any computed hyperparameter before assignment","Log derived noise values in sweeps to spot NaN/inf early"],"tags":["rl-rollout","sampling-params","nan-infinity","validation"],"backgroundTag":"non-finite-config-value","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}