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

Flux quantized with lora #10990

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Conversation

hlky
Copy link
Member

@hlky hlky commented Mar 6, 2025

What does this PR do?

Fixes #10989

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.

@hlky hlky requested a review from sayakpaul March 6, 2025 16:06
Comment on lines 1998 to 1999
# TODO (sayakpaul): We still need to consider if the module we're expanding is
# quantized and handle it accordingly if that is the case.
Copy link
Member Author

Choose a reason for hiding this comment

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

cc @sayakpaul should be ok to remove these TODO now

Copy link
Member

Choose a reason for hiding this comment

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

Pleae go ahead and remove.

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

@sayakpaul sayakpaul left a comment

Choose a reason for hiding this comment

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

Fantastic! I left some nits, let me know if they make sense.

Somewhat related to #10588, which I had planned to work on. But glad that you beat me to it. Do we want to club that in this PR?

Also, let's add a test to test_4bit.py?

@@ -18,6 +18,7 @@
import torch
from huggingface_hub.utils import validate_hf_hub_args

from ..quantizers.bitsandbytes import dequantize_bnb_weight
Copy link
Member

Choose a reason for hiding this comment

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

Should this be guarded with is_bitsandbytes_available()?

Copy link
Member Author

Choose a reason for hiding this comment

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

Guard added, it is guarded internally to quantizers.bitsandbytes so would also be ok without

Comment on lines 1974 to 1978
module_weight = (
dequantize_bnb_weight(module.weight, state=module.weight.quant_state).data
if module.weight.__class__.__name__ == "Params4bit"
else module.weight.data
)
Copy link
Member

Choose a reason for hiding this comment

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

This looks good. But to be extra cautious, I would first determine if module.weight.__class__.__name__ == "Params4bit". Then do

if not is_bistandbytes_available():
    raise ....
else:
   ....

Also I think the data device needs to be on a device where bitsanbdytes is known to be supported. Otherwise, its won't be able to dequantize.

Copy link
Member Author

Choose a reason for hiding this comment

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

Added the guard here

Comment on lines 1998 to 1999
# TODO (sayakpaul): We still need to consider if the module we're expanding is
# quantized and handle it accordingly if that is the case.
Copy link
Member

Choose a reason for hiding this comment

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

Pleae go ahead and remove.

@hlky
Copy link
Member Author

hlky commented Mar 7, 2025

Test also added, needs slice updating from runner.

Copy link
Member

@sayakpaul sayakpaul left a comment

Choose a reason for hiding this comment

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

Very cool to merge after the slices have been updated. Thanks, @hlky!

@hlky
Copy link
Member Author

hlky commented Mar 7, 2025

@bot /style

Copy link
Contributor

github-actions bot commented Mar 7, 2025

Style fixes have been applied. View the workflow run here.

@hlky
Copy link
Member Author

hlky commented Mar 7, 2025

What's the easiest way to trigger the slow bnb tests?

@sayakpaul
Copy link
Member

Would have been this workflow:
https://github.com/huggingface/diffusers/actions/workflows/run_tests_from_a_pr.yml but it won't have bitsandbytes installed. So, it will get skipped.

Easier would be to use with the big GPU (aws-g6e-xlarge-plus): https://github.com/huggingface/diffusers/actions/workflows/ssh-runner.yml, following this internal doc.

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.

Flux Controlnet Lora Fails To Load When Transformers Are Quantized.
3 participants