Skip to content

Conversation

@patrickvonplaten
Copy link
Contributor

@patrickvonplaten patrickvonplaten commented Nov 25, 2022

@pcuenca - I think this is the cleaner way:

    1. First save all configs
    1. Then run init

Since the two are very independent, I don't see a reason why this could break anything. Also note that we're already doing this in Flax:

original_init(self, *args, **kwargs)

@patrickvonplaten patrickvonplaten changed the title fix Allow to set config params directly in init Nov 25, 2022
@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Nov 25, 2022

The documentation is not available anymore as the PR was closed or merged.

Copy link
Member

@pcuenca pcuenca left a comment

Choose a reason for hiding this comment

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

Makes total sense! Thank you!

"""

_compatibles = _COMPATIBLE_STABLE_DIFFUSION_SCHEDULERS.copy()
_deprecated_kwargs = ["predict_epsilon"]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@pcuenca what do you think about this logic? It has another advantage in that I can now easily write a test for all models and schedulers that verifies that kwarg should only be in init if this list is > 0

Copy link
Member

Choose a reason for hiding this comment

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

I like it! We don't have to introduce workarounds, it gives us a clean path to deprecate or replace arguments and is testable. Very cool.

init_dict["prediction_type"] = "epsilon" if predict_epsilon else "sample"
for deprecated_kwarg in cls._deprecated_kwargs:
if deprecated_kwarg in unused_kwargs:
init_dict[deprecated_kwarg] = unused_kwargs.pop(deprecated_kwarg)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note we don't need to deprecate here this will be handled in the init

Copy link
Member

@pcuenca pcuenca left a comment

Choose a reason for hiding this comment

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

Thank you!

Comment on lines +85 to +87
- **_deprecated_kwargs** (`List[str]`) -- Keyword arguments that are deprecated. Note that the init function
should only have a `kwargs` argument if at least one argument is deprecated (should be overridden by
subclass).
Copy link
Member

Choose a reason for hiding this comment

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

💯

"""

_compatibles = _COMPATIBLE_STABLE_DIFFUSION_SCHEDULERS.copy()
_deprecated_kwargs = ["predict_epsilon"]
Copy link
Member

Choose a reason for hiding this comment

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

I like it! We don't have to introduce workarounds, it gives us a clean path to deprecate or replace arguments and is testable. Very cool.

@patrickvonplaten patrickvonplaten merged commit 8faa822 into main Nov 25, 2022
@patrickvonplaten patrickvonplaten deleted the hot_fix_scheduler_config branch November 25, 2022 15:06
sliard pushed a commit to sliard/diffusers that referenced this pull request Dec 21, 2022
* fix

* fix deprecated kwargs logic

* add tests

* finish
yoonseokjin pushed a commit to yoonseokjin/diffusers that referenced this pull request Dec 25, 2023
* fix

* fix deprecated kwargs logic

* add tests

* finish
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.

4 participants