-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
[bitsandbbytes] follow-ups #9730
Conversation
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. |
src/diffusers/quantizers/base.py
Outdated
""" | ||
checks if the quantized param has expected shape. | ||
""" | ||
if not hasattr(self, "check_quantized_param_shape"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Think this should be?
if not hasattr(self, "check_quantized_param_shape"): | |
if not hasattr(self, "check_if_quantized_param"):: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method is checking for itself? That can't be the case right? Because the subclass inherits it? So it should already be in there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My bad. Have updated in 3298a04.
Once a model is quantized, you can push the model to the Hub with the [`~ModelMixin.push_to_hub`] method. The quantization `config.json` file is pushed first, followed by the quantized model weights. | ||
|
||
```py | ||
from diffusers import FluxTransformer2DModel, BitsAndBytesConfig | ||
|
||
quantization_config = BitsAndBytesConfig(load_in_8bit=True) | ||
|
||
model_8bit = FluxTransformer2DModel.from_pretrained( | ||
"black-forest-labs/FLUX.1-dev", | ||
subfolder="transformer", | ||
quantization_config=quantization_config | ||
) | ||
``` | ||
Once a model is quantized, you can push the model to the Hub with the [`~ModelMixin.push_to_hub`] method. The quantization `config.json` file is pushed first, followed by the quantized model weights. You can also save the serialized 4-bit models locally with [`~ModelMixin.save_pretrained`]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To unify the content between 8bit and 4bit hfoption.
and hf_quantizer.check_if_quantized_param(model, param, param_name, state_dict, param_device=device) | ||
): | ||
hf_quantizer.check_quantized_param_shape(param_name, empty_state_dict[param_name].shape, param.shape) | ||
elif not is_quant_method_bnb: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could have done with else
but I think it's a tad bit safer.
What does this PR do?
bitsandbytes
#9213 (comment)hf-internal-testing