Skip to content

Add set_shift to FlowMatchEulerDiscreteScheduler #10269

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 17, 2024
Merged

Conversation

hlky
Copy link
Contributor

@hlky hlky commented Dec 17, 2024

What does this PR do?

from diffusers import FlowMatchEulerDiscreteScheduler

scheduler = FlowMatchEulerDiscreteScheduler()
scheduler.set_timesteps(20)
print(scheduler.sigmas, scheduler.timesteps)
"""
tensor([1.0000, 0.9474, 0.8948, 0.8423, 0.7897, 0.7371, 0.6845, 0.6319, 0.5794,
        0.5268, 0.4742, 0.4216, 0.3691, 0.3165, 0.2639, 0.2113, 0.1587, 0.1062,
        0.0536, 0.0010, 0.0000]) tensor([1000.0000,  947.4211,  894.8421,  842.2632,  789.6843,  737.1052,
         684.5263,  631.9474,  579.3684,  526.7895,  474.2105,  421.6316,
         369.0526,  316.4737,  263.8947,  211.3158,  158.7368,  106.1579,
          53.5789,    1.0000])
"""

scheduler.set_shift(7.0)
scheduler.set_timesteps(20)
print(scheduler.sigmas, scheduler.timesteps)
"""
tensor([1.0000, 0.9921, 0.9835, 0.9739, 0.9633, 0.9515, 0.9382, 0.9232, 0.9060,
        0.8863, 0.8633, 0.8361, 0.8037, 0.7642, 0.7151, 0.6522, 0.5691, 0.4540,
        0.2838, 0.0070, 0.0000]) tensor([1000.0000,  992.1342,  983.4892,  973.9432,  963.3475,  951.5190,
         938.2291,  923.1893,  906.0295,  886.2676,  863.2631,  836.1465,
         803.7072,  764.2072,  715.0599,  652.2395,  569.1180,  453.9579,
         283.8139,    6.9583])
"""

Fixes #8501

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

@yiyixuxu

@HuggingFaceDocBuilderDev

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.

@yiyixuxu
Copy link
Collaborator

yiyixuxu commented Dec 17, 2024

this is actually something I would like to be able to easily handle in the refactor PR you have here https://github.com/huggingface/diffusers/pull/10146/files,i.e. we can make a special sigma schedule for hunyuan that shift dynamically

@yiyixuxu
Copy link
Collaborator

same as the dynamic shift in flux/sd3, it is nice we added support in both, but with the refactor, what I have in mind is that we don't have to change the pipeline, they just use flux schedule with sd3 pipeline

@yiyixuxu
Copy link
Collaborator

ok to add this for now if you feel strongly about this! but I think this is something we will have to refactor out later

@hlky
Copy link
Contributor Author

hlky commented Dec 17, 2024

I felt it was useful to have for the next version with HunyuanVideo, we can do this in the scheduler refactor but the design isn't finalised and there's no feedback yet so we probably won't get that in by the next version at the end of the week.

Copy link
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.

let's merge then:)

@hlky hlky merged commit ec1c7a7 into huggingface:main Dec 17, 2024
12 checks passed
@hlky
Copy link
Contributor Author

hlky commented Dec 18, 2024

Just to note this is already seeing some usage #10136 (comment) pipe.scheduler._shift = 7.0 it's much more convenient for users with one-off scripts like this than importing the scheduler and creating it again from pipe.scheduler.config with shift=....

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.

Allow configuring shift= for SD3 dynamically
3 participants