{"record":{"id":"7907fc24285f27ba","repo":"Comfy-Org/ComfyUI","slug":"invalid-causality-axis-self-causality-axis","errorCode":null,"errorMessage":"Invalid causality_axis: {self.causality_axis}","messagePattern":"Invalid causality_axis: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"comfy/ldm/lightricks/vae/causal_audio_autoencoder.py","lineNumber":248,"sourceCode":"            # 2: [0,0,1]\n            # 3: [0,1,1]\n            # 4: [1,1,2]\n            # 5: [1,2,2]\n            # Notice that the first and second elements in the output rely only on the first element in the input,\n            # while all other elements rely on two elements in the input.\n            # So we can drop the first element to undo the padding (rather than the last element).\n            # This is a no-op for non-causal convolutions.\n            match self.causality_axis:\n                case CausalityAxis.NONE:\n                    pass  # x remains unchanged\n                case CausalityAxis.HEIGHT:\n                    x = x[:, :, 1:, :]\n                case CausalityAxis.WIDTH:\n                    x = x[:, :, :, 1:]\n                case CausalityAxis.WIDTH_COMPATIBILITY:\n                    pass  # x remains unchanged\n                case _:\n                    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`.\")","sourceCodeStart":230,"sourceCodeEnd":266,"githubUrl":"https://github.com/Comfy-Org/ComfyUI/blob/1c6d8d45b3693bfbb32385b410d813a7fd6be216/comfy/ldm/lightricks/vae/causal_audio_autoencoder.py#L230-L266","documentation":"Raised in CausalConv2d.forward's padding-trim match when self.causality_axis does not match any known CausalityAxis case. It mirrors the init-time guard (error 184) and fires at inference time if the axis was set to an unexpected value after construction.","triggerScenarios":"Assigning an invalid value to conv.causality_axis after construction, or constructing the module through a path that skips __init__ validation (e.g. custom unpickling or meta-device instantiation followed by manual field assignment).","commonSituations":"Checkpoint loading code that restores attributes from a state dict/config with foreign enum values; test code mutating module attributes directly; duplicated enum classes across module copies.","solutions":["Re-set the attribute to a valid member: conv.causality_axis = CausalityAxis.WIDTH","Fix the loading code so enum-typed attributes are converted through the enum, not assigned raw","Reconstruct the module via its normal __init__ with a validated causality_axis"],"exampleFix":"# before\nconv.causality_axis = \"width\"  # raw string assigned post-init\n\n# after\nconv.causality_axis = CausalityAxis.WIDTH","handlingStrategy":"validation","validationCode":"assert isinstance(conv.causality_axis, CausalityAxis), \"causality_axis must be a CausalityAxis member\"","typeGuard":"def is_causality_axis(v) -> bool:\n    return isinstance(v, CausalityAxis)","tryCatchPattern":null,"preventionTips":["Never assign raw strings to module enum attributes after construction","Rebuild modules via __init__ rather than patching fields during checkpoint loading"],"tags":["enum","convolution","runtime","audio-vae"],"backgroundTag":null,"analyzedSha":"1c6d8d45b3693bfbb32385b410d813a7fd6be216","analyzedAt":"2026-08-14T19:37:18.893Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}