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

account for the new merged/unmerged weight to perform the quantization again #1370

Merged
merged 1 commit into from
Jan 18, 2024

Conversation

pacman100
Copy link
Contributor

@pacman100 pacman100 commented Jan 18, 2024

What does this PR do?

BNB has CI failures with 2 tests failing due to the following:
In merge method, the following things happens wherein the lora delta weights are added to the dequantized base layer weights. This is followed by setting the weight of the base layer to a new instance of Params4bit with the new merged weights:

w_data = bnb.functional.dequantize_4bit(weight.data, weight.quant_state) + lora_data
self.get_base_layer().weight = bnb.nn.Params4bit(w_data.to("cpu"), requires_grad=False,**kwargs).to(weight.device)            

Now, kwargs copies the ones currently there which has bnb_quantized=True and the old quant_state so the new merged weights aren't quantized and the old quant state remains. After this, during Linear4bit forward call, the old quant state is used while the weights are unquantized. This happens due to changes of the PR bitsandbytes-foundation/bitsandbytes#970.

This PR fixes the failures by setting bnb_quantized=False when merging/unmerging 4-bit layers.

@pacman100 pacman100 changed the title account for the new merged/unmerged weight to perform the quantizatio… account for the new merged/unmerged weight to perform the quantization n again Jan 18, 2024
@pacman100 pacman100 changed the title account for the new merged/unmerged weight to perform the quantization n again account for the new merged/unmerged weight to perform the quantization again Jan 18, 2024
@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.

@Titus-von-Koeller
Copy link
Contributor

Thanks @pacman100 for the quick reaction and fix! Really appreciated.

Seems like it's ready to merge :)

Copy link
Contributor

@younesbelkada younesbelkada left a comment

Choose a reason for hiding this comment

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

Thanks for the quick fix!

@Titus-von-Koeller Titus-von-Koeller merged commit ebbff40 into main Jan 18, 2024
14 checks passed
@Titus-von-Koeller Titus-von-Koeller deleted the smangrul/fix-bnb-4bit branch January 18, 2024 14:39
BenjaminBossan pushed a commit to BenjaminBossan/peft that referenced this pull request Mar 14, 2024
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.

4 participants