Commit Graph

173 Commits

Author SHA1 Message Date
Dr.Lt.Data
ad4b959d7e Merge branch 'master' into dr-support-pip-cm 2025-10-31 07:31:50 +09:00
rattus
513b0c46fb
Add RAM Pressure cache mode (#10454)
* execution: Roll the UI cache into the outputs

Currently the UI cache is parallel to the output cache with
expectations of being a content superset of the output cache.
At the same time the UI and output cache are maintained completely
seperately, making it awkward to free the output cache content without
changing the behaviour of the UI cache.

There are two actual users (getters) of the UI cache. The first is
the case of a direct content hit on the output cache when executing a
node. This case is very naturally handled by merging the UI and outputs
cache.

The second case is the history JSON generation at the end of the prompt.
This currently works by asking the cache for all_node_ids and then
pulling the cache contents for those nodes. all_node_ids is the nodes
of the dynamic prompt.

So fold the UI cache into the output cache. The current UI cache setter
now writes to a prompt-scope dict. When the output cache is set, just
get this value from the dict and tuple up with the outputs.

When generating the history, simply iterate prompt-scope dict.

This prepares support for more complex caching strategies (like RAM
pressure caching) where less than 1 workflow will be cached and it
will be desirable to keep the UI cache and output cache in sync.

* sd: Implement RAM getter for VAE

* model_patcher: Implement RAM getter for ModelPatcher

* sd: Implement RAM getter for CLIP

* Implement RAM Pressure cache

Implement a cache sensitive to RAM pressure. When RAM headroom drops
down below a certain threshold, evict RAM-expensive nodes from the
cache.

Models and tensors are measured directly for RAM usage. An OOM score
is then computed based on the RAM usage of the node.

Note the due to indirection through shared objects (like a model
patcher), multiple nodes can account the same RAM as their individual
usage. The intent is this will free chains of nodes particularly
model loaders and associate loras as they all score similar and are
sorted in close to each other.

Has a bias towards unloading model nodes mid flow while being able
to keep results like text encodings and VAE.

* execution: Convert the cache entry to NamedTuple

As commented in review.

Convert this to a named tuple and abstract away the tuple type
completely from graph.py.
2025-10-30 17:39:02 -04:00
Dr.Lt.Data
de357a01f8 Merge branch 'master' into dr-support-pip-cm 2025-10-28 19:01:11 +09:00
comfyanonymous
8cf2ba4ba6
Remove comfy api key from queue api. (#10502) 2025-10-28 03:23:52 -04:00
Dr.Lt.Data
aaf06ace12 Merge branch 'master' into dr-support-pip-cm 2025-10-23 06:54:58 +09:00
rattus
4739d7717f
execution: fold in dependency aware caching / Fix --cache-none with loops/lazy etc (Resubmit) (#10440)
* execution: fold in dependency aware caching

This makes --cache-none compatiable with lazy and expanded
subgraphs.

Currently the --cache-none option is powered by the
DependencyAwareCache. The cache attempts to maintain a parallel
copy of the execution list data structure, however it is only
setup once at the start of execution and does not get meaninigful
updates to the execution list.

This causes multiple problems when --cache-none is used with lazy
and expanded subgraphs as the DAC does not accurately update its
copy of the execution data structure.

DAC has an attempt to handle subgraphs ensure_subcache however
this does not accurately connect to nodes outside the subgraph.
The current semantics of DAC are to free a node ASAP after the
dependent nodes are executed.

This means that if a subgraph refs such a node it will be requed
and re-executed by the execution_list but DAC wont see it in
its to-free lists anymore and leak memory.

Rather than try and cover all the cases where the execution list
changes from inside the cache, move the while problem to the
executor which maintains an always up-to-date copy of the wanted
data-structure.

The executor now has a fast-moving run-local cache of its own.
Each _to node has its own mini cache, and the cache is unconditionally
primed at the time of add_strong_link.

add_strong_link is called for all of static workflows, lazy links
and expanded subgraphs so its the singular source of truth for
output dependendencies.

In the case of a cache-hit, the executor cache will hold the non-none
value (it will respect updates if they happen somehow as well).

In the case of a cache-miss, the executor caches a None and will
wait for a notification to update the value when the node completes.

When a node completes execution, it simply releases its mini-cache
and in turn its strong refs on its direct anscestor outputs, allowing
for ASAP freeing (same as the DependencyAwareCache but a little more
automatic).

This now allows for re-implementation of --cache-none with no cache
at all. The dependency aware cache was also observing the dependency
sematics for the objects and UI cache which is not accurate (this
entire logic was always outputs specific).

This also prepares for more complex caching strategies (such as RAM
pressure based caching), where a cache can implement any freeing
strategy completely independently of the DepedancyAwareness
requirement.

* main: re-implement --cache-none as no cache at all

The execution list now tracks the dependency aware caching more
correctly that the DependancyAwareCache.

Change it to a cache that does nothing.

* test_execution: add --cache-none to the test suite

--cache-none is now expected to work universally. Run it through the
full unit test suite. Propagate the server parameterization for whether
or not the server is capabale of caching, so that the minority of tests
that specifically check for cache hits can if else. Hard assert NOT
caching in the else to give some coverage of --cache-none expected
behaviour to not acutally cache.
2025-10-22 15:49:05 -04:00
Dr.Lt.Data
8e1b1b722b Merge branch 'master' into dr-support-pip-cm 2025-10-21 12:34:57 +09:00
comfyanonymous
b7992f871a
Revert "execution: fold in dependency aware caching / Fix --cache-none with l…" (#10422)
This reverts commit b1467da480.
2025-10-20 19:03:06 -04:00
Dr.Lt.Data
9dd26b0349 Merge branch 'master' into dr-support-pip-cm 2025-10-18 07:22:23 +09:00
rattus128
b1467da480
execution: fold in dependency aware caching / Fix --cache-none with loops/lazy etc (#10368)
* execution: fold in dependency aware caching

This makes --cache-none compatiable with lazy and expanded
subgraphs.

Currently the --cache-none option is powered by the
DependencyAwareCache. The cache attempts to maintain a parallel
copy of the execution list data structure, however it is only
setup once at the start of execution and does not get meaninigful
updates to the execution list.

This causes multiple problems when --cache-none is used with lazy
and expanded subgraphs as the DAC does not accurately update its
copy of the execution data structure.

DAC has an attempt to handle subgraphs ensure_subcache however
this does not accurately connect to nodes outside the subgraph.
The current semantics of DAC are to free a node ASAP after the
dependent nodes are executed.

This means that if a subgraph refs such a node it will be requed
and re-executed by the execution_list but DAC wont see it in
its to-free lists anymore and leak memory.

Rather than try and cover all the cases where the execution list
changes from inside the cache, move the while problem to the
executor which maintains an always up-to-date copy of the wanted
data-structure.

The executor now has a fast-moving run-local cache of its own.
Each _to node has its own mini cache, and the cache is unconditionally
primed at the time of add_strong_link.

add_strong_link is called for all of static workflows, lazy links
and expanded subgraphs so its the singular source of truth for
output dependendencies.

In the case of a cache-hit, the executor cache will hold the non-none
value (it will respect updates if they happen somehow as well).

In the case of a cache-miss, the executor caches a None and will
wait for a notification to update the value when the node completes.

When a node completes execution, it simply releases its mini-cache
and in turn its strong refs on its direct anscestor outputs, allowing
for ASAP freeing (same as the DependencyAwareCache but a little more
automatic).

This now allows for re-implementation of --cache-none with no cache
at all. The dependency aware cache was also observing the dependency
sematics for the objects and UI cache which is not accurate (this
entire logic was always outputs specific).

This also prepares for more complex caching strategies (such as RAM
pressure based caching), where a cache can implement any freeing
strategy completely independently of the DepedancyAwareness
requirement.

* main: re-implement --cache-none as no cache at all

The execution list now tracks the dependency aware caching more
correctly that the DependancyAwareCache.

Change it to a cache that does nothing.

* test_execution: add --cache-none to the test suite

--cache-none is now expected to work universally. Run it through the
full unit test suite. Propagate the server parameterization for whether
or not the server is capabale of caching, so that the minority of tests
that specifically check for cache hits can if else. Hard assert NOT
caching in the else to give some coverage of --cache-none expected
behaviour to not acutally cache.
2025-10-17 13:55:15 -07:00
Dr.Lt.Data
47436c59d7 Merge branch 'master' into dr-support-pip-cm 2025-10-03 10:23:40 +09:00
comfyanonymous
e9364ee279
Turn on TORCH_ROCM_AOTRITON_ENABLE_EXPERIMENTAL by default. (#10168) 2025-10-02 17:57:15 -04:00
Dr.Lt.Data
20ac0052f8 Merge branch 'master' into dr-support-pip-cm 2025-09-29 06:58:35 +09:00
Rui Wang (王瑞)
1364548c72
feat: ComfyUI can be run on the specified Ascend NPU (#9663)
* feature: Set the Ascend NPU to use a single one

* Enable the `--cuda-device` parameter to support both CUDA and Ascend NPUs simultaneously.

* Make the code just set the ASCENT_RT_VISIBLE_DEVICES environment variable without any other edits to master branch

---------

Co-authored-by: Jedrzej Kosinski <kosinkadink1@gmail.com>
2025-09-27 22:36:02 -04:00
Dr.Lt.Data
036aa3efa8 fixed: Even if --enable-manager is applied, it should switch to a disabled state if comfyui_manager is not installed. 2025-09-19 07:38:10 +09:00
comfyanonymous
e7ff647d02 --disable-manager -> --enable-manager 2025-09-17 20:58:42 -04:00
Dr.Lt.Data
08e9c3ddf0 fixed: more robust detection of missing comfyui_manager 2025-09-04 11:51:11 +09:00
Dr.Lt.Data
f8aab7cab0 fixed: more robust detection of missing comfyui_manager 2025-09-04 11:49:48 +09:00
Dr.Lt.Data
561eaf6ccf fixed: Robust detection of missing comfyui_manager 2025-09-04 11:44:53 +09:00
Dr.Lt.Data
31469f962f fixed: issue of not properly detecting the removal of the comfyui_manager package in a conda environment. 2025-09-04 11:31:37 +09:00
Dr.Lt.Data
7fd87423b3 Merge branch 'master' into dr-support-pip-cm 2025-08-31 17:16:00 +09:00
comfyanonymous
9b15155972
Probably not necessary anymore. (#9646) 2025-08-31 01:32:10 -04:00
comfyanonymous
885015eecf
Lower ram usage on windows. (#9628) 2025-08-29 23:06:04 -04:00
Dr.Lt.Data
6087e0210c modified: Changed behavior so that if comfyui-manager is not installed, it provides an installation guide message instead of raising an exception. 2025-08-24 16:05:10 +09:00
Dr.Lt.Data
3c8196a170 Merge branch 'master' into dr-support-pip-cm 2025-07-30 12:14:34 +09:00
guill
0a3d062e06
ComfyAPI Core v0.0.2 (#8962)
* ComfyAPI Core v0.0.2

* Respond to PR feedback

* Fix Python 3.9 errors

* Fix missing backward compatibility proxy

* Reorganize types a bit

The input types, input impls, and utility types are now all available in
the versioned API. See the change in `comfy_extras/nodes_video.py` for
an example of their usage.

* Remove the need for `--generate-api-stubs`

* Fix generated stubs differing by Python version

* Fix ruff formatting issues
2025-07-29 22:17:22 -04:00
Dr.Lt.Data
4e904305ce Merge branch 'dr-support-pip-cm' 2025-07-24 12:22:50 +09:00
comfyanonymous
5ad33787de
Add default device argument. (#9023) 2025-07-23 14:20:49 -04:00
Dr.Lt.Data
16a0b24da4 Merge branch 'master' into dr-support-pip-cm 2025-07-12 09:19:32 +09:00
guill
2b653e8c18
Support for async node functions (#8830)
* Support for async execution functions

This commit adds support for node execution functions defined as async. When
a node's execution function is defined as async, we can continue
executing other nodes while it is processing.

Standard uses of `await` should "just work", but people will still have
to be careful if they spawn actual threads. Because torch doesn't really
have async/await versions of functions, this won't particularly help
with most locally-executing nodes, but it does work for e.g. web
requests to other machines.

In addition to the execute function, the `VALIDATE_INPUTS` and
`check_lazy_status` functions can also be defined as async, though we'll
only resolve one node at a time right now for those.

* Add the execution model tests to CI

* Add a missing file

It looks like this got caught by .gitignore? There's probably a better
place to put it, but I'm not sure what that is.

* Add the websocket library for automated tests

* Add additional tests for async error cases

Also fixes one bug that was found when an async function throws an error
after being scheduled on a task.

* Add a feature flags message to reduce bandwidth

We now only send 1 preview message of the latest type the client can
support.

We'll add a console warning when the client fails to send a feature
flags message at some point in the future.

* Add async tests to CI

* Don't actually add new tests in this PR

Will do it in a separate PR

* Resolve unit test in GPU-less runner

* Just remove the tests that GHA can't handle

* Change line endings to UNIX-style

* Avoid loading model_management.py so early

Because model_management.py has a top-level `logging.info`, we have to
be careful not to import that file before we call `setup_logging`. If we
do, we end up having the default logging handler registered in addition
to our custom one.
2025-07-10 14:46:19 -04:00
comfyanonymous
1fd306824d
Add warning to catch torch import mistakes. (#8852) 2025-07-10 01:03:27 -04:00
Dr.Lt.Data
9eba1547f4 Merge branch 'master' into dr-support-pip-cm 2025-06-29 15:31:19 +09:00
comfyanonymous
a3cf272522
Skip custom node logic completely if disabled and no whitelisted nodes. (#8719) 2025-06-28 15:53:40 -04:00
xufeng
ba9548f756
“--whitelist-custom-nodes” args for comfy core to go with “--disable-all-custom-nodes” for development purposes (#8592)
* feat: “--whitelist-custom-nodes” args for comfy core to go with “--disable-all-custom-nodes” for development purposes

* feat: Simplify custom nodes whitelist logic to use consistent code paths
2025-06-28 15:24:02 -04:00
Dr.Lt.Data
39f39c3aa9 Merge branch 'master' into dr-support-pip-cm 2025-06-21 23:51:13 +09:00
comfyanonymous
1883e70b43
Fix exception when using a noise mask with cosmos predict2. (#8621)
* Fix exception when using a noise mask with cosmos predict2.

* Fix ruff.
2025-06-21 03:30:39 -04:00
Lucas - BLOCK33
31ca603ccb
Improve the log time function for 10 minute + renders (#6207)
* modified:   main.py

* Update main.py
2025-06-20 23:04:55 -04:00
Dr.Lt.Data
d1ab6adc3a Merge branch 'master' into dr-support-pip-cm 2025-06-16 06:38:35 +09:00
comfyanonymous
d2566eb4b2
Add a warning for old python versions. (#8504) 2025-06-12 15:38:33 -04:00
pythongosssss
50c605e957
Add support for sqlite database (#8444)
* Add support for sqlite database

* fix
2025-06-11 16:43:39 -04:00
Dr.Lt.Data
ef641f3e4b Merge branch 'master' into dr-support-pip-cm 2025-05-26 02:23:34 +09:00
Michael Abrahams
8bb858e4d3
Improve performance with large number of queued prompts (#8176)
* get_current_queue_volatile

* restore get_current_queue method

* remove extra import
2025-05-21 05:14:17 -04:00
Dr.Lt.Data
9ac185456f Merge branch 'master' into dr-support-pip-cm 2025-05-19 06:04:10 +09:00
comfyanonymous
6a2e4bb9e0
Remove old hack used to fix windows pytorch 2.4 on the portable. (#8139)
Not necessary anymore.
2025-05-15 08:21:47 -04:00
Dr.Lt.Data
31aecbe1ad Merge branch 'master' into dr-support-pip-cm 2025-05-09 06:38:49 +09:00
comfyanonymous
094e9ef126
Add a way to disable api nodes: --disable-api-nodes (#7960) 2025-05-06 04:53:53 -04:00
Dr.Lt.Data
28d23a7813 Merge branch 'master' into dr-support-pip-cm 2025-05-03 22:38:35 +09:00
catboxanon
d9a87c1e6a
Fix outdated comment about Internet connectivity (#7827) 2025-05-02 05:28:27 -04:00
Dr.Lt.Data
14598c1104 Merge branch 'master' into dr-support-pip-cm 2025-04-28 23:22:56 +09:00
Dr.Lt.Data
57dae1469f modified: --disable-manager will prevent importing comfyui-manager
feat: --disable-manager-ui will disable the endpoints and ui of comfyui-manager
2025-04-28 17:56:50 +09:00