invoke-ai/InvokeAI · error · ValueError
denoising_start should be 0 when initial latents are not pro
Error message
denoising_start should be 0 when initial latents are not provided.
What it means
Without initial latents, denoising starts from pure noise at sigma_0, which corresponds to denoising_start == 0. `_run_diffusion` raises this ValueError when no init latents are supplied but denoising_start is greater than a small epsilon (1e-5), because skipping the early steps requires an initial latent to start from.
Source
Thrown at invokeai/app/invocations/krea2_denoise.py:373
device,
)
neg_prompt_embeds = neg_extension.regional_text_conditioning.prompt_embeds
# Load initial latents (img2img).
init_latents = context.tensors.load(self.latents.latents_name) if self.latents else None
if init_latents is not None:
init_latents = init_latents.to(device=device, dtype=inference_dtype)
if init_latents.dim() == 5:
init_latents = init_latents.squeeze(2)
noise = self._get_noise(self.height, self.width, inference_dtype, device, self.seed)
if init_latents is not None:
s_0 = sigmas_sched[0].item()
latents = s_0 * noise + (1.0 - s_0) * init_latents
else:
if self.denoising_start > 1e-5:
raise ValueError("denoising_start should be 0 when initial latents are not provided.")
latents = noise
# Pack latents into 2x2 patches: (B, C, H, W) -> (B, grid_h*grid_w, C*4).
latents = pack_latents(latents, 1, KREA2_LATENT_CHANNELS, latent_height, latent_width)
# Position ids: text tokens at origin, image tokens carry their grid coords.
text_seq_len = pos_prompt_embeds.shape[1]
position_ids = prepare_position_ids(text_seq_len, grid_height, grid_width, device)
# The negative prompt can tokenize to a different length than the positive prompt, so it needs its
# own position ids. Reusing the positive ids would leave the rotary embedding (text + image tokens)
# a different length than the uncond query sequence and crash in the transformer's apply_rotary_emb.
neg_position_ids = (
prepare_position_ids(neg_prompt_embeds.shape[1], grid_height, grid_width, device)
if neg_prompt_embeds is not None
else None
)
# Inpaint extension operates in 4D, so unpack/repack around each merge.View on GitHub (pinned to 0b6a024f2f)
Solutions
- Set denoising_start to 0 when no initial latents are provided.
- Provide initial latents (VAE Encode of an image) if a nonzero denoising_start is intended (img2img mode).
- Guard caller code: only apply the refiner start fraction when init latents exist.
Example fix
// before: txt2img with a refiner start denoise = Krea2Denoise(latents=None, denoising_start=0.7, denoising_end=1.0) // after denoise = Krea2Denoise(latents=None, denoising_start=0.0, denoising_end=1.0) # or wire latents=vae_encode.latents for img2img
Defensive patterns
Strategy: validation
Validate before calling
if latents is None and denoising_start > 1e-5:
raise ValueError("Set denoising_start=0 for txt2img, or supply initial latents for img2img.") Type guard
def start_matches_mode(latents, denoising_start: float) -> bool:
return latents is not None or denoising_start <= 1e-5 Try / catch
try:
out = invoke_krea2_denoise(latents=latents, denoising_start=start)
except ValueError as e:
if "denoising_start should be 0" in str(e):
out = invoke_krea2_denoise(latents=latents, denoising_start=0.0, denoising_end=end)
else:
raise Prevention
- Only apply refiner-style start fractions when an init-latents branch exists.
- Reset denoising_start to 0 when switching a graph from img2img to txt2img.
- Gate start-fraction settings behind the presence of an input image.
When it happens
Trigger: Running the krea2_denoise invocation in pure txt2img mode (latents=None) with denoising_start > 1e-5 — e.g. a refiner-style start fraction applied without an img2img latent input.
Common situations: Users copying refiner settings (denoising_start=0.7) onto a txt2img graph; template workflows that enable a start fraction but lack the image-to-latents branch; scripts setting start values unconditionally.
Related errors
- The requested denoising range does not contain any effective
- denoising_start must be less than denoising_end.
- per_layer_weights must be comma-separated numbers: {e}
- per_layer_weights must have exactly {_NUM_TEXT_LAYERS} value
- per_layer_weights must contain only finite values.
AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29).
Data as JSON: /api/errors/b5b5c92619bd3300.
Report an issue: GitHub.