Buckets:
| <meta charset="utf-8" /><meta name="hf:doc:metadata" content="{"title":"AutoRound","local":"autoround","sections":[{"title":"Load a quantized model","local":"load-a-quantized-model","sections":[],"depth":2},{"title":"torch.compile","local":"torchcompile","sections":[],"depth":2},{"title":"Backends","local":"backends","sections":[],"depth":2},{"title":"Save and load","local":"save-and-load","sections":[{"title":"Supported Quantization Schemes","local":"supported-quantization-schemes","sections":[],"depth":3}],"depth":2},{"title":"Resources","local":"resources","sections":[],"depth":2}],"depth":1}"> | |
| <link href="/docs/diffusers/pr_13485/en/_app/immutable/assets/0.e3b0c442.css" rel="modulepreload"> | |
| <link rel="modulepreload" href="/docs/diffusers/pr_13485/en/_app/immutable/entry/start.e61dc983.js"> | |
| <link rel="modulepreload" href="/docs/diffusers/pr_13485/en/_app/immutable/chunks/scheduler.53228c21.js"> | |
| <link rel="modulepreload" href="/docs/diffusers/pr_13485/en/_app/immutable/chunks/singletons.dad46fe2.js"> | |
| <link rel="modulepreload" href="/docs/diffusers/pr_13485/en/_app/immutable/chunks/index.e93d0901.js"> | |
| <link rel="modulepreload" href="/docs/diffusers/pr_13485/en/_app/immutable/chunks/paths.bf5b33bd.js"> | |
| <link rel="modulepreload" href="/docs/diffusers/pr_13485/en/_app/immutable/entry/app.310c9973.js"> | |
| <link rel="modulepreload" href="/docs/diffusers/pr_13485/en/_app/immutable/chunks/preload-helper.8e82ef81.js"> | |
| <link rel="modulepreload" href="/docs/diffusers/pr_13485/en/_app/immutable/chunks/index.cac5d66a.js"> | |
| <link rel="modulepreload" href="/docs/diffusers/pr_13485/en/_app/immutable/nodes/0.751a844b.js"> | |
| <link rel="modulepreload" href="/docs/diffusers/pr_13485/en/_app/immutable/chunks/each.e59479a4.js"> | |
| <link rel="modulepreload" href="/docs/diffusers/pr_13485/en/_app/immutable/nodes/302.37f9a775.js"> | |
| <link rel="modulepreload" href="/docs/diffusers/pr_13485/en/_app/immutable/chunks/CopyLLMTxtMenu.a125c963.js"> | |
| <link rel="modulepreload" href="/docs/diffusers/pr_13485/en/_app/immutable/chunks/globals.7f7f1b26.js"> | |
| <link rel="modulepreload" href="/docs/diffusers/pr_13485/en/_app/immutable/chunks/IconCopy.56f02e4d.js"> | |
| <link rel="modulepreload" href="/docs/diffusers/pr_13485/en/_app/immutable/chunks/MermaidChart.svelte_svelte_type_style_lang.1f7a3169.js"> | |
| <link rel="modulepreload" href="/docs/diffusers/pr_13485/en/_app/immutable/chunks/CodeBlock.606cbaf4.js"> | |
| <link rel="modulepreload" href="/docs/diffusers/pr_13485/en/_app/immutable/chunks/HfOption.6b51ddef.js"><!-- HEAD_svelte-u9bgzb_START --><meta name="hf:doc:metadata" content="{"title":"AutoRound","local":"autoround","sections":[{"title":"Load a quantized model","local":"load-a-quantized-model","sections":[],"depth":2},{"title":"torch.compile","local":"torchcompile","sections":[],"depth":2},{"title":"Backends","local":"backends","sections":[],"depth":2},{"title":"Save and load","local":"save-and-load","sections":[{"title":"Supported Quantization Schemes","local":"supported-quantization-schemes","sections":[],"depth":3}],"depth":2},{"title":"Resources","local":"resources","sections":[],"depth":2}],"depth":1}"><!-- HEAD_svelte-u9bgzb_END --> <p></p> <div class="items-center shrink-0 min-w-[100px] max-sm:min-w-[50px] justify-end ml-auto flex" style="float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"><div class="inline-flex rounded-md max-sm:rounded-sm"><button class="inline-flex items-center gap-1 h-7 max-sm:h-7 px-2 max-sm:px-1.5 text-sm font-medium text-gray-800 border border-r-0 rounded-l-md max-sm:rounded-l-sm border-gray-200 bg-white hover:shadow-inner dark:border-gray-850 dark:bg-gray-950 dark:text-gray-200 dark:hover:bg-gray-800" aria-live="polite"><span class="inline-flex items-center justify-center rounded-md p-0.5 max-sm:p-0 hover:text-gray-800 dark:hover:text-gray-200"><svg class="sm:size-3.5 size-3" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg></span> <span>Copy page</span></button> <button class="inline-flex items-center justify-center w-6 max-sm:w-5 h-7 max-sm:h-7 disabled:pointer-events-none text-sm text-gray-500 hover:text-gray-700 dark:hover:text-white rounded-r-md max-sm:rounded-r-sm border border-l transition border-gray-200 bg-white hover:shadow-inner dark:border-gray-850 dark:bg-gray-950 dark:text-gray-200 dark:hover:bg-gray-800" aria-haspopup="menu" aria-expanded="false" aria-label="Open copy menu"><svg class="transition-transform text-gray-400 overflow-visible sm:size-3.5 size-3 rotate-0" width="1em" height="1em" viewBox="0 0 12 7" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M1 1L6 6L11 1" stroke="currentColor"></path></svg></button></div> </div> <h1 class="relative group"><a id="autoround" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#autoround"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>AutoRound</span></h1> <p data-svelte-h="svelte-tu5itb"><a href="https://github.com/intel/auto-round" rel="nofollow">AutoRound</a> is an advanced quantization toolkit. It achieves high accuracy at ultra-low bit widths (2-4 bits) with minimal tuning by leveraging sign-gradient descent and providing broad hardware compatibility. See our papers <a href="https://arxiv.org/pdf/2309.05516" rel="nofollow">SignRoundV1</a> and <a href="https://arxiv.org/abs/2512.04746" rel="nofollow">SignRoundV2</a> for more details.</p> <p data-svelte-h="svelte-ywdyzu">Install <code>auto-round</code>(version ≥ 0.13.0):</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class="language-bash "><!-- HTML_TAG_START -->pip install <span class="hljs-string">"auto-round>=0.13.0"</span><!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-14f8r8m">To use the Marlin kernel for faster CUDA inference, install <code>gptqmodel</code>:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class="language-bash "><!-- HTML_TAG_START -->pip install <span class="hljs-string">"gptqmodel>=5.8.0"</span><!-- HTML_TAG_END --></pre></div> <h2 class="relative group"><a id="load-a-quantized-model" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#load-a-quantized-model"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Load a quantized model</span></h2> <p data-svelte-h="svelte-sdkz52">Load a pre-quantized AutoRound model by passing <code>AutoRoundConfig</code> to <a href="/docs/diffusers/pr_13485/en/api/models/overview#diffusers.ModelMixin.from_pretrained">from_pretrained()</a>. The method works with any model that loads via <a href="https://hf.co/docs/accelerate/index" rel="nofollow">Accelerate</a> and has <code>torch.nn.Linear</code> layers.</p> <p data-svelte-h="svelte-6zmrxj">You can use <a href="/docs/diffusers/pr_13485/en/api/quantization#diffusers.PipelineQuantizationConfig">PipelineQuantizationConfig</a> to quantize specific components of a pipeline:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class="language-python "><!-- HTML_TAG_START --><span class="hljs-keyword">import</span> torch | |
| <span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DiffusionPipeline, PipelineQuantizationConfig, AutoRoundConfig | |
| pipeline_quant_config = PipelineQuantizationConfig( | |
| quant_mapping={<span class="hljs-string">"transformer"</span>: AutoRoundConfig(backend=<span class="hljs-string">"auto"</span>)} | |
| ) | |
| pipe = DiffusionPipeline.from_pretrained( | |
| <span class="hljs-string">"INCModel/Z-Image-W4A16-AutoRound"</span>, | |
| quantization_config=pipeline_quant_config, | |
| torch_dtype=torch.bfloat16, | |
| device_map=<span class="hljs-string">"cuda"</span>, | |
| ) | |
| image = pipe(<span class="hljs-string">"a cat holding a sign that says hello"</span>).images[<span class="hljs-number">0</span>] | |
| image.save(<span class="hljs-string">"output.png"</span>)<!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-11unngb">Or load a quantized model component directly:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class="language-python "><!-- HTML_TAG_START --><span class="hljs-keyword">import</span> torch | |
| <span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> ZImageTransformer2DModel, ZImagePipeline, AutoRoundConfig | |
| model_id = <span class="hljs-string">"INCModel/Z-Image-W4A16-AutoRound"</span> | |
| quantization_config = AutoRoundConfig(backend=<span class="hljs-string">"auto"</span>) | |
| transformer = ZImageTransformer2DModel.from_pretrained( | |
| model_id, | |
| subfolder=<span class="hljs-string">"transformer"</span>, | |
| quantization_config=quantization_config, | |
| torch_dtype=torch.bfloat16, | |
| device_map=<span class="hljs-string">"cuda"</span>, | |
| ) | |
| pipe = ZImagePipeline.from_pretrained( | |
| model_id, | |
| transformer=transformer, | |
| torch_dtype=torch.bfloat16, | |
| device_map=<span class="hljs-string">"cuda"</span>, | |
| ) | |
| image = pipe(<span class="hljs-string">"a cat holding a sign that says hello"</span>).images[<span class="hljs-number">0</span>] | |
| image.save(<span class="hljs-string">"output.png"</span>)<!-- HTML_TAG_END --></pre></div> <blockquote class="note" data-svelte-h="svelte-f34jbl"><p>AutoRound in Diffusers only supports loading <em>pre-quantized</em> models. To quantize a model from scratch, use the <a href="https://github.com/intel/auto-round" rel="nofollow">AutoRound CLI or Python API</a> directly, then load the result with Diffusers.</p></blockquote> <h2 class="relative group"><a id="torchcompile" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#torchcompile"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>torch.compile</span></h2> <p data-svelte-h="svelte-1ocfcf1">AutoRound is compatible with <a href="../optimization/fp16#torchcompile"><code>torch.compile</code></a> for faster inference. You can compile the quantized transformer (DiT) for better performance:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class="language-python "><!-- HTML_TAG_START --><span class="hljs-keyword">import</span> torch | |
| <span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DiffusionPipeline, PipelineQuantizationConfig, AutoRoundConfig | |
| pipeline_quant_config = PipelineQuantizationConfig( | |
| quant_mapping={<span class="hljs-string">"transformer"</span>: AutoRoundConfig(backend=<span class="hljs-string">"auto"</span>)} | |
| ) | |
| pipe = DiffusionPipeline.from_pretrained( | |
| <span class="hljs-string">"INCModel/Z-Image-W4A16-AutoRound"</span>, | |
| quantization_config=pipeline_quant_config, | |
| torch_dtype=torch.bfloat16, | |
| device_map=<span class="hljs-string">"cuda"</span>, | |
| ) | |
| pipe.transformer = torch.<span class="hljs-built_in">compile</span>(pipe.transformer, mode=<span class="hljs-string">"default"</span>, fullgraph=<span class="hljs-literal">False</span>)<!-- HTML_TAG_END --></pre></div> <h2 class="relative group"><a id="backends" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#backends"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Backends</span></h2> <p data-svelte-h="svelte-toaxv">AutoRound supports multiple inference backends for Weight-only quantized model. The backend controls which kernel handles dequantization during the forward pass. Set the <code>backend</code> parameter in <code>AutoRoundConfig</code> to choose one:</p> <table data-svelte-h="svelte-1d1ivlc"><thead><tr><th>Backend</th> <th>Value</th> <th>Device</th> <th>Requirements</th> <th>Notes</th></tr></thead> <tbody><tr><td><strong>Auto</strong></td> <td><code>"auto"</code></td> <td>Any</td> <td>—</td> <td>Default. Automatically selects the best available backend.</td></tr> <tr><td><strong>PyTorch</strong></td> <td><code>"torch"</code></td> <td>CPU / CUDA</td> <td>—</td> <td>Pure PyTorch implementation. Broadest compatibility.</td></tr> <tr><td><strong>Triton</strong></td> <td><code>"tritonv2"</code></td> <td>CUDA</td> <td><code>triton</code></td> <td>Triton-based kernel for GPU inference.</td></tr> <tr><td><strong>ExllamaV2</strong></td> <td><code>"exllamav2"</code></td> <td>CUDA</td> <td><code>gptqmodel>=5.8.0</code></td> <td>Good CUDA performance via the ExllamaV2 kernel.</td></tr> <tr><td><strong>Marlin</strong></td> <td><code>"marlin"</code></td> <td>CUDA</td> <td><code>gptqmodel>=5.8.0</code></td> <td>Best CUDA performance via the Marlin kernel.</td></tr></tbody></table> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class="language-python "><!-- HTML_TAG_START --><span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> AutoRoundConfig | |
| <span class="hljs-comment"># Auto-select (default)</span> | |
| config = AutoRoundConfig() | |
| <span class="hljs-comment"># Explicit Triton backend for CUDA</span> | |
| config = AutoRoundConfig(backend=<span class="hljs-string">"tritonv2"</span>) | |
| <span class="hljs-comment"># Marlin backend for best CUDA performance (requires gptqmodel>=5.8.0)</span> | |
| config = AutoRoundConfig(backend=<span class="hljs-string">"marlin"</span>) | |
| <span class="hljs-comment"># ExllamaV2 backend for good CUDA performance (requires gptqmodel>=5.8.0)</span> | |
| config = AutoRoundConfig(backend=<span class="hljs-string">"exllamav2"</span>) | |
| <span class="hljs-comment"># PyTorch backend for CPU/CUDA inference</span> | |
| config = AutoRoundConfig(backend=<span class="hljs-string">"torch"</span>)<!-- HTML_TAG_END --></pre></div> <h2 class="relative group"><a id="save-and-load" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#save-and-load"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Save and load</span></h2> <div class="flex space-x-2 items-center my-1.5 mr-8 h-7 !pl-0 -mx-3 md:mx-0"><div class="flex items-center border rounded-lg px-1.5 py-1 leading-none select-none text-smd border-gray-800 bg-black dark:bg-gray-700 text-white">save </div><div class="flex items-center border rounded-lg px-1.5 py-1 leading-none select-none text-smd text-gray-500 cursor-pointer opacity-90 hover:text-gray-700 dark:hover:text-gray-200 hover:shadow-sm">load </div></div> <div class="language-select"><p data-svelte-h="svelte-1pu3qmj">AutoRound requires data calibration to quantize a model. This is done outside of Diffusers using the <a href="https://github.com/intel/auto-round" rel="nofollow">AutoRound library</a> directly:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class="language-python "><!-- HTML_TAG_START --><span class="hljs-keyword">from</span> auto_round <span class="hljs-keyword">import</span> AutoRound | |
| autoround = AutoRound( | |
| <span class="hljs-string">"Tongyi-MAI/Z-Image"</span>, | |
| scheme=<span class="hljs-string">"W4A16"</span>, <span class="hljs-comment"># W4G128 symmetric</span> | |
| enable_torch_compile=<span class="hljs-literal">True</span>, | |
| num_inference_steps=<span class="hljs-number">3</span>, | |
| guidance_scale=<span class="hljs-number">7.5</span>, | |
| dataset=<span class="hljs-string">"coco2014"</span>, | |
| ) | |
| autoround.quantize_and_save(<span class="hljs-string">"Z-Image-W4A16-AutoRound"</span>)<!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-22mbbc">For more details on calibration options, see the <a href="https://github.com/intel/auto-round" rel="nofollow">AutoRound documentation</a>.</p> </div> <h3 class="relative group"><a id="supported-quantization-schemes" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#supported-quantization-schemes"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Supported Quantization Schemes</span></h3> <p data-svelte-h="svelte-1fpnfaj">AutoRound supports several Schemes:</p> <ul data-svelte-h="svelte-ju3s1"><li><strong>W4A16</strong>(bits:4,group_size:128,sym:True,act_bits:16)</li> <li><strong>W8A16</strong>(bits:8,group_size:128,sym:True,act_bits:16)</li> <li><strong>W3A16</strong>(bits:3,group_size:128,sym:True,act_bits:16)</li> <li><strong>W2A16</strong>(bits:2,group_size:128,sym:True,act_bits:16)</li> <li><strong>GGUF:Q4_K_M</strong>(all Q<em>_K,Q</em>_0,Q*_1 provided by llamacpp are supported)</li> <li><strong>NVFP4</strong>(Experimental feature, recommend exporting to <code>llm_compressor</code> format.data_type nvfp4,act_data_type nvfp4,static_global_scale,group_size 16)</li> <li><strong>MXFP4</strong>(<strong>Research feature, no real kernel</strong>, Standard MXFP4, data_type mxfp,act_data_type mxfp,bits 4, act_bits 4, group_size 32)</li> <li><strong>MXINT4</strong>(<strong>Research feature, no real kernel</strong>, Standard MXINT4, data_type mxint,act_data_type mxint,bits 4, act_bits 4, group_size 32)</li> <li><strong>MXFP4_RCEIL</strong>(<strong>Research feature,no real kernel</strong>, NVIDIA’s variant, data_type mxfp,act_data_type mxfp_rceil,bits 4, act_bits 4, group_size 32)</li> <li><strong>MXFP8</strong>(<strong>Research feature, no real kernel</strong>, data_type mxfp,act_data_type mxfp_rceil,group_size 32)</li> <li><strong>FPW8A16</strong>(<strong>Research feature, no real kernel</strong>, data_type fp8,group_size 0->per tensor )</li> <li><strong>FP8_STATIC</strong>(<strong>Research feature, no real kernel</strong>, data_type:fp8,act_data_type:fp8,group_size -1 ->per channel, act_group_size=0->per tensor)</li></ul> <p data-svelte-h="svelte-1ibw6p1">Besides, you could modify the <code>group_size</code>, <code>bits</code>, <code>sym</code> and many other configs you want, though there are maybe no real kernels.</p> <h2 class="relative group"><a id="resources" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#resources"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Resources</span></h2> <ul data-svelte-h="svelte-149tol8"><li><a href="https://huggingface.co/models?search=autoround" rel="nofollow">Pre-quantized AutoRound models on the Hub</a></li></ul> <a class="!text-gray-400 !no-underline text-sm flex items-center not-prose mt-4" href="https://github.com/huggingface/diffusers/blob/main/docs/source/en/quantization/autoround.md" target="_blank"><svg class="mr-1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M31,16l-7,7l-1.41-1.41L28.17,16l-5.58-5.59L24,9l7,7z"></path><path d="M1,16l7-7l1.41,1.41L3.83,16l5.58,5.59L8,23l-7-7z"></path><path d="M12.419,25.484L17.639,6.552l1.932,0.518L14.351,26.002z"></path></svg> <span data-svelte-h="svelte-zjs2n5"><span class="underline">Update</span> on GitHub</span></a> <p></p> | |
| <script> | |
| { | |
| __sveltekit_wf41pu = { | |
| assets: "/docs/diffusers/pr_13485/en", | |
| base: "/docs/diffusers/pr_13485/en", | |
| env: {} | |
| }; | |
| const element = document.currentScript.parentElement; | |
| const data = [null,null]; | |
| Promise.all([ | |
| import("/docs/diffusers/pr_13485/en/_app/immutable/entry/start.e61dc983.js"), | |
| import("/docs/diffusers/pr_13485/en/_app/immutable/entry/app.310c9973.js") | |
| ]).then(([kit, app]) => { | |
| kit.start(app, element, { | |
| node_ids: [0, 302], | |
| data, | |
| form: null, | |
| error: null | |
| }); | |
| }); | |
| } | |
| </script> | |
Xet Storage Details
- Size:
- 34.3 kB
- Xet hash:
- 7273cfa37376d4809051d2afd59ca20470ca78e5bfa1fc4c331c9c40cd7e6e83
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.