Skip to content

Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.

refactor(execution): remove redundant scheduler state

JPPhoto7b60266e62f8
diff --git a/docs/src/content/docs/contributing/loop-nodes.md b/docs/src/content/docs/contributing/loop-nodes.md
index 7a5f96c673..3cbafba677 100644
--- a/docs/src/content/docs/contributing/loop-nodes.md
+++ b/docs/src/content/docs/contributing/loop-nodes.md
@@ -90,9 +90,9 @@ Finalization is keyed by the loop source and its parent iteration path so nested
collections or state.
The execution-engine seam is additive to this loop contract. The session runner applies each result through
-`GraphExecutionState.apply()` using a stable execution reference and records frame-aware output tokens and accepted
-`For`/`ForReturn` continuation state is mirrored by a typed, frame-scoped
-`ContinuationRecord`. `ForInvocation` and `ForReturnInvocation` also declare one validated, frame-scoped
+`GraphExecutionState.apply()` using a stable execution reference and records frame-aware output tokens; accepted
+`For`/`ForReturn` continuation state is mirrored by a typed, frame-scoped `ContinuationRecord`.
+`ForInvocation` and `ForReturnInvocation` also declare one validated, frame-scoped
`continuation` effect per prepared invocation. The `For` effect starts the `for` continuation with the current
iteration and state; the `ForReturn` effect completes it with output, state, and the continue decision. These effects
are persisted under the invocation reference. Session-built effect references carry graph-state, durable-frame,
@@ -100,8 +100,7 @@ iteration-path, and workflow-call-depth identity, and stale or cross-scope effec
never encode `loop_linkage` as a data token. A fresh graph with exactly one static flat `For`/`ForReturn` pair,
including an empty literal collection or a supported non-empty input-driven collection producer, now uses the generic
scheduler adapter for readiness and continuation transitions.
-Graph state owns the
-generic continuation boundary: it carries returned state, honors `continue_condition`, materializes the next body
+Graph state owns the generic continuation boundary: it carries returned state, honors `continue_condition`, materializes the next body
iteration, and finalizes the aggregate. An empty literal collection completes through the existing synthetic terminal
`For` result without running the body or `ForReturn`. The generic scheduler remains opaque and never receives a literal
successor node ID. The compatibility continuation bridge is retained only for unsupported loop shapes and explicitly
diff --git a/invokeai/app/services/shared/README.md b/invokeai/app/services/shared/README.md
index 7adab4c369..ceae4dd386 100644
--- a/invokeai/app/services/shared/README.md
+++ b/invokeai/app/services/shared/README.md
@@ -572,7 +572,8 @@ Workflow-call note:
points. The planner continues to use the graph state's journal, mappings, caches, and scheduler.
- `_IfActivationController` Owns fallback runtime `If` admission and compiles opaque, frame-local activation dependency
records for unsupported fresh shapes and legacy prepared nodes. Fresh ordinary-node single-`If` graphs, the bounded
- nested pair, the exact bounded three-`If` inner/middle/outer chain, the exact four-`If` nested chain, and exactly two, exactly three, or exactly four independent sibling `If`s
+ nested pair, the exact bounded three-`If` inner/middle/outer chain, the exact four-`If` nested chain, and exactly two,
+ exactly three, or exactly four independent sibling `If`s
compile those dependencies in graph state. The bounded three-`If` chain also admits one middle-`If` value fan-out to
one ordinary leaf consumer; that leaf inherits only the outer branch dependency, not middle-`If` polarity. Other
fan-out remains fallback. Fresh admission leaves rejected
diff --git a/invokeai/app/services/shared/execution_engine/scheduler.py b/invokeai/app/services/shared/execution_engine/scheduler.py
index 0849340e9c..74d51c227c 100644
--- a/invokeai/app/services/shared/execution_engine/scheduler.py
+++ b/invokeai/app/services/shared/execution_engine/scheduler.py
@@ -226,7 +226,6 @@ class ExecutionScheduler:
self._ready_predicate = ready_predicate
self._claimed: set[NodeId] = set()
self.indegree: dict[NodeId, int] = {}
- self._ready: set[NodeId] = set()
self._enqueued: set[NodeId] = set()
self._arrival_order: dict[NodeId, int] = {}
self._next_arrival = 0
@@ -259,7 +258,6 @@ class ExecutionScheduler:
if not self._passes_ready_predicate(node_id):
return False
if node_id not in self._enqueued:
- self._ready.add(node_id)
self._enqueued.add(node_id)
self._arrival_order[node_id] = self._next_arrival
self._next_arrival += 1
@@ -295,7 +293,6 @@ class ExecutionScheduler:
self._active_class = self._next_class()
assert self._active_class is not None
node_id = self._next_id_for_class(self._active_class)
- self._ready.remove(node_id)
self._enqueued.remove(node_id)
self._claimed.add(node_id)
return node_id
@@ -364,7 +361,6 @@ class ExecutionScheduler:
self._enqueued.discard(node_id)
self._claimed.discard(node_id)
- self._ready.discard(node_id)
self._arrival_order.pop(node_id, None)
self.discarded.add(node_id)
newly_ready: list[NodeId] = []
@@ -407,7 +403,6 @@ class ExecutionScheduler:
self.executed.add(node_id)
self._enqueued.discard(node_id)
self._claimed.discard(node_id)
- self._ready.discard(node_id)
self._arrival_order.pop(node_id, None)
newly_ready: list[NodeId] = []
for dependent in dependents:
@@ -443,7 +438,6 @@ class ExecutionScheduler:
for node_id, node in self.plan.nodes.items()
}
previous_arrival = self._arrival_order
- self._ready = set()
self._enqueued = set()
self._arrival_order = {}
self._next_arrival = max(previous_arrival.values(), default=-1) + 1
@@ -455,7 +449,6 @@ class ExecutionScheduler:
and self.indegree[node_id] == 0
and self._passes_ready_predicate(node_id)
):
- self._ready.add(node_id)
self._enqueued.add(node_id)
arrival = previous_arrival.get(node_id)
if arrival is None: