{"record":{"id":"a188f9b7ee572a38","repo":"sgl-project/sglang","slug":"rollout-noise-level-must-be-a-number-got-noise-r","errorCode":null,"errorMessage":"rollout_noise_level must be a number, got {noise!r}","messagePattern":"rollout_noise_level must be a number, got (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/configs/post_training/rl_rollout.py","lineNumber":30,"sourceCode":"from sglang.multimodal_gen.utils import StoreBoolean\n\n_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        \"\"\"","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/configs/post_training/rl_rollout.py#L12-L48","documentation":"The RL rollout sampling config validates rollout_noise_level (SDE noise strength) and rejects any value that is not an int or float. Booleans are explicitly rejected even though bool subclasses int in Python, because True/False as a noise level is almost always a mistake.","triggerScenarios":"Setting rollout_noise_level=true/false, a string like \"0.1\", None, or any non-numeric value in RL rollout sampling params; validate() is invoked via validate_sampling_params before rollout starts.","commonSituations":"Passing a CLI/YAML value that stays a string (e.g. rollout_noise_level: \"0.1\" from config parsing); using a boolean flag by mistake (copied from rollout_debug_mode); templating configs that substitute None when the value is omitted.","solutions":["Set rollout_noise_level to a plain number, e.g. 0.0 or 1.0","If loading from YAML/JSON/CLI, coerce before validation: float(value) with the string handled explicitly","If the field is optional in your flow, default it to 0.0 rather than leaving None"],"exampleFix":"# before\nparams.rollout_noise_level = \"0.1\"  # or True\n\n# after\nparams.rollout_noise_level = 0.1","handlingStrategy":"type-guard","validationCode":"from numbers import Real\nassert isinstance(params.rollout_noise_level, Real) and not isinstance(params.rollout_noise_level, bool), \"rollout_noise_level must be numeric\"","typeGuard":"def is_valid_noise_level(v) -> bool:\n    return isinstance(v, (int, float)) and not isinstance(v, bool)","tryCatchPattern":null,"preventionTips":["Coerce config-file strings with float() before assigning","Never reuse boolean flags for numeric fields","Run validate_sampling_params() early in setup, not right before rollout"],"tags":["rl-rollout","sampling-params","type-validation","config"],"backgroundTag":"config-type-validation-failed","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}