Comfy-Org/ComfyUI · error · ValueError
Invalid causality_axis: {self.causality_axis}
Error message
Invalid causality_axis: {self.causality_axis} What it means
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.
Source
Thrown at comfy/ldm/lightricks/vae/causal_audio_autoencoder.py:248
# 2: [0,0,1]
# 3: [0,1,1]
# 4: [1,1,2]
# 5: [1,2,2]
# Notice that the first and second elements in the output rely only on the first element in the input,
# while all other elements rely on two elements in the input.
# So we can drop the first element to undo the padding (rather than the last element).
# This is a no-op for non-causal convolutions.
match self.causality_axis:
case CausalityAxis.NONE:
pass # x remains unchanged
case CausalityAxis.HEIGHT:
x = x[:, :, 1:, :]
case CausalityAxis.WIDTH:
x = x[:, :, :, 1:]
case CausalityAxis.WIDTH_COMPATIBILITY:
pass # x remains unchanged
case _:
raise ValueError(f"Invalid causality_axis: {self.causality_axis}")
return x
class Downsample(nn.Module):
"""
A downsampling layer that can use either a strided convolution
or average pooling. Supports standard and causal padding for the
convolutional mode.
"""
def __init__(self, in_channels, with_conv, causality_axis: CausalityAxis = CausalityAxis.WIDTH):
super().__init__()
self.with_conv = with_conv
self.causality_axis = causality_axis
if self.causality_axis != CausalityAxis.NONE and not self.with_conv:
raise ValueError("causality is only supported when `with_conv=True`.")View on GitHub (pinned to 1c6d8d45b3)
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
Example fix
# before conv.causality_axis = "width" # raw string assigned post-init # after conv.causality_axis = CausalityAxis.WIDTH
Defensive patterns
Strategy: validation
Validate before calling
assert isinstance(conv.causality_axis, CausalityAxis), "causality_axis must be a CausalityAxis member"
Type guard
def is_causality_axis(v) -> bool:
return isinstance(v, CausalityAxis) Prevention
- Never assign raw strings to module enum attributes after construction
- Rebuild modules via __init__ rather than patching fields during checkpoint loading
When it happens
Trigger: 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).
Common situations: 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.
Related errors
- Invalid causality_axis: {causality_axis}
- {cls.__name__} does not have a NONE member to map None to
- Invalid {cls.__name__} string: '{value}'. Valid values are:
- Cannot convert type {type(value).__name__} to {cls.__name__}
- Unknown attention type: {attn_type}
AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14).
Data as JSON: /api/errors/7907fc24285f27ba.
Report an issue: GitHub.