import{s as fi,o as hi,n as Q}from"../chunks/scheduler.9bc65507.js";import{S as ci,i as gi,g as r,s,r as d,A as bi,h as p,f as l,c as i,j as di,u as f,x as m,k as et,y as yi,a,v as h,d as c,t as g,w as b}from"../chunks/index.707bf1b6.js";import{T as W}from"../chunks/Tip.c2ecdbf4.js";import{C as U}from"../chunks/CodeBlock.54a9f38d.js";import{H as G,E as Mi}from"../chunks/EditOnGithub.922df6ba.js";import{H as Bn,a as rl}from"../chunks/HfOption.6d864328.js";function Ti($){let n,M='Interested in adding a new quantization method to Transformers? Read the <a href="./hf_quantizer">HfQuantizer</a> guide to learn how!';return{c(){n=r("p"),n.innerHTML=M},l(o){n=p(o,"P",{"data-svelte-h":!0}),m(n)!=="svelte-px0yfi"&&(n.innerHTML=M)},m(o,y){a(o,n,y)},p:Q,d(o){o&&l(n)}}}function wi($){let n,M='Try Quanto + transformers with this <a href="https://colab.research.google.com/drive/16CXfVmtdQvciSh9BopZUDYcmXCDpvgrT?usp=sharing" rel="nofollow">notebook</a>!';return{c(){n=r("p"),n.innerHTML=M},l(o){n=p(o,"P",{"data-svelte-h":!0}),m(n)!=="svelte-1m6vmvl"&&(n.innerHTML=M)},m(o,y){a(o,n,y)},p:Q,d(o){o&&l(n)}}}function $i($){let n,M='Try AWQ quantization with this <a href="https://colab.research.google.com/drive/1HzZH89yAXJaZgwJDhQj9LqSBux932BvY" rel="nofollow">notebook</a>!';return{c(){n=r("p"),n.innerHTML=M},l(o){n=p(o,"P",{"data-svelte-h":!0}),m(n)!=="svelte-1yzcfmc"&&(n.innerHTML=M)},m(o,y){a(o,n,y)},p:Q,d(o){o&&l(n)}}}function Ji($){let n,M="Fused modules cannot be combined with other optimization techniques such as FlashAttention-2.";return{c(){n=r("p"),n.textContent=M},l(o){n=p(o,"P",{"data-svelte-h":!0}),m(n)!=="svelte-hwgpn3"&&(n.textContent=M)},m(o,y){a(o,n,y)},p:Q,d(o){o&&l(n)}}}function vi($){let n,M='To enable fused modules for supported architectures, create an <a href="/docs/transformers/v4.40.2/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.',o,y,u='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,_,j;return _=new U({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=r("p"),n.innerHTML=M,o=s(),y=r("p"),y.innerHTML=u,T=s(),d(_.$$.fragment)},l(w){n=p(w,"P",{"data-svelte-h":!0}),m(n)!=="svelte-15ibmiv"&&(n.innerHTML=M),o=i(w),y=p(w,"P",{"data-svelte-h":!0}),m(y)!=="svelte-1zxz2i"&&(y.innerHTML=u),T=i(w),f(_.$$.fragment,w)},m(w,q){a(w,n,q),a(w,o,q),a(w,y,q),a(w,T,q),h(_,w,q),j=!0},p:Q,i(w){j||(c(_.$$.fragment,w),j=!0)},o(w){g(_.$$.fragment,w),j=!1},d(w){w&&(l(n),l(o),l(y),l(T)),b(_,w)}}}function Ui($){let n,M='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.',o,y,u,T,_="The parameter <code>modules_to_fuse</code> should include:",j,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 y=new U({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=r("p"),n.innerHTML=M,o=s(),d(y.$$.fragment),u=s(),T=r("p"),T.innerHTML=_,j=s(),w=r("ul"),w.innerHTML=q},l(C){n=p(C,"P",{"data-svelte-h":!0}),m(n)!=="svelte-ecilwg"&&(n.innerHTML=M),o=i(C),f(y.$$.fragment,C),u=i(C),T=p(C,"P",{"data-svelte-h":!0}),m(T)!=="svelte-1divolh"&&(T.innerHTML=_),j=i(C),w=p(C,"UL",{"data-svelte-h":!0}),m(w)!=="svelte-ln3msn"&&(w.innerHTML=q)},m(C,k){a(C,n,k),a(C,o,k),h(y,C,k),a(C,u,k),a(C,T,k),a(C,j,k),a(C,w,k),Z=!0},p:Q,i(C){Z||(c(y.$$.fragment,C),Z=!0)},o(C){g(y.$$.fragment,C),Z=!1},d(C){C&&(l(n),l(o),l(u),l(T),l(j),l(w)),b(y,C)}}}function _i($){let n,M,o,y;return n=new rl({props:{id:"fuse",option:"supported architectures",$$slots:{default:[vi]},$$scope:{ctx:$}}}),o=new rl({props:{id:"fuse",option:"unsupported architectures",$$slots:{default:[Ui]},$$scope:{ctx:$}}}),{c(){d(n.$$.fragment),M=s(),d(o.$$.fragment)},l(u){f(n.$$.fragment,u),M=i(u),f(o.$$.fragment,u)},m(u,T){h(n,u,T),a(u,M,T),h(o,u,T),y=!0},p(u,T){const _={};T&2&&(_.$$scope={dirty:T,ctx:u}),n.$set(_);const j={};T&2&&(j.$$scope={dirty:T,ctx:u}),o.$set(j)},i(u){y||(c(n.$$.fragment,u),c(o.$$.fragment,u),y=!0)},o(u){g(n.$$.fragment,u),g(o.$$.fragment,u),y=!1},d(u){u&&l(M),b(n,u),b(o,u)}}}function Ci($){let n,M="Note this feature is supported on AMD GPUs.";return{c(){n=r("p"),n.textContent=M},l(o){n=p(o,"P",{"data-svelte-h":!0}),m(n)!=="svelte-147si7w"&&(n.textContent=M)},m(o,y){a(o,n,y)},p:Q,d(o){o&&l(n)}}}function ji($){let n,M='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=r("p"),n.innerHTML=M},l(o){n=p(o,"P",{"data-svelte-h":!0}),m(n)!=="svelte-1tfpiad"&&(n.innerHTML=M)},m(o,y){a(o,n,y)},p:Q,d(o){o&&l(n)}}}function qi($){let n,M='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="https://huggingface.co/facebook/opt-350m" rel="nofollow">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=r("p"),n.innerHTML=M},l(o){n=p(o,"P",{"data-svelte-h":!0}),m(n)!=="svelte-jdzahk"&&(n.innerHTML=M)},m(o,y){a(o,n,y)},p:Q,d(o){o&&l(n)}}}function ki($){let n,M="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=r("p"),n.textContent=M},l(o){n=p(o,"P",{"data-svelte-h":!0}),m(n)!=="svelte-14ppi1y"&&(n.textContent=M)},m(o,y){a(o,n,y)},p:Q,d(o){o&&l(n)}}}function Zi($){let n,M;return n=new U({props:{code:"cGlwJTIwaW5zdGFsbCUyMHRyYW5zZm9ybWVycyUyMGFjY2VsZXJhdGUlMjBiaXRzYW5kYnl0ZXMlM0UwLjM3LjA=",highlighted:"pip install transformers accelerate bitsandbytes&gt;0.37.0",wrap:!1}}),{c(){d(n.$$.fragment)},l(o){f(n.$$.fragment,o)},m(o,y){h(n,o,y),M=!0},p:Q,i(o){M||(c(n.$$.fragment,o),M=!0)},o(o){g(n.$$.fragment,o),M=!1},d(o){b(n,o)}}}function Gi($){let n,M;return n=new U({props:{code:"cGlwJTIwaW5zdGFsbCUyMGJpdHNhbmRieXRlcyUzRSUzRDAuMzkuMCUwQXBpcCUyMGluc3RhbGwlMjAtLXVwZ3JhZGUlMjBhY2NlbGVyYXRlJTBBcGlwJTIwaW5zdGFsbCUyMC0tdXBncmFkZSUyMHRyYW5zZm9ybWVycw==",highlighted:`pip install bitsandbytes&gt;=0.39.0
pip install --upgrade accelerate
pip install --upgrade transformers`,wrap:!1}}),{c(){d(n.$$.fragment)},l(o){f(n.$$.fragment,o)},m(o,y){h(n,o,y),M=!0},p:Q,i(o){M||(c(n.$$.fragment,o),M=!0)},o(o){g(n.$$.fragment,o),M=!1},d(o){b(n,o)}}}function zi($){let n,M,o,y;return n=new rl({props:{id:"bnb",option:"8-bit",$$slots:{default:[Zi]},$$scope:{ctx:$}}}),o=new rl({props:{id:"bnb",option:"4-bit",$$slots:{default:[Gi]},$$scope:{ctx:$}}}),{c(){d(n.$$.fragment),M=s(),d(o.$$.fragment)},l(u){f(n.$$.fragment,u),M=i(u),f(o.$$.fragment,u)},m(u,T){h(n,u,T),a(u,M,T),h(o,u,T),y=!0},p(u,T){const _={};T&2&&(_.$$scope={dirty:T,ctx:u}),n.$set(_);const j={};T&2&&(j.$$scope={dirty:T,ctx:u}),o.$set(j)},i(u){y||(c(n.$$.fragment,u),c(o.$$.fragment,u),y=!0)},o(u){g(n.$$.fragment,u),g(o.$$.fragment,u),y=!1},d(u){u&&l(M),b(n,u),b(o,u)}}}function Ii($){let n,M="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:",o,y,u,T,_="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:",j,w,q,Z,C='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/v4.40.2/en/main_classes/model#transformers.utils.PushToHubMixin.push_to_hub">push_to_hub()</a> method. The quantization config.json file is pushed first, followed by the quantized model weights.',k,J,z;return y=new U({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 U({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}}),J=new U({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=r("p"),n.innerHTML=M,o=s(),d(y.$$.fragment),u=s(),T=r("p"),T.innerHTML=_,j=s(),d(w.$$.fragment),q=s(),Z=r("p"),Z.innerHTML=C,k=s(),d(J.$$.fragment)},l(v){n=p(v,"P",{"data-svelte-h":!0}),m(n)!=="svelte-1dz8xeq"&&(n.innerHTML=M),o=i(v),f(y.$$.fragment,v),u=i(v),T=p(v,"P",{"data-svelte-h":!0}),m(T)!=="svelte-kfzkum"&&(T.innerHTML=_),j=i(v),f(w.$$.fragment,v),q=i(v),Z=p(v,"P",{"data-svelte-h":!0}),m(Z)!=="svelte-iathwo"&&(Z.innerHTML=C),k=i(v),f(J.$$.fragment,v)},m(v,I){a(v,n,I),a(v,o,I),h(y,v,I),a(v,u,I),a(v,T,I),a(v,j,I),h(w,v,I),a(v,q,I),a(v,Z,I),a(v,k,I),h(J,v,I),z=!0},p:Q,i(v){z||(c(y.$$.fragment,v),c(w.$$.fragment,v),c(J.$$.fragment,v),z=!0)},o(v){g(y.$$.fragment,v),g(w.$$.fragment,v),g(J.$$.fragment,v),z=!1},d(v){v&&(l(n),l(o),l(u),l(T),l(j),l(q),l(Z),l(k)),b(y,v),b(w,v),b(J,v)}}}function Qi($){let n,M="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:",o,y,u,T,_="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:",j,w,q,Z,C="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 y=new U({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 U({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=r("p"),n.innerHTML=M,o=s(),d(y.$$.fragment),u=s(),T=r("p"),T.innerHTML=_,j=s(),d(w.$$.fragment),q=s(),Z=r("p"),Z.innerHTML=C},l(J){n=p(J,"P",{"data-svelte-h":!0}),m(n)!=="svelte-1b6jp1p"&&(n.innerHTML=M),o=i(J),f(y.$$.fragment,J),u=i(J),T=p(J,"P",{"data-svelte-h":!0}),m(T)!=="svelte-kfzkum"&&(T.innerHTML=_),j=i(J),f(w.$$.fragment,J),q=i(J),Z=p(J,"P",{"data-svelte-h":!0}),m(Z)!=="svelte-1pmx2wb"&&(Z.innerHTML=C)},m(J,z){a(J,n,z),a(J,o,z),h(y,J,z),a(J,u,z),a(J,T,z),a(J,j,z),h(w,J,z),a(J,q,z),a(J,Z,z),k=!0},p:Q,i(J){k||(c(y.$$.fragment,J),c(w.$$.fragment,J),k=!0)},o(J){g(y.$$.fragment,J),g(w.$$.fragment,J),k=!1},d(J){J&&(l(n),l(o),l(u),l(T),l(j),l(q),l(Z)),b(y,J),b(w,J)}}}function Wi($){let n,M,o,y;return n=new rl({props:{id:"bnb",option:"8-bit",$$slots:{default:[Ii]},$$scope:{ctx:$}}}),o=new rl({props:{id:"bnb",option:"4-bit",$$slots:{default:[Qi]},$$scope:{ctx:$}}}),{c(){d(n.$$.fragment),M=s(),d(o.$$.fragment)},l(u){f(n.$$.fragment,u),M=i(u),f(o.$$.fragment,u)},m(u,T){h(n,u,T),a(u,M,T),h(o,u,T),y=!0},p(u,T){const _={};T&2&&(_.$$scope={dirty:T,ctx:u}),n.$set(_);const j={};T&2&&(j.$$scope={dirty:T,ctx:u}),o.$set(j)},i(u){y||(c(n.$$.fragment,u),c(o.$$.fragment,u),y=!0)},o(u){g(n.$$.fragment,u),g(o.$$.fragment,u),y=!1},d(u){u&&l(M),b(n,u),b(o,u)}}}function Bi($){let n,M="Training with 8-bit and 4-bit weights are only supported for training <em>extra</em> parameters.";return{c(){n=r("p"),n.innerHTML=M},l(o){n=p(o,"P",{"data-svelte-h":!0}),m(n)!=="svelte-of9sym"&&(n.innerHTML=M)},m(o,y){a(o,n,y)},p:Q,d(o){o&&l(n)}}}function Vi($){let n,M='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=r("p"),n.innerHTML=M},l(o){n=p(o,"P",{"data-svelte-h":!0}),m(n)!=="svelte-1bb05fp"&&(n.innerHTML=M)},m(o,y){a(o,n,y)},p:Q,d(o){o&&l(n)}}}function Xi($){let n,M='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=r("p"),n.innerHTML=M},l(o){n=p(o,"P",{"data-svelte-h":!0}),m(n)!=="svelte-rme94c"&&(n.innerHTML=M)},m(o,y){a(o,n,y)},p:Q,d(o){o&&l(n)}}}function Fi($){let n,M,o,y,u,T,_,j="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.",C,k,J,z,v,I,ml,lt,Vn='<a href="https://github.com/huggingface/quanto" rel="nofollow">🤗 Quanto</a> library is a versatile pytorch quantization toolkit. The quantization method used is the linear quantization. Quanto provides several unique features such as:',ul,at,Xn="<li>weights quantization (<code>float8</code>,<code>int8</code>,<code>int4</code>,<code>int2</code>)</li> <li>activation quantization (<code>float8</code>,<code>int8</code>)</li> <li>modality agnostic (e.g CV,LLM)</li> <li>device agnostic (e.g CUDA,MPS,CPU)</li> <li>compatibility with <code>torch.compile</code></li> <li>easy to add custom kernel for specific device</li> <li>supports quantization aware training</li>",dl,nt,Fn="Before you begin, make sure the following libraries are installed:",fl,st,hl,it,Rn='Now you can quantize a model by passing <a href="/docs/transformers/v4.40.2/en/main_classes/quantization#transformers.QuantoConfig">QuantoConfig</a> object in the <a href="/docs/transformers/v4.40.2/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a> method. This works for any model in any modality, as long as it contains <code>torch.nn.Linear</code> layers.',cl,ot,xn='The integration with transformers only supports weights quantization. For the more complex use case such as activation quantization, calibration and quantization aware training, you should use <a href="https://github.com/huggingface/quanto" rel="nofollow">quanto</a> library instead.',gl,rt,bl,pt,Ln="Note that serialization is not supported yet with transformers but it is coming soon! If you want to save the model, you can use quanto library instead.",yl,mt,Nn='Quanto library uses linear quantization algorithm for quantization. Even though this is a basic quantization technique, we get very good results! Have a look at the following becnhmark (llama-2-7b on perplexity metric). You can find more benchamarks <a href="https://github.com/huggingface/quanto/tree/main/bench/generation" rel="nofollow">here</a>',Ml,B,Hn='<div><img class="rounded-xl" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/quantization/NousResearch-Llama-2-7b-hf_Perplexity.png" alt="llama-2-7b-quanto-perplexity"/></div>',Tl,ut,An="The library is versatible enough to be compatible with most PTQ optimization algorithms. The plan in the future is to integrate the most popular algorithms in the most seamless possible way (AWQ, Smoothquant).",wl,dt,$l,ft,En='Try AQLM on <a href="https://colab.research.google.com/drive/1-xZmBRXT5Fm3Ghn4Mwa2KRypORXb855X?usp=sharing" rel="nofollow">Google Colab</a>!',Jl,ht,Yn='Additive Quantization of Language Models (<a href="https://arxiv.org/abs/2401.06118" rel="nofollow">AQLM</a>) is a Large Language Models compression method. It quantizes multiple weights together and take advantage of interdependencies between them. AQLM represents groups of 8-16 weights as a sum of multiple vector codes.',vl,ct,Pn="Inference support for AQLM is realised in the <code>aqlm</code> library. Make sure to install it to run the models (note aqlm works only with python&gt;=3.10):",Ul,gt,_l,bt,Sn="The library provides efficient kernels for both GPU and CPU inference and training.",Cl,yt,Dn='The instructions on how to quantize models yourself, as well as all the relevant code can be found in the corresponding GitHub <a href="https://github.com/Vahe1994/AQLM" rel="nofollow">repository</a>.',jl,Mt,ql,Tt,Kn='Starting with version <code>aqlm 1.0.2</code>, AQLM supports Parameter-Efficient Fine-Tuning in a form of <a href="https://huggingface.co/docs/peft/package_reference/lora" rel="nofollow">LoRA</a> integrated into the <a href="https://huggingface.co/blog/peft" rel="nofollow">PEFT</a> library.',kl,wt,Zl,$t,On="AQLM quantization setups vary mainly on the number of codebooks used as well as codebook sizes in bits. The most popular setups, as well as inference kernels they support are:",Gl,Jt,ts="<thead><tr><th>Kernel</th> <th>Number of codebooks</th> <th>Codebook size, bits</th> <th>Notation</th> <th>Accuracy</th> <th>Speedup</th> <th>Fast GPU inference</th> <th>Fast CPU inference</th></tr></thead> <tbody><tr><td>Triton</td> <td>K</td> <td>N</td> <td>KxN</td> <td>-</td> <td>Up to ~0.7x</td> <td>✅</td> <td>❌</td></tr> <tr><td>CUDA</td> <td>1</td> <td>16</td> <td>1x16</td> <td>Best</td> <td>Up to ~1.3x</td> <td>✅</td> <td>❌</td></tr> <tr><td>CUDA</td> <td>2</td> <td>8</td> <td>2x8</td> <td>OK</td> <td>Up to ~3.0x</td> <td>✅</td> <td>❌</td></tr> <tr><td>Numba</td> <td>K</td> <td>8</td> <td>Kx8</td> <td>Good</td> <td>Up to ~4.0x</td> <td>❌</td> <td>✅</td></tr></tbody>",zl,vt,Il,V,Ql,Ut,es='<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.',Wl,_t,ls='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.',Bl,Ct,as="Make sure you have autoawq installed:",Vl,jt,Xl,qt,ns='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:',Fl,kt,Rl,Zt,ss='A quantized model is loaded with the <a href="/docs/transformers/v4.40.2/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:',xl,Gt,Ll,zt,is="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:",Nl,It,Hl,Qt,os='AWQ quantization can also be combined with <a href="perf_infer_gpu_one#flashattention-2">FlashAttention-2</a> to further accelerate inference:',Al,Wt,El,Bt,Yl,Vt,rs='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.',Pl,X,Sl,F,Dl,Xt,Kl,Ft,ps="Recent versions of <code>autoawq</code> supports exllama-v2 kernels for faster prefill and decoding. To get started, first install the latest version of <code>autoawq</code> by running:",Ol,Rt,ta,xt,ms="Get started by passing an <code>AwqConfig()</code> with <code>version=&quot;exllama&quot;</code>.",ea,Lt,la,R,aa,Nt,na,x,sa,Ht,us='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.',ia,At,ds="Before you begin, make sure the following libraries are installed:",oa,Et,ra,Yt,fs='To quantize a model (currently only supported for text models), you need to create a <a href="/docs/transformers/v4.40.2/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.',pa,Pt,ma,St,hs="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.",ua,Dt,da,Kt,cs='Load a model to quantize and pass the <code>gptq_config</code> to the <a href="/docs/transformers/v4.40.2/en/model_doc/auto#transformers.AutoModel.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.',fa,Ot,ha,te,gs="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):",ca,ee,ga,L,ba,le,bs='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/v4.40.2/en/main_classes/model#transformers.utils.PushToHubMixin.push_to_hub">push_to_hub()</a> method to save the <a href="/docs/transformers/v4.40.2/en/main_classes/quantization#transformers.GPTQConfig">GPTQConfig</a>:',ya,ae,Ma,ne,ys='You could also save your quantized model locally with the <a href="/docs/transformers/v4.40.2/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:',Ta,se,wa,ie,Ms='Reload a quantized model with the <a href="/docs/transformers/v4.40.2/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.',$a,oe,Ja,re,va,pe,Ts='<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/v4.40.2/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:',Ua,me,_a,N,Ca,ue,ws="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.",ja,de,qa,fe,ka,he,$s='<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.',Za,ce,Js="To use bitsandbytes, make sure you have the following libraries installed:",Ga,H,za,ge,vs='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/v4.40.2/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.',Ia,A,Qa,E,Wa,be,Us="You can check your memory footprint with the <code>get_memory_footprint</code> method:",Ba,ye,Va,Me,_s='Quantized models can be loaded from the <a href="/docs/transformers/v4.40.2/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:',Xa,Te,Fa,we,Ra,Y,xa,$e,Cs="This section explores some of the specific features of 8-bit models, such as offloading, outlier thresholds, skipping module conversion, and finetuning.",La,Je,Na,ve,js='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/v4.40.2/en/main_classes/quantization#transformers.BitsAndBytesConfig">BitsAndBytesConfig</a>:',Ha,Ue,Aa,_e,qs="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:",Ea,Ce,Ya,je,ks="Now load your model with the custom <code>device_map</code> and <code>quantization_config</code>:",Pa,qe,Sa,ke,Da,Ze,Zs="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).",Ka,Ge,Gs='To find the best threshold for your model, we recommend experimenting with the <code>llm_int8_threshold</code> parameter in <a href="/docs/transformers/v4.40.2/en/main_classes/quantization#transformers.BitsAndBytesConfig">BitsAndBytesConfig</a>:',Oa,ze,tn,Ie,en,Qe,zs='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/v4.40.2/en/main_classes/quantization#transformers.BitsAndBytesConfig">BitsAndBytesConfig</a>:',ln,We,an,Be,nn,Ve,Is='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).',sn,Xe,on,P,rn,Fe,Qs="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.",pn,Re,mn,xe,Ws='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/v4.40.2/en/main_classes/quantization#transformers.BitsAndBytesConfig">BitsAndBytesConfig</a>:',un,Le,dn,Ne,fn,He,Bs='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/v4.40.2/en/main_classes/quantization#transformers.BitsAndBytesConfig">BitsAndBytesConfig</a>:',hn,Ae,cn,Ee,Vs="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.",gn,Ye,bn,Pe,Xs='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.',yn,Se,Mn,De,Tn,Ke,Fs='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.',wn,Oe,$n,tl,Rs='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.',Jn,S,xs='<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>',vn,D,Ls='<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>',Un,el,Ns='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.',_n,ll,Cn,al,Hs='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.',jn,K,As="Unfused module",qn,nl,Es='<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>',kn,O,Ys="Fused module",Zn,sl,Ps='<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>',Gn,il,Ss='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.',zn,tt,Ds='<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>',In,ol,Qn,pl,Wn;return u=new G({props:{title:"Quantization",local:"quantization",headingTag:"h1"}}),k=new W({props:{$$slots:{default:[Ti]},$$scope:{ctx:$}}}),z=new G({props:{title:"Quanto",local:"quanto",headingTag:"h2"}}),I=new W({props:{$$slots:{default:[wi]},$$scope:{ctx:$}}}),st=new U({props:{code:"cGlwJTIwaW5zdGFsbCUyMHF1YW50byUwQXBpcCUyMGluc3RhbGwlMjBnaXQlMkJodHRwcyUzQSUyRiUyRmdpdGh1Yi5jb20lMkZodWdnaW5nZmFjZSUyRmFjY2VsZXJhdGUuZ2l0JTBBcGlwJTIwaW5zdGFsbCUyMGdpdCUyQmh0dHBzJTNBJTJGJTJGZ2l0aHViLmNvbSUyRmh1Z2dpbmdmYWNlJTJGdHJhbnNmb3JtZXJzLmdpdA==",highlighted:`pip install quanto
pip install git+https://github.com/huggingface/accelerate.git
pip install git+https://github.com/huggingface/transformers.git`,wrap:!1}}),rt=new U({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvckNhdXNhbExNJTJDJTIwQXV0b1Rva2VuaXplciUyQyUyMFF1YW50b0NvbmZpZyUwQSUwQW1vZGVsX2lkJTIwJTNEJTIwJTIyZmFjZWJvb2slMkZvcHQtMTI1bSUyMiUwQXRva2VuaXplciUyMCUzRCUyMEF1dG9Ub2tlbml6ZXIuZnJvbV9wcmV0cmFpbmVkKG1vZGVsX2lkKSUwQXF1YW50aXphdGlvbl9jb25maWclMjAlM0QlMjBRdWFudG9Db25maWcod2VpZ2h0cyUzRCUyMmludDglMjIpJTBBcXVhbnRpemVkX21vZGVsJTIwJTNEJTIwQXV0b01vZGVsRm9yQ2F1c2FsTE0uZnJvbV9wcmV0cmFpbmVkKG1vZGVsX2lkJTJDJTIwZGV2aWNlX21hcCUzRCUyMmN1ZGElM0EwJTIyJTJDJTIwcXVhbnRpemF0aW9uX2NvbmZpZyUzRHF1YW50aXphdGlvbl9jb25maWcp",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForCausalLM, AutoTokenizer, QuantoConfig

model_id = <span class="hljs-string">&quot;facebook/opt-125m&quot;</span>
tokenizer = AutoTokenizer.from_pretrained(model_id)
quantization_config = QuantoConfig(weights=<span class="hljs-string">&quot;int8&quot;</span>)
quantized_model = AutoModelForCausalLM.from_pretrained(model_id, device_map=<span class="hljs-string">&quot;cuda:0&quot;</span>, quantization_config=quantization_config)`,wrap:!1}}),dt=new G({props:{title:"AQLM",local:"aqlm",headingTag:"h2"}}),gt=new U({props:{code:"cGlwJTIwaW5zdGFsbCUyMGFxbG0lNUJncHUlMkNjcHUlNUQ=",highlighted:"pip install aqlm[gpu,cpu]",wrap:!1}}),Mt=new G({props:{title:"PEFT",local:"peft",headingTag:"h3"}}),wt=new G({props:{title:"AQLM configurations",local:"aqlm-configurations",headingTag:"h3"}}),vt=new G({props:{title:"AWQ",local:"awq",headingTag:"h2"}}),V=new W({props:{$$slots:{default:[$i]},$$scope:{ctx:$}}}),jt=new U({props:{code:"cGlwJTIwaW5zdGFsbCUyMGF1dG9hd3E=",highlighted:"pip install autoawq",wrap:!1}}),kt=new U({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}}),Gt=new U({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}}),It=new U({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}}),Wt=new U({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}}),Bt=new G({props:{title:"Fused modules",local:"fused-modules",headingTag:"h3"}}),X=new W({props:{warning:!0,$$slots:{default:[Ji]},$$scope:{ctx:$}}}),F=new Bn({props:{id:"fuse",options:["supported architectures","unsupported architectures"],$$slots:{default:[_i]},$$scope:{ctx:$}}}),Xt=new G({props:{title:"Exllama-v2 support",local:"exllama-v2-support",headingTag:"h3"}}),Rt=new U({props:{code:"cGlwJTIwaW5zdGFsbCUyMGdpdCUyQmh0dHBzJTNBJTJGJTJGZ2l0aHViLmNvbSUyRmNhc3Blci1oYW5zZW4lMkZBdXRvQVdRLmdpdA==",highlighted:"pip install git+https://github.com/casper-hansen/AutoAWQ.git",wrap:!1}}),Lt=new U({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQXV0b01vZGVsRm9yQ2F1c2FsTE0lMkMlMjBBdXRvVG9rZW5pemVyJTJDJTIwQXdxQ29uZmlnJTBBJTBBcXVhbnRpemF0aW9uX2NvbmZpZyUyMCUzRCUyMEF3cUNvbmZpZyh2ZXJzaW9uJTNEJTIyZXhsbGFtYSUyMiklMEElMEFtb2RlbCUyMCUzRCUyMEF1dG9Nb2RlbEZvckNhdXNhbExNLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJUaGVCbG9rZSUyRk1pc3RyYWwtN0ItSW5zdHJ1Y3QtdjAuMS1BV1ElMjIlMkMlMEElMjAlMjAlMjAlMjBxdWFudGl6YXRpb25fY29uZmlnJTNEcXVhbnRpemF0aW9uX2NvbmZpZyUyQyUwQSUyMCUyMCUyMCUyMGRldmljZV9tYXAlM0QlMjJhdXRvJTIyJTJDJTBBKSUwQSUwQWlucHV0X2lkcyUyMCUzRCUyMHRvcmNoLnJhbmRpbnQoMCUyQyUyMDEwMCUyQyUyMCgxJTJDJTIwMTI4KSUyQyUyMGR0eXBlJTNEdG9yY2gubG9uZyUyQyUyMGRldmljZSUzRCUyMmN1ZGElMjIpJTBBb3V0cHV0JTIwJTNEJTIwbW9kZWwoaW5wdXRfaWRzKSUwQXByaW50KG91dHB1dC5sb2dpdHMpJTBBJTBBdG9rZW5pemVyJTIwJTNEJTIwQXV0b1Rva2VuaXplci5mcm9tX3ByZXRyYWluZWQoJTIyVGhlQmxva2UlMkZNaXN0cmFsLTdCLUluc3RydWN0LXYwLjEtQVdRJTIyKSUwQWlucHV0X2lkcyUyMCUzRCUyMHRva2VuaXplci5lbmNvZGUoJTIySG93JTIwdG8lMjBtYWtlJTIwYSUyMGNha2UlMjIlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKS50byhtb2RlbC5kZXZpY2UpJTBBb3V0cHV0JTIwJTNEJTIwbW9kZWwuZ2VuZXJhdGUoaW5wdXRfaWRzJTJDJTIwZG9fc2FtcGxlJTNEVHJ1ZSUyQyUyMG1heF9sZW5ndGglM0Q1MCUyQyUyMHBhZF90b2tlbl9pZCUzRDUwMjU2KSUwQXByaW50KHRva2VuaXplci5kZWNvZGUob3V0cHV0JTVCMCU1RCUyQyUyMHNraXBfc3BlY2lhbF90b2tlbnMlM0RUcnVlKSk=",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForCausalLM, AutoTokenizer, AwqConfig

quantization_config = AwqConfig(version=<span class="hljs-string">&quot;exllama&quot;</span>)

model = AutoModelForCausalLM.from_pretrained(
    <span class="hljs-string">&quot;TheBloke/Mistral-7B-Instruct-v0.1-AWQ&quot;</span>,
    quantization_config=quantization_config,
    device_map=<span class="hljs-string">&quot;auto&quot;</span>,
)

input_ids = torch.randint(<span class="hljs-number">0</span>, <span class="hljs-number">100</span>, (<span class="hljs-number">1</span>, <span class="hljs-number">128</span>), dtype=torch.long, device=<span class="hljs-string">&quot;cuda&quot;</span>)
output = model(input_ids)
<span class="hljs-built_in">print</span>(output.logits)

tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;TheBloke/Mistral-7B-Instruct-v0.1-AWQ&quot;</span>)
input_ids = tokenizer.encode(<span class="hljs-string">&quot;How to make a cake&quot;</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>).to(model.device)
output = model.generate(input_ids, do_sample=<span class="hljs-literal">True</span>, max_length=<span class="hljs-number">50</span>, pad_token_id=<span class="hljs-number">50256</span>)
<span class="hljs-built_in">print</span>(tokenizer.decode(output[<span class="hljs-number">0</span>], skip_special_tokens=<span class="hljs-literal">True</span>))`,wrap:!1}}),R=new W({props:{warning:!0,$$slots:{default:[Ci]},$$scope:{ctx:$}}}),Nt=new G({props:{title:"AutoGPTQ",local:"autogptq",headingTag:"h2"}}),x=new W({props:{$$slots:{default:[ji]},$$scope:{ctx:$}}}),Et=new U({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}}),Pt=new U({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}}),Dt=new U({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}}),Ot=new U({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}}),ee=new U({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}}),L=new W({props:{warning:!0,$$slots:{default:[qi]},$$scope:{ctx:$}}}),ae=new U({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}}),se=new U({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}}),oe=new U({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}}),re=new G({props:{title:"ExLlama",local:"exllama",headingTag:"h3"}}),me=new U({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}}),N=new W({props:{warning:!0,$$slots:{default:[ki]},$$scope:{ctx:$}}}),de=new U({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}}),fe=new G({props:{title:"bitsandbytes",local:"bitsandbytes",headingTag:"h2"}}),H=new Bn({props:{id:"bnb",options:["8-bit","4-bit"],$$slots:{default:[zi]},$$scope:{ctx:$}}}),A=new Bn({props:{id:"bnb",options:["8-bit","4-bit"],$$slots:{default:[Wi]},$$scope:{ctx:$}}}),E=new W({props:{warning:!0,$$slots:{default:[Bi]},$$scope:{ctx:$}}}),ye=new U({props:{code:"cHJpbnQobW9kZWwuZ2V0X21lbW9yeV9mb290cHJpbnQoKSk=",highlighted:'<span class="hljs-built_in">print</span>(model.get_memory_footprint())',wrap:!1}}),Te=new U({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}}),we=new G({props:{title:"8-bit",local:"8-bit",headingTag:"h3"}}),Y=new W({props:{$$slots:{default:[Vi]},$$scope:{ctx:$}}}),Je=new G({props:{title:"Offloading",local:"offloading",headingTag:"h4"}}),Ue=new U({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}}),Ce=new U({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}}),qe=new U({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}}),ke=new G({props:{title:"Outlier threshold",local:"outlier-threshold",headingTag:"h4"}}),ze=new U({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}}),Ie=new G({props:{title:"Skip module conversion",local:"skip-module-conversion",headingTag:"h4"}}),We=new U({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}}),Be=new G({props:{title:"Finetuning",local:"finetuning",headingTag:"h4"}}),Xe=new G({props:{title:"4-bit",local:"4-bit",headingTag:"h3"}}),P=new W({props:{$$slots:{default:[Xi]},$$scope:{ctx:$}}}),Re=new G({props:{title:"Compute data type",local:"compute-data-type",headingTag:"h4"}}),Le=new U({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}}),Ne=new G({props:{title:"Normal Float 4 (NF4)",local:"normal-float-4-nf4",headingTag:"h4"}}),Ae=new U({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}}),Ye=new G({props:{title:"Nested quantization",local:"nested-quantization",headingTag:"h4"}}),Se=new U({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}}),De=new G({props:{title:"Optimum",local:"optimum",headingTag:"h2"}}),Oe=new G({props:{title:"Benchmarks",local:"benchmarks",headingTag:"h2"}}),ll=new G({props:{title:"Fused AWQ modules",local:"fused-awq-modules",headingTag:"h3"}}),ol=new Mi({props:{source:"https://github.com/huggingface/transformers/blob/main/docs/source/en/quantization.md"}}),{c(){n=r("meta"),M=s(),o=r("p"),y=s(),d(u.$$.fragment),T=s(),_=r("p"),_.textContent=j,w=s(),q=r("p"),q.textContent=Z,C=s(),d(k.$$.fragment),J=s(),d(z.$$.fragment),v=s(),d(I.$$.fragment),ml=s(),lt=r("p"),lt.innerHTML=Vn,ul=s(),at=r("ul"),at.innerHTML=Xn,dl=s(),nt=r("p"),nt.textContent=Fn,fl=s(),d(st.$$.fragment),hl=s(),it=r("p"),it.innerHTML=Rn,cl=s(),ot=r("p"),ot.innerHTML=xn,gl=s(),d(rt.$$.fragment),bl=s(),pt=r("p"),pt.textContent=Ln,yl=s(),mt=r("p"),mt.innerHTML=Nn,Ml=s(),B=r("div"),B.innerHTML=Hn,Tl=s(),ut=r("p"),ut.textContent=An,wl=s(),d(dt.$$.fragment),$l=s(),ft=r("p"),ft.innerHTML=En,Jl=s(),ht=r("p"),ht.innerHTML=Yn,vl=s(),ct=r("p"),ct.innerHTML=Pn,Ul=s(),d(gt.$$.fragment),_l=s(),bt=r("p"),bt.textContent=Sn,Cl=s(),yt=r("p"),yt.innerHTML=Dn,jl=s(),d(Mt.$$.fragment),ql=s(),Tt=r("p"),Tt.innerHTML=Kn,kl=s(),d(wt.$$.fragment),Zl=s(),$t=r("p"),$t.textContent=On,Gl=s(),Jt=r("table"),Jt.innerHTML=ts,zl=s(),d(vt.$$.fragment),Il=s(),d(V.$$.fragment),Ql=s(),Ut=r("p"),Ut.innerHTML=es,Wl=s(),_t=r("p"),_t.innerHTML=ls,Bl=s(),Ct=r("p"),Ct.textContent=as,Vl=s(),d(jt.$$.fragment),Xl=s(),qt=r("p"),qt.innerHTML=ns,Fl=s(),d(kt.$$.fragment),Rl=s(),Zt=r("p"),Zt.innerHTML=ss,xl=s(),d(Gt.$$.fragment),Ll=s(),zt=r("p"),zt.innerHTML=is,Nl=s(),d(It.$$.fragment),Hl=s(),Qt=r("p"),Qt.innerHTML=os,Al=s(),d(Wt.$$.fragment),El=s(),d(Bt.$$.fragment),Yl=s(),Vt=r("p"),Vt.innerHTML=rs,Pl=s(),d(X.$$.fragment),Sl=s(),d(F.$$.fragment),Dl=s(),d(Xt.$$.fragment),Kl=s(),Ft=r("p"),Ft.innerHTML=ps,Ol=s(),d(Rt.$$.fragment),ta=s(),xt=r("p"),xt.innerHTML=ms,ea=s(),d(Lt.$$.fragment),la=s(),d(R.$$.fragment),aa=s(),d(Nt.$$.fragment),na=s(),d(x.$$.fragment),sa=s(),Ht=r("p"),Ht.innerHTML=us,ia=s(),At=r("p"),At.textContent=ds,oa=s(),d(Et.$$.fragment),ra=s(),Yt=r("p"),Yt.innerHTML=fs,pa=s(),d(Pt.$$.fragment),ma=s(),St=r("p"),St.textContent=hs,ua=s(),d(Dt.$$.fragment),da=s(),Kt=r("p"),Kt.innerHTML=cs,fa=s(),d(Ot.$$.fragment),ha=s(),te=r("p"),te.innerHTML=gs,ca=s(),d(ee.$$.fragment),ga=s(),d(L.$$.fragment),ba=s(),le=r("p"),le.innerHTML=bs,ya=s(),d(ae.$$.fragment),Ma=s(),ne=r("p"),ne.innerHTML=ys,Ta=s(),d(se.$$.fragment),wa=s(),ie=r("p"),ie.innerHTML=Ms,$a=s(),d(oe.$$.fragment),Ja=s(),d(re.$$.fragment),va=s(),pe=r("p"),pe.innerHTML=Ts,Ua=s(),d(me.$$.fragment),_a=s(),d(N.$$.fragment),Ca=s(),ue=r("p"),ue.textContent=ws,ja=s(),d(de.$$.fragment),qa=s(),d(fe.$$.fragment),ka=s(),he=r("p"),he.innerHTML=$s,Za=s(),ce=r("p"),ce.textContent=Js,Ga=s(),d(H.$$.fragment),za=s(),ge=r("p"),ge.innerHTML=vs,Ia=s(),d(A.$$.fragment),Qa=s(),d(E.$$.fragment),Wa=s(),be=r("p"),be.innerHTML=Us,Ba=s(),d(ye.$$.fragment),Va=s(),Me=r("p"),Me.innerHTML=_s,Xa=s(),d(Te.$$.fragment),Fa=s(),d(we.$$.fragment),Ra=s(),d(Y.$$.fragment),xa=s(),$e=r("p"),$e.textContent=Cs,La=s(),d(Je.$$.fragment),Na=s(),ve=r("p"),ve.innerHTML=js,Ha=s(),d(Ue.$$.fragment),Aa=s(),_e=r("p"),_e.innerHTML=qs,Ea=s(),d(Ce.$$.fragment),Ya=s(),je=r("p"),je.innerHTML=ks,Pa=s(),d(qe.$$.fragment),Sa=s(),d(ke.$$.fragment),Da=s(),Ze=r("p"),Ze.textContent=Zs,Ka=s(),Ge=r("p"),Ge.innerHTML=Gs,Oa=s(),d(ze.$$.fragment),tn=s(),d(Ie.$$.fragment),en=s(),Qe=r("p"),Qe.innerHTML=zs,ln=s(),d(We.$$.fragment),an=s(),d(Be.$$.fragment),nn=s(),Ve=r("p"),Ve.innerHTML=Is,sn=s(),d(Xe.$$.fragment),on=s(),d(P.$$.fragment),rn=s(),Fe=r("p"),Fe.textContent=Qs,pn=s(),d(Re.$$.fragment),mn=s(),xe=r("p"),xe.innerHTML=Ws,un=s(),d(Le.$$.fragment),dn=s(),d(Ne.$$.fragment),fn=s(),He=r("p"),He.innerHTML=Bs,hn=s(),d(Ae.$$.fragment),cn=s(),Ee=r("p"),Ee.innerHTML=Vs,gn=s(),d(Ye.$$.fragment),bn=s(),Pe=r("p"),Pe.innerHTML=Xs,yn=s(),d(Se.$$.fragment),Mn=s(),d(De.$$.fragment),Tn=s(),Ke=r("p"),Ke.innerHTML=Fs,wn=s(),d(Oe.$$.fragment),$n=s(),tl=r("p"),tl.innerHTML=Rs,Jn=s(),S=r("div"),S.innerHTML=xs,vn=s(),D=r("div"),D.innerHTML=Ls,Un=s(),el=r("p"),el.innerHTML=Ns,_n=s(),d(ll.$$.fragment),Cn=s(),al=r("p"),al.innerHTML=Hs,jn=s(),K=r("figcaption"),K.textContent=As,qn=s(),nl=r("table"),nl.innerHTML=Es,kn=s(),O=r("figcaption"),O.textContent=Ys,Zn=s(),sl=r("table"),sl.innerHTML=Ps,Gn=s(),il=r("p"),il.innerHTML=Ss,zn=s(),tt=r("div"),tt.innerHTML=Ds,In=s(),d(ol.$$.fragment),Qn=s(),pl=r("p"),this.h()},l(t){const e=bi("svelte-u9bgzb",document.head);n=p(e,"META",{name:!0,content:!0}),e.forEach(l),M=i(t),o=p(t,"P",{}),di(o).forEach(l),y=i(t),f(u.$$.fragment,t),T=i(t),_=p(t,"P",{"data-svelte-h":!0}),m(_)!=="svelte-1euzkei"&&(_.textContent=j),w=i(t),q=p(t,"P",{"data-svelte-h":!0}),m(q)!=="svelte-1f5pv07"&&(q.textContent=Z),C=i(t),f(k.$$.fragment,t),J=i(t),f(z.$$.fragment,t),v=i(t),f(I.$$.fragment,t),ml=i(t),lt=p(t,"P",{"data-svelte-h":!0}),m(lt)!=="svelte-1uxysak"&&(lt.innerHTML=Vn),ul=i(t),at=p(t,"UL",{"data-svelte-h":!0}),m(at)!=="svelte-1rrl1p8"&&(at.innerHTML=Xn),dl=i(t),nt=p(t,"P",{"data-svelte-h":!0}),m(nt)!=="svelte-13c61n1"&&(nt.textContent=Fn),fl=i(t),f(st.$$.fragment,t),hl=i(t),it=p(t,"P",{"data-svelte-h":!0}),m(it)!=="svelte-jgr9ku"&&(it.innerHTML=Rn),cl=i(t),ot=p(t,"P",{"data-svelte-h":!0}),m(ot)!=="svelte-acy0np"&&(ot.innerHTML=xn),gl=i(t),f(rt.$$.fragment,t),bl=i(t),pt=p(t,"P",{"data-svelte-h":!0}),m(pt)!=="svelte-1sscg20"&&(pt.textContent=Ln),yl=i(t),mt=p(t,"P",{"data-svelte-h":!0}),m(mt)!=="svelte-1woqmtc"&&(mt.innerHTML=Nn),Ml=i(t),B=p(t,"DIV",{class:!0,"data-svelte-h":!0}),m(B)!=="svelte-196rp13"&&(B.innerHTML=Hn),Tl=i(t),ut=p(t,"P",{"data-svelte-h":!0}),m(ut)!=="svelte-5v5thh"&&(ut.textContent=An),wl=i(t),f(dt.$$.fragment,t),$l=i(t),ft=p(t,"P",{"data-svelte-h":!0}),m(ft)!=="svelte-vu1jh7"&&(ft.innerHTML=En),Jl=i(t),ht=p(t,"P",{"data-svelte-h":!0}),m(ht)!=="svelte-11fbd25"&&(ht.innerHTML=Yn),vl=i(t),ct=p(t,"P",{"data-svelte-h":!0}),m(ct)!=="svelte-1rdkef8"&&(ct.innerHTML=Pn),Ul=i(t),f(gt.$$.fragment,t),_l=i(t),bt=p(t,"P",{"data-svelte-h":!0}),m(bt)!=="svelte-6sf1ac"&&(bt.textContent=Sn),Cl=i(t),yt=p(t,"P",{"data-svelte-h":!0}),m(yt)!=="svelte-mrigan"&&(yt.innerHTML=Dn),jl=i(t),f(Mt.$$.fragment,t),ql=i(t),Tt=p(t,"P",{"data-svelte-h":!0}),m(Tt)!=="svelte-1uurbap"&&(Tt.innerHTML=Kn),kl=i(t),f(wt.$$.fragment,t),Zl=i(t),$t=p(t,"P",{"data-svelte-h":!0}),m($t)!=="svelte-1ouechy"&&($t.textContent=On),Gl=i(t),Jt=p(t,"TABLE",{"data-svelte-h":!0}),m(Jt)!=="svelte-mgp7ro"&&(Jt.innerHTML=ts),zl=i(t),f(vt.$$.fragment,t),Il=i(t),f(V.$$.fragment,t),Ql=i(t),Ut=p(t,"P",{"data-svelte-h":!0}),m(Ut)!=="svelte-1c5vyni"&&(Ut.innerHTML=es),Wl=i(t),_t=p(t,"P",{"data-svelte-h":!0}),m(_t)!=="svelte-vomabp"&&(_t.innerHTML=ls),Bl=i(t),Ct=p(t,"P",{"data-svelte-h":!0}),m(Ct)!=="svelte-1ozln1k"&&(Ct.textContent=as),Vl=i(t),f(jt.$$.fragment,t),Xl=i(t),qt=p(t,"P",{"data-svelte-h":!0}),m(qt)!=="svelte-1lxz9t"&&(qt.innerHTML=ns),Fl=i(t),f(kt.$$.fragment,t),Rl=i(t),Zt=p(t,"P",{"data-svelte-h":!0}),m(Zt)!=="svelte-g3j4pi"&&(Zt.innerHTML=ss),xl=i(t),f(Gt.$$.fragment,t),Ll=i(t),zt=p(t,"P",{"data-svelte-h":!0}),m(zt)!=="svelte-19un5li"&&(zt.innerHTML=is),Nl=i(t),f(It.$$.fragment,t),Hl=i(t),Qt=p(t,"P",{"data-svelte-h":!0}),m(Qt)!=="svelte-ptrt24"&&(Qt.innerHTML=os),Al=i(t),f(Wt.$$.fragment,t),El=i(t),f(Bt.$$.fragment,t),Yl=i(t),Vt=p(t,"P",{"data-svelte-h":!0}),m(Vt)!=="svelte-jywid1"&&(Vt.innerHTML=rs),Pl=i(t),f(X.$$.fragment,t),Sl=i(t),f(F.$$.fragment,t),Dl=i(t),f(Xt.$$.fragment,t),Kl=i(t),Ft=p(t,"P",{"data-svelte-h":!0}),m(Ft)!=="svelte-1fw2pai"&&(Ft.innerHTML=ps),Ol=i(t),f(Rt.$$.fragment,t),ta=i(t),xt=p(t,"P",{"data-svelte-h":!0}),m(xt)!=="svelte-in32kr"&&(xt.innerHTML=ms),ea=i(t),f(Lt.$$.fragment,t),la=i(t),f(R.$$.fragment,t),aa=i(t),f(Nt.$$.fragment,t),na=i(t),f(x.$$.fragment,t),sa=i(t),Ht=p(t,"P",{"data-svelte-h":!0}),m(Ht)!=="svelte-sq0x7n"&&(Ht.innerHTML=us),ia=i(t),At=p(t,"P",{"data-svelte-h":!0}),m(At)!=="svelte-13c61n1"&&(At.textContent=ds),oa=i(t),f(Et.$$.fragment,t),ra=i(t),Yt=p(t,"P",{"data-svelte-h":!0}),m(Yt)!=="svelte-tvg01n"&&(Yt.innerHTML=fs),pa=i(t),f(Pt.$$.fragment,t),ma=i(t),St=p(t,"P",{"data-svelte-h":!0}),m(St)!=="svelte-1cjo88z"&&(St.textContent=hs),ua=i(t),f(Dt.$$.fragment,t),da=i(t),Kt=p(t,"P",{"data-svelte-h":!0}),m(Kt)!=="svelte-1ku7upk"&&(Kt.innerHTML=cs),fa=i(t),f(Ot.$$.fragment,t),ha=i(t),te=p(t,"P",{"data-svelte-h":!0}),m(te)!=="svelte-1tle3a0"&&(te.innerHTML=gs),ca=i(t),f(ee.$$.fragment,t),ga=i(t),f(L.$$.fragment,t),ba=i(t),le=p(t,"P",{"data-svelte-h":!0}),m(le)!=="svelte-14usz3e"&&(le.innerHTML=bs),ya=i(t),f(ae.$$.fragment,t),Ma=i(t),ne=p(t,"P",{"data-svelte-h":!0}),m(ne)!=="svelte-1je75md"&&(ne.innerHTML=ys),Ta=i(t),f(se.$$.fragment,t),wa=i(t),ie=p(t,"P",{"data-svelte-h":!0}),m(ie)!=="svelte-1dqo92z"&&(ie.innerHTML=Ms),$a=i(t),f(oe.$$.fragment,t),Ja=i(t),f(re.$$.fragment,t),va=i(t),pe=p(t,"P",{"data-svelte-h":!0}),m(pe)!=="svelte-1y7fpva"&&(pe.innerHTML=Ts),Ua=i(t),f(me.$$.fragment,t),_a=i(t),f(N.$$.fragment,t),Ca=i(t),ue=p(t,"P",{"data-svelte-h":!0}),m(ue)!=="svelte-m9nw5y"&&(ue.textContent=ws),ja=i(t),f(de.$$.fragment,t),qa=i(t),f(fe.$$.fragment,t),ka=i(t),he=p(t,"P",{"data-svelte-h":!0}),m(he)!=="svelte-5a92xi"&&(he.innerHTML=$s),Za=i(t),ce=p(t,"P",{"data-svelte-h":!0}),m(ce)!=="svelte-gf36q7"&&(ce.textContent=Js),Ga=i(t),f(H.$$.fragment,t),za=i(t),ge=p(t,"P",{"data-svelte-h":!0}),m(ge)!=="svelte-nz5tzu"&&(ge.innerHTML=vs),Ia=i(t),f(A.$$.fragment,t),Qa=i(t),f(E.$$.fragment,t),Wa=i(t),be=p(t,"P",{"data-svelte-h":!0}),m(be)!=="svelte-1bxp667"&&(be.innerHTML=Us),Ba=i(t),f(ye.$$.fragment,t),Va=i(t),Me=p(t,"P",{"data-svelte-h":!0}),m(Me)!=="svelte-1qnrip0"&&(Me.innerHTML=_s),Xa=i(t),f(Te.$$.fragment,t),Fa=i(t),f(we.$$.fragment,t),Ra=i(t),f(Y.$$.fragment,t),xa=i(t),$e=p(t,"P",{"data-svelte-h":!0}),m($e)!=="svelte-1yx1x2g"&&($e.textContent=Cs),La=i(t),f(Je.$$.fragment,t),Na=i(t),ve=p(t,"P",{"data-svelte-h":!0}),m(ve)!=="svelte-1s76weg"&&(ve.innerHTML=js),Ha=i(t),f(Ue.$$.fragment,t),Aa=i(t),_e=p(t,"P",{"data-svelte-h":!0}),m(_e)!=="svelte-15oy7am"&&(_e.innerHTML=qs),Ea=i(t),f(Ce.$$.fragment,t),Ya=i(t),je=p(t,"P",{"data-svelte-h":!0}),m(je)!=="svelte-k1g8c2"&&(je.innerHTML=ks),Pa=i(t),f(qe.$$.fragment,t),Sa=i(t),f(ke.$$.fragment,t),Da=i(t),Ze=p(t,"P",{"data-svelte-h":!0}),m(Ze)!=="svelte-ur5rgd"&&(Ze.textContent=Zs),Ka=i(t),Ge=p(t,"P",{"data-svelte-h":!0}),m(Ge)!=="svelte-if3gye"&&(Ge.innerHTML=Gs),Oa=i(t),f(ze.$$.fragment,t),tn=i(t),f(Ie.$$.fragment,t),en=i(t),Qe=p(t,"P",{"data-svelte-h":!0}),m(Qe)!=="svelte-qscn9h"&&(Qe.innerHTML=zs),ln=i(t),f(We.$$.fragment,t),an=i(t),f(Be.$$.fragment,t),nn=i(t),Ve=p(t,"P",{"data-svelte-h":!0}),m(Ve)!=="svelte-4nvx4q"&&(Ve.innerHTML=Is),sn=i(t),f(Xe.$$.fragment,t),on=i(t),f(P.$$.fragment,t),rn=i(t),Fe=p(t,"P",{"data-svelte-h":!0}),m(Fe)!=="svelte-7ob7j"&&(Fe.textContent=Qs),pn=i(t),f(Re.$$.fragment,t),mn=i(t),xe=p(t,"P",{"data-svelte-h":!0}),m(xe)!=="svelte-1ym10kt"&&(xe.innerHTML=Ws),un=i(t),f(Le.$$.fragment,t),dn=i(t),f(Ne.$$.fragment,t),fn=i(t),He=p(t,"P",{"data-svelte-h":!0}),m(He)!=="svelte-hz4fbr"&&(He.innerHTML=Bs),hn=i(t),f(Ae.$$.fragment,t),cn=i(t),Ee=p(t,"P",{"data-svelte-h":!0}),m(Ee)!=="svelte-1qoc2ct"&&(Ee.innerHTML=Vs),gn=i(t),f(Ye.$$.fragment,t),bn=i(t),Pe=p(t,"P",{"data-svelte-h":!0}),m(Pe)!=="svelte-l0u9eq"&&(Pe.innerHTML=Xs),yn=i(t),f(Se.$$.fragment,t),Mn=i(t),f(De.$$.fragment,t),Tn=i(t),Ke=p(t,"P",{"data-svelte-h":!0}),m(Ke)!=="svelte-opujmz"&&(Ke.innerHTML=Fs),wn=i(t),f(Oe.$$.fragment,t),$n=i(t),tl=p(t,"P",{"data-svelte-h":!0}),m(tl)!=="svelte-10oh9lm"&&(tl.innerHTML=Rs),Jn=i(t),S=p(t,"DIV",{class:!0,"data-svelte-h":!0}),m(S)!=="svelte-10jjm5l"&&(S.innerHTML=xs),vn=i(t),D=p(t,"DIV",{class:!0,"data-svelte-h":!0}),m(D)!=="svelte-48at03"&&(D.innerHTML=Ls),Un=i(t),el=p(t,"P",{"data-svelte-h":!0}),m(el)!=="svelte-1sm7gom"&&(el.innerHTML=Ns),_n=i(t),f(ll.$$.fragment,t),Cn=i(t),al=p(t,"P",{"data-svelte-h":!0}),m(al)!=="svelte-81zmsw"&&(al.innerHTML=Hs),jn=i(t),K=p(t,"FIGCAPTION",{class:!0,"data-svelte-h":!0}),m(K)!=="svelte-grefv0"&&(K.textContent=As),qn=i(t),nl=p(t,"TABLE",{"data-svelte-h":!0}),m(nl)!=="svelte-19aactm"&&(nl.innerHTML=Es),kn=i(t),O=p(t,"FIGCAPTION",{class:!0,"data-svelte-h":!0}),m(O)!=="svelte-1r15bg7"&&(O.textContent=Ys),Zn=i(t),sl=p(t,"TABLE",{"data-svelte-h":!0}),m(sl)!=="svelte-19fczbk"&&(sl.innerHTML=Ps),Gn=i(t),il=p(t,"P",{"data-svelte-h":!0}),m(il)!=="svelte-gu8e8k"&&(il.innerHTML=Ss),zn=i(t),tt=p(t,"DIV",{class:!0,"data-svelte-h":!0}),m(tt)!=="svelte-1ke50ja"&&(tt.innerHTML=Ds),In=i(t),f(ol.$$.fragment,t),Qn=i(t),pl=p(t,"P",{}),di(pl).forEach(l),this.h()},h(){et(n,"name","hf:doc:metadata"),et(n,"content",Ri),et(B,"class","flex gap-4"),et(S,"class","flex gap-4"),et(D,"class","flex gap-4"),et(K,"class","text-center text-gray-500 text-lg"),et(O,"class","text-center text-gray-500 text-lg"),et(tt,"class","flex gap-4")},m(t,e){yi(document.head,n),a(t,M,e),a(t,o,e),a(t,y,e),h(u,t,e),a(t,T,e),a(t,_,e),a(t,w,e),a(t,q,e),a(t,C,e),h(k,t,e),a(t,J,e),h(z,t,e),a(t,v,e),h(I,t,e),a(t,ml,e),a(t,lt,e),a(t,ul,e),a(t,at,e),a(t,dl,e),a(t,nt,e),a(t,fl,e),h(st,t,e),a(t,hl,e),a(t,it,e),a(t,cl,e),a(t,ot,e),a(t,gl,e),h(rt,t,e),a(t,bl,e),a(t,pt,e),a(t,yl,e),a(t,mt,e),a(t,Ml,e),a(t,B,e),a(t,Tl,e),a(t,ut,e),a(t,wl,e),h(dt,t,e),a(t,$l,e),a(t,ft,e),a(t,Jl,e),a(t,ht,e),a(t,vl,e),a(t,ct,e),a(t,Ul,e),h(gt,t,e),a(t,_l,e),a(t,bt,e),a(t,Cl,e),a(t,yt,e),a(t,jl,e),h(Mt,t,e),a(t,ql,e),a(t,Tt,e),a(t,kl,e),h(wt,t,e),a(t,Zl,e),a(t,$t,e),a(t,Gl,e),a(t,Jt,e),a(t,zl,e),h(vt,t,e),a(t,Il,e),h(V,t,e),a(t,Ql,e),a(t,Ut,e),a(t,Wl,e),a(t,_t,e),a(t,Bl,e),a(t,Ct,e),a(t,Vl,e),h(jt,t,e),a(t,Xl,e),a(t,qt,e),a(t,Fl,e),h(kt,t,e),a(t,Rl,e),a(t,Zt,e),a(t,xl,e),h(Gt,t,e),a(t,Ll,e),a(t,zt,e),a(t,Nl,e),h(It,t,e),a(t,Hl,e),a(t,Qt,e),a(t,Al,e),h(Wt,t,e),a(t,El,e),h(Bt,t,e),a(t,Yl,e),a(t,Vt,e),a(t,Pl,e),h(X,t,e),a(t,Sl,e),h(F,t,e),a(t,Dl,e),h(Xt,t,e),a(t,Kl,e),a(t,Ft,e),a(t,Ol,e),h(Rt,t,e),a(t,ta,e),a(t,xt,e),a(t,ea,e),h(Lt,t,e),a(t,la,e),h(R,t,e),a(t,aa,e),h(Nt,t,e),a(t,na,e),h(x,t,e),a(t,sa,e),a(t,Ht,e),a(t,ia,e),a(t,At,e),a(t,oa,e),h(Et,t,e),a(t,ra,e),a(t,Yt,e),a(t,pa,e),h(Pt,t,e),a(t,ma,e),a(t,St,e),a(t,ua,e),h(Dt,t,e),a(t,da,e),a(t,Kt,e),a(t,fa,e),h(Ot,t,e),a(t,ha,e),a(t,te,e),a(t,ca,e),h(ee,t,e),a(t,ga,e),h(L,t,e),a(t,ba,e),a(t,le,e),a(t,ya,e),h(ae,t,e),a(t,Ma,e),a(t,ne,e),a(t,Ta,e),h(se,t,e),a(t,wa,e),a(t,ie,e),a(t,$a,e),h(oe,t,e),a(t,Ja,e),h(re,t,e),a(t,va,e),a(t,pe,e),a(t,Ua,e),h(me,t,e),a(t,_a,e),h(N,t,e),a(t,Ca,e),a(t,ue,e),a(t,ja,e),h(de,t,e),a(t,qa,e),h(fe,t,e),a(t,ka,e),a(t,he,e),a(t,Za,e),a(t,ce,e),a(t,Ga,e),h(H,t,e),a(t,za,e),a(t,ge,e),a(t,Ia,e),h(A,t,e),a(t,Qa,e),h(E,t,e),a(t,Wa,e),a(t,be,e),a(t,Ba,e),h(ye,t,e),a(t,Va,e),a(t,Me,e),a(t,Xa,e),h(Te,t,e),a(t,Fa,e),h(we,t,e),a(t,Ra,e),h(Y,t,e),a(t,xa,e),a(t,$e,e),a(t,La,e),h(Je,t,e),a(t,Na,e),a(t,ve,e),a(t,Ha,e),h(Ue,t,e),a(t,Aa,e),a(t,_e,e),a(t,Ea,e),h(Ce,t,e),a(t,Ya,e),a(t,je,e),a(t,Pa,e),h(qe,t,e),a(t,Sa,e),h(ke,t,e),a(t,Da,e),a(t,Ze,e),a(t,Ka,e),a(t,Ge,e),a(t,Oa,e),h(ze,t,e),a(t,tn,e),h(Ie,t,e),a(t,en,e),a(t,Qe,e),a(t,ln,e),h(We,t,e),a(t,an,e),h(Be,t,e),a(t,nn,e),a(t,Ve,e),a(t,sn,e),h(Xe,t,e),a(t,on,e),h(P,t,e),a(t,rn,e),a(t,Fe,e),a(t,pn,e),h(Re,t,e),a(t,mn,e),a(t,xe,e),a(t,un,e),h(Le,t,e),a(t,dn,e),h(Ne,t,e),a(t,fn,e),a(t,He,e),a(t,hn,e),h(Ae,t,e),a(t,cn,e),a(t,Ee,e),a(t,gn,e),h(Ye,t,e),a(t,bn,e),a(t,Pe,e),a(t,yn,e),h(Se,t,e),a(t,Mn,e),h(De,t,e),a(t,Tn,e),a(t,Ke,e),a(t,wn,e),h(Oe,t,e),a(t,$n,e),a(t,tl,e),a(t,Jn,e),a(t,S,e),a(t,vn,e),a(t,D,e),a(t,Un,e),a(t,el,e),a(t,_n,e),h(ll,t,e),a(t,Cn,e),a(t,al,e),a(t,jn,e),a(t,K,e),a(t,qn,e),a(t,nl,e),a(t,kn,e),a(t,O,e),a(t,Zn,e),a(t,sl,e),a(t,Gn,e),a(t,il,e),a(t,zn,e),a(t,tt,e),a(t,In,e),h(ol,t,e),a(t,Qn,e),a(t,pl,e),Wn=!0},p(t,[e]){const Ks={};e&2&&(Ks.$$scope={dirty:e,ctx:t}),k.$set(Ks);const Os={};e&2&&(Os.$$scope={dirty:e,ctx:t}),I.$set(Os);const ti={};e&2&&(ti.$$scope={dirty:e,ctx:t}),V.$set(ti);const ei={};e&2&&(ei.$$scope={dirty:e,ctx:t}),X.$set(ei);const li={};e&2&&(li.$$scope={dirty:e,ctx:t}),F.$set(li);const ai={};e&2&&(ai.$$scope={dirty:e,ctx:t}),R.$set(ai);const ni={};e&2&&(ni.$$scope={dirty:e,ctx:t}),x.$set(ni);const si={};e&2&&(si.$$scope={dirty:e,ctx:t}),L.$set(si);const ii={};e&2&&(ii.$$scope={dirty:e,ctx:t}),N.$set(ii);const oi={};e&2&&(oi.$$scope={dirty:e,ctx:t}),H.$set(oi);const ri={};e&2&&(ri.$$scope={dirty:e,ctx:t}),A.$set(ri);const pi={};e&2&&(pi.$$scope={dirty:e,ctx:t}),E.$set(pi);const mi={};e&2&&(mi.$$scope={dirty:e,ctx:t}),Y.$set(mi);const ui={};e&2&&(ui.$$scope={dirty:e,ctx:t}),P.$set(ui)},i(t){Wn||(c(u.$$.fragment,t),c(k.$$.fragment,t),c(z.$$.fragment,t),c(I.$$.fragment,t),c(st.$$.fragment,t),c(rt.$$.fragment,t),c(dt.$$.fragment,t),c(gt.$$.fragment,t),c(Mt.$$.fragment,t),c(wt.$$.fragment,t),c(vt.$$.fragment,t),c(V.$$.fragment,t),c(jt.$$.fragment,t),c(kt.$$.fragment,t),c(Gt.$$.fragment,t),c(It.$$.fragment,t),c(Wt.$$.fragment,t),c(Bt.$$.fragment,t),c(X.$$.fragment,t),c(F.$$.fragment,t),c(Xt.$$.fragment,t),c(Rt.$$.fragment,t),c(Lt.$$.fragment,t),c(R.$$.fragment,t),c(Nt.$$.fragment,t),c(x.$$.fragment,t),c(Et.$$.fragment,t),c(Pt.$$.fragment,t),c(Dt.$$.fragment,t),c(Ot.$$.fragment,t),c(ee.$$.fragment,t),c(L.$$.fragment,t),c(ae.$$.fragment,t),c(se.$$.fragment,t),c(oe.$$.fragment,t),c(re.$$.fragment,t),c(me.$$.fragment,t),c(N.$$.fragment,t),c(de.$$.fragment,t),c(fe.$$.fragment,t),c(H.$$.fragment,t),c(A.$$.fragment,t),c(E.$$.fragment,t),c(ye.$$.fragment,t),c(Te.$$.fragment,t),c(we.$$.fragment,t),c(Y.$$.fragment,t),c(Je.$$.fragment,t),c(Ue.$$.fragment,t),c(Ce.$$.fragment,t),c(qe.$$.fragment,t),c(ke.$$.fragment,t),c(ze.$$.fragment,t),c(Ie.$$.fragment,t),c(We.$$.fragment,t),c(Be.$$.fragment,t),c(Xe.$$.fragment,t),c(P.$$.fragment,t),c(Re.$$.fragment,t),c(Le.$$.fragment,t),c(Ne.$$.fragment,t),c(Ae.$$.fragment,t),c(Ye.$$.fragment,t),c(Se.$$.fragment,t),c(De.$$.fragment,t),c(Oe.$$.fragment,t),c(ll.$$.fragment,t),c(ol.$$.fragment,t),Wn=!0)},o(t){g(u.$$.fragment,t),g(k.$$.fragment,t),g(z.$$.fragment,t),g(I.$$.fragment,t),g(st.$$.fragment,t),g(rt.$$.fragment,t),g(dt.$$.fragment,t),g(gt.$$.fragment,t),g(Mt.$$.fragment,t),g(wt.$$.fragment,t),g(vt.$$.fragment,t),g(V.$$.fragment,t),g(jt.$$.fragment,t),g(kt.$$.fragment,t),g(Gt.$$.fragment,t),g(It.$$.fragment,t),g(Wt.$$.fragment,t),g(Bt.$$.fragment,t),g(X.$$.fragment,t),g(F.$$.fragment,t),g(Xt.$$.fragment,t),g(Rt.$$.fragment,t),g(Lt.$$.fragment,t),g(R.$$.fragment,t),g(Nt.$$.fragment,t),g(x.$$.fragment,t),g(Et.$$.fragment,t),g(Pt.$$.fragment,t),g(Dt.$$.fragment,t),g(Ot.$$.fragment,t),g(ee.$$.fragment,t),g(L.$$.fragment,t),g(ae.$$.fragment,t),g(se.$$.fragment,t),g(oe.$$.fragment,t),g(re.$$.fragment,t),g(me.$$.fragment,t),g(N.$$.fragment,t),g(de.$$.fragment,t),g(fe.$$.fragment,t),g(H.$$.fragment,t),g(A.$$.fragment,t),g(E.$$.fragment,t),g(ye.$$.fragment,t),g(Te.$$.fragment,t),g(we.$$.fragment,t),g(Y.$$.fragment,t),g(Je.$$.fragment,t),g(Ue.$$.fragment,t),g(Ce.$$.fragment,t),g(qe.$$.fragment,t),g(ke.$$.fragment,t),g(ze.$$.fragment,t),g(Ie.$$.fragment,t),g(We.$$.fragment,t),g(Be.$$.fragment,t),g(Xe.$$.fragment,t),g(P.$$.fragment,t),g(Re.$$.fragment,t),g(Le.$$.fragment,t),g(Ne.$$.fragment,t),g(Ae.$$.fragment,t),g(Ye.$$.fragment,t),g(Se.$$.fragment,t),g(De.$$.fragment,t),g(Oe.$$.fragment,t),g(ll.$$.fragment,t),g(ol.$$.fragment,t),Wn=!1},d(t){t&&(l(M),l(o),l(y),l(T),l(_),l(w),l(q),l(C),l(J),l(v),l(ml),l(lt),l(ul),l(at),l(dl),l(nt),l(fl),l(hl),l(it),l(cl),l(ot),l(gl),l(bl),l(pt),l(yl),l(mt),l(Ml),l(B),l(Tl),l(ut),l(wl),l($l),l(ft),l(Jl),l(ht),l(vl),l(ct),l(Ul),l(_l),l(bt),l(Cl),l(yt),l(jl),l(ql),l(Tt),l(kl),l(Zl),l($t),l(Gl),l(Jt),l(zl),l(Il),l(Ql),l(Ut),l(Wl),l(_t),l(Bl),l(Ct),l(Vl),l(Xl),l(qt),l(Fl),l(Rl),l(Zt),l(xl),l(Ll),l(zt),l(Nl),l(Hl),l(Qt),l(Al),l(El),l(Yl),l(Vt),l(Pl),l(Sl),l(Dl),l(Kl),l(Ft),l(Ol),l(ta),l(xt),l(ea),l(la),l(aa),l(na),l(sa),l(Ht),l(ia),l(At),l(oa),l(ra),l(Yt),l(pa),l(ma),l(St),l(ua),l(da),l(Kt),l(fa),l(ha),l(te),l(ca),l(ga),l(ba),l(le),l(ya),l(Ma),l(ne),l(Ta),l(wa),l(ie),l($a),l(Ja),l(va),l(pe),l(Ua),l(_a),l(Ca),l(ue),l(ja),l(qa),l(ka),l(he),l(Za),l(ce),l(Ga),l(za),l(ge),l(Ia),l(Qa),l(Wa),l(be),l(Ba),l(Va),l(Me),l(Xa),l(Fa),l(Ra),l(xa),l($e),l(La),l(Na),l(ve),l(Ha),l(Aa),l(_e),l(Ea),l(Ya),l(je),l(Pa),l(Sa),l(Da),l(Ze),l(Ka),l(Ge),l(Oa),l(tn),l(en),l(Qe),l(ln),l(an),l(nn),l(Ve),l(sn),l(on),l(rn),l(Fe),l(pn),l(mn),l(xe),l(un),l(dn),l(fn),l(He),l(hn),l(cn),l(Ee),l(gn),l(bn),l(Pe),l(yn),l(Mn),l(Tn),l(Ke),l(wn),l($n),l(tl),l(Jn),l(S),l(vn),l(D),l(Un),l(el),l(_n),l(Cn),l(al),l(jn),l(K),l(qn),l(nl),l(kn),l(O),l(Zn),l(sl),l(Gn),l(il),l(zn),l(tt),l(In),l(Qn),l(pl)),l(n),b(u,t),b(k,t),b(z,t),b(I,t),b(st,t),b(rt,t),b(dt,t),b(gt,t),b(Mt,t),b(wt,t),b(vt,t),b(V,t),b(jt,t),b(kt,t),b(Gt,t),b(It,t),b(Wt,t),b(Bt,t),b(X,t),b(F,t),b(Xt,t),b(Rt,t),b(Lt,t),b(R,t),b(Nt,t),b(x,t),b(Et,t),b(Pt,t),b(Dt,t),b(Ot,t),b(ee,t),b(L,t),b(ae,t),b(se,t),b(oe,t),b(re,t),b(me,t),b(N,t),b(de,t),b(fe,t),b(H,t),b(A,t),b(E,t),b(ye,t),b(Te,t),b(we,t),b(Y,t),b(Je,t),b(Ue,t),b(Ce,t),b(qe,t),b(ke,t),b(ze,t),b(Ie,t),b(We,t),b(Be,t),b(Xe,t),b(P,t),b(Re,t),b(Le,t),b(Ne,t),b(Ae,t),b(Ye,t),b(Se,t),b(De,t),b(Oe,t),b(ll,t),b(ol,t)}}}const Ri='{"title":"Quantization","local":"quantization","sections":[{"title":"Quanto","local":"quanto","sections":[],"depth":2},{"title":"AQLM","local":"aqlm","sections":[{"title":"PEFT","local":"peft","sections":[],"depth":3},{"title":"AQLM configurations","local":"aqlm-configurations","sections":[],"depth":3}],"depth":2},{"title":"AWQ","local":"awq","sections":[{"title":"Fused modules","local":"fused-modules","sections":[],"depth":3},{"title":"Exllama-v2 support","local":"exllama-v2-support","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 xi($){return hi(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Pi extends ci{constructor(n){super(),gi(this,n,xi,Fi,fi,{})}}export{Pi as component};
