import{s as Wn,o as Qn,n as B}from"../chunks/scheduler.9bc65507.js";import{S as Vn,i as Fn,g as p,s as i,r as f,A as Xn,h as m,f as l,c as o,j as Bn,u as h,x as u,k as qe,y as Rn,a,v as c,d as g,t as b,w as M}from"../chunks/index.707bf1b6.js";import{T as W}from"../chunks/Tip.c2ecdbf4.js";import{C as v}from"../chunks/CodeBlock.54a9f38d.js";import{H as z}from"../chunks/Heading.342b1fa6.js";import{H as Ua,a as ke}from"../chunks/HfOption.6d864328.js";function xn(_){let n,y='Interested in adding a new quantization method to Transformers? Read the <a href="./hf_quantizer">HfQuantizer</a> guide to learn how!';return{c(){n=p("p"),n.innerHTML=y},l(s){n=m(s,"P",{"data-svelte-h":!0}),u(n)!=="svelte-px0yfi"&&(n.innerHTML=y)},m(s,d){a(s,n,d)},p:B,d(s){s&&l(n)}}}function Ln(_){let n,y='Try AWQ quantization with this <a href="https://colab.research.google.com/drive/1HzZH89yAXJaZgwJDhQj9LqSBux932BvY" rel="nofollow">notebook</a>!';return{c(){n=p("p"),n.innerHTML=y},l(s){n=m(s,"P",{"data-svelte-h":!0}),u(n)!=="svelte-1yzcfmc"&&(n.innerHTML=y)},m(s,d){a(s,n,d)},p:B,d(s){s&&l(n)}}}function Nn(_){let n,y="Fused modules cannot be combined with other optimization techniques such as FlashAttention-2.";return{c(){n=p("p"),n.textContent=y},l(s){n=m(s,"P",{"data-svelte-h":!0}),u(n)!=="svelte-hwgpn3"&&(n.textContent=y)},m(s,d){a(s,n,d)},p:B,d(s){s&&l(n)}}}function En(_){let n,y='To enable fused modules for supported architectures, create an <a href="/docs/transformers/main/en/main_classes/quantization#transformers.AwqConfig">AwqConfig</a> and set the parameters <code>fuse_max_seq_len</code> and <code>do_fuse=True</code>. The <code>fuse_max_seq_len</code> parameter is the total sequence length and it should include the context length and the expected generation length. You can set it to a larger value to be safe.',s,d,r='For example, to fuse the AWQ modules of the <a href="https://huggingface.co/TheBloke/Mistral-7B-OpenOrca-AWQ" rel="nofollow">TheBloke/Mistral-7B-OpenOrca-AWQ</a> model.',T,U,C;return U=new v({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQXdxQ29uZmlnJTJDJTIwQXV0b01vZGVsRm9yQ2F1c2FsTE0lMEElMEFtb2RlbF9pZCUyMCUzRCUyMCUyMlRoZUJsb2tlJTJGTWlzdHJhbC03Qi1PcGVuT3JjYS1BV1ElMjIlMEElMEFxdWFudGl6YXRpb25fY29uZmlnJTIwJTNEJTIwQXdxQ29uZmlnKCUwQSUyMCUyMCUyMCUyMGJpdHMlM0Q0JTJDJTBBJTIwJTIwJTIwJTIwZnVzZV9tYXhfc2VxX2xlbiUzRDUxMiUyQyUwQSUyMCUyMCUyMCUyMGRvX2Z1c2UlM0RUcnVlJTJDJTBBKSUwQSUwQW1vZGVsJTIwJTNEJTIwQXV0b01vZGVsRm9yQ2F1c2FsTE0uZnJvbV9wcmV0cmFpbmVkKG1vZGVsX2lkJTJDJTIwcXVhbnRpemF0aW9uX2NvbmZpZyUzRHF1YW50aXphdGlvbl9jb25maWcpLnRvKDAp",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AwqConfig, AutoModelForCausalLM

model_id = <span class="hljs-string">&quot;TheBloke/Mistral-7B-OpenOrca-AWQ&quot;</span>

quantization_config = AwqConfig(
    bits=<span class="hljs-number">4</span>,
    fuse_max_seq_len=<span class="hljs-number">512</span>,
    do_fuse=<span class="hljs-literal">True</span>,
)

model = AutoModelForCausalLM.from_pretrained(model_id, quantization_config=quantization_config).to(<span class="hljs-number">0</span>)`,wrap:!1}}),{c(){n=p("p"),n.innerHTML=y,s=i(),d=p("p"),d.innerHTML=r,T=i(),f(U.$$.fragment)},l(w){n=m(w,"P",{"data-svelte-h":!0}),u(n)!=="svelte-cvz4de"&&(n.innerHTML=y),s=o(w),d=m(w,"P",{"data-svelte-h":!0}),u(d)!=="svelte-1zxz2i"&&(d.innerHTML=r),T=o(w),h(U.$$.fragment,w)},m(w,q){a(w,n,q),a(w,s,q),a(w,d,q),a(w,T,q),c(U,w,q),C=!0},p:B,i(w){C||(g(U.$$.fragment,w),C=!0)},o(w){b(U.$$.fragment,w),C=!1},d(w){w&&(l(n),l(s),l(d),l(T)),M(U,w)}}}function An(_){let n,y='For architectures that don’t support fused modules yet, you need to create a custom fusing mapping to define which modules need to be fused with the <code>modules_to_fuse</code> parameter. For example, to fuse the AWQ modules of the <a href="https://huggingface.co/TheBloke/Yi-34B-AWQ" rel="nofollow">TheBloke/Yi-34B-AWQ</a> model.',s,d,r,T,U="The parameter <code>modules_to_fuse</code> should include:",C,w,q="<li><code>&quot;attention&quot;</code>: The names of the attention layers to fuse in the following order: query, key, value and output projection layer. If you don’t want to fuse these layers, pass an empty list.</li> <li><code>&quot;layernorm&quot;</code>: The names of all the LayerNorm layers you want to replace with a custom fused LayerNorm. If you don’t want to fuse these layers, pass an empty list.</li> <li><code>&quot;mlp&quot;</code>: The names of the MLP layers you want to fuse into a single MLP layer in the order: (gate (dense, layer, post-attention) / up / down layers).</li> <li><code>&quot;use_alibi&quot;</code>: If your model uses ALiBi positional embedding.</li> <li><code>&quot;num_attention_heads&quot;</code>: The number of attention heads.</li> <li><code>&quot;num_key_value_heads&quot;</code>: The number of key value heads that should be used to implement Grouped Query Attention (GQA). If <code>num_key_value_heads=num_attention_heads</code>, the model will use Multi Head Attention (MHA), if <code>num_key_value_heads=1</code> the model will use Multi Query Attention (MQA), otherwise GQA is used.</li> <li><code>&quot;hidden_size&quot;</code>: The dimension of the hidden representations.</li>",Z;return d=new v({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQXdxQ29uZmlnJTJDJTIwQXV0b01vZGVsRm9yQ2F1c2FsTE0lMEElMEFtb2RlbF9pZCUyMCUzRCUyMCUyMlRoZUJsb2tlJTJGWWktMzRCLUFXUSUyMiUwQSUwQXF1YW50aXphdGlvbl9jb25maWclMjAlM0QlMjBBd3FDb25maWcoJTBBJTIwJTIwJTIwJTIwYml0cyUzRDQlMkMlMEElMjAlMjAlMjAlMjBmdXNlX21heF9zZXFfbGVuJTNENTEyJTJDJTBBJTIwJTIwJTIwJTIwbW9kdWxlc190b19mdXNlJTNEJTdCJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIyYXR0ZW50aW9uJTIyJTNBJTIwJTVCJTIycV9wcm9qJTIyJTJDJTIwJTIya19wcm9qJTIyJTJDJTIwJTIydl9wcm9qJTIyJTJDJTIwJTIyb19wcm9qJTIyJTVEJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIybGF5ZXJub3JtJTIyJTNBJTIwJTVCJTIybG4xJTIyJTJDJTIwJTIybG4yJTIyJTJDJTIwJTIybm9ybSUyMiU1RCUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMm1scCUyMiUzQSUyMCU1QiUyMmdhdGVfcHJvaiUyMiUyQyUyMCUyMnVwX3Byb2olMjIlMkMlMjAlMjJkb3duX3Byb2olMjIlNUQlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJ1c2VfYWxpYmklMjIlM0ElMjBGYWxzZSUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMm51bV9hdHRlbnRpb25faGVhZHMlMjIlM0ElMjA1NiUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMm51bV9rZXlfdmFsdWVfaGVhZHMlMjIlM0ElMjA4JTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIyaGlkZGVuX3NpemUlMjIlM0ElMjA3MTY4JTBBJTIwJTIwJTIwJTIwJTdEJTBBKSUwQSUwQW1vZGVsJTIwJTNEJTIwQXV0b01vZGVsRm9yQ2F1c2FsTE0uZnJvbV9wcmV0cmFpbmVkKG1vZGVsX2lkJTJDJTIwcXVhbnRpemF0aW9uX2NvbmZpZyUzRHF1YW50aXphdGlvbl9jb25maWcpLnRvKDAp",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AwqConfig, AutoModelForCausalLM

model_id = <span class="hljs-string">&quot;TheBloke/Yi-34B-AWQ&quot;</span>

quantization_config = AwqConfig(
    bits=<span class="hljs-number">4</span>,
    fuse_max_seq_len=<span class="hljs-number">512</span>,
    modules_to_fuse={
        <span class="hljs-string">&quot;attention&quot;</span>: [<span class="hljs-string">&quot;q_proj&quot;</span>, <span class="hljs-string">&quot;k_proj&quot;</span>, <span class="hljs-string">&quot;v_proj&quot;</span>, <span class="hljs-string">&quot;o_proj&quot;</span>],
        <span class="hljs-string">&quot;layernorm&quot;</span>: [<span class="hljs-string">&quot;ln1&quot;</span>, <span class="hljs-string">&quot;ln2&quot;</span>, <span class="hljs-string">&quot;norm&quot;</span>],
        <span class="hljs-string">&quot;mlp&quot;</span>: [<span class="hljs-string">&quot;gate_proj&quot;</span>, <span class="hljs-string">&quot;up_proj&quot;</span>, <span class="hljs-string">&quot;down_proj&quot;</span>],
        <span class="hljs-string">&quot;use_alibi&quot;</span>: <span class="hljs-literal">False</span>,
        <span class="hljs-string">&quot;num_attention_heads&quot;</span>: <span class="hljs-number">56</span>,
        <span class="hljs-string">&quot;num_key_value_heads&quot;</span>: <span class="hljs-number">8</span>,
        <span class="hljs-string">&quot;hidden_size&quot;</span>: <span class="hljs-number">7168</span>
    }
)

model = AutoModelForCausalLM.from_pretrained(model_id, quantization_config=quantization_config).to(<span class="hljs-number">0</span>)`,wrap:!1}}),{c(){n=p("p"),n.innerHTML=y,s=i(),f(d.$$.fragment),r=i(),T=p("p"),T.innerHTML=U,C=i(),w=p("ul"),w.innerHTML=q},l(j){n=m(j,"P",{"data-svelte-h":!0}),u(n)!=="svelte-ecilwg"&&(n.innerHTML=y),s=o(j),h(d.$$.fragment,j),r=o(j),T=m(j,"P",{"data-svelte-h":!0}),u(T)!=="svelte-1divolh"&&(T.innerHTML=U),C=o(j),w=m(j,"UL",{"data-svelte-h":!0}),u(w)!=="svelte-ln3msn"&&(w.innerHTML=q)},m(j,k){a(j,n,k),a(j,s,k),c(d,j,k),a(j,r,k),a(j,T,k),a(j,C,k),a(j,w,k),Z=!0},p:B,i(j){Z||(g(d.$$.fragment,j),Z=!0)},o(j){b(d.$$.fragment,j),Z=!1},d(j){j&&(l(n),l(s),l(r),l(T),l(C),l(w)),M(d,j)}}}function Hn(_){let n,y,s,d;return n=new ke({props:{id:"fuse",option:"supported architectures",$$slots:{default:[En]},$$scope:{ctx:_}}}),s=new ke({props:{id:"fuse",option:"unsupported architectures",$$slots:{default:[An]},$$scope:{ctx:_}}}),{c(){f(n.$$.fragment),y=i(),f(s.$$.fragment)},l(r){h(n.$$.fragment,r),y=o(r),h(s.$$.fragment,r)},m(r,T){c(n,r,T),a(r,y,T),c(s,r,T),d=!0},p(r,T){const U={};T&2&&(U.$$scope={dirty:T,ctx:r}),n.$set(U);const C={};T&2&&(C.$$scope={dirty:T,ctx:r}),s.$set(C)},i(r){d||(g(n.$$.fragment,r),g(s.$$.fragment,r),d=!0)},o(r){b(n.$$.fragment,r),b(s.$$.fragment,r),d=!1},d(r){r&&l(y),M(n,r),M(s,r)}}}function Yn(_){let n,y='Try GPTQ quantization with PEFT in this <a href="https://colab.research.google.com/drive/1_TIrmuKOFhuRRiTWN94iLKUFu6ZX4ceb?usp=sharing" rel="nofollow">notebook</a> and learn more about it’s details in this <a href="https://huggingface.co/blog/gptq-integration" rel="nofollow">blog post</a>!';return{c(){n=p("p"),n.innerHTML=y},l(s){n=m(s,"P",{"data-svelte-h":!0}),u(n)!=="svelte-1tfpiad"&&(n.innerHTML=y)},m(s,d){a(s,n,d)},p:B,d(s){s&&l(n)}}}function Pn(_){let n,y='Depending on your hardware, it can take some time to quantize a model from scratch. It can take ~5 minutes to quantize the <a href="">facebook/opt-350m</a> model on a free-tier Google Colab GPU, but it’ll take ~4 hours to quantize a 175B parameter model on a NVIDIA A100. Before you quantize a model, it is a good idea to check the Hub if a GPTQ-quantized version of the model already exists.';return{c(){n=p("p"),n.innerHTML=y},l(s){n=m(s,"P",{"data-svelte-h":!0}),u(n)!=="svelte-q6786l"&&(n.innerHTML=y)},m(s,d){a(s,n,d)},p:B,d(s){s&&l(n)}}}function Sn(_){let n,y="Only 4-bit models are supported, and we recommend deactivating the ExLlama kernels if you’re finetuning a quantized model with PEFT.";return{c(){n=p("p"),n.textContent=y},l(s){n=m(s,"P",{"data-svelte-h":!0}),u(n)!=="svelte-14ppi1y"&&(n.textContent=y)},m(s,d){a(s,n,d)},p:B,d(s){s&&l(n)}}}function Dn(_){let n,y;return n=new v({props:{code:"cGlwJTIwaW5zdGFsbCUyMHRyYW5zZm9ybWVycyUyMGFjY2VsZXJhdGUlMjBiaXRzYW5kYnl0ZXMlM0UwLjM3LjA=",highlighted:"pip install transformers accelerate bitsandbytes&gt;0.37.0",wrap:!1}}),{c(){f(n.$$.fragment)},l(s){h(n.$$.fragment,s)},m(s,d){c(n,s,d),y=!0},p:B,i(s){y||(g(n.$$.fragment,s),y=!0)},o(s){b(n.$$.fragment,s),y=!1},d(s){M(n,s)}}}function Kn(_){let n,y;return n=new v({props:{code:"cGlwJTIwaW5zdGFsbCUyMGJpdHNhbmRieXRlcyUzRSUzRDAuMzkuMCUwQXBpcCUyMGluc3RhbGwlMjAtLXVwZ3JhZGUlMjBhY2NlbGVyYXRlJTBBcGlwJTIwaW5zdGFsbCUyMC0tdXBncmFkZSUyMHRyYW5zZm9ybWVycw==",highlighted:`pip install bitsandbytes&gt;=0.39.0
pip install --upgrade accelerate
pip install --upgrade transformers`,wrap:!1}}),{c(){f(n.$$.fragment)},l(s){h(n.$$.fragment,s)},m(s,d){c(n,s,d),y=!0},p:B,i(s){y||(g(n.$$.fragment,s),y=!0)},o(s){b(n.$$.fragment,s),y=!1},d(s){M(n,s)}}}function On(_){let n,y,s,d;return n=new ke({props:{id:"bnb",option:"8-bit",$$slots:{default:[Dn]},$$scope:{ctx:_}}}),s=new ke({props:{id:"bnb",option:"4-bit",$$slots:{default:[Kn]},$$scope:{ctx:_}}}),{c(){f(n.$$.fragment),y=i(),f(s.$$.fragment)},l(r){h(n.$$.fragment,r),y=o(r),h(s.$$.fragment,r)},m(r,T){c(n,r,T),a(r,y,T),c(s,r,T),d=!0},p(r,T){const U={};T&2&&(U.$$scope={dirty:T,ctx:r}),n.$set(U);const C={};T&2&&(C.$$scope={dirty:T,ctx:r}),s.$set(C)},i(r){d||(g(n.$$.fragment,r),g(s.$$.fragment,r),d=!0)},o(r){b(n.$$.fragment,r),b(s.$$.fragment,r),d=!1},d(r){r&&l(y),M(n,r),M(s,r)}}}function ts(_){let n,y="Quantizing a model in 8-bit halves the memory-usage, and for large models, set <code>device_map=&quot;auto&quot;</code> to efficiently use the GPUs available:",s,d,r,T,U="By default, all the other modules such as <code>torch.nn.LayerNorm</code> are converted to <code>torch.float16</code>. You can change the data type of these modules with the <code>torch_dtype</code> parameter if you want:",C,w,q,Z,j='Once a model is quantized to 8-bit, you can’t push the quantized weights to the Hub unless you’re using the latest version of Transformers and bitsandbytes. If you have the latest versions, then you can push the 8-bit model to the Hub with the <a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.push_to_hub">push_to_hub()</a> method. The quantization config.json file is pushed first, followed by the quantized model weights.',k,$,G;return d=new v({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvckNhdXNhbExNJTBBJTBBbW9kZWxfOGJpdCUyMCUzRCUyMEF1dG9Nb2RlbEZvckNhdXNhbExNLmZyb21fcHJldHJhaW5lZCglMjJiaWdzY2llbmNlJTJGYmxvb20tMWI3JTIyJTJDJTIwZGV2aWNlX21hcCUzRCUyMmF1dG8lMjIlMkMlMjBsb2FkX2luXzhiaXQlM0RUcnVlKQ==",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForCausalLM

model_8bit = AutoModelForCausalLM.from_pretrained(<span class="hljs-string">&quot;bigscience/bloom-1b7&quot;</span>, device_map=<span class="hljs-string">&quot;auto&quot;</span>, load_in_8bit=<span class="hljs-literal">True</span>)`,wrap:!1}}),w=new v({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQXV0b01vZGVsRm9yQ2F1c2FsTE0lMEElMEFtb2RlbF84Yml0JTIwJTNEJTIwQXV0b01vZGVsRm9yQ2F1c2FsTE0uZnJvbV9wcmV0cmFpbmVkKCUyMmZhY2Vib29rJTJGb3B0LTM1MG0lMjIlMkMlMjBsb2FkX2luXzhiaXQlM0RUcnVlJTJDJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5mbG9hdDMyKSUwQW1vZGVsXzhiaXQubW9kZWwuZGVjb2Rlci5sYXllcnMlNUItMSU1RC5maW5hbF9sYXllcl9ub3JtLndlaWdodC5kdHlwZQ==",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForCausalLM

model_8bit = AutoModelForCausalLM.from_pretrained(<span class="hljs-string">&quot;facebook/opt-350m&quot;</span>, load_in_8bit=<span class="hljs-literal">True</span>, torch_dtype=torch.float32)
model_8bit.model.decoder.layers[-<span class="hljs-number">1</span>].final_layer_norm.weight.dtype`,wrap:!1}}),$=new v({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvckNhdXNhbExNJTJDJTIwQXV0b1Rva2VuaXplciUwQSUwQW1vZGVsJTIwJTNEJTIwQXV0b01vZGVsRm9yQ2F1c2FsTE0uZnJvbV9wcmV0cmFpbmVkKCUyMmJpZ3NjaWVuY2UlMkZibG9vbS01NjBtJTIyJTJDJTIwZGV2aWNlX21hcCUzRCUyMmF1dG8lMjIlMkMlMjBsb2FkX2luXzhiaXQlM0RUcnVlKSUwQXRva2VuaXplciUyMCUzRCUyMEF1dG9Ub2tlbml6ZXIuZnJvbV9wcmV0cmFpbmVkKCUyMmJpZ3NjaWVuY2UlMkZibG9vbS01NjBtJTIyKSUwQSUwQW1vZGVsLnB1c2hfdG9faHViKCUyMmJsb29tLTU2MG0tOGJpdCUyMik=",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForCausalLM, AutoTokenizer

model = AutoModelForCausalLM.from_pretrained(<span class="hljs-string">&quot;bigscience/bloom-560m&quot;</span>, device_map=<span class="hljs-string">&quot;auto&quot;</span>, load_in_8bit=<span class="hljs-literal">True</span>)
tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;bigscience/bloom-560m&quot;</span>)

model.push_to_hub(<span class="hljs-string">&quot;bloom-560m-8bit&quot;</span>)`,wrap:!1}}),{c(){n=p("p"),n.innerHTML=y,s=i(),f(d.$$.fragment),r=i(),T=p("p"),T.innerHTML=U,C=i(),f(w.$$.fragment),q=i(),Z=p("p"),Z.innerHTML=j,k=i(),f($.$$.fragment)},l(J){n=m(J,"P",{"data-svelte-h":!0}),u(n)!=="svelte-1dz8xeq"&&(n.innerHTML=y),s=o(J),h(d.$$.fragment,J),r=o(J),T=m(J,"P",{"data-svelte-h":!0}),u(T)!=="svelte-kfzkum"&&(T.innerHTML=U),C=o(J),h(w.$$.fragment,J),q=o(J),Z=m(J,"P",{"data-svelte-h":!0}),u(Z)!=="svelte-o2gwe6"&&(Z.innerHTML=j),k=o(J),h($.$$.fragment,J)},m(J,I){a(J,n,I),a(J,s,I),c(d,J,I),a(J,r,I),a(J,T,I),a(J,C,I),c(w,J,I),a(J,q,I),a(J,Z,I),a(J,k,I),c($,J,I),G=!0},p:B,i(J){G||(g(d.$$.fragment,J),g(w.$$.fragment,J),g($.$$.fragment,J),G=!0)},o(J){b(d.$$.fragment,J),b(w.$$.fragment,J),b($.$$.fragment,J),G=!1},d(J){J&&(l(n),l(s),l(r),l(T),l(C),l(q),l(Z),l(k)),M(d,J),M(w,J),M($,J)}}}function es(_){let n,y="Quantizing a model in 4-bit reduces your memory-usage by 4x, and for large models, set <code>device_map=&quot;auto&quot;</code> to efficiently use the GPUs available:",s,d,r,T,U="By default, all the other modules such as <code>torch.nn.LayerNorm</code> are converted to <code>torch.float16</code>. You can change the data type of these modules with the <code>torch_dtype</code> parameter if you want:",C,w,q,Z,j="If you have <code>bitsandbytes&gt;=0.41.3</code>, you can serialize 4-bit models and push them on Hugging Face Hub. Simply call <code>model.push_to_hub()</code> after loading it in 4-bit precision. You can also save the serialized 4-bit models locally with <code>model.save_pretrained()</code> command.",k;return d=new v({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvckNhdXNhbExNJTBBJTBBbW9kZWxfNGJpdCUyMCUzRCUyMEF1dG9Nb2RlbEZvckNhdXNhbExNLmZyb21fcHJldHJhaW5lZCglMjJiaWdzY2llbmNlJTJGYmxvb20tMWI3JTIyJTJDJTIwZGV2aWNlX21hcCUzRCUyMmF1dG8lMjIlMkMlMjBsb2FkX2luXzRiaXQlM0RUcnVlKQ==",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForCausalLM

model_4bit = AutoModelForCausalLM.from_pretrained(<span class="hljs-string">&quot;bigscience/bloom-1b7&quot;</span>, device_map=<span class="hljs-string">&quot;auto&quot;</span>, load_in_4bit=<span class="hljs-literal">True</span>)`,wrap:!1}}),w=new v({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQXV0b01vZGVsRm9yQ2F1c2FsTE0lMEElMEFtb2RlbF80Yml0JTIwJTNEJTIwQXV0b01vZGVsRm9yQ2F1c2FsTE0uZnJvbV9wcmV0cmFpbmVkKCUyMmZhY2Vib29rJTJGb3B0LTM1MG0lMjIlMkMlMjBsb2FkX2luXzRiaXQlM0RUcnVlJTJDJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5mbG9hdDMyKSUwQW1vZGVsXzRiaXQubW9kZWwuZGVjb2Rlci5sYXllcnMlNUItMSU1RC5maW5hbF9sYXllcl9ub3JtLndlaWdodC5kdHlwZQ==",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForCausalLM

model_4bit = AutoModelForCausalLM.from_pretrained(<span class="hljs-string">&quot;facebook/opt-350m&quot;</span>, load_in_4bit=<span class="hljs-literal">True</span>, torch_dtype=torch.float32)
model_4bit.model.decoder.layers[-<span class="hljs-number">1</span>].final_layer_norm.weight.dtype`,wrap:!1}}),{c(){n=p("p"),n.innerHTML=y,s=i(),f(d.$$.fragment),r=i(),T=p("p"),T.innerHTML=U,C=i(),f(w.$$.fragment),q=i(),Z=p("p"),Z.innerHTML=j},l($){n=m($,"P",{"data-svelte-h":!0}),u(n)!=="svelte-1b6jp1p"&&(n.innerHTML=y),s=o($),h(d.$$.fragment,$),r=o($),T=m($,"P",{"data-svelte-h":!0}),u(T)!=="svelte-kfzkum"&&(T.innerHTML=U),C=o($),h(w.$$.fragment,$),q=o($),Z=m($,"P",{"data-svelte-h":!0}),u(Z)!=="svelte-1pmx2wb"&&(Z.innerHTML=j)},m($,G){a($,n,G),a($,s,G),c(d,$,G),a($,r,G),a($,T,G),a($,C,G),c(w,$,G),a($,q,G),a($,Z,G),k=!0},p:B,i($){k||(g(d.$$.fragment,$),g(w.$$.fragment,$),k=!0)},o($){b(d.$$.fragment,$),b(w.$$.fragment,$),k=!1},d($){$&&(l(n),l(s),l(r),l(T),l(C),l(q),l(Z)),M(d,$),M(w,$)}}}function ls(_){let n,y,s,d;return n=new ke({props:{id:"bnb",option:"8-bit",$$slots:{default:[ts]},$$scope:{ctx:_}}}),s=new ke({props:{id:"bnb",option:"4-bit",$$slots:{default:[es]},$$scope:{ctx:_}}}),{c(){f(n.$$.fragment),y=i(),f(s.$$.fragment)},l(r){h(n.$$.fragment,r),y=o(r),h(s.$$.fragment,r)},m(r,T){c(n,r,T),a(r,y,T),c(s,r,T),d=!0},p(r,T){const U={};T&2&&(U.$$scope={dirty:T,ctx:r}),n.$set(U);const C={};T&2&&(C.$$scope={dirty:T,ctx:r}),s.$set(C)},i(r){d||(g(n.$$.fragment,r),g(s.$$.fragment,r),d=!0)},o(r){b(n.$$.fragment,r),b(s.$$.fragment,r),d=!1},d(r){r&&l(y),M(n,r),M(s,r)}}}function as(_){let n,y="Training with 8-bit and 4-bit weights are only supported for training <em>extra</em> parameters.";return{c(){n=p("p"),n.innerHTML=y},l(s){n=m(s,"P",{"data-svelte-h":!0}),u(n)!=="svelte-of9sym"&&(n.innerHTML=y)},m(s,d){a(s,n,d)},p:B,d(s){s&&l(n)}}}function ns(_){let n,y='Learn more about the details of 8-bit quantization in this <a href="https://huggingface.co/blog/hf-bitsandbytes-integration" rel="nofollow">blog post</a>!';return{c(){n=p("p"),n.innerHTML=y},l(s){n=m(s,"P",{"data-svelte-h":!0}),u(n)!=="svelte-1bb05fp"&&(n.innerHTML=y)},m(s,d){a(s,n,d)},p:B,d(s){s&&l(n)}}}function ss(_){let n,y='Try 4-bit quantization in this <a href="https://colab.research.google.com/drive/1ge2F1QSK8Q7h0hn3YKuBCOAS0bK8E0wf" rel="nofollow">notebook</a> and learn more about it’s details in this <a href="https://huggingface.co/blog/4bit-transformers-bitsandbytes" rel="nofollow">blog post</a>.';return{c(){n=p("p"),n.innerHTML=y},l(s){n=m(s,"P",{"data-svelte-h":!0}),u(n)!=="svelte-rme94c"&&(n.innerHTML=y)},m(s,d){a(s,n,d)},p:B,d(s){s&&l(n)}}}function is(_){let n,y,s,d,r,T,U,C="Quantization techniques focus on representing data with less information while also trying to not lose too much accuracy. This often means converting a data type to represent the same information with fewer bits. For example, if your model weights are stored as 32-bit floating points and they’re quantized to 16-bit floating points, this halves the model size which makes it easier to store and reduces memory-usage. Lower precision can also speedup inference because it takes less time to perform calculations with fewer bits.",w,q,Z="Transformers supports several quantization schemes to help you run inference with large language models (LLMs) and finetune adapters on quantized models. This guide will show you how to use Activation-aware Weight Quantization (AWQ), AutoGPTQ, and bitsandbytes.",j,k,$,G,J,I,Ge,K,ja='<a href="https://hf.co/papers/2306.00978" rel="nofollow">Activation-aware Weight Quantization (AWQ)</a> doesn’t quantize all the weights in a model, and instead, it preserves a small percentage of weights that are important for LLM performance. This significantly reduces quantization loss such that you can run models in 4-bit precision without experiencing any performance degradation.',Ie,O,Ca='There are several libraries for quantizing models with the AWQ algorithm, such as <a href="https://github.com/mit-han-lab/llm-awq" rel="nofollow">llm-awq</a>, <a href="https://github.com/casper-hansen/AutoAWQ" rel="nofollow">autoawq</a> or <a href="https://huggingface.co/docs/optimum/main/en/intel/optimization_inc" rel="nofollow">optimum-intel</a>. Transformers supports loading models quantized with the llm-awq and autoawq libraries. This guide will show you how to load models quantized with autoawq, but the process is similar for llm-awq quantized models.',ze,tt,qa="Make sure you have autoawq installed:",Be,et,We,lt,ka='AWQ-quantized models can be identified by checking the <code>quantization_config</code> attribute in the model’s <a href="https://huggingface.co/TheBloke/zephyr-7B-alpha-AWQ/blob/main/config.json" rel="nofollow">config.json</a> file:',Qe,at,Ve,nt,Za='A quantized model is loaded with the <a href="/docs/transformers/main/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method. If you loaded your model on the CPU, make sure to move it to a GPU device first. Use the <code>device_map</code> parameter to specify where to place the model:',Fe,st,Xe,it,Ga="Loading an AWQ-quantized model automatically sets other weights to fp16 by default for performance reasons. If you want to load these other weights in a different format, use the <code>torch_dtype</code> parameter:",Re,ot,xe,rt,Ia='AWQ quantization can also be combined with <a href="perf_infer_gpu_one#flashattention-2">FlashAttention-2</a> to further accelerate inference:',Le,pt,Ne,mt,Ee,dt,za='Fused modules offers improved accuracy and performance and it is supported out-of-the-box for AWQ modules for <a href="https://huggingface.co/meta-llama" rel="nofollow">Llama</a> and <a href="https://huggingface.co/mistralai/Mistral-7B-v0.1" rel="nofollow">Mistral</a> architectures, but you can also fuse AWQ modules for unsupported architectures.',Ae,Q,He,V,Ye,ut,Pe,F,Se,ft,Ba='The <a href="https://github.com/PanQiWei/AutoGPTQ" rel="nofollow">AutoGPTQ</a> library implements the GPTQ algorithm, a post-training quantization technique where each row of the weight matrix is quantized independently to find a version of the weights that minimizes the error. These weights are quantized to int4, but they’re restored to fp16 on the fly during inference. This can save your memory-usage by 4x because the int4 weights are dequantized in a fused kernel rather than a GPU’s global memory, and you can also expect a speedup in inference because using a lower bitwidth takes less time to communicate.',De,ht,Wa="Before you begin, make sure the following libraries are installed:",Ke,ct,Oe,gt,Qa='To quantize a model (currently only supported for text models), you need to create a <a href="/docs/transformers/main/en/main_classes/quantization#transformers.GPTQConfig">GPTQConfig</a> class and set the number of bits to quantize to, a dataset to calibrate the weights for quantization, and a tokenizer to prepare the dataset.',tl,bt,el,Mt,Va="You could also pass your own dataset as a list of strings, but it is highly recommended to use the same dataset from the GPTQ paper.",ll,yt,al,Tt,Fa='Load a model to quantize and pass the <code>gptq_config</code> to the <a href="/docs/transformers/main/en/model_doc/auto#transformers.FlaxAutoModelForVision2Seq.from_pretrained">from_pretrained()</a> method. Set <code>device_map=&quot;auto&quot;</code> to automatically offload the model to a CPU to help fit the model in memory, and allow the model modules to be moved between the CPU and GPU for quantization.',nl,wt,sl,$t,Xa="If you’re running out of memory because a dataset is too large, disk offloading is not supported. If this is the case, try passing the <code>max_memory</code> parameter to allocate the amount of memory to use on your device (GPU and CPU):",il,Jt,ol,X,rl,_t,Ra='Once your model is quantized, you can push the model and tokenizer to the Hub where it can be easily shared and accessed. Use the <a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.push_to_hub">push_to_hub()</a> method to save the <a href="/docs/transformers/main/en/main_classes/quantization#transformers.GPTQConfig">GPTQConfig</a>:',pl,vt,ml,Ut,xa='You could also save your quantized model locally with the <a href="/docs/transformers/main/en/main_classes/model#transformers.PreTrainedModel.save_pretrained">save_pretrained()</a> method. If the model was quantized with the <code>device_map</code> parameter, make sure to move the entire model to a GPU or CPU before saving it. For example, to save the model on a CPU:',dl,jt,ul,Ct,La='Reload a quantized model with the <a href="/docs/transformers/main/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method, and set <code>device_map=&quot;auto&quot;</code> to automatically distribute the model on all available GPUs to load the model faster without using more memory than needed.',fl,qt,hl,kt,cl,Zt,Na='<a href="https://github.com/turboderp/exllama" rel="nofollow">ExLlama</a> is a Python/C++/CUDA implementation of the <a href="model_doc/llama">Llama</a> model that is designed for faster inference with 4-bit GPTQ weights (check out these <a href="https://github.com/huggingface/optimum/tree/main/tests/benchmark#gptq-benchmark" rel="nofollow">benchmarks</a>). The ExLlama kernel is activated by default when you create a <a href="/docs/transformers/main/en/main_classes/quantization#transformers.GPTQConfig">GPTQConfig</a> object. To boost inference speed even further, use the <a href="https://github.com/turboderp/exllamav2" rel="nofollow">ExLlamaV2</a> kernels by configuring the <code>exllama_config</code> parameter:',gl,Gt,bl,R,Ml,It,Ea="The ExLlama kernels are only supported when the entire model is on the GPU. If you’re doing inference on a CPU with AutoGPTQ (version > 0.4.2), then you’ll need to disable the ExLlama kernel. This overwrites the attributes related to the ExLlama kernels in the quantization config of the config.json file.",yl,zt,Tl,Bt,wl,Wt,Aa='<a href="https://github.com/TimDettmers/bitsandbytes" rel="nofollow">bitsandbytes</a> is the easiest option for quantizing a model to 8 and 4-bit. 8-bit quantization multiplies outliers in fp16 with non-outliers in int8, converts the non-outlier values back to fp16, and then adds them together to return the weights in fp16. This reduces the degradative effect outlier values have on a model’s performance. 4-bit quantization compresses a model even further, and it is commonly used with <a href="https://hf.co/papers/2305.14314" rel="nofollow">QLoRA</a> to finetune quantized LLMs.',$l,Qt,Ha="To use bitsandbytes, make sure you have the following libraries installed:",Jl,x,_l,Vt,Ya='Now you can quantize a model with the <code>load_in_8bit</code> or <code>load_in_4bit</code> parameters in the <a href="/docs/transformers/main/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method. This works for any model in any modality, as long as it supports loading with Accelerate and contains <code>torch.nn.Linear</code> layers.',vl,L,Ul,N,jl,Ft,Pa="You can check your memory footprint with the <code>get_memory_footprint</code> method:",Cl,Xt,ql,Rt,Sa='Quantized models can be loaded from the <a href="/docs/transformers/main/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method without needing to specify the <code>load_in_8bit</code> or <code>load_in_4bit</code> parameters:',kl,xt,Zl,Lt,Gl,E,Il,Nt,Da="This section explores some of the specific features of 8-bit models, such as offloading, outlier thresholds, skipping module conversion, and finetuning.",zl,Et,Bl,At,Ka='8-bit models can offload weights between the CPU and GPU to support fitting very large models into memory. The weights dispatched to the CPU are actually stored in <strong>float32</strong>, and aren’t converted to 8-bit. For example, to enable offloading for the <a href="https://huggingface.co/bigscience/bloom-1b7" rel="nofollow">bigscience/bloom-1b7</a> model, start by creating a <a href="/docs/transformers/main/en/main_classes/quantization#transformers.BitsAndBytesConfig">BitsAndBytesConfig</a>:',Wl,Ht,Ql,Yt,Oa="Design a custom device map to fit everything on your GPU except for the <code>lm_head</code>, which you’ll dispatch to the CPU:",Vl,Pt,Fl,St,tn="Now load your model with the custom <code>device_map</code> and <code>quantization_config</code>:",Xl,Dt,Rl,Kt,xl,Ot,en="An “outlier” is a hidden state value greater than a certain threshold, and these values are computed in fp16. While the values are usually normally distributed ([-3.5, 3.5]), this distribution can be very different for large models ([-60, 6] or [6, 60]). 8-bit quantization works well for values ~5, but beyond that, there is a significant performance penalty. A good default threshold value is 6, but a lower threshold may be needed for more unstable models (small models or finetuning).",Ll,te,ln='To find the best threshold for your model, we recommend experimenting with the <code>llm_int8_threshold</code> parameter in <a href="/docs/transformers/main/en/main_classes/quantization#transformers.BitsAndBytesConfig">BitsAndBytesConfig</a>:',Nl,ee,El,le,Al,ae,an='For some models, like <a href="model_doc/jukebox">Jukebox</a>, you don’t need to quantize every module to 8-bit which can actually cause instability. With Jukebox, there are several <code>lm_head</code> modules that should be skipped using the <code>llm_int8_skip_modules</code> parameter in <a href="/docs/transformers/main/en/main_classes/quantization#transformers.BitsAndBytesConfig">BitsAndBytesConfig</a>:',Hl,ne,Yl,se,Pl,ie,nn='With the <a href="https://github.com/huggingface/peft" rel="nofollow">PEFT</a> library, you can finetune large models like <a href="https://huggingface.co/google/flan-t5-large" rel="nofollow">flan-t5-large</a> and <a href="https://huggingface.co/facebook/opt-6.7b" rel="nofollow">facebook/opt-6.7b</a> with 8-bit quantization. You don’t need to pass the <code>device_map</code> parameter for training because it’ll automatically load your model on a GPU. However, you can still customize the device map with the <code>device_map</code> parameter if you want to (<code>device_map=&quot;auto&quot;</code> should only be used for inference).',Sl,oe,Dl,A,Kl,re,sn="This section explores some of the specific features of 4-bit models, such as changing the compute data type, using the Normal Float 4 (NF4) data type, and using nested quantization.",Ol,pe,ta,me,on='To speedup computation, you can change the data type from float32 (the default value) to bf16 using the <code>bnb_4bit_compute_dtype</code> parameter in <a href="/docs/transformers/main/en/main_classes/quantization#transformers.BitsAndBytesConfig">BitsAndBytesConfig</a>:',ea,de,la,ue,aa,fe,rn='NF4 is a 4-bit data type from the <a href="https://hf.co/papers/2305.14314" rel="nofollow">QLoRA</a> paper, adapted for weights initialized from a normal distribution. You should use NF4 for training 4-bit base models. This can be configured with the <code>bnb_4bit_quant_type</code> parameter in the <a href="/docs/transformers/main/en/main_classes/quantization#transformers.BitsAndBytesConfig">BitsAndBytesConfig</a>:',na,he,sa,ce,pn="For inference, the <code>bnb_4bit_quant_type</code> does not have a huge impact on performance. However, to remain consistent with the model weights, you should use the <code>bnb_4bit_compute_dtype</code> and <code>torch_dtype</code> values.",ia,ge,oa,be,mn='Nested quantization is a technique that can save additional memory at no additional performance cost. This feature performs a second quantization of the already quantized weights to save an addition 0.4 bits/parameter. For example, with nested quantization, you can finetune a <a href="https://huggingface.co/meta-llama/Llama-2-13b" rel="nofollow">Llama-13b</a> model on a 16GB NVIDIA T4 GPU with a sequence length of 1024, a batch size of 1, and enabling gradient accumulation with 4 steps.',ra,Me,pa,ye,ma,Te,dn='The <a href="https://huggingface.co/docs/optimum/index" rel="nofollow">Optimum</a> library supports quantization for Intel, Furiosa, ONNX Runtime, GPTQ, and lower-level PyTorch quantization functions. Consider using Optimum for quantization if you’re using specific and optimized hardware like Intel CPUs, Furiosa NPUs or a model accelerator like ONNX Runtime.',da,we,ua,$e,un='To compare the speed, throughput, and latency of each quantization scheme, check the following benchmarks obtained from the <a href="https://github.com/huggingface/optimum-benchmark" rel="nofollow">optimum-benchmark</a> library. The benchmark was run on a NVIDIA A1000 for the <a href="https://huggingface.co/TheBloke/Mistral-7B-v0.1-AWQ" rel="nofollow">TheBloke/Mistral-7B-v0.1-AWQ</a> and <a href="https://huggingface.co/TheBloke/Mistral-7B-v0.1-GPTQ" rel="nofollow">TheBloke/Mistral-7B-v0.1-GPTQ</a> models. These were also tested against the bitsandbytes quantization methods as well as a native fp16 model.',fa,H,fn='<div><img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/quantization/forward_memory_plot.png" alt="forward peak memory per batch size"/> <figcaption class="mt-2 text-center text-sm text-gray-500">forward peak memory/batch size</figcaption></div> <div><img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/quantization/generate_memory_plot.png" alt="generate peak memory per batch size"/> <figcaption class="mt-2 text-center text-sm text-gray-500">generate peak memory/batch size</figcaption></div>',ha,Y,hn='<div><img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/quantization/generate_throughput_plot.png" alt="generate throughput per batch size"/> <figcaption class="mt-2 text-center text-sm text-gray-500">generate throughput/batch size</figcaption></div> <div><img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/quantization/forward_latency_plot.png" alt="forward latency per batch size"/> <figcaption class="mt-2 text-center text-sm text-gray-500">forward latency/batch size</figcaption></div>',ca,Je,cn='The benchmarks indicate AWQ quantization is the fastest for inference, text generation, and has the lowest peak memory for text generation. However, AWQ has the largest forward latency per batch size. For a more detailed discussion about the pros and cons of each quantization method, read the <a href="https://huggingface.co/blog/overview-quantization-transformers" rel="nofollow">Overview of natively supported quantization schemes in 🤗 Transformers</a> blog post.',ga,_e,ba,ve,gn='The <a href="https://huggingface.co/TheBloke/Mistral-7B-OpenOrca-AWQ" rel="nofollow">TheBloke/Mistral-7B-OpenOrca-AWQ</a> model was benchmarked with <code>batch_size=1</code> with and without fused modules.',Ma,P,bn="Unfused module",ya,Ue,Mn='<thead><tr><th align="right">Batch Size</th> <th align="right">Prefill Length</th> <th align="right">Decode Length</th> <th align="right">Prefill tokens/s</th> <th align="right">Decode tokens/s</th> <th align="left">Memory (VRAM)</th></tr></thead> <tbody><tr><td align="right">1</td> <td align="right">32</td> <td align="right">32</td> <td align="right">60.0984</td> <td align="right">38.4537</td> <td align="left">4.50 GB (5.68%)</td></tr> <tr><td align="right">1</td> <td align="right">64</td> <td align="right">64</td> <td align="right">1333.67</td> <td align="right">31.6604</td> <td align="left">4.50 GB (5.68%)</td></tr> <tr><td align="right">1</td> <td align="right">128</td> <td align="right">128</td> <td align="right">2434.06</td> <td align="right">31.6272</td> <td align="left">4.50 GB (5.68%)</td></tr> <tr><td align="right">1</td> <td align="right">256</td> <td align="right">256</td> <td align="right">3072.26</td> <td align="right">38.1731</td> <td align="left">4.50 GB (5.68%)</td></tr> <tr><td align="right">1</td> <td align="right">512</td> <td align="right">512</td> <td align="right">3184.74</td> <td align="right">31.6819</td> <td align="left">4.59 GB (5.80%)</td></tr> <tr><td align="right">1</td> <td align="right">1024</td> <td align="right">1024</td> <td align="right">3148.18</td> <td align="right">36.8031</td> <td align="left">4.81 GB (6.07%)</td></tr> <tr><td align="right">1</td> <td align="right">2048</td> <td align="right">2048</td> <td align="right">2927.33</td> <td align="right">35.2676</td> <td align="left">5.73 GB (7.23%)</td></tr></tbody>',Ta,S,yn="Fused module",wa,je,Tn='<thead><tr><th align="right">Batch Size</th> <th align="right">Prefill Length</th> <th align="right">Decode Length</th> <th align="right">Prefill tokens/s</th> <th align="right">Decode tokens/s</th> <th align="left">Memory (VRAM)</th></tr></thead> <tbody><tr><td align="right">1</td> <td align="right">32</td> <td align="right">32</td> <td align="right">81.4899</td> <td align="right">80.2569</td> <td align="left">4.00 GB (5.05%)</td></tr> <tr><td align="right">1</td> <td align="right">64</td> <td align="right">64</td> <td align="right">1756.1</td> <td align="right">106.26</td> <td align="left">4.00 GB (5.05%)</td></tr> <tr><td align="right">1</td> <td align="right">128</td> <td align="right">128</td> <td align="right">2479.32</td> <td align="right">105.631</td> <td align="left">4.00 GB (5.06%)</td></tr> <tr><td align="right">1</td> <td align="right">256</td> <td align="right">256</td> <td align="right">1813.6</td> <td align="right">85.7485</td> <td align="left">4.01 GB (5.06%)</td></tr> <tr><td align="right">1</td> <td align="right">512</td> <td align="right">512</td> <td align="right">2848.9</td> <td align="right">97.701</td> <td align="left">4.11 GB (5.19%)</td></tr> <tr><td align="right">1</td> <td align="right">1024</td> <td align="right">1024</td> <td align="right">3044.35</td> <td align="right">87.7323</td> <td align="left">4.41 GB (5.57%)</td></tr> <tr><td align="right">1</td> <td align="right">2048</td> <td align="right">2048</td> <td align="right">2715.11</td> <td align="right">89.4709</td> <td align="left">5.57 GB (7.04%)</td></tr></tbody>',$a,Ce,wn='The speed and throughput of fused and unfused modules were also tested with the <a href="https://github.com/huggingface/optimum-benchmark" rel="nofollow">optimum-benchmark</a> library.',Ja,D,$n='<div><img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/quantization/fused_forward_memory_plot.png" alt="generate throughput per batch size"/> <figcaption class="mt-2 text-center text-sm text-gray-500">forward peak memory/batch size</figcaption></div> <div><img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/quantization/fused_generate_throughput_plot.png" alt="forward latency per batch size"/> <figcaption class="mt-2 text-center text-sm text-gray-500">generate throughput/batch size</figcaption></div>',_a,Ze,va;return r=new z({props:{title:"Quantization",local:"quantization",headingTag:"h1"}}),k=new W({props:{$$slots:{default:[xn]},$$scope:{ctx:_}}}),G=new z({props:{title:"AWQ",local:"awq",headingTag:"h2"}}),I=new W({props:{$$slots:{default:[Ln]},$$scope:{ctx:_}}}),et=new v({props:{code:"cGlwJTIwaW5zdGFsbCUyMGF1dG9hd3E=",highlighted:"pip install autoawq",wrap:!1}}),at=new v({props:{code:"JTdCJTBBJTIwJTIwJTIyX25hbWVfb3JfcGF0aCUyMiUzQSUyMCUyMiUyRndvcmtzcGFjZSUyRnByb2Nlc3MlMkZodWdnaW5nZmFjZWg0X3plcGh5ci03Yi1hbHBoYSUyRnNvdXJjZSUyMiUyQyUwQSUyMCUyMCUyMmFyY2hpdGVjdHVyZXMlMjIlM0ElMjAlNUIlMEElMjAlMjAlMjAlMjAlMjJNaXN0cmFsRm9yQ2F1c2FsTE0lMjIlMEElMjAlMjAlNUQlMkMlMEElMjAlMjAuLi4lMEElMjAlMjAuLi4lMEElMjAlMjAuLi4lMEElMjAlMjAlMjJxdWFudGl6YXRpb25fY29uZmlnJTIyJTNBJTIwJTdCJTBBJTIwJTIwJTIwJTIwJTIycXVhbnRfbWV0aG9kJTIyJTNBJTIwJTIyYXdxJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIyemVyb19wb2ludCUyMiUzQSUyMHRydWUlMkMlMEElMjAlMjAlMjAlMjAlMjJncm91cF9zaXplJTIyJTNBJTIwMTI4JTJDJTBBJTIwJTIwJTIwJTIwJTIyYml0cyUyMiUzQSUyMDQlMkMlMEElMjAlMjAlMjAlMjAlMjJ2ZXJzaW9uJTIyJTNBJTIwJTIyZ2VtbSUyMiUwQSUyMCUyMCU3RCUwQSU3RA==",highlighted:`<span class="hljs-punctuation">{</span>
  <span class="hljs-attr">&quot;_name_or_path&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;/workspace/process/huggingfaceh4_zephyr-7b-alpha/source&quot;</span><span class="hljs-punctuation">,</span>
  <span class="hljs-attr">&quot;architectures&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">[</span>
    <span class="hljs-string">&quot;MistralForCausalLM&quot;</span>
  <span class="hljs-punctuation">]</span><span class="hljs-punctuation">,</span>
  ...
  ...
  ...
  <span class="hljs-attr">&quot;quantization_config&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">{</span>
    <span class="hljs-attr">&quot;quant_method&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;awq&quot;</span><span class="hljs-punctuation">,</span>
    <span class="hljs-attr">&quot;zero_point&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-literal"><span class="hljs-keyword">true</span></span><span class="hljs-punctuation">,</span>
    <span class="hljs-attr">&quot;group_size&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-number">128</span><span class="hljs-punctuation">,</span>
    <span class="hljs-attr">&quot;bits&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-number">4</span><span class="hljs-punctuation">,</span>
    <span class="hljs-attr">&quot;version&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;gemm&quot;</span>
  <span class="hljs-punctuation">}</span>
<span class="hljs-punctuation">}</span>`,wrap:!1}}),st=new v({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvckNhdXNhbExNJTJDJTIwQXV0b1Rva2VuaXplciUwQSUwQW1vZGVsX2lkJTIwJTNEJTIwJTIyVGhlQmxva2UlMkZ6ZXBoeXItN0ItYWxwaGEtQVdRJTIyJTBBbW9kZWwlMjAlM0QlMjBBdXRvTW9kZWxGb3JDYXVzYWxMTS5mcm9tX3ByZXRyYWluZWQobW9kZWxfaWQlMkMlMjBkZXZpY2VfbWFwJTNEJTIyY3VkYSUzQTAlMjIp",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForCausalLM, AutoTokenizer

model_id = <span class="hljs-string">&quot;TheBloke/zephyr-7B-alpha-AWQ&quot;</span>
model = AutoModelForCausalLM.from_pretrained(model_id, device_map=<span class="hljs-string">&quot;cuda:0&quot;</span>)`,wrap:!1}}),ot=new v({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvckNhdXNhbExNJTJDJTIwQXV0b1Rva2VuaXplciUwQSUwQW1vZGVsX2lkJTIwJTNEJTIwJTIyVGhlQmxva2UlMkZ6ZXBoeXItN0ItYWxwaGEtQVdRJTIyJTBBbW9kZWwlMjAlM0QlMjBBdXRvTW9kZWxGb3JDYXVzYWxMTS5mcm9tX3ByZXRyYWluZWQobW9kZWxfaWQlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MzIp",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForCausalLM, AutoTokenizer

model_id = <span class="hljs-string">&quot;TheBloke/zephyr-7B-alpha-AWQ&quot;</span>
model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.float32)`,wrap:!1}}),pt=new v({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvckNhdXNhbExNJTJDJTIwQXV0b1Rva2VuaXplciUwQSUwQW1vZGVsJTIwJTNEJTIwQXV0b01vZGVsRm9yQ2F1c2FsTE0uZnJvbV9wcmV0cmFpbmVkKCUyMlRoZUJsb2tlJTJGemVwaHlyLTdCLWFscGhhLUFXUSUyMiUyQyUyMGF0dG5faW1wbGVtZW50YXRpb24lM0QlMjJmbGFzaF9hdHRlbnRpb25fMiUyMiUyQyUyMGRldmljZV9tYXAlM0QlMjJjdWRhJTNBMCUyMik=",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForCausalLM, AutoTokenizer

model = AutoModelForCausalLM.from_pretrained(<span class="hljs-string">&quot;TheBloke/zephyr-7B-alpha-AWQ&quot;</span>, attn_implementation=<span class="hljs-string">&quot;flash_attention_2&quot;</span>, device_map=<span class="hljs-string">&quot;cuda:0&quot;</span>)`,wrap:!1}}),mt=new z({props:{title:"Fused modules",local:"fused-modules",headingTag:"h3"}}),Q=new W({props:{warning:!0,$$slots:{default:[Nn]},$$scope:{ctx:_}}}),V=new Ua({props:{id:"fuse",options:["supported architectures","unsupported architectures"],$$slots:{default:[Hn]},$$scope:{ctx:_}}}),ut=new z({props:{title:"AutoGPTQ",local:"autogptq",headingTag:"h2"}}),F=new W({props:{$$slots:{default:[Yn]},$$scope:{ctx:_}}}),ct=new v({props:{code:"cGlwJTIwaW5zdGFsbCUyMGF1dG8tZ3B0cSUwQXBpcCUyMGluc3RhbGwlMjBnaXQlMkJodHRwcyUzQSUyRiUyRmdpdGh1Yi5jb20lMkZodWdnaW5nZmFjZSUyRm9wdGltdW0uZ2l0JTBBcGlwJTIwaW5zdGFsbCUyMGdpdCUyQmh0dHBzJTNBJTJGJTJGZ2l0aHViLmNvbSUyRmh1Z2dpbmdmYWNlJTJGdHJhbnNmb3JtZXJzLmdpdCUwQXBpcCUyMGluc3RhbGwlMjAtLXVwZ3JhZGUlMjBhY2NlbGVyYXRl",highlighted:`pip install auto-gptq
pip install git+https://github.com/huggingface/optimum.git
pip install git+https://github.com/huggingface/transformers.git
pip install --upgrade accelerate`,wrap:!1}}),bt=new v({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvckNhdXNhbExNJTJDJTIwQXV0b1Rva2VuaXplciUyQyUyMEdQVFFDb25maWclMEElMEFtb2RlbF9pZCUyMCUzRCUyMCUyMmZhY2Vib29rJTJGb3B0LTEyNW0lMjIlMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZChtb2RlbF9pZCklMEFncHRxX2NvbmZpZyUyMCUzRCUyMEdQVFFDb25maWcoYml0cyUzRDQlMkMlMjBkYXRhc2V0JTNEJTIyYzQlMjIlMkMlMjB0b2tlbml6ZXIlM0R0b2tlbml6ZXIp",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForCausalLM, AutoTokenizer, GPTQConfig

model_id = <span class="hljs-string">&quot;facebook/opt-125m&quot;</span>
tokenizer = AutoTokenizer.from_pretrained(model_id)
gptq_config = GPTQConfig(bits=<span class="hljs-number">4</span>, dataset=<span class="hljs-string">&quot;c4&quot;</span>, tokenizer=tokenizer)`,wrap:!1}}),yt=new v({props:{code:"ZGF0YXNldCUyMCUzRCUyMCU1QiUyMmF1dG8tZ3B0cSUyMGlzJTIwYW4lMjBlYXN5LXRvLXVzZSUyMG1vZGVsJTIwcXVhbnRpemF0aW9uJTIwbGlicmFyeSUyMHdpdGglMjB1c2VyLWZyaWVuZGx5JTIwYXBpcyUyQyUyMGJhc2VkJTIwb24lMjBHUFRRJTIwYWxnb3JpdGhtLiUyMiU1RCUwQWdwdHFfY29uZmlnJTIwJTNEJTIwR1BUUUNvbmZpZyhiaXRzJTNENCUyQyUyMGRhdGFzZXQlM0RkYXRhc2V0JTJDJTIwdG9rZW5pemVyJTNEdG9rZW5pemVyKQ==",highlighted:`dataset = [<span class="hljs-string">&quot;auto-gptq is an easy-to-use model quantization library with user-friendly apis, based on GPTQ algorithm.&quot;</span>]
gptq_config = GPTQConfig(bits=<span class="hljs-number">4</span>, dataset=dataset, tokenizer=tokenizer)`,wrap:!1}}),wt=new v({props:{code:"cXVhbnRpemVkX21vZGVsJTIwJTNEJTIwQXV0b01vZGVsRm9yQ2F1c2FsTE0uZnJvbV9wcmV0cmFpbmVkKG1vZGVsX2lkJTJDJTIwZGV2aWNlX21hcCUzRCUyMmF1dG8lMjIlMkMlMjBxdWFudGl6YXRpb25fY29uZmlnJTNEZ3B0cV9jb25maWcp",highlighted:'quantized_model = AutoModelForCausalLM.from_pretrained(model_id, device_map=<span class="hljs-string">&quot;auto&quot;</span>, quantization_config=gptq_config)',wrap:!1}}),Jt=new v({props:{code:"cXVhbnRpemVkX21vZGVsJTIwJTNEJTIwQXV0b01vZGVsRm9yQ2F1c2FsTE0uZnJvbV9wcmV0cmFpbmVkKG1vZGVsX2lkJTJDJTIwZGV2aWNlX21hcCUzRCUyMmF1dG8lMjIlMkMlMjBtYXhfbWVtb3J5JTNEJTdCMCUzQSUyMCUyMjMwR2lCJTIyJTJDJTIwMSUzQSUyMCUyMjQ2R2lCJTIyJTJDJTIwJTIyY3B1JTIyJTNBJTIwJTIyMzBHaUIlMjIlN0QlMkMlMjBxdWFudGl6YXRpb25fY29uZmlnJTNEZ3B0cV9jb25maWcp",highlighted:'quantized_model = AutoModelForCausalLM.from_pretrained(model_id, device_map=<span class="hljs-string">&quot;auto&quot;</span>, max_memory={<span class="hljs-number">0</span>: <span class="hljs-string">&quot;30GiB&quot;</span>, <span class="hljs-number">1</span>: <span class="hljs-string">&quot;46GiB&quot;</span>, <span class="hljs-string">&quot;cpu&quot;</span>: <span class="hljs-string">&quot;30GiB&quot;</span>}, quantization_config=gptq_config)',wrap:!1}}),X=new W({props:{warning:!0,$$slots:{default:[Pn]},$$scope:{ctx:_}}}),vt=new v({props:{code:"cXVhbnRpemVkX21vZGVsLnB1c2hfdG9faHViKCUyMm9wdC0xMjVtLWdwdHElMjIpJTBBdG9rZW5pemVyLnB1c2hfdG9faHViKCUyMm9wdC0xMjVtLWdwdHElMjIp",highlighted:`quantized_model.push_to_hub(<span class="hljs-string">&quot;opt-125m-gptq&quot;</span>)
tokenizer.push_to_hub(<span class="hljs-string">&quot;opt-125m-gptq&quot;</span>)`,wrap:!1}}),jt=new v({props:{code:"cXVhbnRpemVkX21vZGVsLnNhdmVfcHJldHJhaW5lZCglMjJvcHQtMTI1bS1ncHRxJTIyKSUwQXRva2VuaXplci5zYXZlX3ByZXRyYWluZWQoJTIyb3B0LTEyNW0tZ3B0cSUyMiklMEElMEElMjMlMjBpZiUyMHF1YW50aXplZCUyMHdpdGglMjBkZXZpY2VfbWFwJTIwc2V0JTBBcXVhbnRpemVkX21vZGVsLnRvKCUyMmNwdSUyMiklMEFxdWFudGl6ZWRfbW9kZWwuc2F2ZV9wcmV0cmFpbmVkKCUyMm9wdC0xMjVtLWdwdHElMjIp",highlighted:`quantized_model.save_pretrained(<span class="hljs-string">&quot;opt-125m-gptq&quot;</span>)
tokenizer.save_pretrained(<span class="hljs-string">&quot;opt-125m-gptq&quot;</span>)

<span class="hljs-comment"># if quantized with device_map set</span>
quantized_model.to(<span class="hljs-string">&quot;cpu&quot;</span>)
quantized_model.save_pretrained(<span class="hljs-string">&quot;opt-125m-gptq&quot;</span>)`,wrap:!1}}),qt=new v({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvckNhdXNhbExNJTBBJTBBbW9kZWwlMjAlM0QlMjBBdXRvTW9kZWxGb3JDYXVzYWxMTS5mcm9tX3ByZXRyYWluZWQoJTIyJTdCeW91cl91c2VybmFtZSU3RCUyRm9wdC0xMjVtLWdwdHElMjIlMkMlMjBkZXZpY2VfbWFwJTNEJTIyYXV0byUyMik=",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForCausalLM

model = AutoModelForCausalLM.from_pretrained(<span class="hljs-string">&quot;{your_username}/opt-125m-gptq&quot;</span>, device_map=<span class="hljs-string">&quot;auto&quot;</span>)`,wrap:!1}}),kt=new z({props:{title:"ExLlama",local:"exllama",headingTag:"h3"}}),Gt=new v({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQXV0b01vZGVsRm9yQ2F1c2FsTE0lMkMlMjBHUFRRQ29uZmlnJTBBJTBBZ3B0cV9jb25maWclMjAlM0QlMjBHUFRRQ29uZmlnKGJpdHMlM0Q0JTJDJTIwZXhsbGFtYV9jb25maWclM0QlN0IlMjJ2ZXJzaW9uJTIyJTNBMiU3RCklMEFtb2RlbCUyMCUzRCUyMEF1dG9Nb2RlbEZvckNhdXNhbExNLmZyb21fcHJldHJhaW5lZCglMjIlN0J5b3VyX3VzZXJuYW1lJTdEJTJGb3B0LTEyNW0tZ3B0cSUyMiUyQyUyMGRldmljZV9tYXAlM0QlMjJhdXRvJTIyJTJDJTIwcXVhbnRpemF0aW9uX2NvbmZpZyUzRGdwdHFfY29uZmlnKQ==",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForCausalLM, GPTQConfig

gptq_config = GPTQConfig(bits=<span class="hljs-number">4</span>, exllama_config={<span class="hljs-string">&quot;version&quot;</span>:<span class="hljs-number">2</span>})
model = AutoModelForCausalLM.from_pretrained(<span class="hljs-string">&quot;{your_username}/opt-125m-gptq&quot;</span>, device_map=<span class="hljs-string">&quot;auto&quot;</span>, quantization_config=gptq_config)`,wrap:!1}}),R=new W({props:{warning:!0,$$slots:{default:[Sn]},$$scope:{ctx:_}}}),zt=new v({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQXV0b01vZGVsRm9yQ2F1c2FsTE0lMkMlMjBHUFRRQ29uZmlnJTBBZ3B0cV9jb25maWclMjAlM0QlMjBHUFRRQ29uZmlnKGJpdHMlM0Q0JTJDJTIwdXNlX2V4bGxhbWElM0RGYWxzZSklMEFtb2RlbCUyMCUzRCUyMEF1dG9Nb2RlbEZvckNhdXNhbExNLmZyb21fcHJldHJhaW5lZCglMjIlN0J5b3VyX3VzZXJuYW1lJTdEJTJGb3B0LTEyNW0tZ3B0cSUyMiUyQyUyMGRldmljZV9tYXAlM0QlMjJjcHUlMjIlMkMlMjBxdWFudGl6YXRpb25fY29uZmlnJTNEZ3B0cV9jb25maWcp",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForCausalLM, GPTQConfig
gptq_config = GPTQConfig(bits=<span class="hljs-number">4</span>, use_exllama=<span class="hljs-literal">False</span>)
model = AutoModelForCausalLM.from_pretrained(<span class="hljs-string">&quot;{your_username}/opt-125m-gptq&quot;</span>, device_map=<span class="hljs-string">&quot;cpu&quot;</span>, quantization_config=gptq_config)`,wrap:!1}}),Bt=new z({props:{title:"bitsandbytes",local:"bitsandbytes",headingTag:"h2"}}),x=new Ua({props:{id:"bnb",options:["8-bit","4-bit"],$$slots:{default:[On]},$$scope:{ctx:_}}}),L=new Ua({props:{id:"bnb",options:["8-bit","4-bit"],$$slots:{default:[ls]},$$scope:{ctx:_}}}),N=new W({props:{warning:!0,$$slots:{default:[as]},$$scope:{ctx:_}}}),Xt=new v({props:{code:"cHJpbnQobW9kZWwuZ2V0X21lbW9yeV9mb290cHJpbnQoKSk=",highlighted:'<span class="hljs-built_in">print</span>(model.get_memory_footprint())',wrap:!1}}),xt=new v({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvckNhdXNhbExNJTJDJTIwQXV0b1Rva2VuaXplciUwQSUwQW1vZGVsJTIwJTNEJTIwQXV0b01vZGVsRm9yQ2F1c2FsTE0uZnJvbV9wcmV0cmFpbmVkKCUyMiU3QnlvdXJfdXNlcm5hbWUlN0QlMkZibG9vbS01NjBtLThiaXQlMjIlMkMlMjBkZXZpY2VfbWFwJTNEJTIyYXV0byUyMik=",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForCausalLM, AutoTokenizer

model = AutoModelForCausalLM.from_pretrained(<span class="hljs-string">&quot;{your_username}/bloom-560m-8bit&quot;</span>, device_map=<span class="hljs-string">&quot;auto&quot;</span>)`,wrap:!1}}),Lt=new z({props:{title:"8-bit",local:"8-bit",headingTag:"h3"}}),E=new W({props:{$$slots:{default:[ns]},$$scope:{ctx:_}}}),Et=new z({props:{title:"Offloading",local:"offloading",headingTag:"h4"}}),Ht=new v({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvckNhdXNhbExNJTJDJTIwQml0c0FuZEJ5dGVzQ29uZmlnJTBBJTBBcXVhbnRpemF0aW9uX2NvbmZpZyUyMCUzRCUyMEJpdHNBbmRCeXRlc0NvbmZpZyhsbG1faW50OF9lbmFibGVfZnAzMl9jcHVfb2ZmbG9hZCUzRFRydWUp",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForCausalLM, BitsAndBytesConfig

quantization_config = BitsAndBytesConfig(llm_int8_enable_fp32_cpu_offload=<span class="hljs-literal">True</span>)`,wrap:!1}}),Pt=new v({props:{code:"ZGV2aWNlX21hcCUyMCUzRCUyMCU3QiUwQSUyMCUyMCUyMCUyMCUyMnRyYW5zZm9ybWVyLndvcmRfZW1iZWRkaW5ncyUyMiUzQSUyMDAlMkMlMEElMjAlMjAlMjAlMjAlMjJ0cmFuc2Zvcm1lci53b3JkX2VtYmVkZGluZ3NfbGF5ZXJub3JtJTIyJTNBJTIwMCUyQyUwQSUyMCUyMCUyMCUyMCUyMmxtX2hlYWQlMjIlM0ElMjAlMjJjcHUlMjIlMkMlMEElMjAlMjAlMjAlMjAlMjJ0cmFuc2Zvcm1lci5oJTIyJTNBJTIwMCUyQyUwQSUyMCUyMCUyMCUyMCUyMnRyYW5zZm9ybWVyLmxuX2YlMjIlM0ElMjAwJTJDJTBBJTdE",highlighted:`device_map = {
    <span class="hljs-string">&quot;transformer.word_embeddings&quot;</span>: <span class="hljs-number">0</span>,
    <span class="hljs-string">&quot;transformer.word_embeddings_layernorm&quot;</span>: <span class="hljs-number">0</span>,
    <span class="hljs-string">&quot;lm_head&quot;</span>: <span class="hljs-string">&quot;cpu&quot;</span>,
    <span class="hljs-string">&quot;transformer.h&quot;</span>: <span class="hljs-number">0</span>,
    <span class="hljs-string">&quot;transformer.ln_f&quot;</span>: <span class="hljs-number">0</span>,
}`,wrap:!1}}),Dt=new v({props:{code:"bW9kZWxfOGJpdCUyMCUzRCUyMEF1dG9Nb2RlbEZvckNhdXNhbExNLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJiaWdzY2llbmNlJTJGYmxvb20tMWI3JTIyJTJDJTBBJTIwJTIwJTIwJTIwZGV2aWNlX21hcCUzRGRldmljZV9tYXAlMkMlMEElMjAlMjAlMjAlMjBxdWFudGl6YXRpb25fY29uZmlnJTNEcXVhbnRpemF0aW9uX2NvbmZpZyUyQyUwQSk=",highlighted:`model_8bit = AutoModelForCausalLM.from_pretrained(
    <span class="hljs-string">&quot;bigscience/bloom-1b7&quot;</span>,
    device_map=device_map,
    quantization_config=quantization_config,
)`,wrap:!1}}),Kt=new z({props:{title:"Outlier threshold",local:"outlier-threshold",headingTag:"h4"}}),ee=new v({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvckNhdXNhbExNJTJDJTIwQml0c0FuZEJ5dGVzQ29uZmlnJTBBJTBBbW9kZWxfaWQlMjAlM0QlMjAlMjJiaWdzY2llbmNlJTJGYmxvb20tMWI3JTIyJTBBJTBBcXVhbnRpemF0aW9uX2NvbmZpZyUyMCUzRCUyMEJpdHNBbmRCeXRlc0NvbmZpZyglMEElMjAlMjAlMjAlMjBsbG1faW50OF90aHJlc2hvbGQlM0QxMCUyQyUwQSklMEElMEFtb2RlbF84Yml0JTIwJTNEJTIwQXV0b01vZGVsRm9yQ2F1c2FsTE0uZnJvbV9wcmV0cmFpbmVkKCUwQSUyMCUyMCUyMCUyMG1vZGVsX2lkJTJDJTBBJTIwJTIwJTIwJTIwZGV2aWNlX21hcCUzRGRldmljZV9tYXAlMkMlMEElMjAlMjAlMjAlMjBxdWFudGl6YXRpb25fY29uZmlnJTNEcXVhbnRpemF0aW9uX2NvbmZpZyUyQyUwQSk=",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForCausalLM, BitsAndBytesConfig

model_id = <span class="hljs-string">&quot;bigscience/bloom-1b7&quot;</span>

quantization_config = BitsAndBytesConfig(
    llm_int8_threshold=<span class="hljs-number">10</span>,
)

model_8bit = AutoModelForCausalLM.from_pretrained(
    model_id,
    device_map=device_map,
    quantization_config=quantization_config,
)`,wrap:!1}}),le=new z({props:{title:"Skip module conversion",local:"skip-module-conversion",headingTag:"h4"}}),ne=new v({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvckNhdXNhbExNJTJDJTIwQXV0b1Rva2VuaXplciUyQyUyMEJpdHNBbmRCeXRlc0NvbmZpZyUwQSUwQW1vZGVsX2lkJTIwJTNEJTIwJTIyYmlnc2NpZW5jZSUyRmJsb29tLTFiNyUyMiUwQSUwQXF1YW50aXphdGlvbl9jb25maWclMjAlM0QlMjBCaXRzQW5kQnl0ZXNDb25maWcoJTBBJTIwJTIwJTIwJTIwbGxtX2ludDhfc2tpcF9tb2R1bGVzJTNEJTVCJTIybG1faGVhZCUyMiU1RCUyQyUwQSklMEElMEFtb2RlbF84Yml0JTIwJTNEJTIwQXV0b01vZGVsRm9yQ2F1c2FsTE0uZnJvbV9wcmV0cmFpbmVkKCUwQSUyMCUyMCUyMCUyMG1vZGVsX2lkJTJDJTBBJTIwJTIwJTIwJTIwZGV2aWNlX21hcCUzRCUyMmF1dG8lMjIlMkMlMEElMjAlMjAlMjAlMjBxdWFudGl6YXRpb25fY29uZmlnJTNEcXVhbnRpemF0aW9uX2NvbmZpZyUyQyUwQSk=",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig

model_id = <span class="hljs-string">&quot;bigscience/bloom-1b7&quot;</span>

quantization_config = BitsAndBytesConfig(
    llm_int8_skip_modules=[<span class="hljs-string">&quot;lm_head&quot;</span>],
)

model_8bit = AutoModelForCausalLM.from_pretrained(
    model_id,
    device_map=<span class="hljs-string">&quot;auto&quot;</span>,
    quantization_config=quantization_config,
)`,wrap:!1}}),se=new z({props:{title:"Finetuning",local:"finetuning",headingTag:"h4"}}),oe=new z({props:{title:"4-bit",local:"4-bit",headingTag:"h3"}}),A=new W({props:{$$slots:{default:[ss]},$$scope:{ctx:_}}}),pe=new z({props:{title:"Compute data type",local:"compute-data-type",headingTag:"h4"}}),de=new v({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQml0c0FuZEJ5dGVzQ29uZmlnJTBBJTBBcXVhbnRpemF0aW9uX2NvbmZpZyUyMCUzRCUyMEJpdHNBbmRCeXRlc0NvbmZpZyhsb2FkX2luXzRiaXQlM0RUcnVlJTJDJTIwYm5iXzRiaXRfY29tcHV0ZV9kdHlwZSUzRHRvcmNoLmJmbG9hdDE2KQ==",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> BitsAndBytesConfig

quantization_config = BitsAndBytesConfig(load_in_4bit=<span class="hljs-literal">True</span>, bnb_4bit_compute_dtype=torch.bfloat16)`,wrap:!1}}),ue=new z({props:{title:"Normal Float 4 (NF4)",local:"normal-float-4-nf4",headingTag:"h4"}}),he=new v({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEJpdHNBbmRCeXRlc0NvbmZpZyUwQSUwQW5mNF9jb25maWclMjAlM0QlMjBCaXRzQW5kQnl0ZXNDb25maWcoJTBBJTIwJTIwJTIwJTIwbG9hZF9pbl80Yml0JTNEVHJ1ZSUyQyUwQSUyMCUyMCUyMCUyMGJuYl80Yml0X3F1YW50X3R5cGUlM0QlMjJuZjQlMjIlMkMlMEEpJTBBJTBBbW9kZWxfbmY0JTIwJTNEJTIwQXV0b01vZGVsRm9yQ2F1c2FsTE0uZnJvbV9wcmV0cmFpbmVkKG1vZGVsX2lkJTJDJTIwcXVhbnRpemF0aW9uX2NvbmZpZyUzRG5mNF9jb25maWcp",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> BitsAndBytesConfig

nf4_config = BitsAndBytesConfig(
    load_in_4bit=<span class="hljs-literal">True</span>,
    bnb_4bit_quant_type=<span class="hljs-string">&quot;nf4&quot;</span>,
)

model_nf4 = AutoModelForCausalLM.from_pretrained(model_id, quantization_config=nf4_config)`,wrap:!1}}),ge=new z({props:{title:"Nested quantization",local:"nested-quantization",headingTag:"h4"}}),Me=new v({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEJpdHNBbmRCeXRlc0NvbmZpZyUwQSUwQWRvdWJsZV9xdWFudF9jb25maWclMjAlM0QlMjBCaXRzQW5kQnl0ZXNDb25maWcoJTBBJTIwJTIwJTIwJTIwbG9hZF9pbl80Yml0JTNEVHJ1ZSUyQyUwQSUyMCUyMCUyMCUyMGJuYl80Yml0X3VzZV9kb3VibGVfcXVhbnQlM0RUcnVlJTJDJTBBKSUwQSUwQW1vZGVsX2RvdWJsZV9xdWFudCUyMCUzRCUyMEF1dG9Nb2RlbEZvckNhdXNhbExNLmZyb21fcHJldHJhaW5lZCglMjJtZXRhLWxsYW1hJTJGTGxhbWEtMi0xM2IlMjIlMkMlMjBxdWFudGl6YXRpb25fY29uZmlnJTNEZG91YmxlX3F1YW50X2NvbmZpZyk=",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> BitsAndBytesConfig

double_quant_config = BitsAndBytesConfig(
    load_in_4bit=<span class="hljs-literal">True</span>,
    bnb_4bit_use_double_quant=<span class="hljs-literal">True</span>,
)

model_double_quant = AutoModelForCausalLM.from_pretrained(<span class="hljs-string">&quot;meta-llama/Llama-2-13b&quot;</span>, quantization_config=double_quant_config)`,wrap:!1}}),ye=new z({props:{title:"Optimum",local:"optimum",headingTag:"h2"}}),we=new z({props:{title:"Benchmarks",local:"benchmarks",headingTag:"h2"}}),_e=new z({props:{title:"Fused AWQ modules",local:"fused-awq-modules",headingTag:"h3"}}),{c(){n=p("meta"),y=i(),s=p("p"),d=i(),f(r.$$.fragment),T=i(),U=p("p"),U.textContent=C,w=i(),q=p("p"),q.textContent=Z,j=i(),f(k.$$.fragment),$=i(),f(G.$$.fragment),J=i(),f(I.$$.fragment),Ge=i(),K=p("p"),K.innerHTML=ja,Ie=i(),O=p("p"),O.innerHTML=Ca,ze=i(),tt=p("p"),tt.textContent=qa,Be=i(),f(et.$$.fragment),We=i(),lt=p("p"),lt.innerHTML=ka,Qe=i(),f(at.$$.fragment),Ve=i(),nt=p("p"),nt.innerHTML=Za,Fe=i(),f(st.$$.fragment),Xe=i(),it=p("p"),it.innerHTML=Ga,Re=i(),f(ot.$$.fragment),xe=i(),rt=p("p"),rt.innerHTML=Ia,Le=i(),f(pt.$$.fragment),Ne=i(),f(mt.$$.fragment),Ee=i(),dt=p("p"),dt.innerHTML=za,Ae=i(),f(Q.$$.fragment),He=i(),f(V.$$.fragment),Ye=i(),f(ut.$$.fragment),Pe=i(),f(F.$$.fragment),Se=i(),ft=p("p"),ft.innerHTML=Ba,De=i(),ht=p("p"),ht.textContent=Wa,Ke=i(),f(ct.$$.fragment),Oe=i(),gt=p("p"),gt.innerHTML=Qa,tl=i(),f(bt.$$.fragment),el=i(),Mt=p("p"),Mt.textContent=Va,ll=i(),f(yt.$$.fragment),al=i(),Tt=p("p"),Tt.innerHTML=Fa,nl=i(),f(wt.$$.fragment),sl=i(),$t=p("p"),$t.innerHTML=Xa,il=i(),f(Jt.$$.fragment),ol=i(),f(X.$$.fragment),rl=i(),_t=p("p"),_t.innerHTML=Ra,pl=i(),f(vt.$$.fragment),ml=i(),Ut=p("p"),Ut.innerHTML=xa,dl=i(),f(jt.$$.fragment),ul=i(),Ct=p("p"),Ct.innerHTML=La,fl=i(),f(qt.$$.fragment),hl=i(),f(kt.$$.fragment),cl=i(),Zt=p("p"),Zt.innerHTML=Na,gl=i(),f(Gt.$$.fragment),bl=i(),f(R.$$.fragment),Ml=i(),It=p("p"),It.textContent=Ea,yl=i(),f(zt.$$.fragment),Tl=i(),f(Bt.$$.fragment),wl=i(),Wt=p("p"),Wt.innerHTML=Aa,$l=i(),Qt=p("p"),Qt.textContent=Ha,Jl=i(),f(x.$$.fragment),_l=i(),Vt=p("p"),Vt.innerHTML=Ya,vl=i(),f(L.$$.fragment),Ul=i(),f(N.$$.fragment),jl=i(),Ft=p("p"),Ft.innerHTML=Pa,Cl=i(),f(Xt.$$.fragment),ql=i(),Rt=p("p"),Rt.innerHTML=Sa,kl=i(),f(xt.$$.fragment),Zl=i(),f(Lt.$$.fragment),Gl=i(),f(E.$$.fragment),Il=i(),Nt=p("p"),Nt.textContent=Da,zl=i(),f(Et.$$.fragment),Bl=i(),At=p("p"),At.innerHTML=Ka,Wl=i(),f(Ht.$$.fragment),Ql=i(),Yt=p("p"),Yt.innerHTML=Oa,Vl=i(),f(Pt.$$.fragment),Fl=i(),St=p("p"),St.innerHTML=tn,Xl=i(),f(Dt.$$.fragment),Rl=i(),f(Kt.$$.fragment),xl=i(),Ot=p("p"),Ot.textContent=en,Ll=i(),te=p("p"),te.innerHTML=ln,Nl=i(),f(ee.$$.fragment),El=i(),f(le.$$.fragment),Al=i(),ae=p("p"),ae.innerHTML=an,Hl=i(),f(ne.$$.fragment),Yl=i(),f(se.$$.fragment),Pl=i(),ie=p("p"),ie.innerHTML=nn,Sl=i(),f(oe.$$.fragment),Dl=i(),f(A.$$.fragment),Kl=i(),re=p("p"),re.textContent=sn,Ol=i(),f(pe.$$.fragment),ta=i(),me=p("p"),me.innerHTML=on,ea=i(),f(de.$$.fragment),la=i(),f(ue.$$.fragment),aa=i(),fe=p("p"),fe.innerHTML=rn,na=i(),f(he.$$.fragment),sa=i(),ce=p("p"),ce.innerHTML=pn,ia=i(),f(ge.$$.fragment),oa=i(),be=p("p"),be.innerHTML=mn,ra=i(),f(Me.$$.fragment),pa=i(),f(ye.$$.fragment),ma=i(),Te=p("p"),Te.innerHTML=dn,da=i(),f(we.$$.fragment),ua=i(),$e=p("p"),$e.innerHTML=un,fa=i(),H=p("div"),H.innerHTML=fn,ha=i(),Y=p("div"),Y.innerHTML=hn,ca=i(),Je=p("p"),Je.innerHTML=cn,ga=i(),f(_e.$$.fragment),ba=i(),ve=p("p"),ve.innerHTML=gn,Ma=i(),P=p("figcaption"),P.textContent=bn,ya=i(),Ue=p("table"),Ue.innerHTML=Mn,Ta=i(),S=p("figcaption"),S.textContent=yn,wa=i(),je=p("table"),je.innerHTML=Tn,$a=i(),Ce=p("p"),Ce.innerHTML=wn,Ja=i(),D=p("div"),D.innerHTML=$n,_a=i(),Ze=p("p"),this.h()},l(t){const e=Xn("svelte-u9bgzb",document.head);n=m(e,"META",{name:!0,content:!0}),e.forEach(l),y=o(t),s=m(t,"P",{}),Bn(s).forEach(l),d=o(t),h(r.$$.fragment,t),T=o(t),U=m(t,"P",{"data-svelte-h":!0}),u(U)!=="svelte-1euzkei"&&(U.textContent=C),w=o(t),q=m(t,"P",{"data-svelte-h":!0}),u(q)!=="svelte-1f5pv07"&&(q.textContent=Z),j=o(t),h(k.$$.fragment,t),$=o(t),h(G.$$.fragment,t),J=o(t),h(I.$$.fragment,t),Ge=o(t),K=m(t,"P",{"data-svelte-h":!0}),u(K)!=="svelte-1c5vyni"&&(K.innerHTML=ja),Ie=o(t),O=m(t,"P",{"data-svelte-h":!0}),u(O)!=="svelte-vomabp"&&(O.innerHTML=Ca),ze=o(t),tt=m(t,"P",{"data-svelte-h":!0}),u(tt)!=="svelte-1ozln1k"&&(tt.textContent=qa),Be=o(t),h(et.$$.fragment,t),We=o(t),lt=m(t,"P",{"data-svelte-h":!0}),u(lt)!=="svelte-1lxz9t"&&(lt.innerHTML=ka),Qe=o(t),h(at.$$.fragment,t),Ve=o(t),nt=m(t,"P",{"data-svelte-h":!0}),u(nt)!=="svelte-108eg93"&&(nt.innerHTML=Za),Fe=o(t),h(st.$$.fragment,t),Xe=o(t),it=m(t,"P",{"data-svelte-h":!0}),u(it)!=="svelte-19un5li"&&(it.innerHTML=Ga),Re=o(t),h(ot.$$.fragment,t),xe=o(t),rt=m(t,"P",{"data-svelte-h":!0}),u(rt)!=="svelte-ptrt24"&&(rt.innerHTML=Ia),Le=o(t),h(pt.$$.fragment,t),Ne=o(t),h(mt.$$.fragment,t),Ee=o(t),dt=m(t,"P",{"data-svelte-h":!0}),u(dt)!=="svelte-jywid1"&&(dt.innerHTML=za),Ae=o(t),h(Q.$$.fragment,t),He=o(t),h(V.$$.fragment,t),Ye=o(t),h(ut.$$.fragment,t),Pe=o(t),h(F.$$.fragment,t),Se=o(t),ft=m(t,"P",{"data-svelte-h":!0}),u(ft)!=="svelte-sq0x7n"&&(ft.innerHTML=Ba),De=o(t),ht=m(t,"P",{"data-svelte-h":!0}),u(ht)!=="svelte-13c61n1"&&(ht.textContent=Wa),Ke=o(t),h(ct.$$.fragment,t),Oe=o(t),gt=m(t,"P",{"data-svelte-h":!0}),u(gt)!=="svelte-ur342m"&&(gt.innerHTML=Qa),tl=o(t),h(bt.$$.fragment,t),el=o(t),Mt=m(t,"P",{"data-svelte-h":!0}),u(Mt)!=="svelte-1cjo88z"&&(Mt.textContent=Va),ll=o(t),h(yt.$$.fragment,t),al=o(t),Tt=m(t,"P",{"data-svelte-h":!0}),u(Tt)!=="svelte-13cn5o4"&&(Tt.innerHTML=Fa),nl=o(t),h(wt.$$.fragment,t),sl=o(t),$t=m(t,"P",{"data-svelte-h":!0}),u($t)!=="svelte-1tle3a0"&&($t.innerHTML=Xa),il=o(t),h(Jt.$$.fragment,t),ol=o(t),h(X.$$.fragment,t),rl=o(t),_t=m(t,"P",{"data-svelte-h":!0}),u(_t)!=="svelte-1k4mff"&&(_t.innerHTML=Ra),pl=o(t),h(vt.$$.fragment,t),ml=o(t),Ut=m(t,"P",{"data-svelte-h":!0}),u(Ut)!=="svelte-l9o6va"&&(Ut.innerHTML=xa),dl=o(t),h(jt.$$.fragment,t),ul=o(t),Ct=m(t,"P",{"data-svelte-h":!0}),u(Ct)!=="svelte-42jvja"&&(Ct.innerHTML=La),fl=o(t),h(qt.$$.fragment,t),hl=o(t),h(kt.$$.fragment,t),cl=o(t),Zt=m(t,"P",{"data-svelte-h":!0}),u(Zt)!=="svelte-1y1pnbl"&&(Zt.innerHTML=Na),gl=o(t),h(Gt.$$.fragment,t),bl=o(t),h(R.$$.fragment,t),Ml=o(t),It=m(t,"P",{"data-svelte-h":!0}),u(It)!=="svelte-m9nw5y"&&(It.textContent=Ea),yl=o(t),h(zt.$$.fragment,t),Tl=o(t),h(Bt.$$.fragment,t),wl=o(t),Wt=m(t,"P",{"data-svelte-h":!0}),u(Wt)!=="svelte-5a92xi"&&(Wt.innerHTML=Aa),$l=o(t),Qt=m(t,"P",{"data-svelte-h":!0}),u(Qt)!=="svelte-gf36q7"&&(Qt.textContent=Ha),Jl=o(t),h(x.$$.fragment,t),_l=o(t),Vt=m(t,"P",{"data-svelte-h":!0}),u(Vt)!=="svelte-1tamrid"&&(Vt.innerHTML=Ya),vl=o(t),h(L.$$.fragment,t),Ul=o(t),h(N.$$.fragment,t),jl=o(t),Ft=m(t,"P",{"data-svelte-h":!0}),u(Ft)!=="svelte-1bxp667"&&(Ft.innerHTML=Pa),Cl=o(t),h(Xt.$$.fragment,t),ql=o(t),Rt=m(t,"P",{"data-svelte-h":!0}),u(Rt)!=="svelte-17ps4nd"&&(Rt.innerHTML=Sa),kl=o(t),h(xt.$$.fragment,t),Zl=o(t),h(Lt.$$.fragment,t),Gl=o(t),h(E.$$.fragment,t),Il=o(t),Nt=m(t,"P",{"data-svelte-h":!0}),u(Nt)!=="svelte-1yx1x2g"&&(Nt.textContent=Da),zl=o(t),h(Et.$$.fragment,t),Bl=o(t),At=m(t,"P",{"data-svelte-h":!0}),u(At)!=="svelte-1v0jh01"&&(At.innerHTML=Ka),Wl=o(t),h(Ht.$$.fragment,t),Ql=o(t),Yt=m(t,"P",{"data-svelte-h":!0}),u(Yt)!=="svelte-15oy7am"&&(Yt.innerHTML=Oa),Vl=o(t),h(Pt.$$.fragment,t),Fl=o(t),St=m(t,"P",{"data-svelte-h":!0}),u(St)!=="svelte-k1g8c2"&&(St.innerHTML=tn),Xl=o(t),h(Dt.$$.fragment,t),Rl=o(t),h(Kt.$$.fragment,t),xl=o(t),Ot=m(t,"P",{"data-svelte-h":!0}),u(Ot)!=="svelte-ur5rgd"&&(Ot.textContent=en),Ll=o(t),te=m(t,"P",{"data-svelte-h":!0}),u(te)!=="svelte-v5sezx"&&(te.innerHTML=ln),Nl=o(t),h(ee.$$.fragment,t),El=o(t),h(le.$$.fragment,t),Al=o(t),ae=m(t,"P",{"data-svelte-h":!0}),u(ae)!=="svelte-1ba1s3u"&&(ae.innerHTML=an),Hl=o(t),h(ne.$$.fragment,t),Yl=o(t),h(se.$$.fragment,t),Pl=o(t),ie=m(t,"P",{"data-svelte-h":!0}),u(ie)!=="svelte-4nvx4q"&&(ie.innerHTML=nn),Sl=o(t),h(oe.$$.fragment,t),Dl=o(t),h(A.$$.fragment,t),Kl=o(t),re=m(t,"P",{"data-svelte-h":!0}),u(re)!=="svelte-7ob7j"&&(re.textContent=sn),Ol=o(t),h(pe.$$.fragment,t),ta=o(t),me=m(t,"P",{"data-svelte-h":!0}),u(me)!=="svelte-15j4whk"&&(me.innerHTML=on),ea=o(t),h(de.$$.fragment,t),la=o(t),h(ue.$$.fragment,t),aa=o(t),fe=m(t,"P",{"data-svelte-h":!0}),u(fe)!=="svelte-7qr54g"&&(fe.innerHTML=rn),na=o(t),h(he.$$.fragment,t),sa=o(t),ce=m(t,"P",{"data-svelte-h":!0}),u(ce)!=="svelte-1qoc2ct"&&(ce.innerHTML=pn),ia=o(t),h(ge.$$.fragment,t),oa=o(t),be=m(t,"P",{"data-svelte-h":!0}),u(be)!=="svelte-l0u9eq"&&(be.innerHTML=mn),ra=o(t),h(Me.$$.fragment,t),pa=o(t),h(ye.$$.fragment,t),ma=o(t),Te=m(t,"P",{"data-svelte-h":!0}),u(Te)!=="svelte-opujmz"&&(Te.innerHTML=dn),da=o(t),h(we.$$.fragment,t),ua=o(t),$e=m(t,"P",{"data-svelte-h":!0}),u($e)!=="svelte-10oh9lm"&&($e.innerHTML=un),fa=o(t),H=m(t,"DIV",{class:!0,"data-svelte-h":!0}),u(H)!=="svelte-10jjm5l"&&(H.innerHTML=fn),ha=o(t),Y=m(t,"DIV",{class:!0,"data-svelte-h":!0}),u(Y)!=="svelte-48at03"&&(Y.innerHTML=hn),ca=o(t),Je=m(t,"P",{"data-svelte-h":!0}),u(Je)!=="svelte-1sm7gom"&&(Je.innerHTML=cn),ga=o(t),h(_e.$$.fragment,t),ba=o(t),ve=m(t,"P",{"data-svelte-h":!0}),u(ve)!=="svelte-81zmsw"&&(ve.innerHTML=gn),Ma=o(t),P=m(t,"FIGCAPTION",{class:!0,"data-svelte-h":!0}),u(P)!=="svelte-grefv0"&&(P.textContent=bn),ya=o(t),Ue=m(t,"TABLE",{"data-svelte-h":!0}),u(Ue)!=="svelte-19aactm"&&(Ue.innerHTML=Mn),Ta=o(t),S=m(t,"FIGCAPTION",{class:!0,"data-svelte-h":!0}),u(S)!=="svelte-1r15bg7"&&(S.textContent=yn),wa=o(t),je=m(t,"TABLE",{"data-svelte-h":!0}),u(je)!=="svelte-19fczbk"&&(je.innerHTML=Tn),$a=o(t),Ce=m(t,"P",{"data-svelte-h":!0}),u(Ce)!=="svelte-gu8e8k"&&(Ce.innerHTML=wn),Ja=o(t),D=m(t,"DIV",{class:!0,"data-svelte-h":!0}),u(D)!=="svelte-1ke50ja"&&(D.innerHTML=$n),_a=o(t),Ze=m(t,"P",{}),Bn(Ze).forEach(l),this.h()},h(){qe(n,"name","hf:doc:metadata"),qe(n,"content",os),qe(H,"class","flex gap-4"),qe(Y,"class","flex gap-4"),qe(P,"class","text-center text-gray-500 text-lg"),qe(S,"class","text-center text-gray-500 text-lg"),qe(D,"class","flex gap-4")},m(t,e){Rn(document.head,n),a(t,y,e),a(t,s,e),a(t,d,e),c(r,t,e),a(t,T,e),a(t,U,e),a(t,w,e),a(t,q,e),a(t,j,e),c(k,t,e),a(t,$,e),c(G,t,e),a(t,J,e),c(I,t,e),a(t,Ge,e),a(t,K,e),a(t,Ie,e),a(t,O,e),a(t,ze,e),a(t,tt,e),a(t,Be,e),c(et,t,e),a(t,We,e),a(t,lt,e),a(t,Qe,e),c(at,t,e),a(t,Ve,e),a(t,nt,e),a(t,Fe,e),c(st,t,e),a(t,Xe,e),a(t,it,e),a(t,Re,e),c(ot,t,e),a(t,xe,e),a(t,rt,e),a(t,Le,e),c(pt,t,e),a(t,Ne,e),c(mt,t,e),a(t,Ee,e),a(t,dt,e),a(t,Ae,e),c(Q,t,e),a(t,He,e),c(V,t,e),a(t,Ye,e),c(ut,t,e),a(t,Pe,e),c(F,t,e),a(t,Se,e),a(t,ft,e),a(t,De,e),a(t,ht,e),a(t,Ke,e),c(ct,t,e),a(t,Oe,e),a(t,gt,e),a(t,tl,e),c(bt,t,e),a(t,el,e),a(t,Mt,e),a(t,ll,e),c(yt,t,e),a(t,al,e),a(t,Tt,e),a(t,nl,e),c(wt,t,e),a(t,sl,e),a(t,$t,e),a(t,il,e),c(Jt,t,e),a(t,ol,e),c(X,t,e),a(t,rl,e),a(t,_t,e),a(t,pl,e),c(vt,t,e),a(t,ml,e),a(t,Ut,e),a(t,dl,e),c(jt,t,e),a(t,ul,e),a(t,Ct,e),a(t,fl,e),c(qt,t,e),a(t,hl,e),c(kt,t,e),a(t,cl,e),a(t,Zt,e),a(t,gl,e),c(Gt,t,e),a(t,bl,e),c(R,t,e),a(t,Ml,e),a(t,It,e),a(t,yl,e),c(zt,t,e),a(t,Tl,e),c(Bt,t,e),a(t,wl,e),a(t,Wt,e),a(t,$l,e),a(t,Qt,e),a(t,Jl,e),c(x,t,e),a(t,_l,e),a(t,Vt,e),a(t,vl,e),c(L,t,e),a(t,Ul,e),c(N,t,e),a(t,jl,e),a(t,Ft,e),a(t,Cl,e),c(Xt,t,e),a(t,ql,e),a(t,Rt,e),a(t,kl,e),c(xt,t,e),a(t,Zl,e),c(Lt,t,e),a(t,Gl,e),c(E,t,e),a(t,Il,e),a(t,Nt,e),a(t,zl,e),c(Et,t,e),a(t,Bl,e),a(t,At,e),a(t,Wl,e),c(Ht,t,e),a(t,Ql,e),a(t,Yt,e),a(t,Vl,e),c(Pt,t,e),a(t,Fl,e),a(t,St,e),a(t,Xl,e),c(Dt,t,e),a(t,Rl,e),c(Kt,t,e),a(t,xl,e),a(t,Ot,e),a(t,Ll,e),a(t,te,e),a(t,Nl,e),c(ee,t,e),a(t,El,e),c(le,t,e),a(t,Al,e),a(t,ae,e),a(t,Hl,e),c(ne,t,e),a(t,Yl,e),c(se,t,e),a(t,Pl,e),a(t,ie,e),a(t,Sl,e),c(oe,t,e),a(t,Dl,e),c(A,t,e),a(t,Kl,e),a(t,re,e),a(t,Ol,e),c(pe,t,e),a(t,ta,e),a(t,me,e),a(t,ea,e),c(de,t,e),a(t,la,e),c(ue,t,e),a(t,aa,e),a(t,fe,e),a(t,na,e),c(he,t,e),a(t,sa,e),a(t,ce,e),a(t,ia,e),c(ge,t,e),a(t,oa,e),a(t,be,e),a(t,ra,e),c(Me,t,e),a(t,pa,e),c(ye,t,e),a(t,ma,e),a(t,Te,e),a(t,da,e),c(we,t,e),a(t,ua,e),a(t,$e,e),a(t,fa,e),a(t,H,e),a(t,ha,e),a(t,Y,e),a(t,ca,e),a(t,Je,e),a(t,ga,e),c(_e,t,e),a(t,ba,e),a(t,ve,e),a(t,Ma,e),a(t,P,e),a(t,ya,e),a(t,Ue,e),a(t,Ta,e),a(t,S,e),a(t,wa,e),a(t,je,e),a(t,$a,e),a(t,Ce,e),a(t,Ja,e),a(t,D,e),a(t,_a,e),a(t,Ze,e),va=!0},p(t,[e]){const Jn={};e&2&&(Jn.$$scope={dirty:e,ctx:t}),k.$set(Jn);const _n={};e&2&&(_n.$$scope={dirty:e,ctx:t}),I.$set(_n);const vn={};e&2&&(vn.$$scope={dirty:e,ctx:t}),Q.$set(vn);const Un={};e&2&&(Un.$$scope={dirty:e,ctx:t}),V.$set(Un);const jn={};e&2&&(jn.$$scope={dirty:e,ctx:t}),F.$set(jn);const Cn={};e&2&&(Cn.$$scope={dirty:e,ctx:t}),X.$set(Cn);const qn={};e&2&&(qn.$$scope={dirty:e,ctx:t}),R.$set(qn);const kn={};e&2&&(kn.$$scope={dirty:e,ctx:t}),x.$set(kn);const Zn={};e&2&&(Zn.$$scope={dirty:e,ctx:t}),L.$set(Zn);const Gn={};e&2&&(Gn.$$scope={dirty:e,ctx:t}),N.$set(Gn);const In={};e&2&&(In.$$scope={dirty:e,ctx:t}),E.$set(In);const zn={};e&2&&(zn.$$scope={dirty:e,ctx:t}),A.$set(zn)},i(t){va||(g(r.$$.fragment,t),g(k.$$.fragment,t),g(G.$$.fragment,t),g(I.$$.fragment,t),g(et.$$.fragment,t),g(at.$$.fragment,t),g(st.$$.fragment,t),g(ot.$$.fragment,t),g(pt.$$.fragment,t),g(mt.$$.fragment,t),g(Q.$$.fragment,t),g(V.$$.fragment,t),g(ut.$$.fragment,t),g(F.$$.fragment,t),g(ct.$$.fragment,t),g(bt.$$.fragment,t),g(yt.$$.fragment,t),g(wt.$$.fragment,t),g(Jt.$$.fragment,t),g(X.$$.fragment,t),g(vt.$$.fragment,t),g(jt.$$.fragment,t),g(qt.$$.fragment,t),g(kt.$$.fragment,t),g(Gt.$$.fragment,t),g(R.$$.fragment,t),g(zt.$$.fragment,t),g(Bt.$$.fragment,t),g(x.$$.fragment,t),g(L.$$.fragment,t),g(N.$$.fragment,t),g(Xt.$$.fragment,t),g(xt.$$.fragment,t),g(Lt.$$.fragment,t),g(E.$$.fragment,t),g(Et.$$.fragment,t),g(Ht.$$.fragment,t),g(Pt.$$.fragment,t),g(Dt.$$.fragment,t),g(Kt.$$.fragment,t),g(ee.$$.fragment,t),g(le.$$.fragment,t),g(ne.$$.fragment,t),g(se.$$.fragment,t),g(oe.$$.fragment,t),g(A.$$.fragment,t),g(pe.$$.fragment,t),g(de.$$.fragment,t),g(ue.$$.fragment,t),g(he.$$.fragment,t),g(ge.$$.fragment,t),g(Me.$$.fragment,t),g(ye.$$.fragment,t),g(we.$$.fragment,t),g(_e.$$.fragment,t),va=!0)},o(t){b(r.$$.fragment,t),b(k.$$.fragment,t),b(G.$$.fragment,t),b(I.$$.fragment,t),b(et.$$.fragment,t),b(at.$$.fragment,t),b(st.$$.fragment,t),b(ot.$$.fragment,t),b(pt.$$.fragment,t),b(mt.$$.fragment,t),b(Q.$$.fragment,t),b(V.$$.fragment,t),b(ut.$$.fragment,t),b(F.$$.fragment,t),b(ct.$$.fragment,t),b(bt.$$.fragment,t),b(yt.$$.fragment,t),b(wt.$$.fragment,t),b(Jt.$$.fragment,t),b(X.$$.fragment,t),b(vt.$$.fragment,t),b(jt.$$.fragment,t),b(qt.$$.fragment,t),b(kt.$$.fragment,t),b(Gt.$$.fragment,t),b(R.$$.fragment,t),b(zt.$$.fragment,t),b(Bt.$$.fragment,t),b(x.$$.fragment,t),b(L.$$.fragment,t),b(N.$$.fragment,t),b(Xt.$$.fragment,t),b(xt.$$.fragment,t),b(Lt.$$.fragment,t),b(E.$$.fragment,t),b(Et.$$.fragment,t),b(Ht.$$.fragment,t),b(Pt.$$.fragment,t),b(Dt.$$.fragment,t),b(Kt.$$.fragment,t),b(ee.$$.fragment,t),b(le.$$.fragment,t),b(ne.$$.fragment,t),b(se.$$.fragment,t),b(oe.$$.fragment,t),b(A.$$.fragment,t),b(pe.$$.fragment,t),b(de.$$.fragment,t),b(ue.$$.fragment,t),b(he.$$.fragment,t),b(ge.$$.fragment,t),b(Me.$$.fragment,t),b(ye.$$.fragment,t),b(we.$$.fragment,t),b(_e.$$.fragment,t),va=!1},d(t){t&&(l(y),l(s),l(d),l(T),l(U),l(w),l(q),l(j),l($),l(J),l(Ge),l(K),l(Ie),l(O),l(ze),l(tt),l(Be),l(We),l(lt),l(Qe),l(Ve),l(nt),l(Fe),l(Xe),l(it),l(Re),l(xe),l(rt),l(Le),l(Ne),l(Ee),l(dt),l(Ae),l(He),l(Ye),l(Pe),l(Se),l(ft),l(De),l(ht),l(Ke),l(Oe),l(gt),l(tl),l(el),l(Mt),l(ll),l(al),l(Tt),l(nl),l(sl),l($t),l(il),l(ol),l(rl),l(_t),l(pl),l(ml),l(Ut),l(dl),l(ul),l(Ct),l(fl),l(hl),l(cl),l(Zt),l(gl),l(bl),l(Ml),l(It),l(yl),l(Tl),l(wl),l(Wt),l($l),l(Qt),l(Jl),l(_l),l(Vt),l(vl),l(Ul),l(jl),l(Ft),l(Cl),l(ql),l(Rt),l(kl),l(Zl),l(Gl),l(Il),l(Nt),l(zl),l(Bl),l(At),l(Wl),l(Ql),l(Yt),l(Vl),l(Fl),l(St),l(Xl),l(Rl),l(xl),l(Ot),l(Ll),l(te),l(Nl),l(El),l(Al),l(ae),l(Hl),l(Yl),l(Pl),l(ie),l(Sl),l(Dl),l(Kl),l(re),l(Ol),l(ta),l(me),l(ea),l(la),l(aa),l(fe),l(na),l(sa),l(ce),l(ia),l(oa),l(be),l(ra),l(pa),l(ma),l(Te),l(da),l(ua),l($e),l(fa),l(H),l(ha),l(Y),l(ca),l(Je),l(ga),l(ba),l(ve),l(Ma),l(P),l(ya),l(Ue),l(Ta),l(S),l(wa),l(je),l($a),l(Ce),l(Ja),l(D),l(_a),l(Ze)),l(n),M(r,t),M(k,t),M(G,t),M(I,t),M(et,t),M(at,t),M(st,t),M(ot,t),M(pt,t),M(mt,t),M(Q,t),M(V,t),M(ut,t),M(F,t),M(ct,t),M(bt,t),M(yt,t),M(wt,t),M(Jt,t),M(X,t),M(vt,t),M(jt,t),M(qt,t),M(kt,t),M(Gt,t),M(R,t),M(zt,t),M(Bt,t),M(x,t),M(L,t),M(N,t),M(Xt,t),M(xt,t),M(Lt,t),M(E,t),M(Et,t),M(Ht,t),M(Pt,t),M(Dt,t),M(Kt,t),M(ee,t),M(le,t),M(ne,t),M(se,t),M(oe,t),M(A,t),M(pe,t),M(de,t),M(ue,t),M(he,t),M(ge,t),M(Me,t),M(ye,t),M(we,t),M(_e,t)}}}const os='{"title":"Quantization","local":"quantization","sections":[{"title":"AWQ","local":"awq","sections":[{"title":"Fused modules","local":"fused-modules","sections":[],"depth":3}],"depth":2},{"title":"AutoGPTQ","local":"autogptq","sections":[{"title":"ExLlama","local":"exllama","sections":[],"depth":3}],"depth":2},{"title":"bitsandbytes","local":"bitsandbytes","sections":[{"title":"8-bit","local":"8-bit","sections":[{"title":"Offloading","local":"offloading","sections":[],"depth":4},{"title":"Outlier threshold","local":"outlier-threshold","sections":[],"depth":4},{"title":"Skip module conversion","local":"skip-module-conversion","sections":[],"depth":4},{"title":"Finetuning","local":"finetuning","sections":[],"depth":4}],"depth":3},{"title":"4-bit","local":"4-bit","sections":[{"title":"Compute data type","local":"compute-data-type","sections":[],"depth":4},{"title":"Normal Float 4 (NF4)","local":"normal-float-4-nf4","sections":[],"depth":4},{"title":"Nested quantization","local":"nested-quantization","sections":[],"depth":4}],"depth":3}],"depth":2},{"title":"Optimum","local":"optimum","sections":[],"depth":2},{"title":"Benchmarks","local":"benchmarks","sections":[{"title":"Fused AWQ modules","local":"fused-awq-modules","sections":[],"depth":3}],"depth":2}],"depth":1}';function rs(_){return Qn(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class cs extends Vn{constructor(n){super(),Fn(this,n,rs,is,Wn,{})}}export{cs as component};
