{"record":{"id":"fc7420870b731530","repo":"invoke-ai/InvokeAI","slug":"denoising-start-should-be-0-when-initial-latents-a-fc7420","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/cogview4_denoise.py","lineNumber":262,"sourceCode":"        # Load the input latents, if provided.\n        init_latents = context.tensors.load(self.latents.latents_name) if self.latents else None\n        if init_latents is not None:\n            init_latents = init_latents.to(device=device, dtype=inference_dtype)\n\n        # Generate initial latent noise.\n        num_channels_latents = transformer_info.model.config.in_channels  # type: ignore\n        assert isinstance(num_channels_latents, int)\n        noise = self._prepare_noise_tensor(context, num_channels_latents, inference_dtype, device)\n\n        # Prepare input latent image.\n        if init_latents is not None:\n            # Noise the init_latents by the appropriate amount for the first timestep.\n            s_0 = sigmas[0]\n            latents = s_0 * noise + (1.0 - s_0) * init_latents\n        else:\n            # init_latents are not provided, so we are not doing image-to-image (i.e. we are starting from pure noise).\n            if self.denoising_start > 1e-5:\n                raise ValueError(\"denoising_start should be 0 when initial latents are not provided.\")\n            latents = noise\n\n        # If len(timesteps) == 1, then short-circuit. We are just noising the input latents, but not taking any\n        # denoising steps.\n        if len(timesteps) <= 1:\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            assert init_latents is not None\n            inpaint_extension = RectifiedFlowInpaintExtension(\n                init_latents=init_latents,\n                inpaint_mask=inpaint_mask,\n                noise=noise,\n            )\n","sourceCodeStart":244,"sourceCodeEnd":280,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/app/invocations/cogview4_denoise.py#L244-L280","documentation":"When doing text-to-image (no initial latents), the diffusion schedule starts from pure noise, so partial denoising is meaningless. _run_diffusion raises if denoising_start is set (greater than 1e-5) while init_latents are absent.","triggerScenarios":"Invoking CogView4 denoise with denoising_start > 1e-5 in a graph that has no initial latents connected (pure text-to-image).","commonSituations":"Reusing an img2img graph template after disconnecting the image/latents input; programmatic graph construction that sets denoising_start unconditionally; UI copy that keeps the slider value after the input image is removed.","solutions":["Set denoising_start to 0 on the denoise node.","Connect initial latents (via an image-to-latents/vae encoder path) if img2img behavior is desired.","Fix graph-building code to set denoising_start only when init latents are provided."],"exampleFix":"// before\nnode.denoising_start = 0.4  # but no init_latents connected\n// after\nnode.denoising_start = 0.0  # or connect latents from ImageToLatents","handlingStrategy":"validation","validationCode":"if node.latents is None and node.denoising_start > 1e-5:\n    node.denoising_start = 0.0","typeGuard":null,"tryCatchPattern":"try:\n    output = node.invoke(context)\nexcept ValueError as e:\n    if \"denoising_start\" in str(e):\n        node.denoising_start = 0.0\n        output = node.invoke(context)\n    else:\n        raise","preventionTips":["Set denoising_start only in img2img graphs where latents are connected","Add graph linting: denoising_start > 0 requires a latents input","Reset sliders when removing the init-image input in UI"],"tags":["validation","denoise","img2img","cogview4"],"backgroundTag":"incompatible-parameters","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}