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: Fix 8-bit serialization tests #30051

Merged
merged 5 commits into from
Apr 16, 2024

Conversation

younesbelkada
Copy link
Contributor

What does this PR do?

with the recent safetensors refactor passing pure str in state dicts are no longer supported. This PR together with bitsandbytes-foundation/bitsandbytes#1164 should fix the issues

cc @ArthurZucker @Narsil @SunMarc @Titus-von-Koeller

@Narsil
Copy link
Contributor

Narsil commented Apr 4, 2024

with the recent safetensors refactor passing pure str in state dicts are no longer supported

It was never supported. The strings where silently dropped. Now it's a strong error (which I think is better behavior since the safetensors version was loosing that information which would have lead to incorrect reloads)

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

I'm gonna need more details, why does B&B saves weight format, and why just removing it from the serialization does not cause any issues?

@younesbelkada
Copy link
Contributor Author

Thanks!
I had a deeper look actually, it seems weight_format was never used in our case since before the ST PR that value from the state dict was popped and ignored. The correct weight format is inferred after the first forward pass
Now that we do have a hard check we simply need to make sure we save uint8 tensors instead of pure str: bitsandbytes-foundation/bitsandbytes#1164 + make sure to ignore them when loading the state dict as done in this PR

Copy link
Collaborator

@amyeroberts amyeroberts left a comment

Choose a reason for hiding this comment

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

LGTM - thanks for handling the update!

src/transformers/quantizers/quantizer_bnb_8bit.py Outdated Show resolved Hide resolved
Co-authored-by: amyeroberts <22614925+amyeroberts@users.noreply.github.com>
Copy link
Contributor

@Titus-von-Koeller Titus-von-Koeller left a comment

Choose a reason for hiding this comment

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

LGTM, thanks Younes for leading this 🤗

@younesbelkada younesbelkada merged commit b86d0f4 into huggingface:main Apr 16, 2024
21 checks passed
@younesbelkada younesbelkada deleted the fix-int8-new-st branch April 16, 2024 10:28
zucchini-nlp pushed a commit to zucchini-nlp/transformers that referenced this pull request Apr 18, 2024
* fix 8-bit serialization tests

* add more clarification

* Update src/transformers/quantizers/quantizer_bnb_8bit.py

Co-authored-by: amyeroberts <22614925+amyeroberts@users.noreply.github.com>

---------

Co-authored-by: amyeroberts <22614925+amyeroberts@users.noreply.github.com>
ArthurZucker pushed a commit that referenced this pull request Apr 22, 2024
* fix 8-bit serialization tests

* add more clarification

* Update src/transformers/quantizers/quantizer_bnb_8bit.py

Co-authored-by: amyeroberts <22614925+amyeroberts@users.noreply.github.com>

---------

Co-authored-by: amyeroberts <22614925+amyeroberts@users.noreply.github.com>
itazap pushed a commit that referenced this pull request May 14, 2024
* fix 8-bit serialization tests

* add more clarification

* Update src/transformers/quantizers/quantizer_bnb_8bit.py

Co-authored-by: amyeroberts <22614925+amyeroberts@users.noreply.github.com>

---------

Co-authored-by: amyeroberts <22614925+amyeroberts@users.noreply.github.com>
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.

6 participants