Skip to content

Conversation

@SunMarc
Copy link
Member

@SunMarc SunMarc commented Feb 14, 2024

What does this PR do ?

This PR adds the quantization methods from quanto library. We will support inference + model quantization if the user perform weights only quantization since we don't require a calibration dataset.

TODO:

  • docs
  • tests
  • Guard against saving now since it is a bit complicated

@SunMarc SunMarc changed the title [Quantization] Quanto [Quantization] Quanto quantizer Feb 14, 2024
@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
Contributor

@younesbelkada younesbelkada left a comment

Choose a reason for hiding this comment

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

Clean work already ! Looking forward to merge the PR !

@younesbelkada
Copy link
Contributor

cc @dacorvo

@SunMarc
Copy link
Member Author

SunMarc commented Feb 22, 2024

Quick update, all tests are passing with the exception of safetensors tests. I've also implemented the quantization on the spot just like we do for bnb quantization. However, if the user wants to use cpu/disk offload, he will need to install the main branch of accelerate for now because of this PR.

@SunMarc SunMarc marked this pull request as ready for review February 28, 2024 23:05
@SunMarc SunMarc requested review from dacorvo and younesbelkada March 1, 2024 16:40
@ArthurZucker
Copy link
Collaborator

LGTM, mostly concerned with quanto specific function addition, that should leave in quanto.py not in the modeling (as much as possible of course).

@SunMarc SunMarc requested a review from ArthurZucker March 7, 2024 19:52
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 for iterating! 🔥 let's make quanto go brrr

Comment on lines +3752 to +3753
if hf_quantizer is not None:
missing_keys = hf_quantizer.update_missing_keys(model, missing_keys, prefix)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Alright no worries 🤗

Copy link
Contributor

@younesbelkada younesbelkada left a comment

Choose a reason for hiding this comment

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

Thanks again @SunMarc - great work ! 🚀 let's 🚢 it

@SunMarc
Copy link
Member Author

SunMarc commented Mar 14, 2024

Note to the core mainteners and especially @ArthurZucker . I reverted a lot of changes I did for the serialization. I decided to postpone the serialization feature by setting the is_serializable property to False in this PR.

I will do a follow up PR for the serialization since the PR to make it compatible with safetensors or weight_only saving in quanto needs lots of changes in the way we load + save models in transformers.

Without serialization, this PR should still be good to merge !

@SunMarc SunMarc merged commit 28de2f4 into huggingface:main Mar 15, 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.

5 participants