102 Commits

Author SHA1 Message Date
Chenlei Hu
8008d2fe7a Lint and fix undefined names (2/N) (#6029) 2024-12-12 18:48:21 -05:00
Chenlei Hu
9bffd67fc9 Lint unused import (#5973)
* Lint unused import

* nit

* Remove unused imports

* revert fix_torch import

* nit
2024-12-09 15:24:39 -05:00
comfyanonymous
5fa5239b2c Set env vars to disable telemetry in libs used by some custom nodes. 2024-12-07 14:51:45 -05:00
comfyanonymous
1176023ebb Improved memory management. (#5450)
* Less fragile memory management.

* Fix issue.

* Remove useless function.

* Prevent and detect some types of memory leaks.

* Run garbage collector when switching workflow if needed.

* Fix issue.
2024-12-02 14:39:34 -05:00
Bratzmeister
13e3497a6b fix --cuda-device arg for AMD/HIP devices (#5586)
* fix --cuda-device arg for AMD/HIP devices

CUDA_VISIBLE_DEVICES is ignored for HIP devices/backend. Instead it uses HIP_VISIBLE_DEVICES. Setting this environment variable has no side effect for CUDA/NVIDIA so it can safely be set in any case and vice versa.

* deleted accidental if
2024-11-12 06:53:36 -05:00
comfyanonymous
3da2c77971 Let --verbose have an argument for the log level. 2024-10-04 10:05:34 -04:00
comfyanonymous
65e107564d Support listening on multiple addresses. 2024-09-23 04:36:59 -04:00
comfyanonymous
871a618247 Create the temp directory on ComfyUI startup instead. 2024-09-18 09:55:57 -04:00
Robin Huang
2db65988c5 Add cli arg to override user directory (#4856)
* Override user directory.

* Use overridden user directory.

* Remove prints.

* Remove references to global user_files.

* Remove unused replace_folder function.

* Remove newline.

* Remove global during get_user_directory.

* Add validation.
2024-09-12 08:10:27 -04:00
comfyanonymous
de083b8cdb Cleanup. 2024-09-10 00:43:37 -04:00
Robin Huang
70e9391d31 Expand user directory for basepath in extra_models_paths.yaml (#4857)
* Expand user path.

* Add test.

* Add unit test for expanding base path.

* Simplify unit test.

* Remove comment.

* Remove comment.

* Checkpoints.

* Refactor.
2024-09-10 00:33:44 -04:00
comfyanonymous
211789cb55 Add an experimental LoraSave node to extract model loras.
The model_diff input should be connected to the output of a
ModelMergeSubtract node.
2024-09-04 16:38:38 -04:00
Chenlei Hu
2ff5eb9c72 Get logs endpoint & system_stats additions (#4690)
* Add route for getting output logs

* Include ComfyUI version

* Move to own function

* Changed to memory logger

* Unify logger setup logic

* Fix get version git fallback

---------

Co-authored-by: pythongosssss <125205205+pythongosssss@users.noreply.github.com>
2024-08-30 12:46:37 -04:00
comfyanonymous
a86fa7a05e unet -> diffusion_models. 2024-08-17 21:31:04 -04:00
guill
f12ab2e978 Execution Model Inversion (#2666)
* 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.

* Allow `input_info` to be of type `None`

* Handle errors (like OOM) more gracefully

* 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.

* Fix an overly aggressive assertion.

This could happen when attempting to evaluate `IS_CHANGED` for a node
during the creation of the cache (in order to create the cache key).

* Fix Pyright warnings

* Add execution model unit tests

* 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.

* 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.

* Fix example in unit test

This wouldn't have caused any issues in the unit test, but it would have
bugged the UI if someone copy+pasted it into their own node pack.

* Use fstrings instead of '%' formatting syntax

* Use custom exception types.

* 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.

* Add docs on when ExecutionBlocker should be used

* Remove unused functionality

* Rename ExecutionResult.SLEEPING to PENDING

* Remove superfluous function parameter

* Pass None for uneval inputs instead of default

This applies to `VALIDATE_INPUTS`, `check_lazy_status`, and lazy values
in evaluation functions.

* 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.

* Raise exception for bad get_node calls.

* Minor refactor of IsChangedCache.get

* Refactor `map_node_over_list` function

* Fix ui output for duplicated nodes

* Add documentation on `check_lazy_status`

* Add file for execution model unit tests

* Clean up Javascript code as per review

* Improve documentation

Converted some comments to docstrings as per review

* Add a new unit test for mixed lazy results

This test validates that when an output list is fed to a lazy node, the
node will properly evaluate previous nodes that are needed by any inputs
to the lazy node.

No code in the execution model has been changed. The test already
passes.

* Allow kwargs in VALIDATE_INPUTS functions

When kwargs are used, validation is skipped for all inputs as if they
had been mentioned explicitly.

* List cached nodes in `execution_cached` message

This was previously just bugged in this PR.
2024-08-15 11:21:11 -04:00
Robin Huang
555482cd09 Add model downloading endpoint. (#4248)
* Add model downloading endpoint.

* Move client session init to async function.

* Break up large function.

* Send "download_progress" as websocket event.

* Fixed

* Fixed.

* Use async mock.

* Move server set up to right before run call.

* Validate that model subdirectory cannot contain relative paths.

* Add download_model test checking for invalid paths.

* Remove DS_Store.

* Consolidate DownloadStatus and DownloadModelResult

* Add progress_interval as an optional parameter.

* Use tuple type from annotations.

* Use pydantic.

* Update comment.

* Revert "Use pydantic."

This reverts commit 7461e8eb0073add315c65c6f5e361f0891bffc7d.

* Add new line.

* Add newline EOF.

* Validate model filename as well.

* Add comment to not reply on internal.

* Restrict downloading to safetensor files only.
2024-08-13 15:48:52 -04:00
comfyanonymous
d789c0d485 Add code to fix issues with new pytorch version on the standalone. 2024-07-24 12:49:29 -04:00
comfyanonymous
89170e492f Remove duplicate import. 2024-07-05 12:10:22 -04:00
comfyanonymous
5b86befc8c Show comfy_extras warning at the end.
Remove code.
2024-07-04 21:44:27 -04:00
Chenlei Hu
161107fd8d Add --no-custom-node cmd flag (#3903)
* Add --no-custom-node cmd flag

* nit
2024-07-01 17:54:03 -04:00
Garrett Sutula
533ddd78a0 Add TLS Support (#3312)
* Add TLS Support

* Add to readme

* Add guidance for windows users on generating certificates

* Add guidance for windows users on generating certificates

* Fix typo
2024-04-30 20:17:02 -04:00
comfyanonymous
cd92ad35a9 Move cleanup_models to improve performance. 2024-03-23 17:27:10 -04:00
comfyanonymous
9956e2b6e7 Switch some more prints to logging. 2024-03-11 16:34:58 -04:00
comfyanonymous
27a4ddb814 Update the old updater if present when running on the windows standalone. 2024-02-26 13:32:14 -05:00
comfyanonymous
28712a5446 Rename status notes to status messages.
I think message describes them better.
2024-01-12 18:17:06 -05:00
realazthat
e57852b5e9 Add error, status to /history endpoint 2024-01-11 10:16:42 -05:00
comfyanonymous
7f99d58877 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
c20e0480fe Add node id and prompt id to websocket progress packet. 2024-01-01 14:27:56 -05:00
comfyanonymous
65ada00818 Add --deterministic option to make pytorch use deterministic algorithms. 2023-12-17 16:59:21 -05:00
comfyanonymous
02b4cb5a7a Do a garbage collect after the interval even if nothing is running. 2023-11-30 15:22:32 -05:00
comfyanonymous
55aed6cc38 Limit gc.collect() to once every 10 seconds. 2023-11-28 14:20:56 -05:00
comfyanonymous
4860d4c7fe Add default CheckpointSave, CLIPSave and VAESave paths to model paths. 2023-10-10 01:25:47 -04:00
Jairo Correa
26a1afbcfe Option to input directory 2023-10-04 19:45:15 -03:00
comfyanonymous
a3e0950ffb Only parse command line args when main.py is called. 2023-09-13 11:38:20 -04:00
comfyanonymous
c40f363254 Allow cancelling of everything with a progress bar. 2023-09-07 23:37:03 -04:00
comfyanonymous
f8c3b7270e Add a warning if a card that doesn't support cuda malloc has it enabled. 2023-08-13 12:37:53 -04:00
comfyanonymous
64510bb4c2 Add --temp-directory argument to set temp directory. 2023-08-11 05:13:03 -04:00
comfyanonymous
327956d2f0 0.0.0.0 doesn't work on windows. 2023-08-01 01:15:18 -04:00
comfyanonymous
dd46c9e941 Move image encoding outside of sampling loop for better preview perf. 2023-07-19 18:06:58 -04:00
comfyanonymous
d1b7051401 Auto disable cuda malloc on some GPUs on windows. 2023-07-19 14:43:55 -04:00
comfyanonymous
5108099f0c Enable --cuda-malloc by default on torch 2.0 and up.
Add --disable-cuda-malloc to disable it.
2023-07-17 15:12:10 -04:00
comfyanonymous
5ddb2ca26f Add a command line argument to enable backend:cudaMallocAsync 2023-07-17 11:00:14 -04:00
comfyanonymous
8fbbd78d3b Print prestartup times for custom nodes. 2023-07-13 13:01:45 -04:00
Dr.Lt.Data
1211003e34 feat/startup-script: Feature to avoid package installation errors when installing custom nodes. (#856)
* support startup script for installation without locking on windows

* modified: Instead of executing scripts from the startup-scripts directory, I will change it to execute the prestartup_script.py for each custom node.
2023-07-11 02:33:21 -04:00
comfyanonymous
033dc1f52a Cleanup. 2023-07-02 11:58:23 -04:00
comfyanonymous
051f79bc8e Send websocket message only when prompt is actually done executing. 2023-06-13 13:38:43 -04:00
reaper47
aaf4d5b7ee Give linux some love 2023-06-07 15:15:38 +02:00
space-nuko
a3b400faa4 Make previews into cli option 2023-06-05 13:19:02 -05:00
space-nuko
b3667fed30 Fix 2023-06-05 09:20:20 -05:00
space-nuko
a816ca9091 Preview sampled images with TAESD 2023-06-05 09:20:17 -05:00