Skip to content

Fix(frontend): Make ordering of multiple FLUX.2 reference images deterministic - #8989

Merged
lstein merged 3 commits into
invoke-ai:mainfrom
lstein:copilot/modify-invocation-graph-collect-nodes
Mar 24, 2026
Merged

Fix(frontend): Make ordering of multiple FLUX.2 reference images deterministic#8989
lstein merged 3 commits into
invoke-ai:mainfrom
lstein:copilot/modify-invocation-graph-collect-nodes

Conversation

@lstein

@lstein lstein commented Mar 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

When building the FLUX.2 invocation graph, reference images were fed into a single collect node via multiple item edges. Because node execution order isn't guaranteed, the resulting collection order was non-deterministic — causing inconsistent behavior in Flux2RefImageExtension (which uses index-based T-coordinate offsets per image).

Fix: Replace the single collect node with a chain of collect nodes, one per reference image. Each node accumulates the previous collection and appends the next item, guaranteeing insertion order matches the source array order.

Before:

const flux2KontextCollect = g.addNode({ type: 'collect', ... });
for (const { config } of validFlux2RefImageConfigs) {
  const kontextConditioning = g.addNode({ type: 'flux_kontext', ... });
  g.addEdge(kontextConditioning, 'kontext_cond', flux2KontextCollect, 'item');
}
g.addEdge(flux2KontextCollect, 'collection', flux2Denoise, 'kontext_conditioning');

After:

let prevCollect: Invocation<'collect'> | null = null;
for (const { config } of validFlux2RefImageConfigs) {
  const kontextConditioning = g.addNode({ type: 'flux_kontext', ... });
  const collectNode = g.addNode({ type: 'collect', ... });
  g.addEdge(kontextConditioning, 'kontext_cond', collectNode, 'item');
  if (prevCollect !== null) {
    g.addEdge(prevCollect, 'collection', collectNode, 'collection');
  }
  prevCollect = collectNode;
}
assert(prevCollect !== null);
g.addEdge(prevCollect, 'collection', flux2Denoise, 'kontext_conditioning');

Related Issues / Discussions

closes #8923 (superseded)

QA Instructions

With multiple FLUX.2 reference images, verify that generation is stable across repeated runs (same images, same seed → same output).

Merge Plan

Simple merge

Checklist

  • The PR has a short but descriptive title, suitable for a changelog
  • Tests added / updated (if applicable)
  • ❗Changes to a redux slice have a corresponding migration
  • Documentation added / updated (if applicable)
  • Updated What's New copy (if doing a release after this PR)

Copilot AI and others added 2 commits March 24, 2026 01:44
@github-actions github-actions Bot added the frontend PRs that change frontend files label Mar 24, 2026
@lstein lstein added the v6.13.x label Mar 24, 2026
@lstein lstein changed the title Fix(frontend): Make ordering of multiple reference images deterministic Fix(frontend): Make ordering of multiple FLUX.2 reference images deterministic Mar 24, 2026

@Pfannkuchensack Pfannkuchensack left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

work good

@lstein
lstein merged commit 7f2878f into invoke-ai:main Mar 24, 2026
13 checks passed
@lstein
lstein deleted the copilot/modify-invocation-graph-collect-nodes branch April 5, 2026 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

frontend PRs that change frontend files v6.13.x

Projects

Status: 6.13.x Theme: MODELS

Development

Successfully merging this pull request may close these issues.

3 participants