-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
Apply applicable quantization_config
to model components when loading a model
#10327
Comments
Yeah this is planned. I thought we had created an issue for it to track, but clearly, it had slipped through the cracks. We should also have something like |
Yup! And it can have a default value with exactly the ones you've mentioned. |
This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread. Please note that issues that do not follow the contributing guidelines are likely to be ignored. |
ping to remove stale |
any updates on this one? |
@sayakpaul is planning on adding this soon. Sorry for the delay |
This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread. Please note that issues that do not follow the contributing guidelines are likely to be ignored. |
ping to remove stale |
Definitely not stale. Will be prioritised soon. |
from diffusers.quantizers import PipelineQuantizationConfig
from diffusers import DiffusionPipeline
import torch
quant_config = PipelineQuantizationConfig(
quant_backend="bitsandbytes_4bit",
quant_kwargs={
"load_in_4bit": True,
"bnb_4bit_quant_type": "nf4",
"bnb_4bit_compute_dtype": torch.bfloat16
},
exclude_modules=["text_encoder", "vae"]
)
pipe = DiffusionPipeline.from_pretrained(
"black-forest-labs/FLUX.1-dev",
quantization_config=quant_config,
torch_dtype=torch.bfloat16
).to("cuda") https://github.com/huggingface/diffusers/compare/feat/pipeline-quant-config?expand=1 |
@vladmandic since you reacted to the above message, do feel free to provide feedback here. |
With new improvements to
quantization_config
, memory requirements of models such as SD35 and FLUX.1 are much lower.However, user must load each model component that he wants quantized manually and then assemble the pipeline.
For example:
The ask is to allow pipeline loader itself to process
quantization_config
and automatically use it on applicable modules if its presentThat would allow much simpler use without user needing to know exact internal components of the each model:
This is a generic ask that should work for pretty much all models, although primary use case is with the most popular models such as SD35 and FLUX.1
@yiyixuxu @sayakpaul @DN6 @asomoza
The text was updated successfully, but these errors were encountered: