# EETQ

[Easy & Efficient Quantization for Transformers (EETQ)](https://github.com/NetEase-FuXi/EETQ) kütüphanesi, NVIDIA GPU'lar için int8 ağırlık-bazlı kanal başına kuantizasyonu destekler. [FasterTransformer](https://github.com/NVIDIA/FasterTransformer) ve [TensorRT-LLM](https://github.com/NVIDIA/TensorRT-LLM)'den yüksek performanslı GEMM ve GEMV çekirdeklerini kullanır. Dikkat katmanı [FlashAttention2](https://github.com/Dao-AILab/flash-attention) ile optimize edilmiştir. Kalibrasyon veri seti gerekmez ve modelin önceden kuantize edilmesine gerek yoktur. Kanal başına kuantizasyon sayesinde doğruluk kaybı ihmal edilebilir düzeydedir.

EETQ ayrıca [PEFT](https://huggingface.co/docs/peft) ile ince ayarı destekler.

EETQ'yi [sürüm sayfasından](https://github.com/NetEase-FuXi/EETQ/releases) veya [kaynak kodundan](https://github.com/NetEase-FuXi/EETQ) yükleyin. EETQ için CUDA 11.4+ gereklidir.

```bash
pip install --no-cache-dir https://github.com/NetEase-FuXi/EETQ/releases/download/v1.0.0/EETQ-1.0.0+cu121+torch2.1.2-cp310-cp310-linux_x86_64.whl
```

```bash
git clone https://github.com/NetEase-FuXi/EETQ.git
cd EETQ/
git submodule update --init --recursive
pip install .
```

[EetqConfig](/docs/transformers/main/tr/main_classes/quantization#transformers.EetqConfig) içindeki kuantizasyon veri türünü tanımlayarak bir modeli anlık olarak kuantize edin.

```py
from transformers import AutoModelForCausalLM, EetqConfig

quantization_config = EetqConfig("int8")
model = AutoModelForCausalLM.from_pretrained(
    "meta-llama/Llama-3.1-8B",
    dtype="auto",
    device_map="auto",
    quantization_config=quantization_config
)
```

Kantize edilmiş modeli [from_pretrained()](/docs/transformers/main/tr/main_classes/model#transformers.PreTrainedModel.from_pretrained) ile yeniden kullanılabilmesi için [save_pretrained()](/docs/transformers/main/tr/main_classes/model#transformers.PreTrainedModel.save_pretrained) ile kaydedin.

```py
quant_path = "/path/to/save/quantized/model"
model.save_pretrained(quant_path)
model = AutoModelForCausalLM.from_pretrained(quant_path, device_map="auto")
```

