{"record":{"id":"d72932e667d7661d","repo":"Comfy-Org/ComfyUI","slug":"causality-is-only-supported-when-with-conv-true","errorCode":null,"errorMessage":"causality is only supported when `with_conv=True`.","messagePattern":"causality is only supported when `with_conv=True`\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"comfy/ldm/lightricks/vae/causal_audio_autoencoder.py","lineNumber":266,"sourceCode":"                    raise ValueError(f\"Invalid causality_axis: {self.causality_axis}\")\n\n        return x\n\n\nclass Downsample(nn.Module):\n    \"\"\"\n    A downsampling layer that can use either a strided convolution\n    or average pooling. Supports standard and causal padding for the\n    convolutional mode.\n    \"\"\"\n\n    def __init__(self, in_channels, with_conv, causality_axis: CausalityAxis = CausalityAxis.WIDTH):\n        super().__init__()\n        self.with_conv = with_conv\n        self.causality_axis = causality_axis\n\n        if self.causality_axis != CausalityAxis.NONE and not self.with_conv:\n            raise ValueError(\"causality is only supported when `with_conv=True`.\")\n\n        if self.with_conv:\n            # Do time downsampling here\n            # no asymmetric padding in torch conv, must do it ourselves\n            self.conv = ops.Conv2d(in_channels, in_channels, kernel_size=3, stride=2, padding=0)\n\n    def forward(self, x):\n        if self.with_conv:\n            # (pad_left, pad_right, pad_top, pad_bottom)\n            match self.causality_axis:\n                case CausalityAxis.NONE:\n                    pad = (0, 1, 0, 1)\n                case CausalityAxis.WIDTH:\n                    pad = (2, 0, 0, 1)\n                case CausalityAxis.HEIGHT:\n                    pad = (0, 1, 2, 0)\n                case CausalityAxis.WIDTH_COMPATIBILITY:\n                    pad = (1, 0, 0, 1)","sourceCodeStart":248,"sourceCodeEnd":284,"githubUrl":"https://github.com/Comfy-Org/ComfyUI/blob/1c6d8d45b3693bfbb32385b410d813a7fd6be216/comfy/ldm/lightricks/vae/causal_audio_autoencoder.py#L248-L284","documentation":"Raised by Downsample.__init__ in the causal audio autoencoder when a causality_axis other than NONE is requested together with with_conv=False. Causal padding is implemented by manually padding before a strided conv; the avg-pool branch has no causal variant, so the combination is rejected.","triggerScenarios":"Instantiating Downsample(in_channels, with_conv=False, causality_axis=CausalityAxis.WIDTH) (or any non-NONE axis), including indirectly from an Encoder/Decoder config that pairs with_conv=False down blocks with a causal axis.","commonSituations":"Experimenting with lighter downsamplers (avg-pool) in a causal streaming audio VAE; config edits that flip with_conv without resetting causality_axis to NONE.","solutions":["Set with_conv=True so the causal strided-convolution path is used","Or set causality_axis=CausalityAxis.NONE if causal behavior is not needed for this block","Fix the Encoder/Decoder block config so with_conv=False blocks always carry a NONE axis"],"exampleFix":"# before\ndown = Downsample(ch, with_conv=False, causality_axis=CausalityAxis.WIDTH)\n\n# after\ndown = Downsample(ch, with_conv=False, causality_axis=CausalityAxis.NONE)","handlingStrategy":"validation","validationCode":"if not with_conv and causality_axis != CausalityAxis.NONE:\n    causality_axis = CausalityAxis.NONE  # or raise your own error early\ndown = Downsample(ch, with_conv=with_conv, causality_axis=causality_axis)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep with_conv=False blocks paired with CausalityAxis.NONE in configs","Validate block configs before building the audio VAE"],"tags":["downsample","causal","audio-vae","constructor"],"backgroundTag":null,"analyzedSha":"1c6d8d45b3693bfbb32385b410d813a7fd6be216","analyzedAt":"2026-08-14T19:37:18.893Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}