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.
TypeScript ai-artartificial-intelligencegenerative-artimage-generationimg2imginpaintinglatent-diffusionlinuxmacosoutpaintingstable-diffusiontxt2imgwindows
Merge origin/main into execution-engine-refactoring
JPPhotof0d03de710c2
diff --cc tests/app/services/shared/test_for_scheduler_performance.pyindex dd8445f9ab,e3a2d0afdc..e7792d5077--- a/tests/app/services/shared/test_for_scheduler_performance.py+++ b/tests/app/services/shared/test_for_scheduler_performance.py@@@ -1,8 -1,11 +1,15 @@@"""Scheduler behavior and overhead for trivial loop bodies.+The required scheduler-scaling regression test counts entries traversed in the growing scheduler- ledgers. Optional absolute-time benchmarks remain marked `slow`. The completion-state tests are not- benchmarks.++ledgers. The linear-overhead check measures CPU time across repeated runs, rather than relying on a++single wall-clock sample. Optional absolute-time benchmarks remain marked `slow`. The++completion-state tests are not benchmarks.+ `test_loop_scheduler_overhead_is_linear` measures CPU time, not wall clock: it compares per-item+ cost at two sizes, and CPU time is not inflated when xdist workers share the runner's cores. It can+ be *deflated* by them, though -- Windows charges CPU in whole 15.625ms quanta at the clock interrupt+ and a contended worker misses some -- so the comparison sums its repeats rather than picking one of+ them. The absolute budget below it is machine-dependent and stays `slow`, as does the sibling+ `test_graph_execution_performance.py`. The completion-state tests are not benchmarks at all."""import time@@@ -129,55 -39,36 +136,73 @@@ def _run_trivial_loopwhile (node := state.next()) is not None:state.complete(node.id, node.invoke(context))assert state.is_complete()- return time.process_time() - started+ return clock() - started+++ ("loop_type", "include_if", "external_condition"),+ [+ ("iterate", False, False),+ ("for", False, False),+ ("iterate", True, False),+ ("iterate", True, True),+ ("for", True, False),+ ("for", True, True),+ ],+)+def test_loop_scheduler_does_not_rescan_growing_state(+ loop_type: str, include_if: bool, external_condition: bool+) -> None:+ visits: dict[int, int] = {}+ visits_by_mapping: dict[int, dict[str, int]] = {}+ for count in (300, 1200):+ counter = _MappingTraversalCounter()+ _run_trivial_loop(+ loop_type,+ count,+ mapping_counter=counter,+ include_if=include_if,+ external_condition=external_condition,+ )+ visits[count] = counter.entries_visited+ visits_by_mapping[count] = counter.visits_by_mapping++ # A small constant number of full mapping passes is acceptable. A pass per iteration is not:+ # it visits growing scheduler state quadratically. For covers durable effect history; Iterate covers+ # result synchronization in the generic scheduler.+ assert all(visits[count] <= count * 128 for count in visits), (+ f"mapping visits for {loop_type}, include_if={include_if}, external_condition={external_condition}: "+ f"{visits}; by mapping: {visits_by_mapping}"+ )- @pytest.mark.slow- def test_for_loop_scheduler_overhead_is_linear_with_wall_clock() -> None:- """Use wall clock for the For guard so Windows' coarse process clock cannot quantize the baseline."""- timings: dict[int, list[float]] = {count: [] for count in (300, 1200)}- for _ in range(5):+ _REPEATS = 3+++ @pytest.mark.parametrize("loop_type", ["iterate", "for"])+ def test_loop_scheduler_overhead_is_linear(loop_type: str) -> None:+ totals = dict.fromkeys((300, 1200), 0.0)+ for _ in range(_REPEATS):for count in (1200, 300):- timings[count].append(_run_trivial_loop("for", count) / count)- per_node = {count: min(samples) for count, samples in timings.items()}- assert per_node[1200] < per_node[300] * 1.5, f"for: {per_node}"+ # CPU time, so a worker losing the core to a sibling does not read as scheduler cost.+ totals[count] += _run_trivial_loop(loop_type, count)++ # One estimate per size over all the repeats, rather than best-of-N over them. `min` assumes the+ # noise only ever inflates a sample, and on a contended Windows runner it does not: CPU time is+ # charged in whole 15.625ms quanta at the clock interrupt, and a worker sharing four vCPUs under+ # `-n logical` misses some of them, so a reading can come back *short*. It came back at exactly+ # 0.0 for a 300-item run that the 1200 reading beside it puts at ~250ms -- sixteen quanta, which+ # no rounding can turn into zero -- and `min` took that for the fastest run, leaving the+ # threshold at `0.0 * 2.5`.+ # From there the assertion could not be satisfied by any scheduler. Summing absorbs a short+ # reading instead of selecting it, and averages an inflated one instead of being blind to it.+ for count, total in totals.items():+ assert total, f"{loop_type}: the CPU clock did not advance across any {count}-item run ({totals})"+ per_node = {count: total / (_REPEATS * count) for count, total in totals.items()}++ # Linear scheduling keeps per-item cost flat. The quadratic regression scaled per-item cost with+ # the item count - about 4x between 300 and 1200 - so 2.5x leaves noise headroom on both sides.+ assert per_node[1200] < per_node[300] * 2.5, f"{loop_type}: {per_node}"@pytest.mark.slow