Buckets:

HuggingFaceDocBuilder's picture
download
raw
19.3 kB
<meta charset="utf-8" /><meta name="hf:doc:metadata" content="{&quot;title&quot;:&quot;Quark&quot;,&quot;local&quot;:&quot;quark&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;지원 매트릭스&quot;,&quot;local&quot;:&quot;Support matrix&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Hugging Face Hub의 모델&quot;,&quot;local&quot;:&quot;Models on Hugging Face Hub&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Transformers에서 Quark모델 사용하기&quot;,&quot;local&quot;:&quot;Using Quark models in Transformers&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2}],&quot;depth&quot;:1}">
<link href="/docs/transformers/main/ko/_app/immutable/assets/0.e3b0c442.css" rel="modulepreload">
<link rel="modulepreload" href="/docs/transformers/main/ko/_app/immutable/entry/start.7dba37eb.js">
<link rel="modulepreload" href="/docs/transformers/main/ko/_app/immutable/chunks/scheduler.53228c21.js">
<link rel="modulepreload" href="/docs/transformers/main/ko/_app/immutable/chunks/singletons.0ca3c1e2.js">
<link rel="modulepreload" href="/docs/transformers/main/ko/_app/immutable/chunks/index.e93d0901.js">
<link rel="modulepreload" href="/docs/transformers/main/ko/_app/immutable/chunks/paths.89b1ecb7.js">
<link rel="modulepreload" href="/docs/transformers/main/ko/_app/immutable/entry/app.d02eea18.js">
<link rel="modulepreload" href="/docs/transformers/main/ko/_app/immutable/chunks/preload-helper.cb103237.js">
<link rel="modulepreload" href="/docs/transformers/main/ko/_app/immutable/chunks/index.3db2ce32.js">
<link rel="modulepreload" href="/docs/transformers/main/ko/_app/immutable/nodes/0.5ffa0822.js">
<link rel="modulepreload" href="/docs/transformers/main/ko/_app/immutable/chunks/each.e59479a4.js">
<link rel="modulepreload" href="/docs/transformers/main/ko/_app/immutable/nodes/150.c7a9138d.js">
<link rel="modulepreload" href="/docs/transformers/main/ko/_app/immutable/chunks/CopyLLMTxtMenu.1327b590.js">
<link rel="modulepreload" href="/docs/transformers/main/ko/_app/immutable/chunks/MermaidChart.svelte_svelte_type_style_lang.49b88d99.js">
<link rel="modulepreload" href="/docs/transformers/main/ko/_app/immutable/chunks/CodeBlock.ada04ea6.js"><!-- HEAD_svelte-u9bgzb_START --><meta name="hf:doc:metadata" content="{&quot;title&quot;:&quot;Quark&quot;,&quot;local&quot;:&quot;quark&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;지원 매트릭스&quot;,&quot;local&quot;:&quot;Support matrix&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Hugging Face Hub의 모델&quot;,&quot;local&quot;:&quot;Models on Hugging Face Hub&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Transformers에서 Quark모델 사용하기&quot;,&quot;local&quot;:&quot;Using Quark models in Transformers&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2}],&quot;depth&quot;: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="quark" 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="#quark"><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>Quark</span></h1> <p data-svelte-h="svelte-me4vhl"><a href="https://quark.docs.amd.com/latest/" rel="nofollow">Quark</a>는 특정 데이터 타입, 알고리즘, 하드웨어에 구애받지 않도록 설계된 딥러닝 양자화 툴킷입니다. Quark에서는 다양한 전처리 전략, 알고리즘, 데이터 타입을 조합하여 사용할 수 있습니다.</p> <p data-svelte-h="svelte-1bunst5">🤗 Transformers를 통해 통합된 PyTorch 지원은 주로 AMD CPU 및 GPU를 대상으로 하며, 주로 평가 목적으로 사용됩니다. 예를 들어, <a href="https://github.com/EleutherAI/lm-evaluation-harness" rel="nofollow">lm-evaluation-harness</a>를 🤗 Transformers 백엔드와 함께 사용하여 Quark로 양자화된 다양한 모델을 원활하게 평가할 수 있습니다.</p> <p data-svelte-h="svelte-p0m34b">Quark에 관심이 있는 사용자는 <a href="https://quark.docs.amd.com/latest/" rel="nofollow">문서</a>를 참고하여 모델 양자화를 시작하고 지원되는 오픈 소스 라이브러리에서 사용할 수 있습니다!</p> <p data-svelte-h="svelte-1s09thl">Quark는 자체 체크포인트/<a href="https://huggingface.co/amd/Llama-3.1-8B-Instruct-FP8-KV-Quark-test/blob/main/config.json#L26" rel="nofollow">설정 포맷</a>를 가지고 있지만, 다른 양자화/런타임 구현체 (<a href="https://huggingface.co/docs/transformers/quantization/awq" rel="nofollow">AutoAWQ</a>, <a href="https://huggingface.co/docs/transformers/quantization/finegrained_fp8" rel="nofollow">네이티브 fp8</a>)와 호환되는 직렬화 레이아웃으로 모델을 생성하는 것도 지원합니다.</p> <p data-svelte-h="svelte-1oaxbd">Transformer에서 Quark 양자화 모델을 로드하려면 먼저 라이브러리를 설치해야 합니다:</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 amd-quark<!-- HTML_TAG_END --></pre></div> <h2 class="relative group"><a id="Support matrix" 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="#Support matrix"><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>지원 매트릭스</span></h2> <p data-svelte-h="svelte-55izzt">Quark를 통해 양자화된 모델은 함께 조합할 수 있는 광범위한 기능을 지원합니다. 구성에 관계없이 모든 양자화된 모델은 <code>PretrainedModel.from_pretrained</code>를 통해 원활하게 다시 로드할 수 있습니다.</p> <p data-svelte-h="svelte-1jn93dh">아래 표는 Quark에서 지원하는 몇 가지 기능을 보여줍니다:</p> <table data-svelte-h="svelte-6ttolg"><thead><tr><th><strong>기능</strong></th> <th><strong>Quark에서 지원하는 항목</strong></th> <th></th></tr></thead> <tbody><tr><td>데이터 타입</td> <td>int8, int4, int2, bfloat16, float16, fp8_e5m2, fp8_e4m3, fp6_e3m2, fp6_e2m3, fp4, OCP MX, MX6, MX9, bfp16</td> <td></td></tr> <tr><td>양자화 전 모델 변환</td> <td>SmoothQuant, QuaRot, SpinQuant, AWQ</td> <td></td></tr> <tr><td>양자화 알고리즘</td> <td>GPTQ</td> <td></td></tr> <tr><td>지원 연산자</td> <td><code>nn.Linear</code>, <code>nn.Conv2d</code>, <code>nn.ConvTranspose2d</code>, <code>nn.Embedding</code>, <code>nn.EmbeddingBag</code></td> <td></td></tr> <tr><td>세분성(Granularity)</td> <td>per-tensor, per-channel, per-block, per-layer, per-layer type</td> <td></td></tr> <tr><td>KV 캐시</td> <td>fp8</td> <td></td></tr> <tr><td>활성화 캘리브레이션</td> <td>MinMax / Percentile / MSE</td> <td></td></tr> <tr><td>양자화 전략</td> <td>weight-only, static, dynamic, with or without output quantization</td> <td></td></tr></tbody></table> <h2 class="relative group"><a id="Models on Hugging Face Hub" 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="#Models on Hugging Face Hub"><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>Hugging Face Hub의 모델</span></h2> <p data-svelte-h="svelte-59hz5x">Quark 네이티브 직렬화를 사용하는 공개 모델은 <a href="https://huggingface.co/models?other=quark" rel="nofollow">https://huggingface.co/models?other=quark</a> 에서 찾을 수 있습니다.</p> <p data-svelte-h="svelte-1in21m">Quark는 <a href="https://huggingface.co/models?other=fp8" rel="nofollow"><code>quant_method=&quot;fp8&quot;</code>을 이용하는 모델</a><a href="https://huggingface.co/models?other=awq" rel="nofollow"><code>quant_method=&quot;awq&quot;</code>을 사용하는 모델</a>도 지원하지만, Transformers는 이러한 모델을 <a href="https://huggingface.co/docs/transformers/quantization/awq" rel="nofollow">AutoAWQ</a>를 통해 불러오거나
<a href="https://huggingface.co/docs/transformers/quantization/finegrained_fp8" rel="nofollow">🤗 Transformers의 네이티브 fp8 지원</a>을 사용합니다.</p> <h2 class="relative group"><a id="Using Quark models in Transformers" 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="#Using Quark models in Transformers"><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>Transformers에서 Quark모델 사용하기</span></h2> <p data-svelte-h="svelte-1oodq55">다음은 Transformers에서 Quark 모델을 불러오는 방법의 예시입니다:</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> transformers <span class="hljs-keyword">import</span> AutoModelForCausalLM, AutoTokenizer
model_id = <span class="hljs-string">&quot;EmbeddedLLM/Llama-3.1-8B-Instruct-w_fp8_per_channel_sym&quot;</span>
model = AutoModelForCausalLM.from_pretrained(model_id)
model = model.to(<span class="hljs-string">&quot;cuda&quot;</span>)
<span class="hljs-built_in">print</span>(model.model.layers[<span class="hljs-number">0</span>].self_attn.q_proj)
<span class="hljs-comment"># QParamsLinear(</span>
<span class="hljs-comment"># (weight_quantizer): ScaledRealQuantizer()</span>
<span class="hljs-comment"># (input_quantizer): ScaledRealQuantizer()</span>
<span class="hljs-comment"># (output_quantizer): ScaledRealQuantizer()</span>
<span class="hljs-comment"># )</span>
tokenizer = AutoTokenizer.from_pretrained(model_id)
inp = tokenizer(<span class="hljs-string">&quot;Where is a good place to cycle around Tokyo?&quot;</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
inp = inp.to(<span class="hljs-string">&quot;cuda&quot;</span>)
res = model.generate(**inp, min_new_tokens=<span class="hljs-number">50</span>, max_new_tokens=<span class="hljs-number">100</span>)
<span class="hljs-built_in">print</span>(tokenizer.batch_decode(res)[<span class="hljs-number">0</span>])
<span class="hljs-comment"># &lt;|begin_of_text|&gt;Where is a good place to cycle around Tokyo? There are several places in Tokyo that are suitable for cycling, depending on your skill level and interests. Here are a few suggestions:</span>
<span class="hljs-comment"># 1. Yoyogi Park: This park is a popular spot for cycling and has a wide, flat path that&#x27;s perfect for beginners. You can also visit the Meiji Shrine, a famous Shinto shrine located in the park.</span>
<span class="hljs-comment"># 2. Imperial Palace East Garden: This beautiful garden has a large, flat path that&#x27;s perfect for cycling. You can also visit the</span><!-- HTML_TAG_END --></pre></div> <a class="!text-gray-400 !no-underline text-sm flex items-center not-prose mt-4" href="https://github.com/huggingface/transformers/blob/main/docs/source/ko/quantization/quark.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_19l5hsr = {
assets: "/docs/transformers/main/ko",
base: "/docs/transformers/main/ko",
env: {}
};
const element = document.currentScript.parentElement;
const data = [null,null];
Promise.all([
import("/docs/transformers/main/ko/_app/immutable/entry/start.7dba37eb.js"),
import("/docs/transformers/main/ko/_app/immutable/entry/app.d02eea18.js")
]).then(([kit, app]) => {
kit.start(app, element, {
node_ids: [0, 150],
data,
form: null,
error: null
});
});
}
</script>

Xet Storage Details

Size:
19.3 kB
·
Xet hash:
28eae6ca8991e1d5338cff6456eb6790bc849efbd9350d5e74af81776241d5fe

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