{"record":{"id":"5fd167d7551452c8","repo":"sgl-project/sglang","slug":"cosmos3-avae-dec-strides-product-must-equal-hop-si","errorCode":null,"errorMessage":"Cosmos3 AVAE dec_strides product must equal hop_size: product={stride_product}, hop_size={self.hop_size}.","messagePattern":"Cosmos3 AVAE dec_strides product must equal hop_size: product=(.+?), hop_size=(.+?)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/models/vaes/cosmos3_avae.py","lineNumber":169,"sourceCode":"                default=2 if bool(config.get(\"stereo\", True)) else 1,\n            )\n        )\n        self.latent_channels = int(\n            _cfg(config, \"vocoder_input_dim\", \"io_channels\", \"latent_ch\", default=64)\n        )\n        dec_strides = [\n            int(s) for s in _cfg(config, \"dec_strides\", default=[2, 4, 5, 6, 8])\n        ]\n        self.hop_size = int(\n            _cfg(\n                config,\n                \"hop_size\",\n                default=math.prod(dec_strides) if dec_strides else 1920,\n            )\n        )\n        stride_product = math.prod(dec_strides)\n        if stride_product != self.hop_size:\n            raise ValueError(\n                \"Cosmos3 AVAE dec_strides product must equal hop_size: \"\n                f\"product={stride_product}, hop_size={self.hop_size}.\"\n            )\n\n        norm = str(_cfg(config, \"normalization_type\", default=\"none\"))\n        if bool(_cfg(config, \"normalize_latents\", default=False)) and norm == \"none\":\n            norm = \"tanh\"\n        self.normalization_type = norm\n        self.tanh_input_scale = float(_cfg(config, \"tanh_input_scale\", default=1.5))\n        self.tanh_output_scale = float(_cfg(config, \"tanh_output_scale\", default=3.5))\n        self.tanh_clamp = float(_cfg(config, \"tanh_clamp\", default=0.995))\n\n        self.decoder = OobleckDecoder(\n            channels=int(_cfg(config, \"dec_dim\", default=320)),\n            input_channels=self.latent_channels,\n            audio_channels=self.audio_channels,\n            upsampling_ratios=list(reversed(dec_strides)),\n            channel_multiples=list(","sourceCodeStart":151,"sourceCodeEnd":187,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/models/vaes/cosmos3_avae.py#L151-L187","documentation":"The Cosmos3 audio VAE decodes latents back to audio frames, so the product of its decoder strides must exactly equal hop_size (frames per latent step, default prod(dec_strides)). If the config explicitly overrides hop_size inconsistently with dec_strides, decode would produce the wrong number of frames, so __init__ fails fast.","triggerScenarios":"Loading a Cosmos3 AVAE config where hop_size (default 1920 when dec_strides is empty) disagrees with math.prod(dec_strides), e.g. setting hop_size=960 while dec_strides multiply to 1920, or providing dec_strides whose product differs from an inherited default hop_size.","commonSituations":"Editing a config to halve hop_size for shorter latents without adjusting strides; merging configs from different Cosmos3 checkpoints; checkpoint whose dec_strides list is parsed as empty (falling back to 1920) due to a schema/name change.","solutions":["Remove the explicit hop_size override so it defaults to prod(dec_strides)","Or fix hop_size to equal math.prod(dec_strides) exactly","Verify the dec_strides list parsed correctly (non-empty, expected values) from the config file"],"exampleFix":"# before\nconfig = {\"dec_strides\": [4, 4, 120], \"hop_size\": 960}\n# after\nconfig = {\"dec_strides\": [4, 4, 120]}  # hop_size defaults to 1920\n# or config = {\"dec_strides\": [4, 4, 60], \"hop_size\": 960}","handlingStrategy":"validation","validationCode":"import math\nstride_product = math.prod(dec_strides)\nif hop_size is None:\n    hop_size = stride_product\nassert math.prod(dec_strides) == hop_size, \"dec_strides must multiply to hop_size\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never override hop_size independently of dec_strides","Add a config linter that recomputes prod(dec_strides) and compares against hop_size"],"tags":["avae","config","cosmos3","init","value-error"],"backgroundTag":"config-consistency-check-failed","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}