Comfy-Org / Comfy-Org/ComfyUI_frontend

[Feature] Add a pause button

Open
#6,439 1 comment 4 reactions 0 assignees View on GitHub
area:workflows enhancement Feature
Dominant language
TypeScript
Stars
2k
Forks
699
Avg merge
1d 7h
Merged PRs (30d)
490

Description

### Feature Idea

Problem: when I launch 10 tasks on ComfyUI, I only have a choice to let them run or stop them
If I want to keep the 10 task in the background without them running, I need to shut down everything.
I still need to keep the remaining tasks without losing them, but yet I still need to pause comfy and potentially liberating a portion of the GPU.
The idea is to have a true pause that let you keep the state of comfy with its remaning taks, but delay their execution until you unpause. In the meantime the pause can alllow you to liberate the memory gpu etc.
That or (https://github.com/comfyanonymous/ComfyUI/issues/6163) as alternative.

### Existing Solutions

_No response_

### Other

_No response_

---

*This issue is transferred from: https://github.com/comfyanonymous/ComfyUI/issues/6164*

Original issue was created by @moreAImore at 2024-12-22T17:20:51.000Z

**Original Comments:**

@Mooshieblob1:

The implementation of a true pause system would face several significant technical challenges:

1. PyTorch/GPU Memory Management:
- GPU memory handling in PyTorch doesn't have a native suspend state
- Unloading models while preserving state would require complex memory management
- Risk of memory fragmentation when releasing/reacquiring GPU resources

2. Queue State Preservation:
- Current queue system is designed for sequential execution
- Would need to implement serialization for:
- Full workflow state
- Intermediate results
- Model states
- Random seeds and other execution parameters
- Storage and restoration of partial execution states

3. Resource Management Complexity:
- Need to track and properly release all GPU resources
- Handle cleanup of temporary buffers and intermediate results
- Manage VRAM allocation/deallocation safely
- Ensure proper resource restoration on resume

4. Implementation Risks:
- Memory leaks from incomplete resource tracking
- State inconsistency after pause/resume cycles
- Performance impact from serialization/deserialization
- Increased disk I/O from state storage
- Potential race conditions in the execution pipeline

@moreAImore:

> The implementation of a true pause system would face several significant technical challenges:

>
> 1. PyTorch/GPU Memory Management:
>
> * GPU memory handling in PyTorch doesn't have a native suspend state
> * Unloading models while preserving state would require complex memory management
> * Risk of memory fragmentation when releasing/reacquiring GPU resources
>
> 2. Queue State Preservation:
>
> * Current queue system is designed for sequential execution
> * Would need to implement serialization for:
>
> * Full workflow state
> * Intermediate results
> * Model states
> * Random seeds and other execution parameters
> * Storage and restoration of partial execution states
>
> 3. Resource Management Complexity:
>
> * Need to track and properly release all GPU resources
> * Handle cleanup of temporary buffers and intermediate results
> * Manage VRAM allocation/deallocation safely
> * Ensure proper resource restoration on resume
>
> 4. Implementation Risks:
>
> * Memory leaks from incomplete resource tracking
> * State inconsistency after pause/resume cycles
> * Performance impact from serialization/deserialization
> * Increased disk I/O from state storage
> * Potential race conditions in the execution pipeline

Interesting.
So instead of facing all of these, would it possible to simply save all the remaining tasks into a bucket that can be loaded back? (All tasks saved into api calls sort of, and user can retrieve them)

This will allow some kind pause,
because you can save the state (at least remaining tasks), shut down the system, then come back later when you RERUN comfy.
See issue 6163.

@patientx:

There is a save-load queues custom node (can't remember the name atm), it gives error when installed but works great, say you added a bunch of work on the queue but want to stop and want to continue where you left of (from the very start of current running workflow) you save the queue. close comfy after you open it again when you "load" the queue you saved it immediately starts doing it one by one. Not perfect but really helps when you keep adding stuff and have to log off etc. something like it officially would be great. And for "Pausing" on windows when you select anything on the cmdline window this pauses everything comfy is doing, press space again and it continues the work. This is good when you want to use your gpu for a quick task outside comfy. Of course there are times this cannot go back to work correctly and gives error. Most of the time works ok I guess.

@Rapha0815:

Any news here? I'm not deep enough into this topic, so I couldn't help technically with that. Anyway it would be an interesting feature.

@tarvcode:

Looking for this feature as well. The limitations mentioned would it apply if you just paused between pending items?

Two items queued up. Hit pause, it will stop when the first item is finished and before the second one starts?

Same as clearing pending tasks, waiting for the first process to finish, then re-running the task you cleared.

For sure not reasonable to pause mid-workflow.

@patientx:

As I previously commented , use the trick with commandline window, click on it , it pauses, do whatever you want , right click , it continues. 

And there is another solution not exactly pausing but if you have a few items in queue and want to stop but don't want to lose the upcoming gens, use the savequeues node , "https://github.com/pkpkTech/ComfyUI-SaveQueues" it only works with classic menu and it gives an error when starting comfyui saying it cant be loaded but it loads and works very well. I use it all the time.

@Rapha0815:

I'm using a workaround meanwhile.

Part 1 of the workflow comes within one group, part 2 another group. I start the workflow with group 2 deactivated, and group 1 uses the "cache node" from https://github.com/WASasquatch/was-node-suite-comfyui as last node.

If I wanna continue, I activate group 2, deactivate group 1, and my group 2 starts with "load cache" node from the same repository, works very well for my case.

Just right now I found this with Google:

https://github.com/wywywywy/ComfyUI-pause

Didn't try yet, but at least it looks interesting for this case.

┆Issue is synchronized with this [Notion page](https://www.notion.so/Issue-6439-Feature-Add-a-pause-button-29c6d73d365081aeb894effa85e2abae) by [Unito](https://www.unito.io)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.