Skip to content

[Modular] Fix dtype assignment when type hint is AutoModel#13271

Open
DN6 wants to merge 2 commits intomainfrom
modular-automodel-dtype-fix
Open

[Modular] Fix dtype assignment when type hint is AutoModel#13271
DN6 wants to merge 2 commits intomainfrom
modular-automodel-dtype-fix

Conversation

@DN6
Copy link
Collaborator

@DN6 DN6 commented Mar 16, 2026

What does this PR do?

Oversight on my part when adding #13168. We avoid passing torch_dtype to non nn.Modules such as Processors and Tokenizers because these objects do not accept that anymore and instead store it in init_kwargs which then throw an error during serialization. However, I neglected the fact that AutoModel does not subclass ModelMixin, so if type_hint is set to diffusers AutoModel the check evaluates to True and we skip passing torch_dtype

This PR fixes the issue by checking whether type_hint is AutoModel

Fixes # (issue)

Before submitting

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.


if self.type_hint is None:
try:
from diffusers import AutoModel
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Moved this up because now we need to import AutoModel regardless of whether type_hint is provided or not.

@DN6 DN6 requested a review from yiyixuxu March 16, 2026 11:46
@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.

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!

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