Buckets:

mishig's picture
download
raw
36.3 kB
<meta charset="utf-8" /><meta name="hf:doc:metadata" content="{&quot;title&quot;:&quot;AutoRound&quot;,&quot;local&quot;:&quot;autoround&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;양자화된 모델 로드&quot;,&quot;local&quot;:&quot;load-a-quantized-model&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;torch.compile&quot;,&quot;local&quot;:&quot;torchcompile&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;백엔드&quot;,&quot;local&quot;:&quot;backends&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;저장 및 로드&quot;,&quot;local&quot;:&quot;save-and-load&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;지원되는 양자화 스킴&quot;,&quot;local&quot;:&quot;supported-quantization-schemes&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3}],&quot;depth&quot;:2},{&quot;title&quot;:&quot;리소스&quot;,&quot;local&quot;:&quot;resources&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2}],&quot;depth&quot;:1}"/>
<link href="/docs/diffusers/main/en/_app/immutable/entry/start.vZc-dOUR.js" rel="modulepreload">
<link href="/docs/diffusers/main/en/_app/immutable/chunks/Bafuik5c.js" rel="modulepreload">
<link href="/docs/diffusers/main/en/_app/immutable/chunks/Bupkjr9f.js" rel="modulepreload">
<link href="/docs/diffusers/main/en/_app/immutable/entry/app.B6c3Ml05.js" rel="modulepreload">
<link href="/docs/diffusers/main/en/_app/immutable/chunks/CyvZ3FS5.js" rel="modulepreload">
<link href="/docs/diffusers/main/en/_app/immutable/chunks/l0QnnOED.js" rel="modulepreload">
<link href="/docs/diffusers/main/en/_app/immutable/chunks/DnVIJfC5.js" rel="modulepreload">
<link href="/docs/diffusers/main/en/_app/immutable/chunks/DsnmJJEf.js" rel="modulepreload">
<link href="/docs/diffusers/main/en/_app/immutable/nodes/0.BQlx092V.js" rel="modulepreload">
<link href="/docs/diffusers/main/en/_app/immutable/chunks/CoSrdQax.js" rel="modulepreload">
<link href="/docs/diffusers/main/en/_app/immutable/nodes/342.Cgc9nrsO.js" rel="modulepreload">
<link href="/docs/diffusers/main/en/_app/immutable/chunks/B4AMoTAu.js" rel="modulepreload">
<link href="/docs/diffusers/main/en/_app/immutable/chunks/B_Tpb3TG.js" rel="modulepreload">
<!--1vyqseg--><meta name="hf:doc:metadata" content="{&quot;title&quot;:&quot;AutoRound&quot;,&quot;local&quot;:&quot;autoround&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;Load a quantized model&quot;,&quot;local&quot;:&quot;load-a-quantized-model&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;torch.compile&quot;,&quot;local&quot;:&quot;torchcompile&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Backends&quot;,&quot;local&quot;:&quot;backends&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Save and load&quot;,&quot;local&quot;:&quot;save-and-load&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;Supported Quantization Schemes&quot;,&quot;local&quot;:&quot;supported-quantization-schemes&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3}],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Resources&quot;,&quot;local&quot;:&quot;resources&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2}],&quot;depth&quot;:1}"/><!---->
<link href="/docs/diffusers/main/en/_app/immutable/assets/0.tn0RQdqM.css" rel="modulepreload"> <!--[--><!--[0--><!--[--><!--[0--><!--[--><p></p> <div class="items-center shrink-0 min-w-[100px] max-sm:min-w-[50px] justify-end ml-auto flex" style="float: inline-end; margin-inline-start: 10px; display: inline-flex; position: relative; z-index: 10;"><div dir="ltr" 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 dir="auto">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> <!--[-1--><!--]--></div><!----> <!--[0--><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 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><a href="https://github.com/intel/auto-round" rel="nofollow">AutoRound</a>는 고급 양자화 툴킷입니다. 부호-경사 하강(sign-gradient descent)을 활용하고 광범위한 하드웨어 호환성을 제공하여, 최소한의 튜닝으로 초저 비트 폭(2~4비트)에서도 높은 정확도를 달성합니다. 자세한 내용은 <a href="https://arxiv.org/pdf/2309.05516" rel="nofollow">SignRoundV1</a> 및 <a href="https://arxiv.org/abs/2512.04746" rel="nofollow">SignRoundV2</a> 논문을 참고하세요.</p> <p><code>auto-round</code>(버전 ≥ 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 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> 복사됨</div><!----></button><!----></div> <pre class="language-bash "><!---->pip install <span class="hljs-string">&quot;auto-round&gt;=0.13.0&quot;</span><!----></pre></div><!----> <p>더 빠른 CUDA 추론을 위해 Marlin 커널을 사용하려면 <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 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> 복사됨</div><!----></button><!----></div> <pre class="language-bash "><!---->pip install <span class="hljs-string">&quot;gptqmodel&gt;=5.8.0&quot;</span><!----></pre></div><!----> <!--[1--><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 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><!---->양자화된 모델 로드<!----></span></h2><!--]--><!----> <p><code>AutoRoundConfig</code>를 <a href="/docs/diffusers/main/ko/api/models/overview#diffusers.ModelMixin.from_pretrained">from_pretrained()</a>에 전달하여 사전 양자화된 AutoRound 모델을 로드합니다. 이 메서드는 <a href="https://hf.co/docs/accelerate/index" rel="nofollow">Accelerate</a>를 통해 로드되고 <code>torch.nn.Linear</code> 레이어를 가진 모든 모델에서 작동합니다.</p> <p><a href="/docs/diffusers/main/ko/api/quantization#diffusers.PipelineQuantizationConfig">PipelineQuantizationConfig</a>를 사용하여 파이프라인의 특정 구성 요소를 양자화할 수 있습니다:</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 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> 복사됨</div><!----></button><!----></div> <pre class="language-python "><!----><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">&quot;transformer&quot;</span>: AutoRoundConfig(backend=<span class="hljs-string">&quot;auto&quot;</span>)}
)
pipe = DiffusionPipeline.from_pretrained(
<span class="hljs-string">&quot;INCModel/Z-Image-W4A16-AutoRound&quot;</span>,
quantization_config=pipeline_quant_config,
dtype=torch.bfloat16,
device_map=<span class="hljs-string">&quot;cuda&quot;</span>, <span class="hljs-comment"># or &quot;mps&quot;, &quot;xpu&quot;, &quot;cpu&quot;</span>
)
image = pipe(<span class="hljs-string">&quot;a cat holding a sign that says hello&quot;</span>).images[<span class="hljs-number">0</span>]
image.save(<span class="hljs-string">&quot;output.png&quot;</span>)<!----></pre></div><!----> <p>또는 양자화된 모델 구성 요소를 직접 로드합니다:</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 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> 복사됨</div><!----></button><!----></div> <pre class="language-python "><!----><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">&quot;INCModel/Z-Image-W4A16-AutoRound&quot;</span>
quantization_config = AutoRoundConfig(backend=<span class="hljs-string">&quot;auto&quot;</span>)
transformer = ZImageTransformer2DModel.from_pretrained(
model_id,
subfolder=<span class="hljs-string">&quot;transformer&quot;</span>,
quantization_config=quantization_config,
dtype=torch.bfloat16,
device_map=<span class="hljs-string">&quot;cuda&quot;</span>, <span class="hljs-comment"># or &quot;mps&quot;, &quot;xpu&quot;, &quot;cpu&quot;</span>
)
pipe = ZImagePipeline.from_pretrained(
model_id,
transformer=transformer,
dtype=torch.bfloat16,
device_map=<span class="hljs-string">&quot;cuda&quot;</span>,
)
image = pipe(<span class="hljs-string">&quot;a cat holding a sign that says hello&quot;</span>).images[<span class="hljs-number">0</span>]
image.save(<span class="hljs-string">&quot;output.png&quot;</span>)<!----></pre></div><!----> <blockquote class="note"><p>Diffusers의 AutoRound는 <em>사전 양자화</em>된 모델만 로드하는 것을 지원합니다. 모델을 처음부터 양자화하려면 <a href="https://github.com/intel/auto-round" rel="nofollow">AutoRound CLI 또는 Python API</a>를 직접 사용하고, 그 결과를 Diffusers로 로드하세요.</p></blockquote> <!--[1--><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 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>AutoRound은 더 빠른 추론을 위해 <a href="../optimization/fp16#torchcompile"><code>torch.compile</code></a>과 호환됩니다. 더 나은 성능을 위해 양자화된 transformer(DiT)를 컴파일할 수 있습니다:</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 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> 복사됨</div><!----></button><!----></div> <pre class="language-python "><!----><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">&quot;transformer&quot;</span>: AutoRoundConfig(backend=<span class="hljs-string">&quot;auto&quot;</span>)}
)
pipe = DiffusionPipeline.from_pretrained(
<span class="hljs-string">&quot;INCModel/Z-Image-W4A16-AutoRound&quot;</span>,
quantization_config=pipeline_quant_config,
dtype=torch.bfloat16,
device_map=<span class="hljs-string">&quot;cuda&quot;</span>, <span class="hljs-comment"># or &quot;mps&quot;, &quot;xpu&quot;, &quot;cpu&quot;</span>
)
pipe.transformer = torch.<span class="hljs-built_in">compile</span>(pipe.transformer, mode=<span class="hljs-string">&quot;default&quot;</span>, fullgraph=<span class="hljs-literal">False</span>)<!----></pre></div><!----> <!--[1--><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 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><!---->백엔드<!----></span></h2><!--]--><!----> <p>AutoRound은 Weight-only 양자화 모델에 대해 여러 추론 백엔드를 지원합니다. 백엔드는 forward pass 동안 dequantization을 처리하는 커널을 제어합니다. <code>AutoRoundConfig</code>의 <code>backend</code> 매개변수를 설정하여 하나를 선택합니다:</p> <table><thead><tr><th>백엔드</th><th>값</th><th>장치</th><th>요구 사항</th><th>The input is a single word "Notes".
참고</th></tr></thead><tbody><tr><td><strong>Auto</strong></td><td><code>"auto"</code></td><td>모두</td><td>—</td><td>기본값. 사용 가능한 최적의 백엔드를 자동으로 선택합니다.</td></tr><tr><td><strong>PyTorch</strong></td><td><code>"torch"</code></td><td>CPU / CUDA</td><td>—</td><td>순수 PyTorch 구현. 가장 넓은 호환성.</td></tr><tr><td><strong>Triton</strong></td><td><code>"tritonv2"</code></td><td>CUDA</td><td><code>triton</code></td><td>GPU 추론을 위한 Triton 기반 커널.</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>ExllamaV2 커널을 통한 뛰어난 CUDA 성능.</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>Marlin 커널을 통해 최적의 CUDA 성능을 제공합니다.</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 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> 복사됨</div><!----></button><!----></div> <pre class="language-python "><!----><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">&quot;tritonv2&quot;</span>)
<span class="hljs-comment"># Marlin backend for best CUDA performance (requires gptqmodel&gt;=5.8.0)</span>
config = AutoRoundConfig(backend=<span class="hljs-string">&quot;marlin&quot;</span>)
<span class="hljs-comment"># ExllamaV2 backend for good CUDA performance (requires gptqmodel&gt;=5.8.0)</span>
config = AutoRoundConfig(backend=<span class="hljs-string">&quot;exllamav2&quot;</span>)
<span class="hljs-comment"># PyTorch backend for CPU/CUDA inference</span>
config = AutoRoundConfig(backend=<span class="hljs-string">&quot;torch&quot;</span>)<!----></pre></div><!----> <!--[1--><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 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><!---->저장 및 로드<!----></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">저장</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"><div><p>AutoRound은 모델을 양자화하기 위해 데이터 보정이 필요합니다. 이는 Diffusers 외부에서 <a href="https://github.com/intel/auto-round" rel="nofollow">AutoRound 라이브러리</a>를 직접 사용하여 수행됩니다:</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 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> 복사됨</div><!----></button><!----></div> <pre class="language-python "><!----><span class="hljs-keyword">from</span> auto_round <span class="hljs-keyword">import</span> AutoRound
autoround = AutoRound(
<span class="hljs-string">&quot;Tongyi-MAI/Z-Image&quot;</span>,
scheme=<span class="hljs-string">&quot;W4A16&quot;</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">&quot;coco2014&quot;</span>,
)
autoround.quantize_and_save(<span class="hljs-string">&quot;Z-Image-W4A16-AutoRound&quot;</span>)<!----></pre></div><!----> <p>교정 옵션에 대한 자세한 내용은 <a href="https://github.com/intel/auto-round" rel="nofollow">AutoRound 문서</a>를 참조하세요.</p><!----></div><!----> <div hidden=""><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 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> 복사됨</div><!----></button><!----></div> <pre class="language-python "><!----><span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> ZImageTransformer2DModel, ZImagePipeline
model_id = <span class="hljs-string">&quot;INCModel/Z-Image-W4A16-AutoRound&quot;</span>
<span class="hljs-comment"># The inference backend will be automatically selected.</span>
pipe = ZImagePipeline.from_pretrained(
model_id,
dtype=torch.bfloat16,
device_map=<span class="hljs-string">&quot;cuda&quot;</span>, <span class="hljs-comment"># or &quot;mps&quot;, &quot;xpu&quot;, &quot;cpu&quot;</span>
)
image = pipe(<span class="hljs-string">&quot;a cat holding a sign that says hello&quot;</span>).images[<span class="hljs-number">0</span>]
image.save(<span class="hljs-string">&quot;output.png&quot;</span>)<!----></pre></div><!----></div><!----><!----></div><!----> <!--[2--><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 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><!---->지원되는 양자화 스킴<!----></span></h3><!--]--><!----> <p>AutoRound은 여러 Schemes를 지원합니다:</p> <ul><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>(llamacpp에서 제공하는 모든 Q<em>_K,Q</em>_0,Q*_1이 지원됩니다)</li> <li><strong>NVFP4</strong>(실험적 기능, <code>llm_compressor</code> 형식으로 내보내는 것을 권장합니다. data_type nvfp4,act_data_type nvfp4,static_global_scale,group_size 16)</li> <li><strong>MXFP4</strong>(<strong>연구용 기능, 실제 커널 없음</strong>, 표준 MXFP4, data_type mxfp,act_data_type mxfp,bits 4, act_bits 4, group_size 32)</li> <li><strong>MXINT4</strong>(<strong>연구용 기능, 실제 커널 없음</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>연구용 기능, 실제 커널 없음</strong>, NVIDIA의 변형, data_type mxfp, act_data_type mxfp_rceil, bits 4, act_bits 4, group_size 32)</li> <li><strong>MXFP8</strong>(<strong>연구용 기능, 실제 커널 없음</strong>, data_type mxfp,act_data_type mxfp_rceil,group_size 32)</li> <li><strong>FPW8A16</strong>(<strong>연구용 기능, 실제 커널 없음</strong>, data_type fp8,group_size 0-&gt;per tensor )</li> <li><strong>FP8_STATIC</strong>(<strong>연구용 기능, 실제 커널 없음</strong>, data_type:fp8,act_data_type:fp8,group_size -1 -&gt;채널별, act_group_size=0-&gt;텐서별)</li></ul> <p>또한, <code>group_size</code>, <code>bits</code>, <code>sym</code> 등 원하는 여러 설정을 수정할 수 있지만, 실제 커널이 없을 수 있습니다.</p> <!--[1--><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 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><!---->리소스<!----></span></h2><!--]--><!----> <ul><li><a href="https://huggingface.co/models?search=autoround" rel="nofollow">Hub의 사전 양자화 AutoRound 모델</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><span class="underline">Update</span> on GitHub</span></a><!----> <p></p><!--]--><!----><!--]--><!--]--><!--]--> <!--[-1--><!--]--><!--]-->
<script>
{
__sveltekit_1rjuniz = {
base: "/docs/diffusers/main/en",
assets: "/docs/diffusers/main/en"
};
const element = document.currentScript.parentElement;
Promise.all([
import("/docs/diffusers/main/en/_app/immutable/entry/start.vZc-dOUR.js"),
import("/docs/diffusers/main/en/_app/immutable/entry/app.B6c3Ml05.js")
]).then(([kit, app]) => {
kit.start(app, element, {
node_ids: [0, 342],
data: [null,null],
form: null,
error: null
});
});
}
</script>

Xet Storage Details

Size:
36.3 kB
·
Xet hash:
f39200dda55fe6d91b01e80b81675d393d2e20a7249a4f1a38188b33ae12617b

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.