sgl-project/sglang · error · ValueError

unknown qk_norm: {qk_norm}. Should be one of None, 'layer_no

Error message

unknown qk_norm: {qk_norm}. Should be one of None, 'layer_norm', 'fp32_layer_norm', 'layer_norm_across_heads', 'rms_norm', 'rms_norm_across_heads', 'l2'.

What it means

Raised in the GLM image DiT attention block's __init__ when the qk_norm argument is not one of the supported normalization schemes (None, 'layer_norm', 'fp32_layer_norm', 'layer_norm_across_heads', 'rms_norm', 'rms_norm_across_heads', 'l2'). The constructor dispatches on this string to build norm_q/norm_k modules, so any unrecognized spelling falls through to this ValueError. It is purely a configuration-string validation error at model construction time.

Source

Thrown at python/sglang/multimodal_gen/runtime/models/dits/glm_image.py:590

                    input_is_parallel=True,
                    quant_config=quant_config,
                    prefix=f"{prefix}.to_out.0" if prefix else "to_out.0",
                )
            ]
        )

        if qk_norm is None:
            self.norm_q = None
            self.norm_k = None
        elif qk_norm == "layer_norm":
            self.norm_q = nn.LayerNorm(
                dim_head, eps=eps, elementwise_affine=elementwise_affine
            )
            self.norm_k = nn.LayerNorm(
                dim_head, eps=eps, elementwise_affine=elementwise_affine
            )
        else:
            raise ValueError(
                f"unknown qk_norm: {qk_norm}. Should be one of None, 'layer_norm', 'fp32_layer_norm', 'layer_norm_across_heads', 'rms_norm', 'rms_norm_across_heads', 'l2'."
            )

        self.attn = USPAttention(
            num_heads=self.num_local_heads,
            head_size=dim_head,
            num_kv_heads=self.num_local_kv_heads,
            dropout_rate=0,
            softmax_scale=None,
            causal=False,
        )

    def forward(
        self,
        hidden_states: torch.Tensor,
        encoder_hidden_states: torch.Tensor,
        attention_mask: Optional[torch.Tensor] = None,
        image_rotary_emb: Optional[Tuple[torch.Tensor, torch.Tensor]] = None,

View on GitHub (pinned to 0132848349)

Solutions

  1. Set qk_norm to one of the exact allowed values: None, 'layer_norm', 'fp32_layer_norm', 'layer_norm_across_heads', 'rms_norm', 'rms_norm_across_heads', 'l2'
  2. Check the model's official config file for the correct qk_norm value and use it verbatim
  3. If loading from a custom config, add a normalization/mapping step that translates your naming to the supported names before constructing the model

Example fix

# before
model = GLMImageModel(config={"qk_norm": "rmsnorm"})

# after
model = GLMImageModel(config={"qk_norm": "rms_norm"})
Defensive patterns

Strategy: validation

Validate before calling

ALLOWED_QK_NORM = {None, 'layer_norm', 'fp32_layer_norm', 'layer_norm_across_heads', 'rms_norm', 'rms_norm_across_heads', 'l2'}
assert config.get('qk_norm') in ALLOWED_QK_NORM, f"qk_norm must be one of {ALLOWED_QK_NORM}, got {config.get('qk_norm')!r}"

Type guard

def is_valid_qk_norm(v) -> bool:
    return v in {None, 'layer_norm', 'fp32_layer_norm', 'layer_norm_across_heads', 'rms_norm', 'rms_norm_across_heads', 'l2'}

Prevention

When it happens

Trigger: Constructing the GLM image model (or its attention module) with a qk_norm string outside the allowed set — e.g. 'rmsnorm', 'layernorm', 'LayerNorm', 'none' (string instead of None), or a value read from a JSON config with a typo.

Common situations: Hand-editing a model config JSON and mistyping the qk_norm field; porting a config from another DiT repo that uses different norm names; passing the string 'none' instead of the Python None.

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


AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28). Data as JSON: /api/errors/e9776462d5288867. Report an issue: GitHub.