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

Update HRA #2160

Merged
merged 7 commits into from
Oct 21, 2024
Merged

Update HRA #2160

merged 7 commits into from
Oct 21, 2024

Conversation

DaShenZi721
Copy link
Contributor

  • The order of matrix multiplication in HRA was modified, improving computational speed. The runtime of test_model_with_batchnorm_reproducibility in tests/test_vision_models.py is reduced to around 20 sec on an RTX 4090.
  • Add an entry and introduction for HRA in the documentation.

@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.

@BenjaminBossan
Copy link
Member

Ah, sorry for the failing CI, could you please merge with/rebase on main?

@BenjaminBossan
Copy link
Member

Sorry, I haven't used rebase before, so I'm not exactly sure what I need to do. Could you explain it to me? Thanks!

No worries, let's just merge instead. So first ensure that you sync your fork with the upstream main branch (can be done via GitHub UI), then switch to your branch, merge the main branch into your branch, then push the changes.

@DaShenZi721
Copy link
Contributor Author

DaShenZi721 commented Oct 18, 2024

OK, I have merged the main branch huggingface:main into my branch. But I can't push... It says Everything up-to-date

@BenjaminBossan
Copy link
Member

OK, I have merged the main branch huggingface:main into my branch. But I can't push... It says Everything up-to-date

You already pushed the merge successfully.

@DaShenZi721
Copy link
Contributor Author

OK. Thanks!

Copy link
Member

@BenjaminBossan BenjaminBossan 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 adjusting the calculation. I could confirm that this speeds up computation while retaining the same results. Also thanks for updating the docs, I just saw a small issue regarding LaTeX, please check.


HRA constructs a chain of `r` trainable Householder reflections (HRs). Because the Householder reflection matrix is an orthogonal matrix and the product of orthogonal matrices is also an orthogonal matrix, HRA satisfies the theoretical guarantee of Orthogonal Finetuning (OFT). Meanwhile, HRA can also be viewed as an low-rank fine-tuning adapter by rewriting formula.

The higher `r`, the more trainable parameters, resulting in a larger model capacity and better performance. Besides, due to the chain structure, the orthogonality of HR planes impacts the capacity and regularity of HRA. To achieve a trade-off between the model capacity and regularity, an orthogonality regularizer of the HR planes is added to the loss function. The weight $\lambda$ can control the strength of the regularizer.
Copy link
Member

Choose a reason for hiding this comment

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

It looks like the LaTeX part is not correctly rendered: https://moon-ci-docs.huggingface.co/docs/peft/pr_2160/en/conceptual_guides/adapter#householder-reflection-adaptation-hra

I found this in the docs, maybe that helps.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, I have changed the LaTeX part's format.

Copy link
Member

@BenjaminBossan BenjaminBossan 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 providing this improvement for HRA and for extending the docs.

@BenjaminBossan BenjaminBossan merged commit d5f4e6d into huggingface:main Oct 21, 2024
14 checks passed
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