invoke-ai/InvokeAI · error · ValueError
Initial latents are required when a denoise mask is provided
Error message
Initial latents are required when a denoise mask is provided.
What it means
A denoise mask tells the pipeline which latent regions to preserve, which only makes sense when there are initial latents to mask. `_validate_inputs` raises this ValueError when denoise_mask is provided but the `latents` input is None.
Source
Thrown at invokeai/app/invocations/krea2_denoise.py:233
raise ValueError(f"Invalid CFG scale type: {type(self.cfg_scale)}")
@staticmethod
def _should_apply_cfg_for_step(cfg_scale: float, *, has_negative_conditioning: bool) -> bool:
return has_negative_conditioning and cfg_scale > 1.0
@staticmethod
def _validate_effective_schedule(*, start_idx: int, end_idx: int) -> None:
if end_idx <= start_idx:
raise ValueError(
"The requested denoising range does not contain any effective denoising steps at the configured "
"step count. Increase denoising_end, decrease denoising_start, or increase steps."
)
def _validate_inputs(self) -> None:
if self.denoising_start >= self.denoising_end:
raise ValueError("denoising_start must be less than denoising_end.")
if self.denoise_mask is not None and self.latents is None:
raise ValueError("Initial latents are required when a denoise mask is provided.")
def _is_distilled(self, context: InvocationContext) -> bool:
"""Whether the transformer is the distilled Turbo checkpoint (fixed mu) vs. Raw (dynamic mu).
Prefer the classified variant (works for diffusers, single-file and GGUF alike); fall back to
the pipeline-level ``is_distilled`` flag in model_index.json, then default to distilled.
A failed config lookup is a real error and is allowed to propagate — silently defaulting to the
Turbo shift would apply the wrong sampling schedule to a Raw model.
"""
from invokeai.backend.model_manager.taxonomy import Krea2VariantType
config = context.models.get_config(self.transformer.transformer)
variant = getattr(config, "variant", None)
if variant is not None:
return variant != Krea2VariantType.Base
# No classified variant (unexpected for Krea-2) — fall back to the pipeline-level flag. Only a
# missing/malformed model_index.json is tolerated here; it defaults to the distilled behavior.View on GitHub (pinned to 0b6a024f2f)
Solutions
- Connect initial latents (from a VAE Encode or Resize Latents node output) to the invocation's latents input.
- If no initial image is intended, remove the denoise_mask connection.
- Check the workflow for a disabled or deleted node upstream of the latents input.
Example fix
// before: mask without latents DenoiseInvocation(denoise_mask=mask, latents=None) // after: provide initial latents DenoiseInvocation(denoise_mask=mask, latents=vae_encode.latents)
Defensive patterns
Strategy: validation
Validate before calling
if denoise_mask is not None and latents is None:
raise ValueError("Provide initial latents (e.g. VAE Encode output) when using a denoise mask.") Type guard
def mask_has_latents(denoise_mask, latents) -> bool:
return denoise_mask is None or latents is not None Try / catch
try:
out = invoke_krea2_denoise(denoise_mask=mask, latents=latents)
except ValueError as e:
if "Initial latents are required" in str(e):
latents = vae_encode(image).latents
out = invoke_krea2_denoise(denoise_mask=mask, latents=latents)
else:
raise Prevention
- Always pair a DenoiseMaskField with a latents input in graph templates.
- Validate inpainting graphs for a connected image -> VAE Encode -> latents path.
- Remove mask connections when running pure txt2img.
When it happens
Trigger: Connecting a DenoiseMaskField to the krea2_denoise node while leaving the latents input unconnected — e.g. running txt2img with a mask instead of img2img/inpaint.
Common situations: Inpainting graphs where the initial-image/VAE-encode branch was disconnected; users expecting mask-based txt2img; workflow templates missing the latents edge.
Related errors
- At least one Krea-2 conditioning is required.
- Initial latents are required when using an inpaint mask (img
- No VAE source provided. Single-file / GGUF transformers requ
- No Mistral encoder source provided. Single-file / GGUF trans
- No VAE source provided. Standalone safetensors/GGUF models r
AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29).
Data as JSON: /api/errors/d75f442bf30cde1a.
Report an issue: GitHub.