InvokeAI icon indicating copy to clipboard operation
InvokeAI copied to clipboard

Rework graph.py

Open JPPhoto opened this issue 1 month ago • 0 comments

Summary

This new graph.py keeps the same DAG model and validation but restructures runtime scheduling and readability: ready queues moved from public deque fields to internal, non-serialized structures grouped by node class, with a configurable class priority and optional batch cap; indegree is now seeded as unmet inputs (fixing iterator stalls) and children are enqueued via a single _enqueue_if_ready() helper; next() drains the active class queue, reseeds when empty, and _prepare() still expands iterators but with clearer predicates; minor fixes include catching ValueError in delete_edge, replacing magic port strings with ITEM_FIELD/COLLECTION_FIELD, and renaming helper methods for clarity. Functionality and performance are preserved aside from the scheduling policy change and the indegree correctness fix.

Additionally, there is a new README.md file that explains a bit about the classes in graph.py so future developers can get a head start.

Related Issues / Discussions

All of this was an effort to understand the execution engine better to support different types in the future - if, loops, and the like.

QA Instructions

I've run a number of workflows with these changes and all seems good.

Merge Plan

Checklist

  • [X] 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
  • [X] Documentation added / updated (if applicable)
  • [ ] Updated What's New copy (if doing a release after this PR)

JPPhoto avatar Oct 27 '25 21:10 JPPhoto