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

make sure to disable gradients for integer tensor #32943

Merged
merged 1 commit into from
Nov 18, 2024

Conversation

winglian
Copy link
Contributor

What does this PR do?

When doing 8bit lora's with deepspeed zero3, the Int8Params should have requires_grad=False otherwise the following error occurs:

[rank0]:   File "/root/miniconda3/envs/py3.11/lib/python3.11/site-packages/bitsandbytes/nn/modules.py", line 574, in __new__
[rank0]:     obj = torch.Tensor._make_subclass(cls, data, requires_grad)
[rank0]:           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank0]: RuntimeError: Only Tensors of floating point and complex dtype can require gradients

this used to work several months ago

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you read the contributor guideline,
    Pull Request section?
  • Was this discussed/approved via a Github issue or the forum? Please add a link
    to it if that's the case.
  • Did you make sure to update the documentation with your changes? Here are the
    documentation guidelines, and
    here are tips on formatting docstrings.
  • Did you write any new necessary tests?

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

Copy link
Contributor

@muellerzr muellerzr left a comment

Choose a reason for hiding this comment

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

Nice discovery!

@muellerzr muellerzr requested a review from ArthurZucker August 22, 2024 15:40
@muellerzr
Copy link
Contributor

cc @ArthurZucker for final :)

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

@ArthurZucker ArthurZucker left a comment

Choose a reason for hiding this comment

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

LGTM other than that!

src/transformers/modeling_utils.py Show resolved Hide resolved
Copy link
Collaborator

@ArthurZucker ArthurZucker left a comment

Choose a reason for hiding this comment

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

IF that is the only fix we can do so be it, but it's fairly weird !

src/transformers/modeling_utils.py Show resolved Hide resolved
@winglian winglian force-pushed the 8bit-deepspeed-zero3 branch from 2688d7c to 130828f Compare October 31, 2024 16:08
@winglian
Copy link
Contributor Author

@ArthurZucker @muellerzr I rebased this against latest transformers and tested on my end

Copy link
Collaborator

@ArthurZucker ArthurZucker left a comment

Choose a reason for hiding this comment

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

Thanks @winglian 🤗

@ArthurZucker ArthurZucker merged commit 36759f3 into huggingface:main Nov 18, 2024
24 checks passed
BernardZach pushed a commit to BernardZach/transformers that referenced this pull request Dec 5, 2024
BernardZach pushed a commit to innovationcore/transformers that referenced this pull request Dec 6, 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
  NODES
COMMUNITY 3
innovation 1
Project 5
USERS 1