Comfy-Org/ComfyUI · error · ValueError

A cutoff above 0.5 does not make sense.

Error message

A cutoff above 0.5 does not make sense.

What it means

Raised by LowPassFilter1d.__init__ when cutoff > 0.5. Cutoff is normalized to the Nyquist frequency (1.0 = Nyquist), so 0.5 already means quarter of the sample rate; anything above 0.5 cannot be represented by the sinc filter kernel. Fails at construction time with a clear ValueError.

Source

Thrown at comfy/ldm/lightricks/vocoders/vocoder.py:70

        filter = filter_.view(1, 1, kernel_size)
    return filter


class LowPassFilter1d(nn.Module):
    def __init__(
        self,
        cutoff=0.5,
        half_width=0.6,
        stride=1,
        padding=True,
        padding_mode="replicate",
        kernel_size=12,
    ):
        super().__init__()
        if cutoff < -0.0:
            raise ValueError("Minimum cutoff must be larger than zero.")
        if cutoff > 0.5:
            raise ValueError("A cutoff above 0.5 does not make sense.")
        self.kernel_size = kernel_size
        self.even = kernel_size % 2 == 0
        self.pad_left = kernel_size // 2 - int(self.even)
        self.pad_right = kernel_size // 2
        self.stride = stride
        self.padding = padding
        self.padding_mode = padding_mode
        filter = kaiser_sinc_filter1d(cutoff, half_width, kernel_size)
        self.register_buffer("filter", filter)

    def forward(self, x):
        _, C, _ = x.shape
        if self.padding:
            x = F.pad(x, (self.pad_left, self.pad_right), mode=self.padding_mode)
        return F.conv1d(x, comfy.model_management.cast_to(self.filter.expand(C, -1, -1), dtype=x.dtype, device=x.device), stride=self.stride, groups=C)


class UpSample1d(nn.Module):

View on GitHub (pinned to 1c6d8d45b3)

Solutions

  1. Divide the desired Hz cutoff by the sample rate to normalize: cutoff_hz / sample_rate, and keep it <= 0.5
  2. Use the default 0.5 for the broadest passband the filter supports
  3. Verify each alias-free stage's cutoff in the vocoder config

Example fix

# before: cutoff given in Hz
LowPassFilter1d(cutoff=20000)
# after: normalized to sample rate (e.g. 48kHz -> ~0.42, or use max valid 0.5)
LowPassFilter1d(cutoff=min(20000 / 48000, 0.5))
Defensive patterns

Strategy: validation

Validate before calling

cutoff = min(desired_hz / sample_rate, 0.5)
assert 0.0 <= cutoff <= 0.5, cutoff
lpf = LowPassFilter1d(cutoff=cutoff)

Type guard

def normalized_cutoff(hz: float, sr: float) -> float:
    c = hz / sr
    if c > 0.5:
        raise ValueError('cutoff exceeds Nyquist; reduce hz or sample rate')
    return c

Prevention

When it happens

Trigger: Passing cutoff > 0.5 to LowPassFilter1d or building the lightricks vocoder with an upsample-stage cutoff above 0.5 in its config.

Common situations: Porting a filter config from a library where cutoff is in Hz (e.g. 20000) instead of normalized units; hand-tuning anti-aliasing parameters without reading the normalization convention.

Related errors


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