Skip to content

Fix lazy If branch pruning and skipped-parent handling in graph runtime#9079

Open
JPPhoto wants to merge 1 commit intoinvoke-ai:mainfrom
JPPhoto:fix-if-branch-edge-pruning
Open

Fix lazy If branch pruning and skipped-parent handling in graph runtime#9079
JPPhoto wants to merge 1 commit intoinvoke-ai:mainfrom
JPPhoto:fix-if-branch-edge-pruning

Conversation

@JPPhoto
Copy link
Copy Markdown
Collaborator

@JPPhoto JPPhoto commented Apr 20, 2026

Summary

Fixes lazy If execution in invokeai/app/services/shared/graph.py for workflows where a selected branch shares ancestors with the unselected branch.

The runtime bug was that resolving an If node decremented indegree for the pruned input but left the pruned execution edge in place, so later parent completion could decrement the same dependency again. This could make the If node become ready too early, underflow indegree, or propagate None into required downstream inputs.

This PR:

  • prunes unselected If input edges from the execution graph during branch resolution
  • ignores skipped prepared exec nodes when matching live parents for downstream materialization
  • tolerates missing result payloads from skipped branch-local exec nodes during If input hydration
  • adds focused backend regression tests for positive and negative branch-selection cases
  • updates invokeai/app/services/shared/README.md to document the runtime behavior

Related Issues / Discussions

Complex workflow failure involving a single If node feeding positive_text_conditioning on flux_denoise.

QA Instructions

Load a workflow where collect -> if -> required downstream input is used and verify:

  • the selected branch output reaches the downstream node
  • branch-exclusive unselected ancestors are skipped
  • no KeyError, indegree underflow, or missing required-connection error occurs from the If runtime path

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-actions github-actions Bot added python PRs that change python files services PRs that change app services python-tests PRs that change python tests labels Apr 20, 2026
@JPPhoto JPPhoto moved this to 6.13.x Theme: MODELS in Invoke - Community Roadmap Apr 20, 2026
@JPPhoto JPPhoto force-pushed the fix-if-branch-edge-pruning branch 2 times, most recently from 70f9d7b to 63e5b16 Compare April 21, 2026 01:59
@JPPhoto JPPhoto force-pushed the fix-if-branch-edge-pruning branch from 63e5b16 to f681759 Compare April 22, 2026 00:56
@JPPhoto JPPhoto requested a review from Pfannkuchensack April 22, 2026 10:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python PRs that change python files python-tests PRs that change python tests services PRs that change app services v6.13.x

Projects

Status: 6.13.x Theme: MODELS

Development

Successfully merging this pull request may close these issues.

1 participant