Skip to content

Conversation

@vladmandic
Copy link
Contributor

@vladmandic vladmandic commented Dec 25, 2024

now that we have flow support for most of the schedulers, we really should not rely on hardcoded optional scheduler config values inside the pipeline - they should be optional.

without this change, flux pipeline will fail for most non-default schedulers (with flow mode enabled) due to missing config value.

note that this change needs to be mirrored for all flux pipelines, but due to how diffusers ci works, i'm really not sure what needs to be manually updated vs not.

@hlky @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.

Comment on lines 77 to 94
base_seq_len: Optional[int] = 256,
max_seq_len: Optional[int] = 4096,
base_shift: Optional[float] = 0.5,
max_shift: Optional[float] = 1.16,
scheduler: Optional[FlowMatchEulerDiscreteScheduler] = None,
):
if base_seq_len or max_seq_len or base_shift or max_shift or scheduler is None:
deprecation_message = "Pass `scheduler` to `calculate_shift`."
deprecate(
"calculate_shift scheduler",
"1.0.0",
deprecation_message,
standard_warn=False,
)
base_seq_len = base_seq_len or scheduler.config.get("base_image_seq_len", 256)
max_seq_len = max_seq_len or scheduler.config.get("max_image_seq_len", 4096)
base_shift = base_shift or scheduler.config.get("base_shift", 0.5)
max_shift = max_shift or scheduler.config.get("max_shift", 1.16)
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the contribution @vladmandic, it will be fun to try to those scheduler changes with Flux.

As you mentioned CI, I've ran make fix-copies to demonstrate. Every occurrence of # Copied from diffusers.pipelines.flux.pipeline_flux.calculate_shift is updated, this highlights the effects in our own codebase, we'll need to update the call of calculate_shift in every pipeline and there can be effects downstream, so I've pushed this version which adds a deprecation message. We'll run make fix-copies again when the changes here are finalised.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks!

@hlky hlky requested a review from yiyixuxu January 8, 2025 13:12
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.

thanks! I left a comment

self.scheduler.config.max_image_seq_len,
self.scheduler.config.base_shift,
self.scheduler.config.max_shift,
scheduler=self.scheduler,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
scheduler=self.scheduler,
scheduler.config.get("base_image_seq_len", 256)
scheduler.config.get("max_image_seq_len", 4096)
scheduler.config.get("base_shift", 0.5)
scheduler.config.get("max_shift", 1.16)

max_seq_len: int = 4096,
base_shift: float = 0.5,
max_shift: float = 1.16,
base_seq_len: Optional[int] = 256,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we don't need to change this function, we can just change how the parameters are passed from the pipeline

@yiyixuxu yiyixuxu added the roadmap Add to current release roadmap label Jan 8, 2025
@yiyixuxu yiyixuxu merged commit f0c6d97 into huggingface:main Jan 9, 2025
12 checks passed
@yiyixuxu
Copy link
Collaborator

yiyixuxu commented Jan 9, 2025

thanks @vladmandic @hlky !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

roadmap Add to current release roadmap

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

4 participants