Buckets:
| # AutoRound | |
| [AutoRound](https://github.com/intel/auto-round), gelişmiş bir kuantizasyon araç setidir. İşaret-gradyan inişinden (sign-gradient descent) yararlanarak ve geniş donanım uyumluluğu sağlayarak, minimal ayarlama ile ultra düşük bit genişliklerinde (2-4 bit) yüksek doğruluk elde eder. Daha fazla ayrıntı için [SignRoundV1](https://arxiv.org/pdf/2309.05516) ve [SignRoundV2](https://arxiv.org/abs/2512.04746) makalelerimize göz atın. | |
| `auto-round` (sürüm ≥ 0.13.0) kurun: | |
| ```bash | |
| pip install "auto-round>=0.13.0" | |
| ``` | |
| Daha hızlı CUDA çıkarımı için Marlin çekirdeğini kullanmak için `gptqmodel` paketini yükleyin: | |
| ```bash | |
| pip install "gptqmodel>=5.8.0" | |
| ``` | |
| ## Kantize edilmiş bir model yükleyin | |
| `AutoRoundConfig` nesnesini [from_pretrained()](/docs/diffusers/main/tr/api/models/overview#diffusers.ModelMixin.from_pretrained) metoduna geçirerek önceden kantize edilmiş bir AutoRound modelini yükleyin. Bu yöntem, [Accelerate](https://hf.co/docs/accelerate/index) üzerinden yüklenen ve `torch.nn.Linear` katmanlarına sahip herhangi bir modelle çalışır. | |
| Bir pipeline'ın belirli bileşenlerini kuantize etmek için [PipelineQuantizationConfig](/docs/diffusers/main/tr/api/quantization#diffusers.PipelineQuantizationConfig) kullanabilirsiniz: | |
| ```python | |
| import torch | |
| from diffusers import DiffusionPipeline, PipelineQuantizationConfig, AutoRoundConfig | |
| pipeline_quant_config = PipelineQuantizationConfig( | |
| quant_mapping={"transformer": AutoRoundConfig(backend="auto")} | |
| ) | |
| pipe = DiffusionPipeline.from_pretrained( | |
| "INCModel/Z-Image-W4A16-AutoRound", | |
| quantization_config=pipeline_quant_config, | |
| dtype=torch.bfloat16, | |
| device_map="cuda", # or "mps", "xpu", "cpu" | |
| ) | |
| image = pipe("a cat holding a sign that says hello").images[0] | |
| image.save("output.png") | |
| ``` | |
| Veya bir kuantize model bileşenini doğrudan yükleyin: | |
| ```python | |
| import torch | |
| from diffusers import ZImageTransformer2DModel, ZImagePipeline, AutoRoundConfig | |
| model_id = "INCModel/Z-Image-W4A16-AutoRound" | |
| quantization_config = AutoRoundConfig(backend="auto") | |
| transformer = ZImageTransformer2DModel.from_pretrained( | |
| model_id, | |
| subfolder="transformer", | |
| quantization_config=quantization_config, | |
| dtype=torch.bfloat16, | |
| device_map="cuda", # or "mps", "xpu", "cpu" | |
| ) | |
| pipe = ZImagePipeline.from_pretrained( | |
| model_id, | |
| transformer=transformer, | |
| dtype=torch.bfloat16, | |
| device_map="cuda", | |
| ) | |
| image = pipe("a cat holding a sign that says hello").images[0] | |
| image.save("output.png") | |
| ``` | |
| > [!NOTE] | |
| > Diffusers içindeki AutoRound yalnızca *önceden kuantize edilmiş* modellerin yüklenmesini destekler. Bir modeli sıfırdan kuantize etmek için [AutoRound CLI veya Python API](https://github.com/intel/auto-round) doğrudan kullanılmalı, ardından sonuç Diffusers ile yüklenmelidir. | |
| ## torch.compile | |
| AutoRound, daha hızlı çıkarım için [`torch.compile`](../optimization/fp16#torchcompile) ile uyumludur. Daha iyi performans için kuantize edilmiş dönüştürücüyü (DiT) derleyebilirsiniz: | |
| ```python | |
| import torch | |
| from diffusers import DiffusionPipeline, PipelineQuantizationConfig, AutoRoundConfig | |
| pipeline_quant_config = PipelineQuantizationConfig( | |
| quant_mapping={"transformer": AutoRoundConfig(backend="auto")} | |
| ) | |
| pipe = DiffusionPipeline.from_pretrained( | |
| "INCModel/Z-Image-W4A16-AutoRound", | |
| quantization_config=pipeline_quant_config, | |
| dtype=torch.bfloat16, | |
| device_map="cuda", # or "mps", "xpu", "cpu" | |
| ) | |
| pipe.transformer = torch.compile(pipe.transformer, mode="default", fullgraph=False) | |
| ``` | |
| ## Arka Uçlar | |
| AutoRound, ağırlık-özel (weight-only) kuantize modeller için birden çok çıkarım (inference) arka ucunu destekler. Arka uç, ileri geçiş sırasında dekuantizasyonu hangi çekirdeğin (kernel) işleyeceğini belirler. Birini seçmek için `AutoRoundConfig` içindeki `backend` parametresini ayarlayın: | |
| | Arka uç | Değer | Cihaz | Gereksinimler | Notlar | | |
| |---------|-------|--------|--------------|-------| | |
| | **Otomatik** | `"auto"` | Herhangi | — | Varsayılan. Kullanılabilir en iyi arka ucu otomatik olarak seçer. | | |
| | **PyTorch** | `"torch"` | CPU / CUDA | — | Saf PyTorch uygulaması. En geniş uyumluluk. | | |
| | **Triton** | `"tritonv2"` | CUDA | `triton` | GPU çıkarımı için Triton tabanlı çekirdek. | | |
| | **ExllamaV2** | `"exllamav2"` | CUDA | `gptqmodel>=5.8.0` | ExllamaV2 çekirdeği sayesinde iyi CUDA performansı. | | |
| | **Marlin** | `"marlin"` | CUDA | `gptqmodel>=5.8.0` | Marlin çekirdeği ile en iyi CUDA performansı. | | |
| ```python | |
| from diffusers import AutoRoundConfig | |
| # Auto-select (default) | |
| config = AutoRoundConfig() | |
| # Explicit Triton backend for CUDA | |
| config = AutoRoundConfig(backend="tritonv2") | |
| # Marlin backend for best CUDA performance (requires gptqmodel>=5.8.0) | |
| config = AutoRoundConfig(backend="marlin") | |
| # ExllamaV2 backend for good CUDA performance (requires gptqmodel>=5.8.0) | |
| config = AutoRoundConfig(backend="exllamav2") | |
| # PyTorch backend for CPU/CUDA inference | |
| config = AutoRoundConfig(backend="torch") | |
| ``` | |
| ## Kaydet ve yükle | |
| AutoRound, bir modeli kuantize etmek için veri kalibrasyonu gerektirir. Bu işlem, Diffusers dışında doğrudan [AutoRound kütüphanesi](https://github.com/intel/auto-round) kullanılarak yapılır: | |
| ```python | |
| from auto_round import AutoRound | |
| autoround = AutoRound( | |
| "Tongyi-MAI/Z-Image", | |
| scheme="W4A16", # W4G128 symmetric | |
| enable_torch_compile=True, | |
| num_inference_steps=3, | |
| guidance_scale=7.5, | |
| dataset="coco2014", | |
| ) | |
| autoround.quantize_and_save("Z-Image-W4A16-AutoRound") | |
| ``` | |
| Kalibrasyon seçenekleri hakkında daha fazla ayrıntı için [AutoRound belgelerini](https://github.com/intel/auto-round) inceleyin. | |
| ```python | |
| import torch | |
| from diffusers import ZImageTransformer2DModel, ZImagePipeline | |
| model_id = "INCModel/Z-Image-W4A16-AutoRound" | |
| # The inference backend will be automatically selected. | |
| pipe = ZImagePipeline.from_pretrained( | |
| model_id, | |
| dtype=torch.bfloat16, | |
| device_map="cuda", # or "mps", "xpu", "cpu" | |
| ) | |
| image = pipe("a cat holding a sign that says hello").images[0] | |
| image.save("output.png") | |
| ``` | |
| ### Desteklenen Kuantizasyon Şemaları | |
| AutoRound birkaç Şema'yı destekler: | |
| - **W4A16**(bits:4,group_size:128,sym:True,act_bits:16) | |
| - **W8A16**(bits:8,group_size:128,sym:True,act_bits:16) | |
| - **W3A16**(bits:3,group_size:128,sym:True,act_bits:16) | |
| - **W2A16**(bits:2,group_size:128,sym:True,act_bits:16) | |
| - **GGUF:Q4_K_M**(llamacpp tarafından sağlanan tüm Q*_K,Q*_0,Q*_1 desteklenir) | |
| - **NVFP4**(Deneysel özellik, `llm_compressor` biçimine dışa aktarılması önerilir. data_type nvfp4,act_data_type nvfp4,static_global_scale,group_size 16) | |
| - **MXFP4**(**Araştırma özelliği, gerçek çekirdek yok**, Standart MXFP4, data_type mxfp,act_data_type mxfp,bits 4, act_bits 4, group_size 32) | |
| - **MXINT4**(**Araştırma özelliği, gerçek çekirdek yok**, Standart MXINT4, data_type mxint,act_data_type mxint,bits 4, act_bits 4, group_size 32) | |
| - **MXFP4_RCEIL**(**Araştırma özelliği, gerçek çekirdek yok**, NVIDIA'nın varyantı, data_type mxfp, act_data_type mxfp_rceil, bits 4, act_bits 4, group_size 32) | |
| - **MXFP8**(**Araştırma özelliği, gerçek çekirdek yok**, data_type mxfp,act_data_type mxfp_rceil,group_size 32) | |
| - **FPW8A16**(**Araştırma özelliği, gerçek çekirdek yok**, data_type fp8,group_size 0->per tensor ) | |
| - **FP8_STATIC**(**Araştırma özelliği, gerçek çekirdek yok**, data_type:fp8,act_data_type:fp8,group_size -1 ->kanal başına, act_group_size=0->tensör başına) | |
| Bunun dışında, `group_size`, `bits`, `sym` ve istediğiniz birçok diğer yapılandırmayı değiştirebilirsiniz, ancak gerçek çekirdekler olmayabilir. | |
| ## Kaynaklar | |
| - [Hub'daki önceden kuantize edilmiş AutoRound modelleri](https://huggingface.co/models?search=autoround) | |
Xet Storage Details
- Size:
- 7.84 kB
- Xet hash:
- 3fee7733021a130eeedd6d6bd2c576906b7da0db8ecb04da906fa7966e7de3c6
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.