Buckets:
| # Optimum Quanto | |
| [Quanto](https://github.com/huggingface/optimum-quanto)는 [Optimum](https://huggingface.co/docs/optimum/index)의 PyTorch 양자화 백엔드입니다. 가중치에 대한 선형 양자화(float8, int8, int4, int2)를 지원하며, 정밀도가 매우 높은 모델과 유사한 정확도를 제공합니다. Quanto는 모든 모델 모달리티와 디바이스와 호환되므로 하드웨어와 관계없이 쉽게 사용할 수 있습니다. | |
| Quanto는 더 빠른 생성을 위해 [torch.compile](https://pytorch.org/tutorials/intermediate/torch_compile_tutorial.html)과도 호환됩니다. | |
| 다음 명령어로 Quanto를 설치합니다. | |
| ```bash | |
| pip install optimum-quanto accelerate transformers | |
| ``` | |
| [QuantoConfig](/docs/transformers/main/ko/main_classes/quantization#transformers.QuantoConfig)을 생성하고 `weights` 매개변수를 지정하여 모델을 양자화합니다. [torch.nn.Linear](https://pytorch.org/docs/stable/generated/torch.nn.Linear.html) 레이어를 포함하는 모든 모달리티의 모든 모델에 적용할 수 있습니다. | |
| > [!TIP] | |
| > Transformers 통합은 가중치 양자화만 지원합니다. 활성화 양자화, 보정(calibration), 또는 QAT가 필요한 경우 Quanto 라이브러리를 직접 사용하세요. | |
| ```py | |
| from transformers import AutoModelForCausalLM, AutoTokenizer, QuantoConfig | |
| quant_config = QuantoConfig(weights="int8") | |
| model = transformers.AutoModelForCausalLM.from_pretrained( | |
| "meta-llama/Llama-3.1-8B", | |
| dtype="auto", | |
| device_map="auto", | |
| quantization_config=quant_config | |
| ) | |
| ``` | |
| ## torch.compile | |
| Quanto 모델을 [torch.compile](https://pytorch.org/tutorials/intermediate/torch_compile_tutorial.html)로 감싸서 생성 속도를 높입니다. | |
| ```py | |
| import torch | |
| from transformers import AutoModelForSpeechSeq2Seq, QuantoConfig | |
| quant_config = QuantoConfig(weights="int8") | |
| model = AutoModelForSpeechSeq2Seq.from_pretrained( | |
| "openai/whisper-large-v2", | |
| dtype="auto", | |
| device_map="auto", | |
| quantization_config=quant_config | |
| ) | |
| model = torch.compile(model) | |
| ``` | |
| ## 리소스 | |
| 라이브러리 설계와 벤치마크에 대해 자세히 알아보려면 [Quanto: a PyTorch quantization backend for Optimum](https://huggingface.co/blog/quanto-introduction) 블로그 게시물을 읽어보세요. | |
| 더 실용적인 예시를 보려면 Quanto [노트북](https://colab.research.google.com/drive/16CXfVmtdQvciSh9BopZUDYcmXCDpvgrT?usp=sharing)을 참고하세요. | |
Xet Storage Details
- Size:
- 2.47 kB
- Xet hash:
- aaca9fde891e4c9d6ad4c5b32358039bccb5123fe50d2dce00c36b6e5134dd56
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.