invoke-ai/InvokeAI · error · ValueError

The denoising window [{denoising_start}, {denoising_end}] ro

Error message

The denoising window [{denoising_start}, {denoising_end}] rounds to zero steps at steps={num_steps}. Increase steps or widen the window.

What it means

After slicing the sigma schedule to the requested window, if fewer than 2 sigmas remain the window yields zero denoising steps — the loop would return its input untouched and downstream would decode raw noise silently. The library raises ValueError to refuse this degenerate configuration.

Source

Thrown at invokeai/backend/ernie_image/sampling_utils.py:75

    for i, t in enumerate(normalized):
        text_bth[i, : t.shape[0], :] = t
    return text_bth, lens


def get_schedule(num_steps: int, denoising_start: float = 0.0, denoising_end: float = 1.0) -> torch.Tensor:
    """Linear sigma schedule from 1.0 -> 0.0, same convention as the upstream pipeline."""
    if not 0.0 <= denoising_start < denoising_end <= 1.0:
        raise ValueError(f"Invalid denoising window: start={denoising_start}, end={denoising_end}")
    sigmas = torch.linspace(1.0, 0.0, num_steps + 1)
    start = int(num_steps * denoising_start)
    end = int(num_steps * denoising_end)
    # Slice to [start, end] inclusive of both ends so the caller can use adjacent pairs.
    window = sigmas[start : end + 1]
    if window.numel() < 2:
        # A window that rounds down to a single sigma yields zero adjacent pairs, i.e. zero steps.
        # The denoise loop would then return its input untouched and the graph would decode raw
        # noise with no error, so refuse instead.
        raise ValueError(
            f"The denoising window [{denoising_start}, {denoising_end}] rounds to zero steps at "
            f"steps={num_steps}. Increase steps or widen the window."
        )
    return window


def vae_normalize(latents: torch.Tensor, bn: torch.nn.Module, eps: float = 1e-5) -> torch.Tensor:
    """Apply the VAE's BatchNorm statistics to map encoder output -> transformer input.

    The ERNIE-Image VAE wraps a BN layer that the upstream pipeline uses to normalize
    latents before patchify (during img2img/inpaint encode) and to denormalize after
    the denoise loop (before decode). This is the encode-side direction.
    """
    mean = bn.running_mean.view(1, -1, 1, 1).to(latents.device, latents.dtype)
    std = torch.sqrt(bn.running_var.view(1, -1, 1, 1) + eps).to(latents.device, latents.dtype)
    return (latents - mean) / std

View on GitHub (pinned to 0b6a024f2f)

Solutions

  1. Increase num_inference_steps so the window spans at least one interval.
  2. Widen the [denoising_start, denoising_end] window.
  3. In callers, validate steps*window_span >= 1 and adjust strength before invoking.

Example fix

// before
get_schedule(4, denoising_start=0.9, denoising_end=0.95)  # 0 steps
// after
get_schedule(40, denoising_start=0.9, denoising_end=0.95)  # 2 sigmas -> 1+ step
Defensive patterns

Strategy: validation

Validate before calling

if int(num_steps * denoising_end) - int(num_steps * denoising_start) < 1:
    num_steps = max(num_steps, math.ceil(1 / (denoising_end - denoising_start)))

Type guard

def yields_at_least_one_step(steps: int, start: float, end: float) -> bool:
    return int(steps * end) - int(steps * start) >= 1

Try / catch

try:
    sigmas = get_schedule(num_steps, denoising_start=s, denoising_end=e)
except ValueError as e:
    if "zero steps" in str(e):
        num_steps = math.ceil(2 / (e - s if (e := denoising_end) > (s := denoising_start) else 0.1))
        sigmas = get_schedule(num_steps, denoising_start=s, denoising_end=e)
    else:
        raise

Prevention

When it happens

Trigger: Calling get_schedule(num_steps, start, end) where int(num_steps*end) - int(num_steps*start) < 1, e.g. get_schedule(4, 0.9, 0.95) — a narrow denoise window with few steps.

Common situations: Very low step counts combined with partial-denoise sliders (small img2img strength); rounding at high denoising_start values (e.g. start=0.999 with 10 steps).

Related errors


AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29). Data as JSON: /api/errors/44f7df01b5b2071c. Report an issue: GitHub.