Skip to content

Don't override torch_dtype and don't use when quantization_config is set - #11039

Merged
DN6 merged 5 commits into
huggingface:mainfrom
hlky:torch-dtype-quantization-config
Mar 21, 2025
Merged

Don't override torch_dtype and don't use when quantization_config is set#11039
DN6 merged 5 commits into
huggingface:mainfrom
hlky:torch-dtype-quantization-config

Conversation

@hlky

@hlkyhlky commented Mar 12, 2025

Copy link
Copy Markdown
Contributor

What does this PR do?

https://github.com/huggingface/diffusers/actions/runs/13800894621/job/38602946014#step:7:1904

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.

@HuggingFaceDocBuilderDev

Copy link
Copy Markdown

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.

@hlkyhlky changed the title Don't use torch_dtype when quantization_config is setDon't override torch_dtype and don't use when quantization_config is setMar 12, 2025
@CyberVy

Copy link
Copy Markdown
Contributor

@hlky Hi!

This is a good PR for me. Sometimes I forget to set torch_dtype when loading a model, which can cause some issues, because the loader defaults totorch.float32. 👍

@sayakpaulsayakpaul mentioned this pull request Mar 18, 2025
f"Passed `torch_dtype` {torch_dtype} is not a `torch.dtype`. Defaulting to `torch.float32`."
)

if quantization_config is not None and torch_dtype is not None:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

In this case, if we were trying to set the dtype of the model e.g. FluxTransformer(quantization_config=BnBConfig, torch_dtype=torch.bfloat16) Wouldn't the dtype be overwritten and then get set to the BnB default float16?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Yes looks like it, I think it's ok without this part.

Comment threadsrc/diffusers/models/modeling_utils.py Outdated
Comment threadsrc/diffusers/loaders/single_file_model.py Outdated
DN6
DN6 approved these changes Mar 21, 2025
@DN6
DN6 merged commit a7d53a5 into huggingface:mainMar 21, 2025
Sign up for freeto 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.

5 participants

@hlky@HuggingFaceDocBuilderDev@CyberVy@DN6@sayakpaul