Additon of new CFG Methods

#12
by xi0v - opened

Hello!
Is it possible to get this supported?
https://huggingface.co/docs/diffusers/main/en/using-diffusers/pag (should have an enable/disable button)

And cfg rescale (rescale classifier-free guidance which I believe is labeled as guidance_rescale in diffusers) (should have an enable/disable button)

Also is it possible to implement CFG++ Samplers?

PAG is possible. Or rather, stablepy supports it, but I just haven't made a GUI for it. I'm just being lazy.πŸ˜†
I wonder what the rest of it is like...?
For better or worse, it's abstracted using stablepy, so it'll probably break if it's not supported by stablepy.
DiffuseCraft is a demo for stablepy, so most of the things that stablepy itself can do have been implemented. So, if it's a feature that DiffuseCraft has, I can add it straight away. If it's a feature that DiffuseCraft doesn't have, but is supported by the pip version of Diffusers, r3gm will probably support it quite quickly, like he did with the scheduler the other day.
He is a busy but friendly and proactive person, so he will probably answer your questions unless they are unreasonable requests in a programmatic context.
If it's something really simple, I can even submit a PR.
https://huggingface.co/spaces/r3gm/DiffuseCraft/discussions?status=open&type=discussion
https://github.com/R3gm/stablepy

Edit:
Since we're here, let's identify the features that DiffuseCraft (stablepy) is missing. It would be easier if we put together a list of ideas. He writes 100 times faster and more accurately than I do...
This is purely a difference in coding ability...

Edit:
Also, tell me which features you want to see prioritized that are not yet in VP, but are in DiffuseCraft. I'll add PAG first.

I added PAG scale and FreeU.

I added PAG scale and FreeU.

Thanks!

Since we're here, let's identify the features that DiffuseCraft (stablepy) is missing. It would be easier if we put together a list of ideas. He writes 100 times faster and more accurately than I do...
This is purely a difference in coding ability...

There is a kind of scheduler/samplers that are very promising, I'd love to see them supported in stablepy. They're called CFG++ or cfgpp in comfyui, https://arxiv.org/abs/2406.08070
Aside from this I think stablepy is feature complete till now.

I also believe that img2img in VP (supported by diffuse craft) would be very good, controlnets and IPAdapters would be great too !

Also inference with lycoris!
I can't use LoKrs or LoHAs on VP or DiffuseCraft. there are alot of LyCORISs out there that are better than LoRAs but I'm unable to use them since they're not supported in stablepy (neither are they in diffusers) so this'll probably be a great addition

Thanks.
I've also been wondering about LyCORIS, and I can use it if I call it directly from PEFT, but as you say, there is no way to call it from Diffusers. I think r3gm has the ability to create functions that are not in Diffusers, but I think the wrapping of Diffusers is the theme of stablepy, so it would be better to improve Diffusers itself first...
The issue with the LyCORIS implementation is how to determine that it is a LyCORIS file. I think this is also true for other LoRA variants.

Is CFG++ supported by Diffusers?

Edit:
Oh... its similar rescale.

Typically, LyCoris algorithms/models contain an identifier called "hada" in the keys which I believe stands for "hadamard product"

https://github.com/KohakuBlueleaf/LyCORIS/blob/main/docs/Algo-Details.md

This is also discovered here by sayakpaul
https://github.com/huggingface/diffusers/issues/4133

There was also an issue about this here https://github.com/huggingface/diffusers/issues/3087

I also found this gist about lycoris inference
https://gist.github.com/adhikjoshi/2c6da89cbcd7a6a3344d3081ccd1dda0


Is CFG++ supported by Diffusers?

I believe not.

Tho reForge webui implemented it
https://github.com/Panchovix/stable-diffusion-webui-reForge

https://cfgpp-diffusion.github.io/

I have informed r3gm about guidance_rescale. Good night.πŸ˜ͺ

This is also discovered here by sayakpaul

There may be some issues with sayakpaul knowing about it but not having it implemented...
It looks like it still hasn't been implemented even with this major LoRA renovation.

Edit:
PEFT's one.
https://huggingface.co/docs/peft/package_reference/adapter_utils

Edit:
CFG++ is not easy even in Forge (nor reForge)?
https://github.com/lllyasviel/stable-diffusion-webui-forge/discussions/1864

Maybe it's due to RAM usage? Is clearing the least used model supported?

It's possible.

Is clearing the least used model supported?

A certain amount of memory is freed up by default, but it may not be enough.
I turned off stablepy's cache option for now.

It slows down a lot if RAM usage is maxed out.
RAM
69/69 GB

Is it possible to clean up zeroGPU RAM as well?

I understand VRAM consuming, but I wonder what is consuming the RAM...πŸ˜…
For now, I've added gc.collect(). It's a spell. Goodnight.

How does it work? Is 69 the sum of CPU RAM and GPU RAM?

maybe CPU RAM. VRAM of zero is 40GB.πŸ˜ͺ
gc is just a garbage collector.

Oh, okay. Good night!

Sign up or log in to comment