Skip to content

fix(flux): skip packing noise when FLUX Denoise continues from latents without add_noise - #9836

Open
gokay-ai wants to merge 5 commits into
invoke-ai:mainfrom
gokay-ai:fix/flux-denoise-skip-unused-noise
Open

gokay-ai wants to merge 5 commits into
invoke-ai:mainfrom
gokay-ai:fix/flux-denoise-skip-unused-noise

Conversation

@gokay-ai

@gokay-ai gokay-ai commented Oct 13, 2026 •

Copy link
Copy Markdown

Summary

Chaining two FLUX Denoise nodes where the second one continues from the first one's latents with add_noise=false (and no mask) crashed with Tensor type unknown to einops <class 'NoneType'>. _run_diffusion already sets noise = None in that case, but still called pack(noise). It now skips the pack when there is no noise, same as init_latents/inpaint_mask right above it and the FLUX.2 node.

Related Issues / Discussions

Fixes #9790

QA Instructions

Added test_flux_add_noise_false_denoises_incoming_latents_without_noise in tests/app/invocations/test_denoise_noise_inputs.py. It runs _run_diffusion with incoming latents, add_noise=False and a schedule with more than one step, with the model, LoRA patching and denoise mocked. The existing add_noise=False test returns early on the single-step short-circuit, so it never got to the pack.

  • Before the fix: the new test fails with the same einops error as in the issue.
  • After: pytest tests/app/invocations/test_denoise_noise_inputs.py tests/app/invocations/test_flux_denoise.py gives 47 passed, 5 xfailed, and pytest tests/app/invocations -k flux gives 330 passed, 4 skipped, 1 xfailed.
  • ruff check / ruff format --check pass on both files.

CPU and mocks only. I didn't run the real two-stage FLUX workflow on a GPU.

Checklist

  • The PR has a short but descriptive title, suitable for a changelog
  • Meaningful regression coverage added / updated where needed; obsolete tests/code removed
  • Persisted-state and API changes include required migrations / compatibility validation
  • Relevant performance/efficiency opportunities considered; material claims have evidence
  • Material review findings resolved and relevant checks rerun
  • Documentation added / updated (if applicable)
  • Updated What's New copy (if doing a release after this PR)

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

Continuing from latents with add_noise=false and no denoise mask leaves
noise as None, but _run_diffusion still packed it and crashed in einops.

Fixes invoke-ai#9790

Signed-off-by: GokayAI <60583610+gokay-ai@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 13, 2026 06:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions github-actions Bot added python PRs that change python files invocations PRs that change invocations python-tests PRs that change python tests labels Oct 13, 2026
@Pfannkuchensack Pfannkuchensack self-assigned this Oct 13, 2026
@Pfannkuchensack
Pfannkuchensack self-requested a review October 13, 2026 21:14
@Pfannkuchensack

Copy link
Copy Markdown
Member

Verified on GPU (RTX 4090, FLUX.1 dev): on main, a two-stage chain (stage 1 up to 0.6, stage 2 continuing from its latents with add_noise=false) fails with the einops NoneType error. With this PR it completes, and the result closely matches a single 20-step run (mean abs diff 0.29/255). FLUX.2, Z-Image and Anima already guard noise the same way, so FLUX.1 was the only affected node. The new test fails without the fix.

No changes requested, looks good to me.

@Pfannkuchensack

Copy link
Copy Markdown
Member

Heads-up on merge order: this PR and #9837 both change the same import line in tests/app/invocations/test_denoise_noise_inputs.py (this one adds from contextlib import nullcontext, #9837 adds from contextlib import ExitStack, nullcontext). Whichever merges second will hit a small conflict there. The correct resolution is to keep from contextlib import ExitStack, nullcontext; the rest merges cleanly (checked locally with both branches at their current heads).

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

invocations PRs that change invocations python PRs that change python files python-tests PRs that change python tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug]: FLUX Denoise crashes when continuing from latents with add_noise=false (two-stage chain)

3 participants