Skip to content

Add final_sigma_zero to UniPCMultistep#7517

Merged
yiyixuxu merged 3 commits intohuggingface:mainfrom
Beinsezii:unipc_zero_sigma
Mar 30, 2024
Merged

Add final_sigma_zero to UniPCMultistep#7517
yiyixuxu merged 3 commits intohuggingface:mainfrom
Beinsezii:unipc_zero_sigma

Conversation

@Beinsezii
Copy link
Copy Markdown
Contributor

@Beinsezii Beinsezii commented Mar 29, 2024

Effectively the same trick as DDIM's set_alpha_to_one and DPM's final_sigma_type='zero' where the extra concatenated sigma is simply zero instead of the prior sigma. Completely fixes the goofy residual noise, particularly with lower step counts.

1st and 2nd order UniPC without the patch
unipc_base
1st and 2nd order UniPC with final_sigma_zero=True
unipc_sig0
Third order errors out for me even on a clean main branch so that's fun. I'll monkey with it later...

Currently False by default but maybe this should be True like DDIM/DPM?

This could also be represented as the same final_sigma_type='zero'|'sig_min' that DPM uses, but I don't really see why it needs to be a string with only two options. Personally I find this scheme much more intuitive.

No UT right now as I didn't see anything for final_sigma_type='zero' in DPM's UTs.

@yiyixuxu

Effectively the same trick as DDIM's `set_alpha_to_one` and
DPM's `final_sigma_type='zero'`.
Currently False by default but maybe this should be True?
Copy link
Copy Markdown
Collaborator

@yiyixuxu yiyixuxu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ohh thanks for doing this!

could we do final_sigma_type='zero'|'sig_min' like DPM scheduler? we always prefer the string type of argument because it is more flexible. e.g. right now we only have two options, but it will allow us to add more options in the future without increase the number of parameters

@HuggingFaceDocBuilderDev
Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Should 1:1 match DPM Multistep now.
@Beinsezii
Copy link
Copy Markdown
Contributor Author

I updated it to use the same values as DPM Multistep, defaulting to "zero" and raising val err on unknown type.

What other possible types might there be? I thought for a bit and nothing really made sense besides sigmas[-1] and zero. I guess you could try to follow the curve by interpolating sigmas [-2:] to create a new non-zero, but that'd still have some residual noise I'd think.

Also if it's Optional[str] should we handle None? Currently I don't as that's how the code is in DPM Multistep.

@yiyixuxu
Copy link
Copy Markdown
Collaborator

looks like some tests are failing because we changed the default
let's add final_sigmas_type = sigma_min to the config for the test?

@yiyixuxu
Copy link
Copy Markdown
Collaborator

yiyixuxu commented Mar 30, 2024

What other possible types might there be?

it is hard to predict what's possible in the future, so as a general rule we are trying to always use string type of argument whenever possible

Also if it's Optional[str] should we handle None

we don't have to handle None :)

@Beinsezii
Copy link
Copy Markdown
Contributor Author

pytest tests/schedulers passes locally now

@yiyixuxu yiyixuxu merged commit f0c8156 into huggingface:main Mar 30, 2024
@yiyixuxu
Copy link
Copy Markdown
Collaborator

thank you!

Beinsezii added a commit to Beinsezii/quickdif that referenced this pull request Mar 30, 2024
This reverts commit 7478f32.

I fixed the noise issue upstream in
huggingface/diffusers#7517
Which was just merged
@Beinsezii Beinsezii deleted the unipc_zero_sigma branch April 3, 2024 21:01
noskill pushed a commit to noskill/diffusers that referenced this pull request Apr 5, 2024
* Add `final_sigma_zero` to UniPCMultistep

Effectively the same trick as DDIM's `set_alpha_to_one` and
DPM's `final_sigma_type='zero'`.
Currently False by default but maybe this should be True?

* `final_sigma_zero: bool` -> `final_sigmas_type: str`

Should 1:1 match DPM Multistep now.

* Set `final_sigmas_type='sigma_min'` in UniPC UTs
Beinsezii added a commit to Beinsezii/quickdif that referenced this pull request Apr 9, 2024
This reverts commit 0c1f156.

I fixed the noise issue upstream in
huggingface/diffusers#7517
Which was just merged
sayakpaul pushed a commit that referenced this pull request Dec 23, 2024
* Add `final_sigma_zero` to UniPCMultistep

Effectively the same trick as DDIM's `set_alpha_to_one` and
DPM's `final_sigma_type='zero'`.
Currently False by default but maybe this should be True?

* `final_sigma_zero: bool` -> `final_sigmas_type: str`

Should 1:1 match DPM Multistep now.

* Set `final_sigmas_type='sigma_min'` in UniPC UTs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants