Commit Graph

85 Commits

Author SHA1 Message Date
Jacob Segal
8d17f3c7bf Fix ui output for duplicated nodes 2024-06-16 18:39:24 -07:00
Jacob Segal
afa4c7b260 Refactor map_node_over_list function 2024-04-21 21:55:03 -07:00
Jacob Segal
fa48ad3a1f Minor refactor of IsChangedCache.get 2024-04-21 21:39:52 -07:00
Jacob Segal
b3e547f22b Merge branch 'master' into execution_model_inversion 2024-04-21 21:31:58 -07:00
Jacob Segal
06f3ce9200 Raise exception for bad get_node calls. 2024-04-21 16:10:01 -07:00
Jacob Segal
2dda3f2827 Add a test for mixed node expansion
This test ensures that a node that returns a combination of expanded
subgraphs and literal values functions correctly.
2024-04-21 15:39:20 -07:00
Jacob Segal
1f06588905 Pass None for uneval inputs instead of default
This applies to `VALIDATE_INPUTS`, `check_lazy_status`, and lazy values
in evaluation functions.
2024-04-21 00:10:04 -07:00
Jacob Segal
ecbef304ed Remove superfluous function parameter 2024-04-20 23:07:18 -07:00
Jacob Segal
75774c6ad1 Rename ExecutionResult.SLEEPING to PENDING 2024-04-20 23:02:43 -07:00
Jacob Segal
dd3bafb40b Display an error for dependency cycles
Previously, dependency cycles that were created during node expansion
would cause the application to quit (due to an uncaught exception). Now,
we'll throw a proper error to the UI. We also make an attempt to 'blame'
the most relevant node in the UI.
2024-04-20 22:40:38 -07:00
Jacob Segal
5dc13651b0 Use custom exception types. 2024-04-20 18:12:42 -07:00
Jacob Segal
a0bf532558 Use fstrings instead of '%' formatting syntax 2024-04-20 17:52:23 -07:00
comfyanonymous
5d08802f78 Sync some minor changes from the other repo. 2024-04-19 03:43:09 -04:00
comfyanonymous
5d8898c056 Fix some performance issues with weight loading and unloading.
Lower peak memory usage when changing model.

Fix case where model weights would be unloaded and reloaded.
2024-03-28 18:04:42 -04:00
Jacob Segal
6b6a93cc5d Merge branch 'master' into execution_model_inversion 2024-03-23 16:31:14 -07:00
comfyanonymous
6a32c06f06 Move cleanup_models to improve performance. 2024-03-23 17:27:10 -04:00
comfyanonymous
314d28c251 Pass extra_pnginfo as None when not in input data. 2024-03-07 15:07:47 -05:00
Jacob Segal
6d09dd70f8 Make custom VALIDATE_INPUTS skip normal validation
Additionally, if `VALIDATE_INPUTS` takes an argument named `input_types`,
that variable will be a dictionary of the socket type of all incoming
connections. If that argument exists, normal socket type validation will
not occur. This removes the last hurdle for enabling variant types
entirely from custom nodes, so I've removed that command-line option.

I've added appropriate unit tests for these changes.
2024-02-24 23:17:01 -08:00
Jacob Segal
e60dbe3a44 Fix issue with unused literals
Behavior should now match the master branch with regard to undeclared
inputs. Undeclared inputs that are socket connections will be used while
undeclared inputs that are literals will be ignored.
2024-02-21 19:36:51 -08:00
Rick Love
f81dbe26e2
FIX recursive_will_execute performance (simple ~300x performance increase} (#2852)
* FIX recursive_will_execute performance

* Minimize code changes

* memo must be created outside lambda
2024-02-21 20:21:24 -05:00
Jacob Segal
508d286b8f Fix Pyright warnings 2024-02-17 21:56:46 -08:00
Jacob Segal
12627ca75a Add a command-line argument to enable variants
This allows the use of nodes that have sockets of type '*' without
applying a patch to the code.
2024-02-14 21:06:53 -08:00
Jacob Segal
2c7145d525 Handle errors (like OOM) more gracefully 2024-02-14 21:05:44 -08:00
Jacob Segal
36b2214e30 Execution Model Inversion
This PR inverts the execution model -- from recursively calling nodes to
using a topological sort of the nodes. This change allows for
modification of the node graph during execution. This allows for two
major advantages:

    1. The implementation of lazy evaluation in nodes. For example, if a
    "Mix Images" node has a mix factor of exactly 0.0, the second image
    input doesn't even need to be evaluated (and visa-versa if the mix
    factor is 1.0).

    2. Dynamic expansion of nodes. This allows for the creation of dynamic
    "node groups". Specifically, custom nodes can return subgraphs that
    replace the original node in the graph. This is an incredibly
    powerful concept. Using this functionality, it was easy to
    implement:
        a. Components (a.k.a. node groups)
        b. Flow control (i.e. while loops) via tail recursion
        c. All-in-one nodes that replicate the WebUI functionality
        d. and more
    All of those were able to be implemented entirely via custom nodes,
    so those features are *not* a part of this PR. (There are some
    front-end changes that should occur before that functionality is
    made widely available, particularly around variant sockets.)

The custom nodes associated with this PR can be found at:
https://github.com/BadCafeCode/execution-inversion-demo-comfyui

Note that some of them require that variant socket types ("*") be
enabled.
2024-01-28 20:48:42 -08:00
comfyanonymous
2d105066df Cleanups. 2024-01-26 21:31:13 -05:00
realazthat
fad02dc2df Don't use PEP 604 type hints, to stay compatible with Python<3.10. 2024-01-17 17:16:34 -05:00
comfyanonymous
56d9496b18 Rename status notes to status messages.
I think message describes them better.
2024-01-12 18:17:06 -05:00
comfyanonymous
bcc0bde2af Clear status notes on execution start. 2024-01-12 17:21:22 -05:00
realazthat
1b3d65bd84 Add error, status to /history endpoint 2024-01-11 10:16:42 -05:00
comfyanonymous
6d281b4ff4 Add a /free route to unload models or free all memory.
A POST request to /free with: {"unload_models":true}
will unload models from vram.

A POST request to /free with: {"free_memory":true}
will unload models and free all cached data from the last run workflow.
2024-01-04 17:15:22 -05:00
comfyanonymous
04b713dda1 Fix VALIDATE_INPUTS getting called multiple times.
Allow VALIDATE_INPUTS to only validate specific inputs.
2023-12-29 17:36:40 -05:00
comfyanonymous
a252963f95 --disable-smart-memory now unloads everything like it did originally. 2023-12-23 04:25:06 -05:00
comfyanonymous
6b769bca01 Do a garbage collect after the interval even if nothing is running. 2023-11-30 15:22:32 -05:00
comfyanonymous
2dd5b4dd78 Only show last 200 elements in the UI history tab. 2023-11-20 16:56:29 -05:00
comfyanonymous
a03dde190e Cap maximum history size at 10000. Delete oldest entry when reached. 2023-11-20 16:38:39 -05:00
comfyanonymous
20d3852aa1 Pull some small changes from the other repo. 2023-10-11 20:38:48 -04:00
pythongosssss
62799c8585 fix crash on node with VALIDATE_INPUTS and actual inputs 2023-09-07 18:42:21 +01:00
comfyanonymous
89a0767abf Smarter memory management.
Try to keep models on the vram when possible.

Better lowvram mode for controlnets.
2023-08-17 01:06:34 -04:00
Michael Poutre
90b0163524
fix(execution): Fix support for input-less nodes 2023-08-01 12:29:01 -07:00
Michael Poutre
7785d073f0
chore: Fix typo 2023-08-01 12:27:50 -07:00
comfyanonymous
09386a3697 Fix issue with lora in some cases when combined with model merging. 2023-07-21 21:27:27 -04:00
comfyanonymous
6e9f28401f Persist node instances between executions instead of deleting them.
If the same node id with the same class exists between two executions the
same instance will be used.

This means you can now cache things in nodes for more efficiency.
2023-06-29 23:38:56 -04:00
comfyanonymous
d52ed407a7 Send websocket message only when prompt is actually done executing. 2023-06-13 13:38:43 -04:00
comfyanonymous
af91df85c2 Add a /history/{prompt_id} endpoint. 2023-06-12 14:34:30 -04:00
comfyanonymous
ad81fd682a Fix issue with cancelling prompt. 2023-05-28 00:32:26 -04:00
space-nuko
03f2d0a764 Rename exception message field 2023-05-27 21:06:07 -05:00
space-nuko
52c9590b7b Exception message 2023-05-27 21:06:07 -05:00
space-nuko
62bdd9d26a Catch typecast errors 2023-05-27 21:06:07 -05:00
space-nuko
a9e7e23724 Fix 2023-05-27 21:06:07 -05:00
space-nuko
e2d080b694 Return null for value format 2023-05-27 21:06:07 -05:00