{"record":{"id":"0483c72343e3fc4a","repo":"invoke-ai/InvokeAI","slug":"denoising-start-should-be-0-when-initial-latents-a-0483c7","errorCode":null,"errorMessage":"denoising_start should be 0 when initial latents are not provided.","messagePattern":"denoising_start should be 0 when initial latents are not provided\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"invokeai/app/invocations/z_image_denoise.py","lineNumber":382,"sourceCode":"        # Prepare input latent image\n        if init_latents is not None:\n            if self.add_noise:\n                assert noise is not None\n                # Noise the init latents using the first sigma from the clipped\n                # InvokeAI schedule.\n                #\n                # Known limitation: if the selected scheduler later starts from a\n                # different first effective sigma/timestep than sigmas[0], the\n                # img2img preblend below may not match that scheduler exactly.\n                # This is an existing pipeline limitation and affects both\n                # internally generated noise and externally supplied noise.\n                s_0 = sigmas[0]\n                latents = s_0 * noise + (1.0 - s_0) * init_latents\n            else:\n                latents = init_latents\n        else:\n            if self.denoising_start > 1e-5:\n                raise ValueError(\"denoising_start should be 0 when initial latents are not provided.\")\n            assert noise is not None\n            latents = noise\n\n        # Short-circuit if no denoising steps\n        if total_steps <= 0:\n            return latents\n\n        # Prepare inpaint extension\n        inpaint_mask = self._prep_inpaint_mask(context, latents)\n        inpaint_extension: RectifiedFlowInpaintExtension | None = None\n        if inpaint_mask is not None:\n            if init_latents is None:\n                raise ValueError(\"Initial latents are required when using an inpaint mask (image-to-image inpainting)\")\n            assert noise is not None\n            inpaint_extension = RectifiedFlowInpaintExtension(\n                init_latents=init_latents,\n                inpaint_mask=inpaint_mask,\n                noise=noise,","sourceCodeStart":364,"sourceCodeEnd":400,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/app/invocations/z_image_denoise.py#L364-L400","documentation":"When no initial latents are supplied (pure text-to-image), the denoise invocation starts from pure noise, so the sigma schedule must begin at the start of denoising. If denoising_start is greater than ~1e-5 while init_latents is None, _run_diffusion raises ValueError because partial denoising is only meaningful relative to existing (image) latents.","triggerScenarios":"Calling the Z-Image denoise invocation with denoising_start > 1e-5 while the initial latents input is unconnected/None — e.g. a txt2img graph that still has a non-zero denoising_start value.","commonSituations":"Building a txt2img workflow after copying parameters from an img2img workflow; a UI that keeps a previous denoising_start value after the image input is removed; scripting where latents input is optional and unset.","solutions":["Set denoising_start to 0 when no initial latents are provided","Or connect initial latents (img2img) if you intend to skip the first portion of the schedule","Validate in the workflow editor that denoising_start is 0 whenever the latents input is unconnected"],"exampleFix":"// before\ndenoise = ZImageDenoiseInvocation(..., denoising_start=0.3)  # no latents connected\n// after\ndenoise = ZImageDenoiseInvocation(..., denoising_start=0.0)  # txt2img\n// or connect initial_latents for img2img","handlingStrategy":"validation","validationCode":"if init_latents is None and denoising_start > 1e-5:\n    denoising_start = 0.0  # or raise before invoking\n","typeGuard":null,"tryCatchPattern":"try:\n    output = denoise.invoke(context)\nexcept ValueError as e:\n    if \"denoising_start should be 0\" in str(e):\n        raise GraphConfigError(\"txt2img graph must use denoising_start=0\") from e\n    raise","preventionTips":["Pair denoising_start>0 strictly with a connected latents input","Reset denoise parameters when switching a graph between txt2img and img2img","Add graph-level validation before execution"],"tags":["diffusion","validation","img2img"],"backgroundTag":"invalid-parameter-combination","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}