sgl-project/sglang · error · ValueError
unknown norm_type {norm_type}
Error message
unknown norm_type {norm_type} What it means
Raised by the conditioning embedding projection module in glm_image.py when norm_type is not 'layer_norm' or 'rms_norm'. The __init__ chooses between nn.LayerNorm and nn.RMSNorm based on this string; anything else is rejected. This guards against silently running without normalization, which would corrupt checkpoint loading and outputs.
Source
Thrown at python/sglang/multimodal_gen/runtime/models/dits/glm_image.py:886
embedding_dim: int,
conditioning_embedding_dim: int,
elementwise_affine: bool = True,
eps: float = 1e-5,
bias: bool = True,
norm_type: str = "layer_norm",
):
super().__init__()
self.linear = nn.Linear(
conditioning_embedding_dim, embedding_dim * 2, bias=bias
)
if norm_type == "layer_norm":
self.norm = nn.LayerNorm(embedding_dim, eps, elementwise_affine, bias)
# For now, don’t replace this with sglang’s LayerNorm
# because the model doesn’t have this parameter and it will break model loading
elif norm_type == "rms_norm":
self.norm = nn.RMSNorm(embedding_dim, eps, elementwise_affine)
else:
raise ValueError(f"unknown norm_type {norm_type}")
def forward(
self, x: torch.Tensor, conditioning_embedding: torch.Tensor
) -> torch.Tensor:
# *** NO SiLU here ***
emb = self.linear(conditioning_embedding.to(x.dtype))
scale, shift = torch.chunk(emb, 2, dim=1)
if is_plain_layer_norm(self.norm, x.shape[-1]):
return _glm_ln_modulate(self.norm, x, scale, shift, x.dtype)
x = self.norm(x) * (1 + scale)[:, None, :] + shift[:, None, :]
return x
class GlmImageTransformer2DModel(CachableDiT, LayerwiseOffloadableModuleMixin):
r"""
Args:
patch_size (`int`, defaults to `2`):
The size of the patches to use in the patch embedding layer.View on GitHub (pinned to 0132848349)
Solutions
- Set norm_type to exactly 'layer_norm' or 'rms_norm' in the model/conditioning config
- Verify against the checkpoint's original config which normalization the conditioning projection was trained with
- Add a config sanitizer that maps alternative spellings to the two accepted values before model construction
Example fix
# before
{"norm_type": "none"}
# after
{"norm_type": "layer_norm"} Defensive patterns
Strategy: validation
Validate before calling
assert cfg['norm_type'] in ('layer_norm', 'rms_norm'), f"norm_type must be layer_norm|rms_norm, got {cfg['norm_type']!r}" Type guard
def is_valid_norm_type(v: str) -> bool:
return v in ('layer_norm', 'rms_norm') Prevention
- Whitelist enum-like config values at load time
- Keep a mapping layer for configs imported from other frameworks
- Test model construction in CI with the shipped config
When it happens
Trigger: Instantiating the conditioning module (e.g. via the GLM image DiT) with norm_type set to a string other than 'layer_norm' or 'rms_norm', such as 'none', 'group_norm', or a casing variant like 'LayerNorm'.
Common situations: Mismatched config keys after converting a checkpoint from another framework (e.g. diffusers-style 'norm_type' values) into this model's expected schema; typos in hand-written configs.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
- unknown qk_norm: {qk_norm}. Should be one of None, 'layer_no
- Unknown history_scale_mode: {history_scale_mode}
- Hidden size {hidden_size} must be divisible by num_heads {nu
- Got {axes_dim} but expected positional dim {pe_dim}
- denoising_strength must be positive
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/c167ba660193ed75.
Report an issue: GitHub.