{"record":{"id":"107bba86f2d19ee6","repo":"hpcaitech/Open-Sora","slug":"unsupported-time-compression-ratio-time-compress","errorCode":null,"errorMessage":"Unsupported time_compression_ratio: {time_compression_ratio}.","messagePattern":"Unsupported time_compression_ratio: (.+?)\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"opensora/models/hunyuan_vae/vae.py","lineNumber":84,"sourceCode":"        # down\n        output_channel = block_out_channels[0]\n        for i, _ in enumerate(block_out_channels):\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(time_compression_ratio))\n\n            if time_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) and not is_final_block\n                )\n            elif time_compression_ratio == 8:\n                add_spatial_downsample = bool(i < num_spatial_downsample_layers)\n                add_time_downsample = bool(i < num_spatial_downsample_layers)\n            else:\n                raise ValueError(f\"Unsupported time_compression_ratio: {time_compression_ratio}.\")\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            down_block = DownEncoderBlockCausal3D(\n                num_layers=self.layers_per_block,\n                in_channels=input_channel,\n                out_channels=output_channel,\n                dropout=dropout,\n                add_downsample=bool(add_spatial_downsample or add_time_downsample),\n                downsample_stride=downsample_stride,\n                resnet_eps=1e-6,\n                resnet_act_fn=act_fn,\n                resnet_groups=norm_num_groups,\n            )\n\n            self.down_blocks.append(down_block)\n","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/hpcaitech/Open-Sora/blob/7ad6a96a135feb81f755c84fb391818718f6beb2/opensora/models/hunyuan_vae/vae.py#L66-L102","documentation":"The Encoder of the Hunyuan causal 3D VAE builds its downsampling schedule from time_compression_ratio and only supports specific values (the branches handle e.g. 4 and 8; the else covers everything else). Passing an unsupported ratio (e.g. 2, 6, 16) at AutoencoderKLCausal3D construction raises this ValueError immediately.","triggerScenarios":"Constructing the encoder with config time_compression_ratio not equal to one of the supported values (commonly 4 or 8), typically from a YAML/JSON model config or a checkpoint's config dict.","commonSituations":"Experimenting with temporal compression settings for video VAE; loading a config edited by hand; porting configs between opensora versions where supported ratios changed.","solutions":["Set time_compression_ratio to a supported value (4 or 8) in the encoder config","If loading from a checkpoint, check the checkpoint's config for the original ratio and keep it","Match the encoder ratio with the corresponding decoder config (vae.py:208 enforces the same set)"],"exampleFix":"# before\nencoder = Encoder(..., time_compression_ratio=6)\n# after\nencoder = Encoder(..., time_compression_ratio=4)","handlingStrategy":"validation","validationCode":"SUPPORTED_TCR = {4, 8}\nassert time_compression_ratio in SUPPORTED_TCR, f\"use one of {SUPPORTED_TCR}\"","typeGuard":"def is_supported_tcr(v) -> bool:\n    return v in {4, 8}","tryCatchPattern":"try:\n    enc = Encoder(..., time_compression_ratio=tcr)\nexcept ValueError:\n    tcr = 4\n    enc = Encoder(..., time_compression_ratio=tcr)","preventionTips":["Validate VAE configs against supported compression ratios before model build","Keep encoder and decoder ratios identical","Don't hand-edit compression ratios without reading vae.py"],"tags":["vae","config","video","temporal-compression"],"backgroundTag":"unsupported-config-value","analyzedSha":"7ad6a96a135feb81f755c84fb391818718f6beb2","analyzedAt":"2026-08-28T16:58:37.171Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}