ComfyUI icon indicating copy to clipboard operation
ComfyUI copied to clipboard

Parallel Execution of Independent Nodes

Open torealise opened this issue 1 year ago • 1 comments

Can we implement parallel execution of independent nodes in ComfyUI to improve performance?

Description:

Allow nodes that do not depend on each other to run simultaneously. This can optimize resource usage and reduce processing time.

Examples:

Image Processing:

  • Node A: Loads Image 1, preprocesses it, and sends it to ControlNet.
  • Node B: Loads Image 2 and sends it to IPAdapter.
  • Node C: Segments Image 3.

All these operations can run in parallel.

Benefits:

  • Faster execution.
  • Better use of CPU/GPU resources.
  • More efficient handling of complex workflows.

If determining which nodes are independent is complex, this configuration could be set manually for each workflow.

Would it be possible to add this feature?

torealise avatar May 21 '24 19:05 torealise

This requires an overhaul of the execution model and in-depth consideration of various corner cases.

For example, tasks that require VRAM should not operate in parallel. Otherwise, you'll encounter the nightmare of VRAM shortage. There are complex issues such as policy decisions on which tasks should run in parallel and which should not, and how to ensure that each node developer correctly applies these policies without errors.

To implement this, it is not a matter that can be addressed simply in an issue. It will need to be refined through lengthy discussions in a discussion forum.

ltdrdata avatar May 22 '24 01:05 ltdrdata

This requires an overhaul of the execution model and in-depth consideration of various corner cases.

For example, tasks that require VRAM should not operate in parallel. Otherwise, you'll encounter the nightmare of VRAM shortage. There are complex issues such as policy decisions on which tasks should run in parallel and which should not, and how to ensure that each node developer correctly applies these policies without errors.

To implement this, it is not a matter that can be addressed simply in an issue. It will need to be refined through lengthy discussions in a discussion forum.

Could we create a tool that allows users to manually specify which nodes can run in parallel for each specific workflow?

This would help calculate the VRAM load for each case and use memory more efficiently. This way, we can avoid VRAM shortages and handle complex workflows more effectively.

By letting users decide which tasks run in parallel, we solve the problems with automatic parallelization and give them control over resource use.

torealise avatar May 22 '24 15:05 torealise