{"record":{"id":"c167ba660193ed75","repo":"sgl-project/sglang","slug":"unknown-norm-type-norm-type","errorCode":null,"errorMessage":"unknown norm_type {norm_type}","messagePattern":"unknown norm_type (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/models/dits/glm_image.py","lineNumber":886,"sourceCode":"        embedding_dim: int,\n        conditioning_embedding_dim: int,\n        elementwise_affine: bool = True,\n        eps: float = 1e-5,\n        bias: bool = True,\n        norm_type: str = \"layer_norm\",\n    ):\n        super().__init__()\n        self.linear = nn.Linear(\n            conditioning_embedding_dim, embedding_dim * 2, bias=bias\n        )\n        if norm_type == \"layer_norm\":\n            self.norm = nn.LayerNorm(embedding_dim, eps, elementwise_affine, bias)\n            # For now, don’t replace this with sglang’s LayerNorm\n            # because the model doesn’t have this parameter and it will break model loading\n        elif norm_type == \"rms_norm\":\n            self.norm = nn.RMSNorm(embedding_dim, eps, elementwise_affine)\n        else:\n            raise ValueError(f\"unknown norm_type {norm_type}\")\n\n    def forward(\n        self, x: torch.Tensor, conditioning_embedding: torch.Tensor\n    ) -> torch.Tensor:\n        # *** NO SiLU here ***\n        emb = self.linear(conditioning_embedding.to(x.dtype))\n        scale, shift = torch.chunk(emb, 2, dim=1)\n        if is_plain_layer_norm(self.norm, x.shape[-1]):\n            return _glm_ln_modulate(self.norm, x, scale, shift, x.dtype)\n        x = self.norm(x) * (1 + scale)[:, None, :] + shift[:, None, :]\n        return x\n\n\nclass GlmImageTransformer2DModel(CachableDiT, LayerwiseOffloadableModuleMixin):\n    r\"\"\"\n    Args:\n        patch_size (`int`, defaults to `2`):\n            The size of the patches to use in the patch embedding layer.","sourceCodeStart":868,"sourceCodeEnd":904,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/models/dits/glm_image.py#L868-L904","documentation":"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.","triggerScenarios":"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'.","commonSituations":"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.","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"],"exampleFix":"# before\n{\"norm_type\": \"none\"}\n\n# after\n{\"norm_type\": \"layer_norm\"}","handlingStrategy":"validation","validationCode":"assert cfg['norm_type'] in ('layer_norm', 'rms_norm'), f\"norm_type must be layer_norm|rms_norm, got {cfg['norm_type']!r}\"","typeGuard":"def is_valid_norm_type(v: str) -> bool:\n    return v in ('layer_norm', 'rms_norm')","tryCatchPattern":null,"preventionTips":["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"],"tags":["config","validation","diffusion","norm"],"backgroundTag":"invalid-config-value","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}