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

FIX: Small regression in BNB LoRA output #2238

Conversation

BenjaminBossan
Copy link
Member

@BenjaminBossan BenjaminBossan commented Nov 27, 2024

Our regression tests reveal that the 8bit LoRA BNB regression test is failing. To reproduce, run:

pytest tests/regression/test_regression.py -s --regression -k test_lora_8bit

The regression was introduced in #2122. We didn't notice this earlier because of other failing tests in the nightly CI.

The cause of the error is subtle. In the original code, we would calculate the LoRA output, convert the dtype if necessary, then add it to the base output. After the mentioned PR, we calculate the LoRA output, add it to the base output, then convert the dtype if necessary (code). The difference is very small on a per layer basis, but it can accumulate over the layers, leading to a significant difference in outputs, as witnessed by the regression test.

This PR rolls back this specific part of the PR (both for 8bit and 4bit) while leaving the main change of that PR intact.

Our regression tests reveal that the 8bit LoRA BNB regression test is
failing. To reproduce, run:

pytest tests/regression/test_regression.py -s --regression -k
test_lora_8bit

The regression was introduced in huggingface#2122. We didn't notice this earlier
because of other failing tests in the nightly CI.

The cause of the error is subtle. In the original code, we would
calculate the LoRA output, convert the dtype if necessary, then add it
to the base output. After the mentioned PR, we calculate the LoRA
output, add it to the base output, then convert the dtype if necessary.
The difference is very small on a per layer basis, but it can accumulate
over the layers, leading to a significant difference in outputs, as
witnessed by the regression test.

This PR rolls back this specific part of the PR (both for 8bit and 4bit)
while leaving the main change of that PR intact.
@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
Contributor

@ariG23498 ariG23498 left a comment

Choose a reason for hiding this comment

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

Very good catch.

@BenjaminBossan BenjaminBossan merged commit 131efba into huggingface:main Nov 28, 2024
14 checks passed
@BenjaminBossan BenjaminBossan deleted the fix-regression-in-bnb-lora-output branch November 28, 2024 10:25
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.

3 participants