Skip to content
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

[core] feat: implement automodel for diffusers. #10668

Closed
wants to merge 3 commits into from
Closed

Conversation

sayakpaul
Copy link
Member

@sayakpaul sayakpaul commented Jan 28, 2025

What does this PR do?

Fixes #10059.

Amidst such a growing number of model classes, I think it makes sense for diffusers to have its AutoModel class.

Instead of defining a list of models manually, I have taken the approach of using importlib to directly import the model from a loaded config. I think this is the simplest and easiest but I am not too fixated on this.

I am opening this PR to gather feedback and iterate. Letting Dhruv to do that first and then will request reviews from others.

I haven't added tests (can do) for it but AutoModel also works with quantization i.e.,:

from diffusers.models.auto_model import AutoModel

model = AutoModel.from_pretrained("hf-internal-testing/flux.1-dev-nf4-pkg", subfolder="transformer")
print(model.__class__.__name__)

Successfully resolves to FluxTransformer2DModel.

TODO

  • Add AutoModel to init.
  • Docs
  • Additional tests if needed (I think I have covered the crucial ones)

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

@sayakpaul sayakpaul requested a review from DN6 January 28, 2025 04:28
@sayakpaul sayakpaul closed this Jan 29, 2025
@sayakpaul sayakpaul deleted the automodel branch January 29, 2025 02:00
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.

[core] introduce AutoModel
2 participants