Skip to content

Fix graph execution state resume after JSON round-trip#9042

Merged
lstein merged 4 commits intoinvoke-ai:mainfrom
JPPhoto:resume-graph-execution-state
Apr 25, 2026
Merged

Fix graph execution state resume after JSON round-trip#9042
lstein merged 4 commits intoinvoke-ai:mainfrom
JPPhoto:resume-graph-execution-state

Conversation

@JPPhoto
Copy link
Copy Markdown
Collaborator

@JPPhoto JPPhoto commented Apr 10, 2026

Summary

Fix a graph execution resume bug in invokeai/app/services/shared/graph.py where GraphExecutionState could stall after model_dump_json() / validate_json() on a partially executed session. The fix rehydrates runtime scheduler state for already-materialized exec nodes after deserialization, and adds a regression test covering partial execution, JSON round-trip, and successful completion.

Related Issues / Discussions

QA Instructions

  • Run pytest tests/test_graph_execution_state.py
  • Confirm the new round-trip resume test passes
  • Confirm a partially executed graph can be serialized, deserialized, and then finished without next() stalling
  • Run ruff check --fix invokeai tests scripts
  • Run ruff format invokeai tests scripts

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 10, 2026
@JPPhoto JPPhoto force-pushed the resume-graph-execution-state branch 3 times, most recently from 07e160a to 85df41d Compare April 14, 2026 00:39
@lstein lstein self-assigned this Apr 14, 2026
@JPPhoto JPPhoto force-pushed the resume-graph-execution-state branch 17 times, most recently from 9ded36f to 7417733 Compare April 21, 2026 01:59
@JPPhoto JPPhoto force-pushed the resume-graph-execution-state branch from 7417733 to ec70216 Compare April 22, 2026 00:56
@JPPhoto JPPhoto force-pushed the resume-graph-execution-state branch from ec70216 to c6d794f Compare April 23, 2026 15:57
Copy link
Copy Markdown
Collaborator

@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.

Some suggestions:

  1. _rehydrate_resolved_if_exec_branches duplicates scheduler logic. The condition-edge loop + copydeep at graph.py:1856-1861 duplicates code at _IfBranchScheduler._apply_condition_inputs (graph.py:177-188). I suggest refactoring so that the scheduling logic is at one place.
  2. _rehydrate_prepared_exec_metadata sets source_node_id and state but iteration_path is left None. This is eventually fixed by _build_iteration_path, but it would be best to either immediately rehydrate iteration_path, or enter a comment that this is deferred to later.
  3. Shouldn't there be a direct test for _rehydrate_resolved_if_exec_branches? I'd suggest adding a test where the graph contains an IfInvocation, execute it past the condition, round-trip the state, and assert the correct branch goes to completion.

@JPPhoto JPPhoto requested a review from lstein April 25, 2026 00:37
@JPPhoto
Copy link
Copy Markdown
Collaborator Author

JPPhoto commented Apr 25, 2026

@lstein All should be addressed!

@lstein lstein enabled auto-merge (squash) April 25, 2026 15:29
Copy link
Copy Markdown
Collaborator

@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.

Looks good!

@lstein lstein merged commit 0531108 into invoke-ai:main Apr 25, 2026
16 checks passed
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants