comfyanonymous / ComfyUI

The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface.
https://www.comfy.org/
GNU General Public License v3.0
52.48k stars 5.54k forks source link

Queue is populated with incorrect data when application is lagging. #1704

Open Lowkus opened 12 months ago

Lowkus commented 12 months ago

When a sufficiently complex workflow is being loaded, and scenarios are added to the queue quickly, the queued items do not always represent the values as they existed when the "Queue" button was pressed. To reproduce this problem, load a complex workflow that is somewhat difficult for your machine, set the seed to "fixed", then begin adding many items to your queue by manually incrementing the seed after each item is added to the queue (increment the seed, hit "Ctrl+Enter", increment the seed, "Ctrl+Enter", etc). The goal is to add the items rapidly enough the application has difficulty keeping up with your queue inserts, which is not difficult for a workflow that bogs down your computer. Once you've added some items to the queue, go to the queue's pending list and click the "load" on each pending scenario to see what actually was added to the queue - if things worked correctly then each queued item will show the seed incrementing by a value of one. What you will likely see instead is the seed staying unchanged in several of the queued items and then suddenly increasing a large amount when the queued item happened to be added when the computer caught up. The correct behavior for the application would be that when an item is added to the queue it would use exactly the values the user saw at the moment they clicked the "Queue" button. To fix the bug, either the "Queue" insert event needs to be disabled until the application is done processing any previous queue insert, or ideally the program should be designed so the workflow and values are cached instantly and that cache would be used to populate the queue so if the application is lagging it will still be able to fetch the data from the cache to populate the queue.

NeedsMoar commented 12 months ago

What hardware are you running / comfy version / operating system?

Lowkus commented 12 months ago

Win10 x64 Pro. 3090 video card. Ryzen 5950X processor. 128GB RAM. I'm running the latest ComfyUI, according to Manager Menu.

NeedsMoar commented 11 months ago

That's incredibly odd then, since it's unlikely you'd be getting bogged down by... well, anything unless there's some firewall software somehow lagging localhost pings (or you're just younger and have better reflexes than me lol). The only thing I can think of is that there may still be some issues with NVidia drivers and Chrome if that's what you're using; I'm using firefox and no issues there with the recently added 4090. Maybe try another browser just to make sure it isn't that, but if your system is stable I wouldn't even bother with the XMP speeds on a model that new unless you're running insanely high speeds.

Since it involves complex workloads and you have enough vram and system ram I'm wondering if --gpuonly might help (or even --highvram which wasn't auto-detected on my 4090). A 5950x is no slouch but some of the early stage non-gpu stuff can be awful on CPU, and some of the other nodes pull stuff off the GPU and do a bunch of manipulation on it for no reason. Some of the pre-processing being done. Still puzzling because the client-server stuff should be instant on loopback.

Lowkus commented 11 months ago

I'm using FireFox and have no firewall during my testing. My workflow has 80 KSamplers each with a slightly different CFG and each being sent to a preview and a file save. I think all those modules and wires make it slow when I add to the queue. If I could get a For Next loop working I could use just one KSampler and everything would be fine. But it seems like the ComfyUI queue design is still flawed if it allows someone to outrun the queue, and could be a problem for many people with slower computers.

Lowkus commented 11 months ago

I'm beginning to think the queue has massive problems. When items are being processed I've seen queue items get rearranged if there is a "Queue Front" item in the list, for example when I look at my pending queue list right now it shows (-151, 148, 150, 149) and while I put 151 at the beginning of the queue I did not manipulate 149 into the back of the queue. I've also noticed that at the current queue counts near 150 items I am seeing a lag of about three seconds between clicking the "Queue" button and seeing the item show up in the queue list. Someone in a thread somewhere mentioned that ComfyUI needs a refactoring and I think I will agree with that, without seeing what the code currently looks like the behavior of the program leads me to believe there might be a mess of spaghetti under the hood.