Buckets:

rtrm's picture
download
raw
12.3 kB
<meta charset="utf-8" /><meta name="hf:doc:metadata" content="{&quot;title&quot;:&quot;HIGGS&quot;,&quot;local&quot;:&quot;higgs&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;Quantization Example&quot;,&quot;local&quot;:&quot;quantization-example&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Pre-quantized models&quot;,&quot;local&quot;:&quot;pre-quantized-models&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Current Limitations&quot;,&quot;local&quot;:&quot;current-limitations&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2}],&quot;depth&quot;:1}">
<link href="/docs/transformers/pr_36049/en/_app/immutable/assets/0.e3b0c442.css" rel="modulepreload">
<link rel="modulepreload" href="/docs/transformers/pr_36049/en/_app/immutable/entry/start.86af8b85.js">
<link rel="modulepreload" href="/docs/transformers/pr_36049/en/_app/immutable/chunks/scheduler.25b97de1.js">
<link rel="modulepreload" href="/docs/transformers/pr_36049/en/_app/immutable/chunks/singletons.20f80512.js">
<link rel="modulepreload" href="/docs/transformers/pr_36049/en/_app/immutable/chunks/index.e188933d.js">
<link rel="modulepreload" href="/docs/transformers/pr_36049/en/_app/immutable/chunks/paths.162096ab.js">
<link rel="modulepreload" href="/docs/transformers/pr_36049/en/_app/immutable/entry/app.d602e208.js">
<link rel="modulepreload" href="/docs/transformers/pr_36049/en/_app/immutable/chunks/index.d9030fc9.js">
<link rel="modulepreload" href="/docs/transformers/pr_36049/en/_app/immutable/nodes/0.8e0a4db0.js">
<link rel="modulepreload" href="/docs/transformers/pr_36049/en/_app/immutable/chunks/each.e59479a4.js">
<link rel="modulepreload" href="/docs/transformers/pr_36049/en/_app/immutable/nodes/425.b7119485.js">
<link rel="modulepreload" href="/docs/transformers/pr_36049/en/_app/immutable/chunks/CodeBlock.e6cd0d95.js">
<link rel="modulepreload" href="/docs/transformers/pr_36049/en/_app/immutable/chunks/EditOnGithub.91d95064.js"><!-- HEAD_svelte-u9bgzb_START --><meta name="hf:doc:metadata" content="{&quot;title&quot;:&quot;HIGGS&quot;,&quot;local&quot;:&quot;higgs&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;Quantization Example&quot;,&quot;local&quot;:&quot;quantization-example&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Pre-quantized models&quot;,&quot;local&quot;:&quot;pre-quantized-models&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Current Limitations&quot;,&quot;local&quot;:&quot;current-limitations&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2}],&quot;depth&quot;:1}"><!-- HEAD_svelte-u9bgzb_END --> <p></p> <h1 class="relative group"><a id="higgs" 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="#higgs"><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>HIGGS</span></h1> <p data-svelte-h="svelte-7loj8q">HIGGS is a 0-shot quantization algorithm that combines Hadamard preprocessing with MSE-Optimal quantization grids to achieve lower quantization error and SOTA performance. You can find more information in the paper <a href="https://arxiv.org/abs/2411.17525" rel="nofollow">arxiv.org/abs/2411.17525</a>.</p> <p data-svelte-h="svelte-14ghacu">Runtime support for HIGGS is implemented through <a href="https://arxiv.org/abs/2407.10960" rel="nofollow">FLUTE</a>, and its <a href="https://github.com/HanGuo97/flute" rel="nofollow">library</a>.</p> <h2 class="relative group"><a id="quantization-example" 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="#quantization-example"><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>Quantization Example</span></h2> <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=""><!-- HTML_TAG_START --><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForCausalLM, AutoTokenizer, HiggsConfig
model = AutoModelForCausalLM.from_pretrained(
<span class="hljs-string">&quot;google/gemma-2-9b-it&quot;</span>,
quantization_config=HiggsConfig(bits=<span class="hljs-number">4</span>),
device_map=<span class="hljs-string">&quot;auto&quot;</span>,
)
tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;google/gemma-2-9b-it&quot;</span>)
tokenizer.decode(model.generate(
**tokenizer(<span class="hljs-string">&quot;Hi,&quot;</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>).to(model.device),
temperature=<span class="hljs-number">0.5</span>,
top_p=<span class="hljs-number">0.80</span>,
)[<span class="hljs-number">0</span>])<!-- HTML_TAG_END --></pre></div> <h2 class="relative group"><a id="pre-quantized-models" 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="#pre-quantized-models"><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>Pre-quantized models</span></h2> <p data-svelte-h="svelte-187htj">Some pre-quantized models can be found in the <a href="https://huggingface.co/collections/ISTA-DASLab/higgs-675308e432fd56b7f6dab94e" rel="nofollow">official collection</a> on Hugging Face Hub.</p> <h2 class="relative group"><a id="current-limitations" 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="#current-limitations"><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>Current Limitations</span></h2> <p data-svelte-h="svelte-z5ka61"><strong>Architectures</strong></p> <p data-svelte-h="svelte-63hor">Currently, FLUTE, and HIGGS by extension, <strong>only support Llama 3 and 3.0 of 8B, 70B and 405B parameters, as well as Gemma-2 9B and 27B</strong>. We’re working on allowing to run more diverse models as well as allow arbitrary models by modifying the FLUTE compilation procedure.</p> <p data-svelte-h="svelte-azj1k8"><strong>torch.compile</strong></p> <p data-svelte-h="svelte-1o179pj">HIGGS is fully compatible with <code>torch.compile</code>. Compiling <code>model.forward</code>, as described <a href="../perf_torch_compile.md">here</a>, here’re the speedups it provides on RTX 4090 for <code>Llama-3.1-8B-Instruct</code> (forward passes/sec):</p> <table data-svelte-h="svelte-1nmv7cr"><thead><tr><th>Batch Size</th> <th>BF16 (With <code>torch.compile</code>)</th> <th>HIGGS 4bit (No <code>torch.compile</code>)</th> <th>HIGGS 4bit (With <code>torch.compile</code>)</th></tr></thead> <tbody><tr><td>1</td> <td>59</td> <td>41</td> <td>124</td></tr> <tr><td>4</td> <td>57</td> <td>42</td> <td>123</td></tr> <tr><td>16</td> <td>56</td> <td>41</td> <td>120</td></tr></tbody></table> <p data-svelte-h="svelte-198kt6q"><strong>Quantized training</strong></p> <p data-svelte-h="svelte-1cwzr5r">Currently, HIGGS doesn’t support quantized training (and backward passes in general). We’re working on adding support for it.</p> <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/en/quantization/higgs.md" target="_blank"><span data-svelte-h="svelte-1kd6by1">&lt;</span> <span data-svelte-h="svelte-x0xyl0">&gt;</span> <span data-svelte-h="svelte-1dajgef"><span class="underline ml-1.5">Update</span> on GitHub</span></a> <p></p>
<script>
{
__sveltekit_tduuc7 = {
assets: "/docs/transformers/pr_36049/en",
base: "/docs/transformers/pr_36049/en",
env: {}
};
const element = document.currentScript.parentElement;
const data = [null,null];
Promise.all([
import("/docs/transformers/pr_36049/en/_app/immutable/entry/start.86af8b85.js"),
import("/docs/transformers/pr_36049/en/_app/immutable/entry/app.d602e208.js")
]).then(([kit, app]) => {
kit.start(app, element, {
node_ids: [0, 425],
data,
form: null,
error: null
});
});
}
</script>

Xet Storage Details

Size:
12.3 kB
·
Xet hash:
89c57ab28d2e7f8c3112e4314ec6bbcb741ae5f61e03bb4873da213cbb30b406

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