SyncAI.news, a Varaisys broadcasting
Overview of natively supported quantization schemes in 🤗 Transformers
HF

Hugging Face Blog

· 1 min read

AI LabsHugging Face Blog

Overview of natively supported quantization schemes in 🤗 Transformers

We aim to give a clear overview of the pros and cons of each quantization scheme supported in transformers to help you decide which one you should go for.

Currently, quantizing models are used for two main purposes:

  • Running inference of a large model on a smaller device
  • Fine-tune adapters on top of quantized models

So far, two integration efforts have been made and are natively supported in transformers : bitsandbytes and auto-gptq. Note that some additional quantization schemes are also supported in the 🤗 optimum library, but this is out of scope for this blogpost.

To learn more about each of the supported schemes, please have a look at one of the resources shared below. Please also have a look at the appropriate sections of the documentation.

Note also that the details shared below are only valid for PyTorch models, this is currently out of scope for Tensorflow and Flax/JAX models.

Table of contents

  • Resources
  • Comparing bitsandbytes and auto-gptq
  • Diving into speed benchmarks
  • Conclusion and final words
  • Acknowledgements

Resources

  • GPTQ blogpost – gives an overview on what is the GPTQ quantization method and how to use it.
  • bistandbytes 4-bit quantization blogpost - This blogpost introduces 4-bit quantization and QLoRa, an efficient finetuning approach.
  • bistandbytes 8-bit quantization blogpost - This blogpost explains how 8-bit quantization works with bitsandbytes.
  • Basic usage Google Colab notebook for GPTQ - This notebook shows how to quantize your transformers model with the GPTQ method, how to do inference, and how to do fine-tuning with the quantized model.
  • Basic usage Google Colab notebook for bitsandbytes - This notebook shows how to use 4-bit models in inference with all their variants, and how to run GPT-neo-X (a 20B parameter model) on a free Google Colab instance.
  • Merve's blogpost on quantization - This blogpost provides a gentle introduction to quantization and the quantization methods supported natively in transformers.

Original source

This story was published by Hugging Face Blog. SyncAI.news shows a preview; the complete article is on the publisher's site.

Read the full story on huggingface.co

Similar News