Comfy-Org/ComfyUI · error · ValueError

kernel_size must be greater than 1. Use make_linear_nd inste

Error message

kernel_size must be greater than 1. Use make_linear_nd instead.

What it means

Raised by DualConv3d.__init__ when kernel_size resolves to (1,1,1). A 1x1x1 'convolution' is a pointwise projection and DualConv3d's split spatial/temporal machinery is pointless overhead for it, so the constructor redirects you to make_linear_nd.

Source

Thrown at comfy/ldm/lightricks/vae/dual_conv3d.py:32

        out_channels,
        kernel_size,
        stride: Union[int, Tuple[int, int, int]] = 1,
        padding: Union[int, Tuple[int, int, int]] = 0,
        dilation: Union[int, Tuple[int, int, int]] = 1,
        groups=1,
        bias=True,
        padding_mode="zeros",
    ):
        super(DualConv3d, self).__init__()

        self.in_channels = in_channels
        self.out_channels = out_channels
        self.padding_mode = padding_mode
        # Ensure kernel_size, stride, padding, and dilation are tuples of length 3
        if isinstance(kernel_size, int):
            kernel_size = (kernel_size, kernel_size, kernel_size)
        if kernel_size == (1, 1, 1):
            raise ValueError(
                "kernel_size must be greater than 1. Use make_linear_nd instead."
            )
        if isinstance(stride, int):
            stride = (stride, stride, stride)
        if isinstance(padding, int):
            padding = (padding, padding, padding)
        if isinstance(dilation, int):
            dilation = (dilation, dilation, dilation)

        # Set parameters for convolutions
        self.groups = groups
        self.bias = bias

        # Define the size of the channels after the first convolution
        intermediate_channels = (
            out_channels if in_channels < out_channels else in_channels
        )

View on GitHub (pinned to 1c6d8d45b3)

Solutions

  1. Use make_linear_nd(dims=(2,1), in_channels, out_channels) instead of make_conv_nd for 1x1 projections
  2. If a real convolution was intended, set kernel_size >= 2 (e.g. 3)
  3. Check the block config's kernel_size field for a stray 1

Example fix

# before
conv = make_conv_nd((2, 1), c_in, c_out, kernel_size=1)

# after
conv = make_linear_nd((2, 1), c_in, c_out)
Defensive patterns

Strategy: validation

Validate before calling

ks = (kernel_size,) * 3 if isinstance(kernel_size, int) else tuple(kernel_size)
if ks == (1, 1, 1):
    layer = make_linear_nd((2, 1), in_channels, out_channels)
else:
    layer = make_conv_nd((2, 1), in_channels, out_channels, kernel_size)

Type guard

def is_pointwise_kernel(ks) -> bool:
    ks = (ks,) * 3 if isinstance(ks, int) else tuple(ks)
    return ks == (1, 1, 1)

Prevention

When it happens

Trigger: Constructing DualConv3d(kernel_size=1) or make_conv_nd(dims=(2,1), kernel_size=1) — the latter forwards to DualConv3d and hits the guard.

Common situations: Config-driven code that sets kernel_size per block and accidentally uses 1 for a pointwise block; reusing a conv factory call template with a wrong kernel size.

Related errors


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