Extraltodeus / pre_cfg_comfy_nodes_for_ComfyUI

A set of nodes to prepare the noise predictions before the CFG function
https://www.patreon.com/extraltodeus
32 stars 3 forks source link

[QUESTION] Using Time-stepping for the negative condition #3

Open gamaraala666 opened 1 month ago

gamaraala666 commented 1 month ago

Hi with all the projects you've built around dealing with cfg, I hope you'll have the answer for a small question that's nagging me. So, yes, it's obvious that limiting the steps is a no-brainer for the negative condition with your nodes for the speed gain alone. But the question is, when ? Everywhere you mention this I've noted that you recommend turning it off after about halfway through the steps. However, I read on reddit that it was better to do the inverse. The negative conditioning should only begin to start effecting halfway through the steps. The logic being that at and near the beginning, there is just pure noise and negative conditioning isn't that effective during this time. Although I haven't personally tested this theory extensively, In practice I've found it to be a pretty good guideline for when to time-step the negative conditioning. My go to point being around 0.4. But, clearly, you, with all your understanding around how cfg works, think differently. Can you maybe explain about why I might want to stop doing it and have it on for only the first half?

Extraltodeus commented 1 month ago

All I know is through testing and I have no background on the matter.

But indeed there are many points of view about this.

Like this research paper often referenced as "Limited interval" which, in short, is about starting the negative at 5.42 and ending at 0.28 with a CFG scale at 16. Showing that you can obtain better randomness and nices images. Using Euler and 32 steps if I remember correctly. But I found it hard to adapt to other samplers and scales in general.

Then also, isn't the postive vs negative role with the CFG is to distinguish your prompt from "anything else"? Wouldn't it make more sense to leave it empty? I think that this is the original purpose or the negative prediction. "What you want" vs "All the model's hallucinations".

But then what? Knowing this you could try a lower CFG at the start (I uploaded my testing version on another branch in which there is a node named "Pre CFG timed CFG rescale"), perp neg, zero_out at the start, starting it later like for the research paper (I find to have more often messy results, maybe skipping only the first step?).

To zero out at the start:

image

And then about when to end the negatives, I think it is more of question of speed vs finishing. If you cut at 0.28 there is practically no difference in quality. At 1 (I'm talking about sigma of course) you may have some bokeh, but it may also fix artifacts such this as this more easily:

ComfyUI_00675_

As far as I am concerned, I tend to leave them enabled normally and cut them for the speed gain. Mostly because I find the images to not be gaining enough randomness by cutting them at the start.

I also intended "skimmed CFG" to try to get some sort of non-contradictive negative prediction. The base node is the result of this attempt. I do not know which math magic they used in the "Limited interval" research paper but I would be curious to know if any setting with it could prove being useful regarding this.

On the skimmed CFG readme, I believe that the least contradictive setting is the last image.

Or to make it much much shorter: I'm not too sure neither 😅 / it makes sense to cut it at least for 1-2 steps at the beginning.

In the end, to gain randomness I prefer to use partially destructive alterations such as using Skimmed_CFG with "stupid" high scales or more rarely with SDXL to cut the influence of the input layer 8 temporarily.

gamaraala666 commented 1 month ago

Thanks for giving me lots of things to unpack. Im gonna waste the next few days on testing this thing as carefully as I can.

But one thing I don't understand in your answer, is that example you showed on how to zero out the start. I feel like i must be missing something obvious or maybe I don't know the basics, so please bear with me.

To my eyes, in that example, it's the ending 90% of the steps that's zeroed out... but in that case, I can't figure out what you meant was zeroed out when you wrote 'To zero out at the start:'?

Extraltodeus commented 1 month ago

You're right! I mixed up the settings >.<

Extraltodeus commented 1 month ago

And this:

image

Is also a non-contradictive setting which works actually well.

gamaraala666 commented 1 month ago

ah, well, huge thanks for all the info, and sharing all your thoughts about this ❤️.
Like i said, its time for me to do some carefully controlled tests. p.s. - skimmedCFG is crazy. you hit it out of the park with that one. I find the dual scale version very interesting. I still don't completely "get" all of the why, or how, it works the way it does. But boy, its a lot of fun figuring it out. Its a permanent fixture in my flows now. cheers!

Extraltodeus commented 1 month ago

I saw your comment appear right now lol.

You made me thing and I went ahead and added a new node to skimmed CFG. It cuts the contradictions at the start, in reference to the Limited Guidance paper.

p.s. - skimmedCFG is crazy. you hit it out of the park with that one. I find the dual scale version very interesting. I still don't completely "get" all of the why, or how, it works the way it does. But boy, its a lot of fun figuring it out. Its a permanent fixture in my flows now.

thank you <3

Extraltodeus commented 1 month ago

I reopen it for the curious :)