Method comparison: LoRA that targets MLP modules #2845
Merged
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.
The "LoRA Without Regret" blog mentions that targeting the MLP part of the transformer is more effective than targeting the attention modules. This experiment tests this by targeting:
["gate_proj", "up_proj", "down_proj"]instead of the default layers (
["q_proj", "v_proj"]).I chose a rank to match the parameter count we would get when targeting the attention modules with rank 32, which is rank 10. Testing on my machine, there is indeed a nice improvement in the test score:
There is, however, also a marked increase in memory usage, despite matching parameter count. Since the operations are different, this may not be a surprise, but let's wait for the final verdict once this experiment runs on our AWS instance.
Note: I also tested higher and lower ranks when targeting the MLP. The effect on memory usage was negligible, but it did improve the score:
In the end, I chose only to add the rank 10 experiment to match the number of trainable parameters.