-
Notifications
You must be signed in to change notification settings - Fork 680
Fix Qlora/lora for 3.2 vision #2028
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
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/torchtune/2028
Note: Links to docs will display an error until the docs builds have been completed. ❗ 1 Active SEVsThere are 1 currently active SEVs. If your PR is affected, please view them below: ✅ No FailuresAs of commit c4d155f with merge base d5c54f3 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing this. I think "apply_lora_to_output" still makes sense for the encoder, just not the CLIP model itself but still in the projection head.
num_hidden_inputs: int, | ||
# LoRA args | ||
apply_lora_to_mlp: bool, | ||
apply_lora_to_output: bool, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should stay in the projection head, it just doesn't make sense in the CLIP model
lora_options = { | ||
"lora_modules": lora_attn_modules, | ||
"apply_lora_to_mlp": apply_lora_to_mlp, | ||
"apply_lora_to_output": apply_lora_to_output, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be removed from here and manually added to the projection head call
self._quantize_base = quantize_base | ||
|
||
if not self._quantize_base and quantization_kwargs: | ||
if not self._quantize_base and any([v for v in quantization_kwargs.values()]): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did and quantization_kwargs
not work for a dictionary? you could also just check for length
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good question! it outputs something like: {use_lora_on_output: None}. Even though the value is None, it has a key, which fails the check
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In [1]: any([None])
Out[1]: False
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry {use_lora_on_output: None}
should fail the check?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If quantize_base is false, then we should NOT have any quantization args, right? If no quantization is happenning, then why have these args?
So this assertion was failing, because quantize_base WAS false (not False --> True), but we have {use_lora_on_output: None}, which returns True.
So if True and True: raise error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with Rafi here, there shouldn't be any kwargs passed in if quantize_base is False. {use_lora_on_output: None} should not be passed in when quantize_base = False.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for fixing this
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2028 +/- ##
===========================================
- Coverage 67.27% 24.88% -42.40%
===========================================
Files 318 318
Lines 17648 17631 -17
===========================================
- Hits 11873 4387 -7486
- Misses 5775 13244 +7469 ☔ View full report in Codecov by Sentry. 🚨 Try these New Features:
|
Context
What is the purpose of this PR? Is it to
In this PR we removed apply_lora_to_output from vision encoder, but forgot to remove it from some places. This raises the error:
Additionally, in 4.0 we added a check for quantize_kwargs and quantize_base. This raises the error:

Test plan