Comfy-Org/ComfyUI · error · ValueError

Invalid causality_axis: {causality_axis}

Error message

Invalid causality_axis: {causality_axis}

What it means

Raised in CausalConv2d.__init__ when the causality_axis match statement falls through, i.e. the value is not one of CausalityAxis.NONE, WIDTH, WIDTH_COMPATIBILITY, or HEIGHT. Because the parameter is normally coerced to a CausalityAxis, this only fires when an invalid enum-like value bypasses validation.

Source

Thrown at comfy/ldm/lightricks/vae/causal_audio_autoencoder.py:142

        # Ensure kernel_size and dilation are tuples
        kernel_size = nn.modules.utils._pair(kernel_size)
        dilation = nn.modules.utils._pair(dilation)

        # Calculate padding dimensions
        pad_h = (kernel_size[0] - 1) * dilation[0]
        pad_w = (kernel_size[1] - 1) * dilation[1]

        # The padding tuple for F.pad is (pad_left, pad_right, pad_top, pad_bottom)
        match self.causality_axis:
            case CausalityAxis.NONE:
                self.padding = (pad_w // 2, pad_w - pad_w // 2, pad_h // 2, pad_h - pad_h // 2)
            case CausalityAxis.WIDTH | CausalityAxis.WIDTH_COMPATIBILITY:
                self.padding = (pad_w, 0, pad_h // 2, pad_h - pad_h // 2)
            case CausalityAxis.HEIGHT:
                self.padding = (pad_w // 2, pad_w - pad_w // 2, pad_h, 0)
            case _:
                raise ValueError(f"Invalid causality_axis: {causality_axis}")

        # The internal convolution layer uses no padding, as we handle it manually
        self.conv = ops.Conv2d(
            in_channels,
            out_channels,
            kernel_size,
            stride=stride,
            padding=0,
            dilation=dilation,
            groups=groups,
            bias=bias,
        )

    def forward(self, x):
        # Apply causal padding before convolution
        x = F.pad(x, self.padding)
        return self.conv(x)

View on GitHub (pinned to 1c6d8d45b3)

Solutions

  1. Convert the value with CausalityAxis(value) (or the module's coerce) before constructing CausalConv2d
  2. Pass an actual CausalityAxis member: CausalityAxis.WIDTH, CausalityAxis.HEIGHT, CausalityAxis.NONE, or CausalityAxis.WIDTH_COMPATIBILITY
  3. If you copied the lightricks module, make sure only one CausalityAxis class is imported everywhere

Example fix

# before
conv = CausalConv2d(c_in, c_out, 3, causality_axis="width")

# after
conv = CausalConv2d(c_in, c_out, 3, causality_axis=CausalityAxis("width"))
Defensive patterns

Strategy: validation

Validate before calling

axis = causality_axis if isinstance(causality_axis, CausalityAxis) else CausalityAxis(causality_axis)
conv = CausalConv2d(c_in, c_out, 3, causality_axis=axis)

Type guard

def is_causality_axis(v) -> bool:
    return isinstance(v, CausalityAxis)

Prevention

When it happens

Trigger: Constructing CausalConv2d (or calling make_conv2d which forwards causality_axis) with a value that is not a valid CausalityAxis member — e.g. a look-alike enum from another module or an unvalidated string that slipped through on a code path that skips coerce.

Common situations: Mixing enum classes between copied lightricks modules; monkey-patched or duplicated CausalityAxis definitions where equality/membership fails; passing raw strings on paths that do not run _missing_ conversion.

Related errors


AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14). Data as JSON: /api/errors/6504ca9b552d9add. Report an issue: GitHub.