{"record":{"id":"5d7ce96ece3b96ac","repo":"sgl-project/sglang","slug":"unsupported-time-compression-ratio-temporal-comp","errorCode":null,"errorMessage":"Unsupported time_compression_ratio: {temporal_compression_ratio}","messagePattern":"Unsupported time_compression_ratio: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/models/vaes/hunyuanvae.py","lineNumber":656,"sourceCode":"                raise ValueError(f\"Unsupported down_block_type: {down_block_type}\")\n\n            input_channel = output_channel\n            output_channel = block_out_channels[i]\n            is_final_block = i == len(block_out_channels) - 1\n            num_spatial_downsample_layers = int(np.log2(spatial_compression_ratio))\n            num_time_downsample_layers = int(np.log2(temporal_compression_ratio))\n\n            if temporal_compression_ratio == 4:\n                add_spatial_downsample = bool(i < num_spatial_downsample_layers)\n                add_time_downsample = bool(\n                    i >= (len(block_out_channels) - 1 - num_time_downsample_layers)\n                    and not is_final_block\n                )\n            elif temporal_compression_ratio == 8:\n                add_spatial_downsample = bool(i < num_spatial_downsample_layers)\n                add_time_downsample = bool(i < num_time_downsample_layers)\n            else:\n                raise ValueError(\n                    f\"Unsupported time_compression_ratio: {temporal_compression_ratio}\"\n                )\n\n            downsample_stride_HW = (2, 2) if add_spatial_downsample else (1, 1)\n            downsample_stride_T = (2,) if add_time_downsample else (1,)\n            downsample_stride = tuple(downsample_stride_T + downsample_stride_HW)\n\n            down_block = HunyuanVideoDownBlock3D(\n                num_layers=layers_per_block,\n                in_channels=input_channel,\n                out_channels=output_channel,\n                add_downsample=bool(add_spatial_downsample or add_time_downsample),\n                resnet_eps=1e-6,\n                resnet_act_fn=act_fn,\n                resnet_groups=norm_num_groups,\n                downsample_stride=downsample_stride,\n                downsample_padding=0,\n            )","sourceCodeStart":638,"sourceCodeEnd":674,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/models/vaes/hunyuanvae.py#L638-L674","documentation":"The HunyuanVideoVAE encoder supports only temporal_compression_ratio values of 4 (implicit in the earlier branch) and 8 when deciding which down blocks add time downsampling. Any other ratio raises this ValueError during __init__.","triggerScenarios":"Loading/constructing the VAE with temporal_compression_ratio set to anything other than 4 or 8 — e.g. 2, 16, or a float like 4.0 that fails the ==8 comparison path — in the config.","commonSituations":"Custom VAE checkpoints with different temporal stride (e.g. image-only or aggressively compressed variants); hand-edited configs; mismatch between a checkpoint's actual temporal stride and the config value copied from another model.","solutions":["Set temporal_compression_ratio to 4 or 8 in the VAE config to match the checkpoint","Check the checkpoint's true temporal stride (compare latent length vs video frame count) and use that value, which must be 4 or 8","If you need another ratio, extend the branch chain in HunyuanVideoVAE.__init__ with the new add_time_downsample rule"],"exampleFix":"// before\n\"temporal_compression_ratio\": 2\n\n// after\n\"temporal_compression_ratio\": 4","handlingStrategy":"validation","validationCode":"assert cfg[\"temporal_compression_ratio\"] in (4, 8), 'temporal_compression_ratio must be 4 or 8'","typeGuard":"def is_supported_temporal_ratio(r) -> bool:\n    return r in (4, 8)","tryCatchPattern":null,"preventionTips":["Verify the checkpoint's real temporal stride before writing the config","Keep temporal and time compression ratios consistent across encoder/decoder configs","Only load checkpoints validated for this VAE implementation"],"tags":["python","value-error","model-config","hunyuan-vae","compression-ratio"],"backgroundTag":"unsupported-config-option","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}