sgl-project/sglang · error · ValueError
Unknown action normalization method {method!r}.
Error message
Unknown action normalization method {method!r}. What it means
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.
Source
Thrown at python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/cosmos3_action.py:198
}
def normalize_action(
action: torch.Tensor, method: str, stats: dict[str, torch.Tensor]
) -> torch.Tensor:
if method == "quantile":
q01, q99 = stats["q01"].to(action), stats["q99"].to(action)
return (2.0 * (action - q01) / (q99 - q01).clamp(min=1e-8) - 1.0).clamp(
-1.0, 1.0
)
if method == "meanstd":
return (action - stats["mean"].to(action)) / stats["std"].to(action).clamp(
min=1e-8
)
if method == "minmax":
lo, hi = stats["min"].to(action), stats["max"].to(action)
return (2.0 * (action - lo) / (hi - lo).clamp(min=1e-8) - 1.0).clamp(-1.0, 1.0)
raise ValueError(f"Unknown action normalization method {method!r}.")
def denormalize_action(
action: torch.Tensor, method: str, stats: dict[str, torch.Tensor]
) -> torch.Tensor:
if method == "quantile":
q01, q99 = stats["q01"].to(action), stats["q99"].to(action)
return (action + 1.0) / 2.0 * (q99 - q01) + q01
if method == "meanstd":
return action * stats["std"].to(action) + stats["mean"].to(action)
if method == "minmax":
lo, hi = stats["min"].to(action), stats["max"].to(action)
return (action + 1.0) / 2.0 * (hi - lo) + lo
raise ValueError(f"Unknown action normalization method {method!r}.")
View on GitHub (pinned to 0132848349)
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
Example fix
# before method = "zscore" # after method = "meanstd"
Defensive patterns
Strategy: type-guard
Validate before calling
method = method.lower().strip()
assert method in {"meanstd", "minmax", "quantile"}, f"unknown normalization method {method!r}" # verify against normalize_action's implemented branches Type guard
def is_supported_normalization(method: str) -> bool:
return method.lower().strip() in {"meanstd", "minmax", "quantile"} Prevention
- 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
When it happens
Trigger: 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).
Common situations: 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.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- Cosmos3 action endpoint supports action_mode='policy' or 'in
- condition_video_keep must be 'first' or 'last', got {keep!r}
- rollout_sde_type must be one of {_VALID_ROLLOUT_SDE_TYPES},
- Cosmos3 action input accepts one image field; use a list or
- Cosmos3 observation image arrays must use uint8 dtype
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/89a31a9dce1559ee.
Report an issue: GitHub.