Enable BitsAndBytes quantization in MPS#13915
Open
LucasSte wants to merge 1 commit into
Open
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Bitsandbytes now has basic support for the Apple MPS backend, as I can tell by bitsandbytes-foundation/bitsandbytes#1818 and
bitsandbytes-foundation/bitsandbytes#1875.
The issue is that diffusers does not allow me to use the quantization on Apple hardware, because of the error
No GPU found. A GPU is needed for quantization.from herediffusers/src/diffusers/quantizers/bitsandbytes/bnb_quantizer.py
Lines 64 to 65 in f2be8bd
Adding MPS to that check, in addition to the other suggested change in #13361 (comment), allows us to enable BitsAndBytes for MPS.
I tested the change with the quantized version of FLUX.2-dev as described in https://github.com/black-forest-labs/flux2/blob/main/docs/flux2_dev_hf.md#4-bit-transformer-and-4-bit-text-encoder-20g-of-vram, and all worked fine.
This PR fixes #13361.
Before submitting
=> Not the case.
=> Enable MPS backend for bitsandbytes quantization #13361
documentation guidelines, and
here are tips on formatting docstrings.
=> I haven't found any documentation that mentions supported backends on BitsAndBytes in the diffusers repository, so I didn't modify anything in the docs folder.
=> I didn't write any tests, because the changes were trivial, but I can write them if reviewers deem necessary.
Who can review?
@sayakpaul
@asomoza
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.