Skip to content

Use chained Collect nodes for FLUX.2 reference images graph#130

Open
Copilot wants to merge 2 commits intomainfrom
copilot/modify-invocation-graph-collect-nodes
Open

Use chained Collect nodes for FLUX.2 reference images graph#130
Copilot wants to merge 2 commits intomainfrom
copilot/modify-invocation-graph-collect-nodes

Conversation

Copy link

Copilot AI commented Mar 24, 2026

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

QA Instructions

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

Merge Plan

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)

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Copilot AI changed the title [WIP] Update invocation graph to use chained Collect nodes Use chained Collect nodes for FLUX.2 reference images graph Mar 24, 2026
Copilot AI requested a review from lstein March 24, 2026 01:50
@lstein lstein marked this pull request as ready for review March 24, 2026 02:40
Copy link
Owner

@lstein lstein left a comment

Choose a reason for hiding this comment

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

Tested and works as expected with FLUX.2 Edit.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants