{"record":{"id":"56e1c2cfeaaba5e6","repo":"sgl-project/sglang","slug":"unsupported-avae-normalization-type-self-normaliz","errorCode":null,"errorMessage":"Unsupported AVAE normalization_type={self.normalization_type!r}.","messagePattern":"Unsupported AVAE normalization_type=(.+?)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/models/vaes/cosmos3_avae.py","lineNumber":212,"sourceCode":"        return self.hop_size\n\n    def get_latent_num_samples(self, num_audio_samples: int) -> int:\n        return int(num_audio_samples) // self.hop_size\n\n    def get_audio_num_samples(self, num_latent_samples: int) -> int:\n        return int(num_latent_samples) * self.hop_size\n\n    def _denormalize_latent(self, latent: torch.Tensor) -> torch.Tensor:\n        if self.normalization_type == \"tanh\":\n            in_dtype = latent.dtype\n            x = torch.clamp(\n                latent.float() / self.tanh_output_scale,\n                -self.tanh_clamp,\n                self.tanh_clamp,\n            )\n            return (torch.atanh(x) * self.tanh_input_scale).to(in_dtype)\n        if self.normalization_type != \"none\":\n            raise ValueError(\n                f\"Unsupported AVAE normalization_type={self.normalization_type!r}.\"\n            )\n        return latent\n\n    @torch.no_grad()\n    def decode(self, latent: torch.Tensor) -> torch.Tensor:\n        squeeze = latent.ndim == 2\n        if squeeze:\n            latent = latent.unsqueeze(0)\n        decoder_dtype = next(self.decoder.parameters()).dtype\n        decoder_device = next(self.decoder.parameters()).device\n        z = self._denormalize_latent(latent.to(decoder_device)).to(decoder_dtype)\n        audio = self.decoder(z).clamp(-1.0, 1.0).to(latent.dtype)\n        return audio.squeeze(0) if squeeze else audio\n\n\nEntryClass = Cosmos3AVAEAudioTokenizer\n","sourceCodeStart":194,"sourceCodeEnd":230,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/models/vaes/cosmos3_avae.py#L194-L230","documentation":"_denormalize_latent supports 'none', tanh-based, and group-norm style normalization; anything else in normalization_type leaves latents un-denormalized, which would silently corrupt decode output, so an unrecognized value raises at decode time.","triggerScenarios":"Decoding with a Cosmos3 AVAE whose config sets normalization_type to an unsupported string (typo like 'groupnorm ' or 'layer_norm') or a new scheme this version doesn't implement.","commonSituations":"Config typos or casing differences; porting a config from a newer Cosmos3 version that added a new normalization type; checkpoint config using an alias not handled by this code version.","solutions":["Set normalization_type to a supported value ('none' or the tanh/group variants accepted by this class)","Check the exact supported set in this file's normalization parsing (just above, near line 195-210) and align spelling","Upgrade the library if the checkpoint needs a newer normalization type"],"exampleFix":"# before\nconfig = {\"normalization_type\": \"LayerNorm\"}\n# after\nconfig = {\"normalization_type\": \"none\"}","handlingStrategy":"validation","validationCode":"SUPPORTED_NORMS = {\"none\"}  # plus tanh/group variants per this class\nif config.get(\"normalization_type\", \"none\") not in SUPPORTED_NORMS:\n    config[\"normalization_type\"] = \"none\"  # or fail loudly at load time","typeGuard":"def is_supported_norm(t: str) -> bool:\n    return t in {\"none\"}  # extend with the class's supported set","tryCatchPattern":"try:\n    frames = avae.decode(latent)\nexcept ValueError as e:\n    if \"normalization_type\" in str(e):\n        raise RuntimeError(\"bad AVAE config; fix normalization_type\") from e\n    raise","preventionTips":["Validate normalization_type at config load, not at decode time","Normalize casing/whitespace on config strings before constructing the AVAE"],"tags":["avae","normalization","decode","config"],"backgroundTag":"unsupported-config-value","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}