{"record":{"id":"89a31a9dce1559ee","repo":"sgl-project/sglang","slug":"unknown-action-normalization-method-method-r","errorCode":null,"errorMessage":"Unknown action normalization method {method!r}.","messagePattern":"Unknown action normalization method (.+?)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/cosmos3_action.py","lineNumber":198,"sourceCode":"    }\n\n\ndef normalize_action(\n    action: torch.Tensor, method: str, stats: dict[str, torch.Tensor]\n) -> torch.Tensor:\n    if method == \"quantile\":\n        q01, q99 = stats[\"q01\"].to(action), stats[\"q99\"].to(action)\n        return (2.0 * (action - q01) / (q99 - q01).clamp(min=1e-8) - 1.0).clamp(\n            -1.0, 1.0\n        )\n    if method == \"meanstd\":\n        return (action - stats[\"mean\"].to(action)) / stats[\"std\"].to(action).clamp(\n            min=1e-8\n        )\n    if method == \"minmax\":\n        lo, hi = stats[\"min\"].to(action), stats[\"max\"].to(action)\n        return (2.0 * (action - lo) / (hi - lo).clamp(min=1e-8) - 1.0).clamp(-1.0, 1.0)\n    raise ValueError(f\"Unknown action normalization method {method!r}.\")\n\n\ndef denormalize_action(\n    action: torch.Tensor, method: str, stats: dict[str, torch.Tensor]\n) -> torch.Tensor:\n    if method == \"quantile\":\n        q01, q99 = stats[\"q01\"].to(action), stats[\"q99\"].to(action)\n        return (action + 1.0) / 2.0 * (q99 - q01) + q01\n    if method == \"meanstd\":\n        return action * stats[\"std\"].to(action) + stats[\"mean\"].to(action)\n    if method == \"minmax\":\n        lo, hi = stats[\"min\"].to(action), stats[\"max\"].to(action)\n        return (action + 1.0) / 2.0 * (hi - lo) + lo\n    raise ValueError(f\"Unknown action normalization method {method!r}.\")\n","sourceCodeStart":180,"sourceCodeEnd":213,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/cosmos3_action.py#L180-L213","documentation":"normalize_action/denormalize_action support a fixed set of normalization schemes (e.g. 'meanstd'/'minmax'/'quantile' as implemented). Any other method string raises ValueError, guarding against silently applying the wrong normalization to action inputs/outputs.","triggerScenarios":"Passing method='gaussian', 'zscore', '' or any unlisted string to normalize_action (called from _prepare_action_latents with the value from the request or pipeline config).","commonSituations":"Config uses a different spelling than the code ('z-score' vs 'meanstd'); new dataset using a normalization scheme not yet implemented; copy-paste from another repo's config format.","solutions":["Use one of the implemented method names — check the if-chains at the top of normalize_action/denormalize_action in cosmos3_action.py","Fix the config/request field that carries the normalization method to the canonical spelling","If a new scheme is genuinely needed, implement it in both normalize_action and denormalize_action and add it to validation docs"],"exampleFix":"# before\nmethod = \"zscore\"\n# after\nmethod = \"meanstd\"","handlingStrategy":"type-guard","validationCode":"method = method.lower().strip()\nassert method in {\"meanstd\", \"minmax\", \"quantile\"}, f\"unknown normalization method {method!r}\"  # verify against normalize_action's implemented branches","typeGuard":"def is_supported_normalization(method: str) -> bool:\n    return method.lower().strip() in {\"meanstd\", \"minmax\", \"quantile\"}","tryCatchPattern":null,"preventionTips":["Centralize normalization method names as constants instead of free-form config strings","Validate config enums at load time, not at request time","Keep normalize/denormalize method lists in sync when adding schemes"],"tags":["cosmos3","normalization","enum-validation","action-stats"],"backgroundTag":"invalid-enum-value","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}