invoke-ai/InvokeAI · error · ValueError

denoising_start must be 0 when no initial latents are provid

Error message

denoising_start must be 0 when no initial latents are provided. There is nothing to partially denoise, and starting from full-magnitude noise at a reduced sigma tells the model the sample is already partly denoised, which produces garbage.

What it means

_load_init_latents returns None when no initial latents are supplied, meaning generation starts from pure noise. That is only valid at denoising_start == 0; a non-zero start would apply a reduced first sigma to full-magnitude noise, making the model treat fresh noise as a partly denoised sample and yielding corrupted output — so it raises instead.

Source

Thrown at invokeai/app/invocations/ernie_image_denoise.py:196

            height=self.height,
        )

    def _load_init_latents(
        self,
        context: InvocationContext,
        noise: torch.Tensor,
        device: torch.device,
        dtype: torch.dtype,
    ) -> Optional[torch.Tensor]:
        """Load and validate the optional image-to-image starting latents.

        The blend with `noise` deliberately happens in the denoise loop rather than here: only that
        layer knows the *post-shift* first sigma, since `get_schedule` emits raw schedule values and
        the scheduler applies its `shift` inside `set_timesteps`.
        """
        if self.latents is None:
            if self.denoising_start > 0:
                raise ValueError(
                    "denoising_start must be 0 when no initial latents are provided. There is nothing to "
                    "partially denoise, and starting from full-magnitude noise at a reduced sigma tells the "
                    "model the sample is already partly denoised, which produces garbage."
                )
            return None

        init_latents = context.tensors.load(self.latents.latents_name).to(device=device, dtype=dtype)
        if init_latents.shape != noise.shape:
            raise ValueError(
                f"Input latents have shape {tuple(init_latents.shape)} but this graph expects "
                f"{tuple(noise.shape)} (batch, patched channels, height, width). ERNIE-Image latents must be "
                "VAE-encoded, BN-normalized (`sampling_utils.vae_normalize`) and 2x2-patchified "
                "(`sampling_utils.patchify_latents`) before they can be denoised."
            )
        return init_latents

    def _build_scheduler(self, context: InvocationContext) -> SchedulerMixin:
        """Instantiate the selected scheduler from the pipeline's own `scheduler/` config.

View on GitHub (pinned to 0b6a024f2f)

Solutions

  1. Set denoising_start to 0 when there is no latents input
  2. Or provide initial latents (VAE-encoded image or prior denoise output) to make a non-zero denoising_start meaningful
  3. Review graph templates that hard-code denoising_start without guaranteeing a latents connection

Example fix

// before
ErnieImageDenoise(latents=None, denoising_start=0.4, ...)
// after
ErnieImageDenoise(latents=None, denoising_start=0.0, ...)  # or supply latents
Defensive patterns

Strategy: validation

Validate before calling

if latents is None and denoising_start > 0:
    raise ValueError("denoising_start must be 0 when no initial latents are provided")

Type guard

def denoise_start_is_valid(latents, denoising_start: float) -> bool:
    return latents is not None or denoising_start == 0

Try / catch

try:
    out = invocation.invoke(context)
except ValueError as e:
    if "denoising_start must be 0" in str(e):
        invocation.denoising_start = 0.0
        out = invocation.invoke(context)
    else:
        raise

Prevention

When it happens

Trigger: Creating ErnieImageDenoise with `latents` None (pure txt2img) while `denoising_start` > 0 (e.g. 0.5 for img2img-style partial denoise).

Common situations: Reusing an img2img graph after disconnecting the latents input while keeping denoising_start; scripted generation that always sets denoising_start for 'faster' steps; UI presets applying a start value globally.

Related errors


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