import{s as $o,o as Jo,n as I}from"../chunks/scheduler.25b97de1.js";import{S as vo,i as Uo,g as r,s,r as u,A as jo,h as p,f as l,c as n,j as wo,u as d,x as m,k as et,y as _o,a,v as f,d as h,t as c,w as M}from"../chunks/index.d9030fc9.js";import{T as W}from"../chunks/Tip.baa67368.js";import{C as w}from"../chunks/CodeBlock.e6cd0d95.js";import{H as q,E as Co}from"../chunks/EditOnGithub.91d95064.js";import{H as zn,a as zl}from"../chunks/HfOption.1e589c90.js";function qo(J){let i,y='Interested in adding a new quantization method to Transformers? Read the <a href="./hf_quantizer">HfQuantizer</a> guide to learn how!';return{c(){i=r("p"),i.innerHTML=y},l(o){i=p(o,"P",{"data-svelte-h":!0}),m(i)!=="svelte-px0yfi"&&(i.innerHTML=y)},m(o,g){a(o,i,g)},p:I,d(o){o&&l(i)}}}function Zo(J){let i,y='Try Quanto + transformers with this <a href="https://colab.research.google.com/drive/16CXfVmtdQvciSh9BopZUDYcmXCDpvgrT?usp=sharing" rel="nofollow">notebook</a>!';return{c(){i=r("p"),i.innerHTML=y},l(o){i=p(o,"P",{"data-svelte-h":!0}),m(i)!=="svelte-1m6vmvl"&&(i.innerHTML=y)},m(o,g){a(o,i,g)},p:I,d(o){o&&l(i)}}}function ko(J){let i,y='Try AWQ quantization with this <a href="https://colab.research.google.com/drive/1HzZH89yAXJaZgwJDhQj9LqSBux932BvY" rel="nofollow">notebook</a>!';return{c(){i=r("p"),i.innerHTML=y},l(o){i=p(o,"P",{"data-svelte-h":!0}),m(i)!=="svelte-1yzcfmc"&&(i.innerHTML=y)},m(o,g){a(o,i,g)},p:I,d(o){o&&l(i)}}}function Go(J){let i,y="Fused modules cannot be combined with other optimization techniques such as FlashAttention-2.";return{c(){i=r("p"),i.textContent=y},l(o){i=p(o,"P",{"data-svelte-h":!0}),m(i)!=="svelte-hwgpn3"&&(i.textContent=y)},m(o,g){a(o,i,g)},p:I,d(o){o&&l(i)}}}function zo(J){let i,y='To enable fused modules for supported architectures, create an <a href="/docs/transformers/v4.41.0/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,g,b='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,C;return j=new w({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(){i=r("p"),i.innerHTML=y,o=s(),g=r("p"),g.innerHTML=b,T=s(),u(j.$$.fragment)},l($){i=p($,"P",{"data-svelte-h":!0}),m(i)!=="svelte-1kq50ms"&&(i.innerHTML=y),o=n($),g=p($,"P",{"data-svelte-h":!0}),m(g)!=="svelte-1zxz2i"&&(g.innerHTML=b),T=n($),d(j.$$.fragment,$)},m($,Z){a($,i,Z),a($,o,Z),a($,g,Z),a($,T,Z),f(j,$,Z),C=!0},p:I,i($){C||(h(j.$$.fragment,$),C=!0)},o($){c(j.$$.fragment,$),C=!1},d($){$&&(l(i),l(o),l(g),l(T)),M(j,$)}}}function Qo(J){let i,y='For architectures that don’t support fused modules yet, you need to create a custom fusing mapping to define which modules need to be fused with the <code>modules_to_fuse</code> parameter. For example, to fuse the AWQ modules of the <a href="https://huggingface.co/TheBloke/Yi-34B-AWQ" rel="nofollow">TheBloke/Yi-34B-AWQ</a> model.',o,g,b,T,j="The parameter <code>modules_to_fuse</code> should include:",C,$,Z="<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>",G;return g=new w({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(){i=r("p"),i.innerHTML=y,o=s(),u(g.$$.fragment),b=s(),T=r("p"),T.innerHTML=j,C=s(),$=r("ul"),$.innerHTML=Z},l(_){i=p(_,"P",{"data-svelte-h":!0}),m(i)!=="svelte-ecilwg"&&(i.innerHTML=y),o=n(_),d(g.$$.fragment,_),b=n(_),T=p(_,"P",{"data-svelte-h":!0}),m(T)!=="svelte-1divolh"&&(T.innerHTML=j),C=n(_),$=p(_,"UL",{"data-svelte-h":!0}),m($)!=="svelte-ln3msn"&&($.innerHTML=Z)},m(_,k){a(_,i,k),a(_,o,k),f(g,_,k),a(_,b,k),a(_,T,k),a(_,C,k),a(_,$,k),G=!0},p:I,i(_){G||(h(g.$$.fragment,_),G=!0)},o(_){c(g.$$.fragment,_),G=!1},d(_){_&&(l(i),l(o),l(b),l(T),l(C),l($)),M(g,_)}}}function Io(J){let i,y,o,g;return i=new zl({props:{id:"fuse",option:"supported architectures",$$slots:{default:[zo]},$$scope:{ctx:J}}}),o=new zl({props:{id:"fuse",option:"unsupported architectures",$$slots:{default:[Qo]},$$scope:{ctx:J}}}),{c(){u(i.$$.fragment),y=s(),u(o.$$.fragment)},l(b){d(i.$$.fragment,b),y=n(b),d(o.$$.fragment,b)},m(b,T){f(i,b,T),a(b,y,T),f(o,b,T),g=!0},p(b,T){const j={};T&2&&(j.$$scope={dirty:T,ctx:b}),i.$set(j);const C={};T&2&&(C.$$scope={dirty:T,ctx:b}),o.$set(C)},i(b){g||(h(i.$$.fragment,b),h(o.$$.fragment,b),g=!0)},o(b){c(i.$$.fragment,b),c(o.$$.fragment,b),g=!1},d(b){b&&l(y),M(i,b),M(o,b)}}}function Wo(J){let i,y="Note this feature is supported on AMD GPUs.";return{c(){i=r("p"),i.textContent=y},l(o){i=p(o,"P",{"data-svelte-h":!0}),m(i)!=="svelte-147si7w"&&(i.textContent=y)},m(o,g){a(o,i,g)},p:I,d(o){o&&l(i)}}}function Fo(J){let i,y='Try GPTQ quantization with PEFT in this <a href="https://colab.research.google.com/drive/1_TIrmuKOFhuRRiTWN94iLKUFu6ZX4ceb?usp=sharing" rel="nofollow">notebook</a> and learn more about it’s details in this <a href="https://huggingface.co/blog/gptq-integration" rel="nofollow">blog post</a>!';return{c(){i=r("p"),i.innerHTML=y},l(o){i=p(o,"P",{"data-svelte-h":!0}),m(i)!=="svelte-1tfpiad"&&(i.innerHTML=y)},m(o,g){a(o,i,g)},p:I,d(o){o&&l(i)}}}function Vo(J){let i,y='Depending on your hardware, it can take some time to quantize a model from scratch. It can take ~5 minutes to quantize the <a href="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(){i=r("p"),i.innerHTML=y},l(o){i=p(o,"P",{"data-svelte-h":!0}),m(i)!=="svelte-jdzahk"&&(i.innerHTML=y)},m(o,g){a(o,i,g)},p:I,d(o){o&&l(i)}}}function xo(J){let i,y="Only 4-bit models are supported, and we recommend deactivating the ExLlama kernels if you’re finetuning a quantized model with PEFT.";return{c(){i=r("p"),i.textContent=y},l(o){i=p(o,"P",{"data-svelte-h":!0}),m(i)!=="svelte-14ppi1y"&&(i.textContent=y)},m(o,g){a(o,i,g)},p:I,d(o){o&&l(i)}}}function Bo(J){let i,y;return i=new w({props:{code:"cGlwJTIwaW5zdGFsbCUyMHRyYW5zZm9ybWVycyUyMGFjY2VsZXJhdGUlMjBiaXRzYW5kYnl0ZXMlM0UwLjM3LjA=",highlighted:"pip install transformers accelerate bitsandbytes&gt;0.37.0",wrap:!1}}),{c(){u(i.$$.fragment)},l(o){d(i.$$.fragment,o)},m(o,g){f(i,o,g),y=!0},p:I,i(o){y||(h(i.$$.fragment,o),y=!0)},o(o){c(i.$$.fragment,o),y=!1},d(o){M(i,o)}}}function Xo(J){let i,y;return i=new w({props:{code:"cGlwJTIwaW5zdGFsbCUyMGJpdHNhbmRieXRlcyUzRSUzRDAuMzkuMCUwQXBpcCUyMGluc3RhbGwlMjAtLXVwZ3JhZGUlMjBhY2NlbGVyYXRlJTBBcGlwJTIwaW5zdGFsbCUyMC0tdXBncmFkZSUyMHRyYW5zZm9ybWVycw==",highlighted:`pip install bitsandbytes&gt;=0.39.0
pip install --upgrade accelerate
pip install --upgrade transformers`,wrap:!1}}),{c(){u(i.$$.fragment)},l(o){d(i.$$.fragment,o)},m(o,g){f(i,o,g),y=!0},p:I,i(o){y||(h(i.$$.fragment,o),y=!0)},o(o){c(i.$$.fragment,o),y=!1},d(o){M(i,o)}}}function Ro(J){let i,y,o,g;return i=new zl({props:{id:"bnb",option:"8-bit",$$slots:{default:[Bo]},$$scope:{ctx:J}}}),o=new zl({props:{id:"bnb",option:"4-bit",$$slots:{default:[Xo]},$$scope:{ctx:J}}}),{c(){u(i.$$.fragment),y=s(),u(o.$$.fragment)},l(b){d(i.$$.fragment,b),y=n(b),d(o.$$.fragment,b)},m(b,T){f(i,b,T),a(b,y,T),f(o,b,T),g=!0},p(b,T){const j={};T&2&&(j.$$scope={dirty:T,ctx:b}),i.$set(j);const C={};T&2&&(C.$$scope={dirty:T,ctx:b}),o.$set(C)},i(b){g||(h(i.$$.fragment,b),h(o.$$.fragment,b),g=!0)},o(b){c(i.$$.fragment,b),c(o.$$.fragment,b),g=!1},d(b){b&&l(y),M(i,b),M(o,b)}}}function Eo(J){let i,y="Quantizing a model in 8-bit halves the memory-usage, and for large models, set <code>device_map=&quot;auto&quot;</code> to efficiently use the GPUs available:",o,g,b,T,j="By default, all the other modules such as <code>torch.nn.LayerNorm</code> are converted to <code>torch.float16</code>. You can change the data type of these modules with the <code>torch_dtype</code> parameter if you want:",C,$,Z,G,_='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.41.0/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,v,z;return g=new w({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}}),$=new w({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}}),v=new w({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(){i=r("p"),i.innerHTML=y,o=s(),u(g.$$.fragment),b=s(),T=r("p"),T.innerHTML=j,C=s(),u($.$$.fragment),Z=s(),G=r("p"),G.innerHTML=_,k=s(),u(v.$$.fragment)},l(U){i=p(U,"P",{"data-svelte-h":!0}),m(i)!=="svelte-1dz8xeq"&&(i.innerHTML=y),o=n(U),d(g.$$.fragment,U),b=n(U),T=p(U,"P",{"data-svelte-h":!0}),m(T)!=="svelte-kfzkum"&&(T.innerHTML=j),C=n(U),d($.$$.fragment,U),Z=n(U),G=p(U,"P",{"data-svelte-h":!0}),m(G)!=="svelte-8zpsnd"&&(G.innerHTML=_),k=n(U),d(v.$$.fragment,U)},m(U,Q){a(U,i,Q),a(U,o,Q),f(g,U,Q),a(U,b,Q),a(U,T,Q),a(U,C,Q),f($,U,Q),a(U,Z,Q),a(U,G,Q),a(U,k,Q),f(v,U,Q),z=!0},p:I,i(U){z||(h(g.$$.fragment,U),h($.$$.fragment,U),h(v.$$.fragment,U),z=!0)},o(U){c(g.$$.fragment,U),c($.$$.fragment,U),c(v.$$.fragment,U),z=!1},d(U){U&&(l(i),l(o),l(b),l(T),l(C),l(Z),l(G),l(k)),M(g,U),M($,U),M(v,U)}}}function No(J){let i,y="Quantizing a model in 4-bit reduces your memory-usage by 4x, and for large models, set <code>device_map=&quot;auto&quot;</code> to efficiently use the GPUs available:",o,g,b,T,j="By default, all the other modules such as <code>torch.nn.LayerNorm</code> are converted to <code>torch.float16</code>. You can change the data type of these modules with the <code>torch_dtype</code> parameter if you want:",C,$,Z,G,_="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 g=new w({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}}),$=new w({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(){i=r("p"),i.innerHTML=y,o=s(),u(g.$$.fragment),b=s(),T=r("p"),T.innerHTML=j,C=s(),u($.$$.fragment),Z=s(),G=r("p"),G.innerHTML=_},l(v){i=p(v,"P",{"data-svelte-h":!0}),m(i)!=="svelte-1b6jp1p"&&(i.innerHTML=y),o=n(v),d(g.$$.fragment,v),b=n(v),T=p(v,"P",{"data-svelte-h":!0}),m(T)!=="svelte-kfzkum"&&(T.innerHTML=j),C=n(v),d($.$$.fragment,v),Z=n(v),G=p(v,"P",{"data-svelte-h":!0}),m(G)!=="svelte-1pmx2wb"&&(G.innerHTML=_)},m(v,z){a(v,i,z),a(v,o,z),f(g,v,z),a(v,b,z),a(v,T,z),a(v,C,z),f($,v,z),a(v,Z,z),a(v,G,z),k=!0},p:I,i(v){k||(h(g.$$.fragment,v),h($.$$.fragment,v),k=!0)},o(v){c(g.$$.fragment,v),c($.$$.fragment,v),k=!1},d(v){v&&(l(i),l(o),l(b),l(T),l(C),l(Z),l(G)),M(g,v),M($,v)}}}function Ho(J){let i,y,o,g;return i=new zl({props:{id:"bnb",option:"8-bit",$$slots:{default:[Eo]},$$scope:{ctx:J}}}),o=new zl({props:{id:"bnb",option:"4-bit",$$slots:{default:[No]},$$scope:{ctx:J}}}),{c(){u(i.$$.fragment),y=s(),u(o.$$.fragment)},l(b){d(i.$$.fragment,b),y=n(b),d(o.$$.fragment,b)},m(b,T){f(i,b,T),a(b,y,T),f(o,b,T),g=!0},p(b,T){const j={};T&2&&(j.$$scope={dirty:T,ctx:b}),i.$set(j);const C={};T&2&&(C.$$scope={dirty:T,ctx:b}),o.$set(C)},i(b){g||(h(i.$$.fragment,b),h(o.$$.fragment,b),g=!0)},o(b){c(i.$$.fragment,b),c(o.$$.fragment,b),g=!1},d(b){b&&l(y),M(i,b),M(o,b)}}}function Lo(J){let i,y="Training with 8-bit and 4-bit weights are only supported for training <em>extra</em> parameters.";return{c(){i=r("p"),i.innerHTML=y},l(o){i=p(o,"P",{"data-svelte-h":!0}),m(i)!=="svelte-of9sym"&&(i.innerHTML=y)},m(o,g){a(o,i,g)},p:I,d(o){o&&l(i)}}}function Ao(J){let i,y='Learn more about the details of 8-bit quantization in this <a href="https://huggingface.co/blog/hf-bitsandbytes-integration" rel="nofollow">blog post</a>!';return{c(){i=r("p"),i.innerHTML=y},l(o){i=p(o,"P",{"data-svelte-h":!0}),m(i)!=="svelte-1bb05fp"&&(i.innerHTML=y)},m(o,g){a(o,i,g)},p:I,d(o){o&&l(i)}}}function Yo(J){let i,y='Try 4-bit quantization in this <a href="https://colab.research.google.com/drive/1ge2F1QSK8Q7h0hn3YKuBCOAS0bK8E0wf" rel="nofollow">notebook</a> and learn more about it’s details in this <a href="https://huggingface.co/blog/4bit-transformers-bitsandbytes" rel="nofollow">blog post</a>.';return{c(){i=r("p"),i.innerHTML=y},l(o){i=p(o,"P",{"data-svelte-h":!0}),m(i)!=="svelte-rme94c"&&(i.innerHTML=y)},m(o,g){a(o,i,g)},p:I,d(o){o&&l(i)}}}function Po(J){let i,y,o,g,b,T,j,C="Quantization techniques focus on representing data with less information while also trying to not lose too much accuracy. This often means converting a data type to represent the same information with fewer bits. For example, if your model weights are stored as 32-bit floating points and they’re quantized to 16-bit floating points, this halves the model size which makes it easier to store and reduces memory-usage. Lower precision can also speedup inference because it takes less time to perform calculations with fewer bits.",$,Z,G="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.",_,k,v,z,U,Q,Il,lt,Qn='<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:',Wl,at,In="<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>",Fl,st,Wn="Before you begin, make sure the following libraries are installed:",Vl,nt,xl,it,Fn='Now you can quantize a model by passing <a href="/docs/transformers/v4.41.0/en/main_classes/quantization#transformers.QuantoConfig">QuantoConfig</a> object in the <a href="/docs/transformers/v4.41.0/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.',Bl,ot,Vn='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.',Xl,rt,Rl,pt,xn="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.",El,mt,Bn='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>',Nl,F,Xn='<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>',Hl,ut,Rn="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).",Ll,dt,Al,ft,En='Try AQLM on <a href="https://colab.research.google.com/drive/1-xZmBRXT5Fm3Ghn4Mwa2KRypORXb855X?usp=sharing" rel="nofollow">Google Colab</a>!',Yl,ht,Nn='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.',Pl,ct,Hn="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):",Sl,Mt,Dl,bt,Ln="The library provides efficient kernels for both GPU and CPU inference and training.",Kl,gt,An='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>.',Ol,yt,ta,Tt,Yn='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.',ea,wt,la,$t,Pn="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:",aa,Jt,Sn="<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>",sa,vt,na,V,ia,Ut,Dn='<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.',oa,jt,Kn='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.',ra,_t,On="Make sure you have autoawq installed:",pa,Ct,ma,qt,ti='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:',ua,Zt,da,kt,ei='A quantized model is loaded with the <a href="/docs/transformers/v4.41.0/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:',fa,Gt,ha,zt,li="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:",ca,Qt,Ma,It,ai='AWQ quantization can also be combined with <a href="perf_infer_gpu_one#flashattention-2">FlashAttention-2</a> to further accelerate inference:',ba,Wt,ga,Ft,ya,Vt,si='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.',Ta,x,wa,B,$a,xt,Ja,Bt,ni="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:",va,Xt,Ua,Rt,ii="Get started by passing an <code>AwqConfig()</code> with <code>version=&quot;exllama&quot;</code>.",ja,Et,_a,X,Ca,Nt,qa,R,Za,Ht,oi='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.',ka,Lt,ri="Before you begin, make sure the following libraries are installed:",Ga,At,za,Yt,pi='To quantize a model (currently only supported for text models), you need to create a <a href="/docs/transformers/v4.41.0/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.',Qa,Pt,Ia,St,mi="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.",Wa,Dt,Fa,Kt,ui='Load a model to quantize and pass the <code>gptq_config</code> to the <a href="/docs/transformers/v4.41.0/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.',Va,Ot,xa,te,di="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):",Ba,ee,Xa,E,Ra,le,fi='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.41.0/en/main_classes/model#transformers.utils.PushToHubMixin.push_to_hub">push_to_hub()</a> method to save the <a href="/docs/transformers/v4.41.0/en/main_classes/quantization#transformers.GPTQConfig">GPTQConfig</a>:',Ea,ae,Na,se,hi='You could also save your quantized model locally with the <a href="/docs/transformers/v4.41.0/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:',Ha,ne,La,ie,ci='Reload a quantized model with the <a href="/docs/transformers/v4.41.0/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.',Aa,oe,Ya,re,Pa,pe,Mi='<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.41.0/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:',Sa,me,Da,N,Ka,ue,bi="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.",Oa,de,ts,fe,es,he,gi='<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.',ls,ce,yi="To use bitsandbytes, make sure you have the following libraries installed:",as,H,ss,Me,Ti='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.41.0/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.',ns,L,is,A,os,be,wi="You can check your memory footprint with the <code>get_memory_footprint</code> method:",rs,ge,ps,ye,$i='Quantized models can be loaded from the <a href="/docs/transformers/v4.41.0/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:',ms,Te,us,we,ds,Y,fs,$e,Ji="This section explores some of the specific features of 8-bit models, such as offloading, outlier thresholds, skipping module conversion, and finetuning.",hs,Je,cs,ve,vi='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.41.0/en/main_classes/quantization#transformers.BitsAndBytesConfig">BitsAndBytesConfig</a>:',Ms,Ue,bs,je,Ui="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:",gs,_e,ys,Ce,ji="Now load your model with the custom <code>device_map</code> and <code>quantization_config</code>:",Ts,qe,ws,Ze,$s,ke,_i="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).",Js,Ge,Ci='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.41.0/en/main_classes/quantization#transformers.BitsAndBytesConfig">BitsAndBytesConfig</a>:',vs,ze,Us,Qe,js,Ie,qi='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.41.0/en/main_classes/quantization#transformers.BitsAndBytesConfig">BitsAndBytesConfig</a>:',_s,We,Cs,Fe,qs,Ve,Zi='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).',Zs,xe,ks,P,Gs,Be,ki="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.",zs,Xe,Qs,Re,Gi='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.41.0/en/main_classes/quantization#transformers.BitsAndBytesConfig">BitsAndBytesConfig</a>:',Is,Ee,Ws,Ne,Fs,He,zi='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.41.0/en/main_classes/quantization#transformers.BitsAndBytesConfig">BitsAndBytesConfig</a>:',Vs,Le,xs,Ae,Qi="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.",Bs,Ye,Xs,Pe,Ii='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.',Rs,Se,Es,De,Ns,Ke,Wi=`Once quantized, you can dequantize the model to the original precision. Note this might result in a small quality loss of the model. Make also sure to have enough GPU RAM to fit the dequantized model.
Below is how to perform dequantization on a 4-bit model using <code>bitsandbytes</code>.`,Hs,Oe,Ls,tl,As,el,Fi='The <a href="https://github.com/NetEase-FuXi/EETQ" rel="nofollow">EETQ</a> library supports int8 per-channel weight-only quantization for NVIDIA GPUS. The high-performance GEMM and GEMV kernels are from FasterTransformer and TensorRT-LLM. It requires no calibration dataset and does not need to pre-quantize your model. Moreover, the accuracy degradation is negligible owing to the per-channel quantization.',Ys,ll,Vi='Make sure you have eetq installed from the <a href="https://github.com/NetEase-FuXi/EETQ/releases" rel="nofollow">relase page</a>',Ps,al,Ss,sl,xi='or via the source code <a href="https://github.com/NetEase-FuXi/EETQ" rel="nofollow">https://github.com/NetEase-FuXi/EETQ</a>. EETQ requires CUDA capability &lt;= 8.9 and &gt;= 7.0',Ds,nl,Ks,il,Bi="An unquantized model can be quantized via “from_pretrained”.",Os,ol,tn,rl,Xi="A quantized model can be saved via “saved_pretrained” and be reused again via the “from_pretrained”.",en,pl,ln,ml,an,ul,Ri='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.',sn,dl,nn,fl,Ei='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.',on,S,Ni='<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>',rn,D,Hi='<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>',pn,hl,Li='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.',mn,cl,un,Ml,Ai='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.',dn,K,Yi="Unfused module",fn,bl,Pi='<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>',hn,O,Si="Fused module",cn,gl,Di='<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>',Mn,yl,Ki='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.',bn,tt,Oi='<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>',gn,Tl,yn,wl,to=`Half-Quadratic Quantization (HQQ) implements on-the-fly quantization via fast robust optimization. It doesn’t require calibration data and can be used to quantize any model.<br/>
Please refer to the <a href="https://github.com/mobiusml/hqq/">official package</a> for more details.`,Tn,$l,eo="For installation, we recommend you use the following approach to get the latest version and build its corresponding CUDA kernels:",wn,Jl,$n,vl,lo='To quantize a model, you need to create an <a href="/docs/transformers/v4.41.0/en/main_classes/quantization#transformers.HqqConfig">HqqConfig</a>. There are two ways of doing it:',Jn,Ul,vn,jl,Un,_l,ao="The second approach is especially interesting for quantizing Mixture-of-Experts (MoEs) because the experts are less affected by lower quantization settings.",jn,Cl,so="Then you simply quantize the model as follows",_n,ql,Cn,Zl,qn,kl,no=`HQQ supports various backends, including pure Pytorch and custom dequantization CUDA kernels. These backends are suitable for older gpus and peft/QLoRA training.
For faster inference, HQQ supports 4-bit fused kernels (TorchAO and Marlin), reaching up to 200 tokens/sec on a single 4090.
For more details on how to use the backends, please refer to <a href="https://github.com/mobiusml/hqq/?tab=readme-ov-file#backend" rel="nofollow">https://github.com/mobiusml/hqq/?tab=readme-ov-file#backend</a>`,Zn,Gl,kn,Ql,Gn;return b=new q({props:{title:"Quantization",local:"quantization",headingTag:"h1"}}),k=new W({props:{$$slots:{default:[qo]},$$scope:{ctx:J}}}),z=new q({props:{title:"Quanto",local:"quanto",headingTag:"h2"}}),Q=new W({props:{$$slots:{default:[Zo]},$$scope:{ctx:J}}}),nt=new w({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 w({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 q({props:{title:"AQLM",local:"aqlm",headingTag:"h2"}}),Mt=new w({props:{code:"cGlwJTIwaW5zdGFsbCUyMGFxbG0lNUJncHUlMkNjcHUlNUQ=",highlighted:"pip install aqlm[gpu,cpu]",wrap:!1}}),yt=new q({props:{title:"PEFT",local:"peft",headingTag:"h3"}}),wt=new q({props:{title:"AQLM configurations",local:"aqlm-configurations",headingTag:"h3"}}),vt=new q({props:{title:"AWQ",local:"awq",headingTag:"h2"}}),V=new W({props:{$$slots:{default:[ko]},$$scope:{ctx:J}}}),Ct=new w({props:{code:"cGlwJTIwaW5zdGFsbCUyMGF1dG9hd3E=",highlighted:"pip install autoawq",wrap:!1}}),Zt=new w({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 w({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}}),Qt=new w({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 w({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}}),Ft=new q({props:{title:"Fused modules",local:"fused-modules",headingTag:"h3"}}),x=new W({props:{warning:!0,$$slots:{default:[Go]},$$scope:{ctx:J}}}),B=new zn({props:{id:"fuse",options:["supported architectures","unsupported architectures"],$$slots:{default:[Io]},$$scope:{ctx:J}}}),xt=new q({props:{title:"Exllama-v2 support",local:"exllama-v2-support",headingTag:"h3"}}),Xt=new w({props:{code:"cGlwJTIwaW5zdGFsbCUyMGdpdCUyQmh0dHBzJTNBJTJGJTJGZ2l0aHViLmNvbSUyRmNhc3Blci1oYW5zZW4lMkZBdXRvQVdRLmdpdA==",highlighted:"pip install git+https://github.com/casper-hansen/AutoAWQ.git",wrap:!1}}),Et=new w({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}}),X=new W({props:{warning:!0,$$slots:{default:[Wo]},$$scope:{ctx:J}}}),Nt=new q({props:{title:"AutoGPTQ",local:"autogptq",headingTag:"h2"}}),R=new W({props:{$$slots:{default:[Fo]},$$scope:{ctx:J}}}),At=new w({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 w({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 w({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 w({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 w({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}}),E=new W({props:{warning:!0,$$slots:{default:[Vo]},$$scope:{ctx:J}}}),ae=new w({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}}),ne=new w({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 w({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 q({props:{title:"ExLlama",local:"exllama",headingTag:"h3"}}),me=new w({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:[xo]},$$scope:{ctx:J}}}),de=new w({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 q({props:{title:"bitsandbytes",local:"bitsandbytes",headingTag:"h2"}}),H=new zn({props:{id:"bnb",options:["8-bit","4-bit"],$$slots:{default:[Ro]},$$scope:{ctx:J}}}),L=new zn({props:{id:"bnb",options:["8-bit","4-bit"],$$slots:{default:[Ho]},$$scope:{ctx:J}}}),A=new W({props:{warning:!0,$$slots:{default:[Lo]},$$scope:{ctx:J}}}),ge=new w({props:{code:"cHJpbnQobW9kZWwuZ2V0X21lbW9yeV9mb290cHJpbnQoKSk=",highlighted:'<span class="hljs-built_in">print</span>(model.get_memory_footprint())',wrap:!1}}),Te=new w({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 q({props:{title:"8-bit",local:"8-bit",headingTag:"h3"}}),Y=new W({props:{$$slots:{default:[Ao]},$$scope:{ctx:J}}}),Je=new q({props:{title:"Offloading",local:"offloading",headingTag:"h4"}}),Ue=new w({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}}),_e=new w({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 w({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}}),Ze=new q({props:{title:"Outlier threshold",local:"outlier-threshold",headingTag:"h4"}}),ze=new w({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}}),Qe=new q({props:{title:"Skip module conversion",local:"skip-module-conversion",headingTag:"h4"}}),We=new w({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}}),Fe=new q({props:{title:"Finetuning",local:"finetuning",headingTag:"h4"}}),xe=new q({props:{title:"4-bit",local:"4-bit",headingTag:"h3"}}),P=new W({props:{$$slots:{default:[Yo]},$$scope:{ctx:J}}}),Xe=new q({props:{title:"Compute data type",local:"compute-data-type",headingTag:"h4"}}),Ee=new w({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 q({props:{title:"Normal Float 4 (NF4)",local:"normal-float-4-nf4",headingTag:"h4"}}),Le=new w({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 q({props:{title:"Nested quantization",local:"nested-quantization",headingTag:"h4"}}),Se=new w({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 q({props:{title:"Dequantizing bitsandbytes models",local:"dequantizing-bitsandbytes-models",headingTag:"h3"}}),Oe=new w({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvckNhdXNhbExNJTJDJTIwQml0c0FuZEJ5dGVzQ29uZmlnJTJDJTIwQXV0b1Rva2VuaXplciUwQSUwQW1vZGVsX2lkJTIwJTNEJTIwJTIyZmFjZWJvb2slMkZvcHQtMTI1bSUyMiUwQSUwQW1vZGVsJTIwJTNEJTIwQXV0b01vZGVsRm9yQ2F1c2FsTE0uZnJvbV9wcmV0cmFpbmVkKG1vZGVsX2lkJTJDJTIwQml0c0FuZEJ5dGVzQ29uZmlnKGxvYWRfaW5fNGJpdCUzRFRydWUpKSUwQXRva2VuaXplciUyMCUzRCUyMEF1dG9Ub2tlbml6ZXIuZnJvbV9wcmV0cmFpbmVkKG1vZGVsX2lkKSUwQSUwQW1vZGVsLmRlcXVhbnRpemUoKSUwQSUwQXRleHQlMjAlM0QlMjB0b2tlbml6ZXIoJTIySGVsbG8lMjBteSUyMG5hbWUlMjBpcyUyMiUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIpLnRvKDApJTBBJTBBb3V0JTIwJTNEJTIwbW9kZWwuZ2VuZXJhdGUoKip0ZXh0KSUwQXByaW50KHRva2VuaXplci5kZWNvZGUob3V0JTVCMCU1RCkp",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForCausalLM, BitsAndBytesConfig, AutoTokenizer

model_id = <span class="hljs-string">&quot;facebook/opt-125m&quot;</span>

model = AutoModelForCausalLM.from_pretrained(model_id, BitsAndBytesConfig(load_in_4bit=<span class="hljs-literal">True</span>))
tokenizer = AutoTokenizer.from_pretrained(model_id)

model.dequantize()

text = tokenizer(<span class="hljs-string">&quot;Hello my name is&quot;</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>).to(<span class="hljs-number">0</span>)

out = model.generate(**text)
<span class="hljs-built_in">print</span>(tokenizer.decode(out[<span class="hljs-number">0</span>]))`,wrap:!1}}),tl=new q({props:{title:"EETQ",local:"eetq",headingTag:"h2"}}),al=new w({props:{code:"cGlwJTIwaW5zdGFsbCUyMC0tbm8tY2FjaGUtZGlyJTIwaHR0cHMlM0ElMkYlMkZnaXRodWIuY29tJTJGTmV0RWFzZS1GdVhpJTJGRUVUUSUyRnJlbGVhc2VzJTJGZG93bmxvYWQlMkZ2MS4wLjAlMkZFRVRRLTEuMC4wJTJCY3UxMjElMkJ0b3JjaDIuMS4yLWNwMzEwLWNwMzEwLWxpbnV4X3g4Nl82NC53aGw=",highlighted:'pip install --no-cache-dir https:<span class="hljs-regexp">//gi</span>thub.com<span class="hljs-regexp">/NetEase-FuXi/</span>EETQ<span class="hljs-regexp">/releases/</span>download<span class="hljs-regexp">/v1.0.0/</span>EETQ-<span class="hljs-number">1.0</span>.<span class="hljs-number">0</span>+cu121+torch2.<span class="hljs-number">1.2</span>-cp310-cp310-linux_x86_64.whl',wrap:!1}}),nl=new w({props:{code:"Z2l0JTIwY2xvbmUlMjBodHRwcyUzQSUyRiUyRmdpdGh1Yi5jb20lMkZOZXRFYXNlLUZ1WGklMkZFRVRRLmdpdCUwQWNkJTIwRUVUUSUyRiUwQWdpdCUyMHN1Ym1vZHVsZSUyMHVwZGF0ZSUyMC0taW5pdCUyMC0tcmVjdXJzaXZlJTBBcGlwJTIwaW5zdGFsbCUyMC4=",highlighted:`git clone https:<span class="hljs-regexp">//gi</span>thub.com<span class="hljs-regexp">/NetEase-FuXi/</span>EETQ.git
cd EETQ/
git submodule update --init --recursive
pip install .`,wrap:!1}}),ol=new w({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvckNhdXNhbExNJTJDJTIwRWV0cUNvbmZpZyUwQXBhdGglMjAlM0QlMjAlMjIlMkZwYXRoJTJGdG8lMkZtb2RlbCUyMiUwQXF1YW50aXphdGlvbl9jb25maWclMjAlM0QlMjBFZXRxQ29uZmlnKCUyMmludDglMjIpJTBBbW9kZWwlMjAlM0QlMjBBdXRvTW9kZWxGb3JDYXVzYWxMTS5mcm9tX3ByZXRyYWluZWQocGF0aCUyQyUyMGRldmljZV9tYXAlM0QlMjJhdXRvJTIyJTJDJTIwcXVhbnRpemF0aW9uX2NvbmZpZyUzRHF1YW50aXphdGlvbl9jb25maWcp",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForCausalLM, EetqConfig
path = <span class="hljs-string">&quot;/path/to/model&quot;</span>
quantization_config = EetqConfig(<span class="hljs-string">&quot;int8&quot;</span>)
model = AutoModelForCausalLM.from_pretrained(path, device_map=<span class="hljs-string">&quot;auto&quot;</span>, quantization_config=quantization_config)`,wrap:!1}}),pl=new w({props:{code:"cXVhbnRfcGF0aCUyMCUzRCUyMCUyMiUyRnBhdGglMkZ0byUyRnNhdmUlMkZxdWFudGl6ZWQlMkZtb2RlbCUyMiUwQW1vZGVsLnNhdmVfcHJldHJhaW5lZChxdWFudF9wYXRoKSUwQW1vZGVsJTIwJTNEJTIwQXV0b01vZGVsRm9yQ2F1c2FsTE0uZnJvbV9wcmV0cmFpbmVkKHF1YW50X3BhdGglMkMlMjBkZXZpY2VfbWFwJTNEJTIyYXV0byUyMik=",highlighted:`quant_path = <span class="hljs-string">&quot;/path/to/save/quantized/model&quot;</span>
model.save_pretrained(quant_path)
model = AutoModelForCausalLM.from_pretrained(quant_path, device_map=<span class="hljs-string">&quot;auto&quot;</span>)`,wrap:!1}}),ml=new q({props:{title:"Optimum",local:"optimum",headingTag:"h2"}}),dl=new q({props:{title:"Benchmarks",local:"benchmarks",headingTag:"h2"}}),cl=new q({props:{title:"Fused AWQ modules",local:"fused-awq-modules",headingTag:"h3"}}),Tl=new q({props:{title:"HQQ",local:"hqq",headingTag:"h2"}}),Jl=new w({props:{code:"cGlwJTIwaW5zdGFsbCUyMGhxcQ==",highlighted:'pip <span class="hljs-keyword">install</span> hqq',wrap:!1}}),Ul=new w({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvckNhdXNhbExNJTJDJTIwQXV0b1Rva2VuaXplciUyQyUyMEhxcUNvbmZpZyUwQSUwQSUyMyUyME1ldGhvZCUyMDElM0ElMjBhbGwlMjBsaW5lYXIlMjBsYXllcnMlMjB3aWxsJTIwdXNlJTIwdGhlJTIwc2FtZSUyMHF1YW50aXphdGlvbiUyMGNvbmZpZyUwQXF1YW50X2NvbmZpZyUyMCUyMCUzRCUyMEhxcUNvbmZpZyhuYml0cyUzRDglMkMlMjBncm91cF9zaXplJTNENjQlMkMlMjBxdWFudF96ZXJvJTNERmFsc2UlMkMlMjBxdWFudF9zY2FsZSUzREZhbHNlJTJDJTIwYXhpcyUzRDApJTIwJTIzYXhpcyUzRDAlMjBpcyUyMHVzZWQlMjBieSUyMGRlZmF1bHQ=",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForCausalLM, AutoTokenizer, HqqConfig

<span class="hljs-comment"># Method 1: all linear layers will use the same quantization config</span>
quant_config  = HqqConfig(nbits=<span class="hljs-number">8</span>, group_size=<span class="hljs-number">64</span>, quant_zero=<span class="hljs-literal">False</span>, quant_scale=<span class="hljs-literal">False</span>, axis=<span class="hljs-number">0</span>) <span class="hljs-comment">#axis=0 is used by default</span>`,wrap:!1}}),jl=new w({props:{code:"JTIzJTIwTWV0aG9kJTIwMiUzQSUyMGVhY2glMjBsaW5lYXIlMjBsYXllciUyMHdpdGglMjB0aGUlMjBzYW1lJTIwdGFnJTIwd2lsbCUyMHVzZSUyMGElMjBkZWRpY2F0ZWQlMjBxdWFudGl6YXRpb24lMjBjb25maWclMEFxNF9jb25maWclMjAlM0QlMjAlN0InbmJpdHMnJTNBNCUyQyUyMCdncm91cF9zaXplJyUzQTY0JTJDJTIwJ3F1YW50X3plcm8nJTNBRmFsc2UlMkMlMjAncXVhbnRfc2NhbGUnJTNBRmFsc2UlN0QlMEFxM19jb25maWclMjAlM0QlMjAlN0InbmJpdHMnJTNBMyUyQyUyMCdncm91cF9zaXplJyUzQTMyJTJDJTIwJ3F1YW50X3plcm8nJTNBRmFsc2UlMkMlMjAncXVhbnRfc2NhbGUnJTNBRmFsc2UlN0QlMEFxdWFudF9jb25maWclMjAlMjAlM0QlMjBIcXFDb25maWcoZHluYW1pY19jb25maWclM0QlN0IlMEElMjAlMjAnc2VsZl9hdHRuLnFfcHJvaiclM0FxNF9jb25maWclMkMlMEElMjAlMjAnc2VsZl9hdHRuLmtfcHJvaiclM0FxNF9jb25maWclMkMlMEElMjAlMjAnc2VsZl9hdHRuLnZfcHJvaiclM0FxNF9jb25maWclMkMlMEElMjAlMjAnc2VsZl9hdHRuLm9fcHJvaiclM0FxNF9jb25maWclMkMlMEElMEElMjAlMjAnbWxwLmdhdGVfcHJvaiclM0FxM19jb25maWclMkMlMEElMjAlMjAnbWxwLnVwX3Byb2onJTIwJTIwJTNBcTNfY29uZmlnJTJDJTBBJTIwJTIwJ21scC5kb3duX3Byb2onJTNBcTNfY29uZmlnJTJDJTBBJTdEKQ==",highlighted:`<span class="hljs-comment"># Method 2: each linear layer with the same tag will use a dedicated quantization config</span>
q4_config = {<span class="hljs-string">&#x27;nbits&#x27;</span>:<span class="hljs-number">4</span>, <span class="hljs-string">&#x27;group_size&#x27;</span>:<span class="hljs-number">64</span>, <span class="hljs-string">&#x27;quant_zero&#x27;</span>:<span class="hljs-literal">False</span>, <span class="hljs-string">&#x27;quant_scale&#x27;</span>:<span class="hljs-literal">False</span>}
q3_config = {<span class="hljs-string">&#x27;nbits&#x27;</span>:<span class="hljs-number">3</span>, <span class="hljs-string">&#x27;group_size&#x27;</span>:<span class="hljs-number">32</span>, <span class="hljs-string">&#x27;quant_zero&#x27;</span>:<span class="hljs-literal">False</span>, <span class="hljs-string">&#x27;quant_scale&#x27;</span>:<span class="hljs-literal">False</span>}
quant_config  = HqqConfig(dynamic_config={
  <span class="hljs-string">&#x27;self_attn.q_proj&#x27;</span>:q4_config,
  <span class="hljs-string">&#x27;self_attn.k_proj&#x27;</span>:q4_config,
  <span class="hljs-string">&#x27;self_attn.v_proj&#x27;</span>:q4_config,
  <span class="hljs-string">&#x27;self_attn.o_proj&#x27;</span>:q4_config,

  <span class="hljs-string">&#x27;mlp.gate_proj&#x27;</span>:q3_config,
  <span class="hljs-string">&#x27;mlp.up_proj&#x27;</span>  :q3_config,
  <span class="hljs-string">&#x27;mlp.down_proj&#x27;</span>:q3_config,
})`,wrap:!1}}),ql=new w({props:{code:"bW9kZWwlMjAlM0QlMjB0cmFuc2Zvcm1lcnMuQXV0b01vZGVsRm9yQ2F1c2FsTE0uZnJvbV9wcmV0cmFpbmVkKCUwQSUyMCUyMCUyMCUyMG1vZGVsX2lkJTJDJTIwJTBBJTIwJTIwJTIwJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5mbG9hdDE2JTJDJTIwJTBBJTIwJTIwJTIwJTIwZGV2aWNlX21hcCUzRCUyMmN1ZGElMjIlMkMlMjAlMEElMjAlMjAlMjAlMjBxdWFudGl6YXRpb25fY29uZmlnJTNEcXVhbnRfY29uZmlnJTBBKQ==",highlighted:`model = transformers.AutoModelForCausalLM.from_pretrained(
    model_id, 
    torch_dtype=torch.float16, 
    device_map=<span class="hljs-string">&quot;cuda&quot;</span>, 
    quantization_config=quant_config
)`,wrap:!1}}),Zl=new q({props:{title:"Optimized Runtime",local:"optimized-runtime",headingTag:"h3"}}),Gl=new Co({props:{source:"https://github.com/huggingface/transformers/blob/main/docs/source/en/quantization.md"}}),{c(){i=r("meta"),y=s(),o=r("p"),g=s(),u(b.$$.fragment),T=s(),j=r("p"),j.textContent=C,$=s(),Z=r("p"),Z.textContent=G,_=s(),u(k.$$.fragment),v=s(),u(z.$$.fragment),U=s(),u(Q.$$.fragment),Il=s(),lt=r("p"),lt.innerHTML=Qn,Wl=s(),at=r("ul"),at.innerHTML=In,Fl=s(),st=r("p"),st.textContent=Wn,Vl=s(),u(nt.$$.fragment),xl=s(),it=r("p"),it.innerHTML=Fn,Bl=s(),ot=r("p"),ot.innerHTML=Vn,Xl=s(),u(rt.$$.fragment),Rl=s(),pt=r("p"),pt.textContent=xn,El=s(),mt=r("p"),mt.innerHTML=Bn,Nl=s(),F=r("div"),F.innerHTML=Xn,Hl=s(),ut=r("p"),ut.textContent=Rn,Ll=s(),u(dt.$$.fragment),Al=s(),ft=r("p"),ft.innerHTML=En,Yl=s(),ht=r("p"),ht.innerHTML=Nn,Pl=s(),ct=r("p"),ct.innerHTML=Hn,Sl=s(),u(Mt.$$.fragment),Dl=s(),bt=r("p"),bt.textContent=Ln,Kl=s(),gt=r("p"),gt.innerHTML=An,Ol=s(),u(yt.$$.fragment),ta=s(),Tt=r("p"),Tt.innerHTML=Yn,ea=s(),u(wt.$$.fragment),la=s(),$t=r("p"),$t.textContent=Pn,aa=s(),Jt=r("table"),Jt.innerHTML=Sn,sa=s(),u(vt.$$.fragment),na=s(),u(V.$$.fragment),ia=s(),Ut=r("p"),Ut.innerHTML=Dn,oa=s(),jt=r("p"),jt.innerHTML=Kn,ra=s(),_t=r("p"),_t.textContent=On,pa=s(),u(Ct.$$.fragment),ma=s(),qt=r("p"),qt.innerHTML=ti,ua=s(),u(Zt.$$.fragment),da=s(),kt=r("p"),kt.innerHTML=ei,fa=s(),u(Gt.$$.fragment),ha=s(),zt=r("p"),zt.innerHTML=li,ca=s(),u(Qt.$$.fragment),Ma=s(),It=r("p"),It.innerHTML=ai,ba=s(),u(Wt.$$.fragment),ga=s(),u(Ft.$$.fragment),ya=s(),Vt=r("p"),Vt.innerHTML=si,Ta=s(),u(x.$$.fragment),wa=s(),u(B.$$.fragment),$a=s(),u(xt.$$.fragment),Ja=s(),Bt=r("p"),Bt.innerHTML=ni,va=s(),u(Xt.$$.fragment),Ua=s(),Rt=r("p"),Rt.innerHTML=ii,ja=s(),u(Et.$$.fragment),_a=s(),u(X.$$.fragment),Ca=s(),u(Nt.$$.fragment),qa=s(),u(R.$$.fragment),Za=s(),Ht=r("p"),Ht.innerHTML=oi,ka=s(),Lt=r("p"),Lt.textContent=ri,Ga=s(),u(At.$$.fragment),za=s(),Yt=r("p"),Yt.innerHTML=pi,Qa=s(),u(Pt.$$.fragment),Ia=s(),St=r("p"),St.textContent=mi,Wa=s(),u(Dt.$$.fragment),Fa=s(),Kt=r("p"),Kt.innerHTML=ui,Va=s(),u(Ot.$$.fragment),xa=s(),te=r("p"),te.innerHTML=di,Ba=s(),u(ee.$$.fragment),Xa=s(),u(E.$$.fragment),Ra=s(),le=r("p"),le.innerHTML=fi,Ea=s(),u(ae.$$.fragment),Na=s(),se=r("p"),se.innerHTML=hi,Ha=s(),u(ne.$$.fragment),La=s(),ie=r("p"),ie.innerHTML=ci,Aa=s(),u(oe.$$.fragment),Ya=s(),u(re.$$.fragment),Pa=s(),pe=r("p"),pe.innerHTML=Mi,Sa=s(),u(me.$$.fragment),Da=s(),u(N.$$.fragment),Ka=s(),ue=r("p"),ue.textContent=bi,Oa=s(),u(de.$$.fragment),ts=s(),u(fe.$$.fragment),es=s(),he=r("p"),he.innerHTML=gi,ls=s(),ce=r("p"),ce.textContent=yi,as=s(),u(H.$$.fragment),ss=s(),Me=r("p"),Me.innerHTML=Ti,ns=s(),u(L.$$.fragment),is=s(),u(A.$$.fragment),os=s(),be=r("p"),be.innerHTML=wi,rs=s(),u(ge.$$.fragment),ps=s(),ye=r("p"),ye.innerHTML=$i,ms=s(),u(Te.$$.fragment),us=s(),u(we.$$.fragment),ds=s(),u(Y.$$.fragment),fs=s(),$e=r("p"),$e.textContent=Ji,hs=s(),u(Je.$$.fragment),cs=s(),ve=r("p"),ve.innerHTML=vi,Ms=s(),u(Ue.$$.fragment),bs=s(),je=r("p"),je.innerHTML=Ui,gs=s(),u(_e.$$.fragment),ys=s(),Ce=r("p"),Ce.innerHTML=ji,Ts=s(),u(qe.$$.fragment),ws=s(),u(Ze.$$.fragment),$s=s(),ke=r("p"),ke.textContent=_i,Js=s(),Ge=r("p"),Ge.innerHTML=Ci,vs=s(),u(ze.$$.fragment),Us=s(),u(Qe.$$.fragment),js=s(),Ie=r("p"),Ie.innerHTML=qi,_s=s(),u(We.$$.fragment),Cs=s(),u(Fe.$$.fragment),qs=s(),Ve=r("p"),Ve.innerHTML=Zi,Zs=s(),u(xe.$$.fragment),ks=s(),u(P.$$.fragment),Gs=s(),Be=r("p"),Be.textContent=ki,zs=s(),u(Xe.$$.fragment),Qs=s(),Re=r("p"),Re.innerHTML=Gi,Is=s(),u(Ee.$$.fragment),Ws=s(),u(Ne.$$.fragment),Fs=s(),He=r("p"),He.innerHTML=zi,Vs=s(),u(Le.$$.fragment),xs=s(),Ae=r("p"),Ae.innerHTML=Qi,Bs=s(),u(Ye.$$.fragment),Xs=s(),Pe=r("p"),Pe.innerHTML=Ii,Rs=s(),u(Se.$$.fragment),Es=s(),u(De.$$.fragment),Ns=s(),Ke=r("p"),Ke.innerHTML=Wi,Hs=s(),u(Oe.$$.fragment),Ls=s(),u(tl.$$.fragment),As=s(),el=r("p"),el.innerHTML=Fi,Ys=s(),ll=r("p"),ll.innerHTML=Vi,Ps=s(),u(al.$$.fragment),Ss=s(),sl=r("p"),sl.innerHTML=xi,Ds=s(),u(nl.$$.fragment),Ks=s(),il=r("p"),il.textContent=Bi,Os=s(),u(ol.$$.fragment),tn=s(),rl=r("p"),rl.textContent=Xi,en=s(),u(pl.$$.fragment),ln=s(),u(ml.$$.fragment),an=s(),ul=r("p"),ul.innerHTML=Ri,sn=s(),u(dl.$$.fragment),nn=s(),fl=r("p"),fl.innerHTML=Ei,on=s(),S=r("div"),S.innerHTML=Ni,rn=s(),D=r("div"),D.innerHTML=Hi,pn=s(),hl=r("p"),hl.innerHTML=Li,mn=s(),u(cl.$$.fragment),un=s(),Ml=r("p"),Ml.innerHTML=Ai,dn=s(),K=r("figcaption"),K.textContent=Yi,fn=s(),bl=r("table"),bl.innerHTML=Pi,hn=s(),O=r("figcaption"),O.textContent=Si,cn=s(),gl=r("table"),gl.innerHTML=Di,Mn=s(),yl=r("p"),yl.innerHTML=Ki,bn=s(),tt=r("div"),tt.innerHTML=Oi,gn=s(),u(Tl.$$.fragment),yn=s(),wl=r("p"),wl.innerHTML=to,Tn=s(),$l=r("p"),$l.textContent=eo,wn=s(),u(Jl.$$.fragment),$n=s(),vl=r("p"),vl.innerHTML=lo,Jn=s(),u(Ul.$$.fragment),vn=s(),u(jl.$$.fragment),Un=s(),_l=r("p"),_l.textContent=ao,jn=s(),Cl=r("p"),Cl.textContent=so,_n=s(),u(ql.$$.fragment),Cn=s(),u(Zl.$$.fragment),qn=s(),kl=r("p"),kl.innerHTML=no,Zn=s(),u(Gl.$$.fragment),kn=s(),Ql=r("p"),this.h()},l(t){const e=jo("svelte-u9bgzb",document.head);i=p(e,"META",{name:!0,content:!0}),e.forEach(l),y=n(t),o=p(t,"P",{}),wo(o).forEach(l),g=n(t),d(b.$$.fragment,t),T=n(t),j=p(t,"P",{"data-svelte-h":!0}),m(j)!=="svelte-1euzkei"&&(j.textContent=C),$=n(t),Z=p(t,"P",{"data-svelte-h":!0}),m(Z)!=="svelte-1f5pv07"&&(Z.textContent=G),_=n(t),d(k.$$.fragment,t),v=n(t),d(z.$$.fragment,t),U=n(t),d(Q.$$.fragment,t),Il=n(t),lt=p(t,"P",{"data-svelte-h":!0}),m(lt)!=="svelte-1uxysak"&&(lt.innerHTML=Qn),Wl=n(t),at=p(t,"UL",{"data-svelte-h":!0}),m(at)!=="svelte-1rrl1p8"&&(at.innerHTML=In),Fl=n(t),st=p(t,"P",{"data-svelte-h":!0}),m(st)!=="svelte-13c61n1"&&(st.textContent=Wn),Vl=n(t),d(nt.$$.fragment,t),xl=n(t),it=p(t,"P",{"data-svelte-h":!0}),m(it)!=="svelte-crctnq"&&(it.innerHTML=Fn),Bl=n(t),ot=p(t,"P",{"data-svelte-h":!0}),m(ot)!=="svelte-acy0np"&&(ot.innerHTML=Vn),Xl=n(t),d(rt.$$.fragment,t),Rl=n(t),pt=p(t,"P",{"data-svelte-h":!0}),m(pt)!=="svelte-1sscg20"&&(pt.textContent=xn),El=n(t),mt=p(t,"P",{"data-svelte-h":!0}),m(mt)!=="svelte-1woqmtc"&&(mt.innerHTML=Bn),Nl=n(t),F=p(t,"DIV",{class:!0,"data-svelte-h":!0}),m(F)!=="svelte-196rp13"&&(F.innerHTML=Xn),Hl=n(t),ut=p(t,"P",{"data-svelte-h":!0}),m(ut)!=="svelte-5v5thh"&&(ut.textContent=Rn),Ll=n(t),d(dt.$$.fragment,t),Al=n(t),ft=p(t,"P",{"data-svelte-h":!0}),m(ft)!=="svelte-vu1jh7"&&(ft.innerHTML=En),Yl=n(t),ht=p(t,"P",{"data-svelte-h":!0}),m(ht)!=="svelte-11fbd25"&&(ht.innerHTML=Nn),Pl=n(t),ct=p(t,"P",{"data-svelte-h":!0}),m(ct)!=="svelte-1rdkef8"&&(ct.innerHTML=Hn),Sl=n(t),d(Mt.$$.fragment,t),Dl=n(t),bt=p(t,"P",{"data-svelte-h":!0}),m(bt)!=="svelte-6sf1ac"&&(bt.textContent=Ln),Kl=n(t),gt=p(t,"P",{"data-svelte-h":!0}),m(gt)!=="svelte-mrigan"&&(gt.innerHTML=An),Ol=n(t),d(yt.$$.fragment,t),ta=n(t),Tt=p(t,"P",{"data-svelte-h":!0}),m(Tt)!=="svelte-1uurbap"&&(Tt.innerHTML=Yn),ea=n(t),d(wt.$$.fragment,t),la=n(t),$t=p(t,"P",{"data-svelte-h":!0}),m($t)!=="svelte-1ouechy"&&($t.textContent=Pn),aa=n(t),Jt=p(t,"TABLE",{"data-svelte-h":!0}),m(Jt)!=="svelte-mgp7ro"&&(Jt.innerHTML=Sn),sa=n(t),d(vt.$$.fragment,t),na=n(t),d(V.$$.fragment,t),ia=n(t),Ut=p(t,"P",{"data-svelte-h":!0}),m(Ut)!=="svelte-1c5vyni"&&(Ut.innerHTML=Dn),oa=n(t),jt=p(t,"P",{"data-svelte-h":!0}),m(jt)!=="svelte-vomabp"&&(jt.innerHTML=Kn),ra=n(t),_t=p(t,"P",{"data-svelte-h":!0}),m(_t)!=="svelte-1ozln1k"&&(_t.textContent=On),pa=n(t),d(Ct.$$.fragment,t),ma=n(t),qt=p(t,"P",{"data-svelte-h":!0}),m(qt)!=="svelte-1lxz9t"&&(qt.innerHTML=ti),ua=n(t),d(Zt.$$.fragment,t),da=n(t),kt=p(t,"P",{"data-svelte-h":!0}),m(kt)!=="svelte-14n2qi5"&&(kt.innerHTML=ei),fa=n(t),d(Gt.$$.fragment,t),ha=n(t),zt=p(t,"P",{"data-svelte-h":!0}),m(zt)!=="svelte-19un5li"&&(zt.innerHTML=li),ca=n(t),d(Qt.$$.fragment,t),Ma=n(t),It=p(t,"P",{"data-svelte-h":!0}),m(It)!=="svelte-ptrt24"&&(It.innerHTML=ai),ba=n(t),d(Wt.$$.fragment,t),ga=n(t),d(Ft.$$.fragment,t),ya=n(t),Vt=p(t,"P",{"data-svelte-h":!0}),m(Vt)!=="svelte-jywid1"&&(Vt.innerHTML=si),Ta=n(t),d(x.$$.fragment,t),wa=n(t),d(B.$$.fragment,t),$a=n(t),d(xt.$$.fragment,t),Ja=n(t),Bt=p(t,"P",{"data-svelte-h":!0}),m(Bt)!=="svelte-1fw2pai"&&(Bt.innerHTML=ni),va=n(t),d(Xt.$$.fragment,t),Ua=n(t),Rt=p(t,"P",{"data-svelte-h":!0}),m(Rt)!=="svelte-in32kr"&&(Rt.innerHTML=ii),ja=n(t),d(Et.$$.fragment,t),_a=n(t),d(X.$$.fragment,t),Ca=n(t),d(Nt.$$.fragment,t),qa=n(t),d(R.$$.fragment,t),Za=n(t),Ht=p(t,"P",{"data-svelte-h":!0}),m(Ht)!=="svelte-sq0x7n"&&(Ht.innerHTML=oi),ka=n(t),Lt=p(t,"P",{"data-svelte-h":!0}),m(Lt)!=="svelte-13c61n1"&&(Lt.textContent=ri),Ga=n(t),d(At.$$.fragment,t),za=n(t),Yt=p(t,"P",{"data-svelte-h":!0}),m(Yt)!=="svelte-1a7q5b4"&&(Yt.innerHTML=pi),Qa=n(t),d(Pt.$$.fragment,t),Ia=n(t),St=p(t,"P",{"data-svelte-h":!0}),m(St)!=="svelte-1cjo88z"&&(St.textContent=mi),Wa=n(t),d(Dt.$$.fragment,t),Fa=n(t),Kt=p(t,"P",{"data-svelte-h":!0}),m(Kt)!=="svelte-1c9ufch"&&(Kt.innerHTML=ui),Va=n(t),d(Ot.$$.fragment,t),xa=n(t),te=p(t,"P",{"data-svelte-h":!0}),m(te)!=="svelte-1tle3a0"&&(te.innerHTML=di),Ba=n(t),d(ee.$$.fragment,t),Xa=n(t),d(E.$$.fragment,t),Ra=n(t),le=p(t,"P",{"data-svelte-h":!0}),m(le)!=="svelte-77ai8g"&&(le.innerHTML=fi),Ea=n(t),d(ae.$$.fragment,t),Na=n(t),se=p(t,"P",{"data-svelte-h":!0}),m(se)!=="svelte-jpnmxs"&&(se.innerHTML=hi),Ha=n(t),d(ne.$$.fragment,t),La=n(t),ie=p(t,"P",{"data-svelte-h":!0}),m(ie)!=="svelte-5z5zum"&&(ie.innerHTML=ci),Aa=n(t),d(oe.$$.fragment,t),Ya=n(t),d(re.$$.fragment,t),Pa=n(t),pe=p(t,"P",{"data-svelte-h":!0}),m(pe)!=="svelte-15zumif"&&(pe.innerHTML=Mi),Sa=n(t),d(me.$$.fragment,t),Da=n(t),d(N.$$.fragment,t),Ka=n(t),ue=p(t,"P",{"data-svelte-h":!0}),m(ue)!=="svelte-m9nw5y"&&(ue.textContent=bi),Oa=n(t),d(de.$$.fragment,t),ts=n(t),d(fe.$$.fragment,t),es=n(t),he=p(t,"P",{"data-svelte-h":!0}),m(he)!=="svelte-5a92xi"&&(he.innerHTML=gi),ls=n(t),ce=p(t,"P",{"data-svelte-h":!0}),m(ce)!=="svelte-gf36q7"&&(ce.textContent=yi),as=n(t),d(H.$$.fragment,t),ss=n(t),Me=p(t,"P",{"data-svelte-h":!0}),m(Me)!=="svelte-dc2tbh"&&(Me.innerHTML=Ti),ns=n(t),d(L.$$.fragment,t),is=n(t),d(A.$$.fragment,t),os=n(t),be=p(t,"P",{"data-svelte-h":!0}),m(be)!=="svelte-1bxp667"&&(be.innerHTML=wi),rs=n(t),d(ge.$$.fragment,t),ps=n(t),ye=p(t,"P",{"data-svelte-h":!0}),m(ye)!=="svelte-11r521p"&&(ye.innerHTML=$i),ms=n(t),d(Te.$$.fragment,t),us=n(t),d(we.$$.fragment,t),ds=n(t),d(Y.$$.fragment,t),fs=n(t),$e=p(t,"P",{"data-svelte-h":!0}),m($e)!=="svelte-1yx1x2g"&&($e.textContent=Ji),hs=n(t),d(Je.$$.fragment,t),cs=n(t),ve=p(t,"P",{"data-svelte-h":!0}),m(ve)!=="svelte-7q086n"&&(ve.innerHTML=vi),Ms=n(t),d(Ue.$$.fragment,t),bs=n(t),je=p(t,"P",{"data-svelte-h":!0}),m(je)!=="svelte-15oy7am"&&(je.innerHTML=Ui),gs=n(t),d(_e.$$.fragment,t),ys=n(t),Ce=p(t,"P",{"data-svelte-h":!0}),m(Ce)!=="svelte-k1g8c2"&&(Ce.innerHTML=ji),Ts=n(t),d(qe.$$.fragment,t),ws=n(t),d(Ze.$$.fragment,t),$s=n(t),ke=p(t,"P",{"data-svelte-h":!0}),m(ke)!=="svelte-ur5rgd"&&(ke.textContent=_i),Js=n(t),Ge=p(t,"P",{"data-svelte-h":!0}),m(Ge)!=="svelte-1ebmm9f"&&(Ge.innerHTML=Ci),vs=n(t),d(ze.$$.fragment,t),Us=n(t),d(Qe.$$.fragment,t),js=n(t),Ie=p(t,"P",{"data-svelte-h":!0}),m(Ie)!=="svelte-y1ci98"&&(Ie.innerHTML=qi),_s=n(t),d(We.$$.fragment,t),Cs=n(t),d(Fe.$$.fragment,t),qs=n(t),Ve=p(t,"P",{"data-svelte-h":!0}),m(Ve)!=="svelte-4nvx4q"&&(Ve.innerHTML=Zi),Zs=n(t),d(xe.$$.fragment,t),ks=n(t),d(P.$$.fragment,t),Gs=n(t),Be=p(t,"P",{"data-svelte-h":!0}),m(Be)!=="svelte-7ob7j"&&(Be.textContent=ki),zs=n(t),d(Xe.$$.fragment,t),Qs=n(t),Re=p(t,"P",{"data-svelte-h":!0}),m(Re)!=="svelte-4jpqny"&&(Re.innerHTML=Gi),Is=n(t),d(Ee.$$.fragment,t),Ws=n(t),d(Ne.$$.fragment,t),Fs=n(t),He=p(t,"P",{"data-svelte-h":!0}),m(He)!=="svelte-1db46yq"&&(He.innerHTML=zi),Vs=n(t),d(Le.$$.fragment,t),xs=n(t),Ae=p(t,"P",{"data-svelte-h":!0}),m(Ae)!=="svelte-1qoc2ct"&&(Ae.innerHTML=Qi),Bs=n(t),d(Ye.$$.fragment,t),Xs=n(t),Pe=p(t,"P",{"data-svelte-h":!0}),m(Pe)!=="svelte-l0u9eq"&&(Pe.innerHTML=Ii),Rs=n(t),d(Se.$$.fragment,t),Es=n(t),d(De.$$.fragment,t),Ns=n(t),Ke=p(t,"P",{"data-svelte-h":!0}),m(Ke)!=="svelte-12z2l0"&&(Ke.innerHTML=Wi),Hs=n(t),d(Oe.$$.fragment,t),Ls=n(t),d(tl.$$.fragment,t),As=n(t),el=p(t,"P",{"data-svelte-h":!0}),m(el)!=="svelte-ayxv4l"&&(el.innerHTML=Fi),Ys=n(t),ll=p(t,"P",{"data-svelte-h":!0}),m(ll)!=="svelte-k0d3tz"&&(ll.innerHTML=Vi),Ps=n(t),d(al.$$.fragment,t),Ss=n(t),sl=p(t,"P",{"data-svelte-h":!0}),m(sl)!=="svelte-1jc8itq"&&(sl.innerHTML=xi),Ds=n(t),d(nl.$$.fragment,t),Ks=n(t),il=p(t,"P",{"data-svelte-h":!0}),m(il)!=="svelte-1ti9l12"&&(il.textContent=Bi),Os=n(t),d(ol.$$.fragment,t),tn=n(t),rl=p(t,"P",{"data-svelte-h":!0}),m(rl)!=="svelte-b8ansb"&&(rl.textContent=Xi),en=n(t),d(pl.$$.fragment,t),ln=n(t),d(ml.$$.fragment,t),an=n(t),ul=p(t,"P",{"data-svelte-h":!0}),m(ul)!=="svelte-opujmz"&&(ul.innerHTML=Ri),sn=n(t),d(dl.$$.fragment,t),nn=n(t),fl=p(t,"P",{"data-svelte-h":!0}),m(fl)!=="svelte-10oh9lm"&&(fl.innerHTML=Ei),on=n(t),S=p(t,"DIV",{class:!0,"data-svelte-h":!0}),m(S)!=="svelte-10jjm5l"&&(S.innerHTML=Ni),rn=n(t),D=p(t,"DIV",{class:!0,"data-svelte-h":!0}),m(D)!=="svelte-48at03"&&(D.innerHTML=Hi),pn=n(t),hl=p(t,"P",{"data-svelte-h":!0}),m(hl)!=="svelte-1sm7gom"&&(hl.innerHTML=Li),mn=n(t),d(cl.$$.fragment,t),un=n(t),Ml=p(t,"P",{"data-svelte-h":!0}),m(Ml)!=="svelte-81zmsw"&&(Ml.innerHTML=Ai),dn=n(t),K=p(t,"FIGCAPTION",{class:!0,"data-svelte-h":!0}),m(K)!=="svelte-grefv0"&&(K.textContent=Yi),fn=n(t),bl=p(t,"TABLE",{"data-svelte-h":!0}),m(bl)!=="svelte-19aactm"&&(bl.innerHTML=Pi),hn=n(t),O=p(t,"FIGCAPTION",{class:!0,"data-svelte-h":!0}),m(O)!=="svelte-1r15bg7"&&(O.textContent=Si),cn=n(t),gl=p(t,"TABLE",{"data-svelte-h":!0}),m(gl)!=="svelte-19fczbk"&&(gl.innerHTML=Di),Mn=n(t),yl=p(t,"P",{"data-svelte-h":!0}),m(yl)!=="svelte-gu8e8k"&&(yl.innerHTML=Ki),bn=n(t),tt=p(t,"DIV",{class:!0,"data-svelte-h":!0}),m(tt)!=="svelte-1ke50ja"&&(tt.innerHTML=Oi),gn=n(t),d(Tl.$$.fragment,t),yn=n(t),wl=p(t,"P",{"data-svelte-h":!0}),m(wl)!=="svelte-1fxt6gs"&&(wl.innerHTML=to),Tn=n(t),$l=p(t,"P",{"data-svelte-h":!0}),m($l)!=="svelte-d1mcqh"&&($l.textContent=eo),wn=n(t),d(Jl.$$.fragment,t),$n=n(t),vl=p(t,"P",{"data-svelte-h":!0}),m(vl)!=="svelte-oha52c"&&(vl.innerHTML=lo),Jn=n(t),d(Ul.$$.fragment,t),vn=n(t),d(jl.$$.fragment,t),Un=n(t),_l=p(t,"P",{"data-svelte-h":!0}),m(_l)!=="svelte-1domfft"&&(_l.textContent=ao),jn=n(t),Cl=p(t,"P",{"data-svelte-h":!0}),m(Cl)!=="svelte-1gckzen"&&(Cl.textContent=so),_n=n(t),d(ql.$$.fragment,t),Cn=n(t),d(Zl.$$.fragment,t),qn=n(t),kl=p(t,"P",{"data-svelte-h":!0}),m(kl)!=="svelte-1w4zqho"&&(kl.innerHTML=no),Zn=n(t),d(Gl.$$.fragment,t),kn=n(t),Ql=p(t,"P",{}),wo(Ql).forEach(l),this.h()},h(){et(i,"name","hf:doc:metadata"),et(i,"content",So),et(F,"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){_o(document.head,i),a(t,y,e),a(t,o,e),a(t,g,e),f(b,t,e),a(t,T,e),a(t,j,e),a(t,$,e),a(t,Z,e),a(t,_,e),f(k,t,e),a(t,v,e),f(z,t,e),a(t,U,e),f(Q,t,e),a(t,Il,e),a(t,lt,e),a(t,Wl,e),a(t,at,e),a(t,Fl,e),a(t,st,e),a(t,Vl,e),f(nt,t,e),a(t,xl,e),a(t,it,e),a(t,Bl,e),a(t,ot,e),a(t,Xl,e),f(rt,t,e),a(t,Rl,e),a(t,pt,e),a(t,El,e),a(t,mt,e),a(t,Nl,e),a(t,F,e),a(t,Hl,e),a(t,ut,e),a(t,Ll,e),f(dt,t,e),a(t,Al,e),a(t,ft,e),a(t,Yl,e),a(t,ht,e),a(t,Pl,e),a(t,ct,e),a(t,Sl,e),f(Mt,t,e),a(t,Dl,e),a(t,bt,e),a(t,Kl,e),a(t,gt,e),a(t,Ol,e),f(yt,t,e),a(t,ta,e),a(t,Tt,e),a(t,ea,e),f(wt,t,e),a(t,la,e),a(t,$t,e),a(t,aa,e),a(t,Jt,e),a(t,sa,e),f(vt,t,e),a(t,na,e),f(V,t,e),a(t,ia,e),a(t,Ut,e),a(t,oa,e),a(t,jt,e),a(t,ra,e),a(t,_t,e),a(t,pa,e),f(Ct,t,e),a(t,ma,e),a(t,qt,e),a(t,ua,e),f(Zt,t,e),a(t,da,e),a(t,kt,e),a(t,fa,e),f(Gt,t,e),a(t,ha,e),a(t,zt,e),a(t,ca,e),f(Qt,t,e),a(t,Ma,e),a(t,It,e),a(t,ba,e),f(Wt,t,e),a(t,ga,e),f(Ft,t,e),a(t,ya,e),a(t,Vt,e),a(t,Ta,e),f(x,t,e),a(t,wa,e),f(B,t,e),a(t,$a,e),f(xt,t,e),a(t,Ja,e),a(t,Bt,e),a(t,va,e),f(Xt,t,e),a(t,Ua,e),a(t,Rt,e),a(t,ja,e),f(Et,t,e),a(t,_a,e),f(X,t,e),a(t,Ca,e),f(Nt,t,e),a(t,qa,e),f(R,t,e),a(t,Za,e),a(t,Ht,e),a(t,ka,e),a(t,Lt,e),a(t,Ga,e),f(At,t,e),a(t,za,e),a(t,Yt,e),a(t,Qa,e),f(Pt,t,e),a(t,Ia,e),a(t,St,e),a(t,Wa,e),f(Dt,t,e),a(t,Fa,e),a(t,Kt,e),a(t,Va,e),f(Ot,t,e),a(t,xa,e),a(t,te,e),a(t,Ba,e),f(ee,t,e),a(t,Xa,e),f(E,t,e),a(t,Ra,e),a(t,le,e),a(t,Ea,e),f(ae,t,e),a(t,Na,e),a(t,se,e),a(t,Ha,e),f(ne,t,e),a(t,La,e),a(t,ie,e),a(t,Aa,e),f(oe,t,e),a(t,Ya,e),f(re,t,e),a(t,Pa,e),a(t,pe,e),a(t,Sa,e),f(me,t,e),a(t,Da,e),f(N,t,e),a(t,Ka,e),a(t,ue,e),a(t,Oa,e),f(de,t,e),a(t,ts,e),f(fe,t,e),a(t,es,e),a(t,he,e),a(t,ls,e),a(t,ce,e),a(t,as,e),f(H,t,e),a(t,ss,e),a(t,Me,e),a(t,ns,e),f(L,t,e),a(t,is,e),f(A,t,e),a(t,os,e),a(t,be,e),a(t,rs,e),f(ge,t,e),a(t,ps,e),a(t,ye,e),a(t,ms,e),f(Te,t,e),a(t,us,e),f(we,t,e),a(t,ds,e),f(Y,t,e),a(t,fs,e),a(t,$e,e),a(t,hs,e),f(Je,t,e),a(t,cs,e),a(t,ve,e),a(t,Ms,e),f(Ue,t,e),a(t,bs,e),a(t,je,e),a(t,gs,e),f(_e,t,e),a(t,ys,e),a(t,Ce,e),a(t,Ts,e),f(qe,t,e),a(t,ws,e),f(Ze,t,e),a(t,$s,e),a(t,ke,e),a(t,Js,e),a(t,Ge,e),a(t,vs,e),f(ze,t,e),a(t,Us,e),f(Qe,t,e),a(t,js,e),a(t,Ie,e),a(t,_s,e),f(We,t,e),a(t,Cs,e),f(Fe,t,e),a(t,qs,e),a(t,Ve,e),a(t,Zs,e),f(xe,t,e),a(t,ks,e),f(P,t,e),a(t,Gs,e),a(t,Be,e),a(t,zs,e),f(Xe,t,e),a(t,Qs,e),a(t,Re,e),a(t,Is,e),f(Ee,t,e),a(t,Ws,e),f(Ne,t,e),a(t,Fs,e),a(t,He,e),a(t,Vs,e),f(Le,t,e),a(t,xs,e),a(t,Ae,e),a(t,Bs,e),f(Ye,t,e),a(t,Xs,e),a(t,Pe,e),a(t,Rs,e),f(Se,t,e),a(t,Es,e),f(De,t,e),a(t,Ns,e),a(t,Ke,e),a(t,Hs,e),f(Oe,t,e),a(t,Ls,e),f(tl,t,e),a(t,As,e),a(t,el,e),a(t,Ys,e),a(t,ll,e),a(t,Ps,e),f(al,t,e),a(t,Ss,e),a(t,sl,e),a(t,Ds,e),f(nl,t,e),a(t,Ks,e),a(t,il,e),a(t,Os,e),f(ol,t,e),a(t,tn,e),a(t,rl,e),a(t,en,e),f(pl,t,e),a(t,ln,e),f(ml,t,e),a(t,an,e),a(t,ul,e),a(t,sn,e),f(dl,t,e),a(t,nn,e),a(t,fl,e),a(t,on,e),a(t,S,e),a(t,rn,e),a(t,D,e),a(t,pn,e),a(t,hl,e),a(t,mn,e),f(cl,t,e),a(t,un,e),a(t,Ml,e),a(t,dn,e),a(t,K,e),a(t,fn,e),a(t,bl,e),a(t,hn,e),a(t,O,e),a(t,cn,e),a(t,gl,e),a(t,Mn,e),a(t,yl,e),a(t,bn,e),a(t,tt,e),a(t,gn,e),f(Tl,t,e),a(t,yn,e),a(t,wl,e),a(t,Tn,e),a(t,$l,e),a(t,wn,e),f(Jl,t,e),a(t,$n,e),a(t,vl,e),a(t,Jn,e),f(Ul,t,e),a(t,vn,e),f(jl,t,e),a(t,Un,e),a(t,_l,e),a(t,jn,e),a(t,Cl,e),a(t,_n,e),f(ql,t,e),a(t,Cn,e),f(Zl,t,e),a(t,qn,e),a(t,kl,e),a(t,Zn,e),f(Gl,t,e),a(t,kn,e),a(t,Ql,e),Gn=!0},p(t,[e]){const io={};e&2&&(io.$$scope={dirty:e,ctx:t}),k.$set(io);const oo={};e&2&&(oo.$$scope={dirty:e,ctx:t}),Q.$set(oo);const ro={};e&2&&(ro.$$scope={dirty:e,ctx:t}),V.$set(ro);const po={};e&2&&(po.$$scope={dirty:e,ctx:t}),x.$set(po);const mo={};e&2&&(mo.$$scope={dirty:e,ctx:t}),B.$set(mo);const uo={};e&2&&(uo.$$scope={dirty:e,ctx:t}),X.$set(uo);const fo={};e&2&&(fo.$$scope={dirty:e,ctx:t}),R.$set(fo);const ho={};e&2&&(ho.$$scope={dirty:e,ctx:t}),E.$set(ho);const co={};e&2&&(co.$$scope={dirty:e,ctx:t}),N.$set(co);const Mo={};e&2&&(Mo.$$scope={dirty:e,ctx:t}),H.$set(Mo);const bo={};e&2&&(bo.$$scope={dirty:e,ctx:t}),L.$set(bo);const go={};e&2&&(go.$$scope={dirty:e,ctx:t}),A.$set(go);const yo={};e&2&&(yo.$$scope={dirty:e,ctx:t}),Y.$set(yo);const To={};e&2&&(To.$$scope={dirty:e,ctx:t}),P.$set(To)},i(t){Gn||(h(b.$$.fragment,t),h(k.$$.fragment,t),h(z.$$.fragment,t),h(Q.$$.fragment,t),h(nt.$$.fragment,t),h(rt.$$.fragment,t),h(dt.$$.fragment,t),h(Mt.$$.fragment,t),h(yt.$$.fragment,t),h(wt.$$.fragment,t),h(vt.$$.fragment,t),h(V.$$.fragment,t),h(Ct.$$.fragment,t),h(Zt.$$.fragment,t),h(Gt.$$.fragment,t),h(Qt.$$.fragment,t),h(Wt.$$.fragment,t),h(Ft.$$.fragment,t),h(x.$$.fragment,t),h(B.$$.fragment,t),h(xt.$$.fragment,t),h(Xt.$$.fragment,t),h(Et.$$.fragment,t),h(X.$$.fragment,t),h(Nt.$$.fragment,t),h(R.$$.fragment,t),h(At.$$.fragment,t),h(Pt.$$.fragment,t),h(Dt.$$.fragment,t),h(Ot.$$.fragment,t),h(ee.$$.fragment,t),h(E.$$.fragment,t),h(ae.$$.fragment,t),h(ne.$$.fragment,t),h(oe.$$.fragment,t),h(re.$$.fragment,t),h(me.$$.fragment,t),h(N.$$.fragment,t),h(de.$$.fragment,t),h(fe.$$.fragment,t),h(H.$$.fragment,t),h(L.$$.fragment,t),h(A.$$.fragment,t),h(ge.$$.fragment,t),h(Te.$$.fragment,t),h(we.$$.fragment,t),h(Y.$$.fragment,t),h(Je.$$.fragment,t),h(Ue.$$.fragment,t),h(_e.$$.fragment,t),h(qe.$$.fragment,t),h(Ze.$$.fragment,t),h(ze.$$.fragment,t),h(Qe.$$.fragment,t),h(We.$$.fragment,t),h(Fe.$$.fragment,t),h(xe.$$.fragment,t),h(P.$$.fragment,t),h(Xe.$$.fragment,t),h(Ee.$$.fragment,t),h(Ne.$$.fragment,t),h(Le.$$.fragment,t),h(Ye.$$.fragment,t),h(Se.$$.fragment,t),h(De.$$.fragment,t),h(Oe.$$.fragment,t),h(tl.$$.fragment,t),h(al.$$.fragment,t),h(nl.$$.fragment,t),h(ol.$$.fragment,t),h(pl.$$.fragment,t),h(ml.$$.fragment,t),h(dl.$$.fragment,t),h(cl.$$.fragment,t),h(Tl.$$.fragment,t),h(Jl.$$.fragment,t),h(Ul.$$.fragment,t),h(jl.$$.fragment,t),h(ql.$$.fragment,t),h(Zl.$$.fragment,t),h(Gl.$$.fragment,t),Gn=!0)},o(t){c(b.$$.fragment,t),c(k.$$.fragment,t),c(z.$$.fragment,t),c(Q.$$.fragment,t),c(nt.$$.fragment,t),c(rt.$$.fragment,t),c(dt.$$.fragment,t),c(Mt.$$.fragment,t),c(yt.$$.fragment,t),c(wt.$$.fragment,t),c(vt.$$.fragment,t),c(V.$$.fragment,t),c(Ct.$$.fragment,t),c(Zt.$$.fragment,t),c(Gt.$$.fragment,t),c(Qt.$$.fragment,t),c(Wt.$$.fragment,t),c(Ft.$$.fragment,t),c(x.$$.fragment,t),c(B.$$.fragment,t),c(xt.$$.fragment,t),c(Xt.$$.fragment,t),c(Et.$$.fragment,t),c(X.$$.fragment,t),c(Nt.$$.fragment,t),c(R.$$.fragment,t),c(At.$$.fragment,t),c(Pt.$$.fragment,t),c(Dt.$$.fragment,t),c(Ot.$$.fragment,t),c(ee.$$.fragment,t),c(E.$$.fragment,t),c(ae.$$.fragment,t),c(ne.$$.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(L.$$.fragment,t),c(A.$$.fragment,t),c(ge.$$.fragment,t),c(Te.$$.fragment,t),c(we.$$.fragment,t),c(Y.$$.fragment,t),c(Je.$$.fragment,t),c(Ue.$$.fragment,t),c(_e.$$.fragment,t),c(qe.$$.fragment,t),c(Ze.$$.fragment,t),c(ze.$$.fragment,t),c(Qe.$$.fragment,t),c(We.$$.fragment,t),c(Fe.$$.fragment,t),c(xe.$$.fragment,t),c(P.$$.fragment,t),c(Xe.$$.fragment,t),c(Ee.$$.fragment,t),c(Ne.$$.fragment,t),c(Le.$$.fragment,t),c(Ye.$$.fragment,t),c(Se.$$.fragment,t),c(De.$$.fragment,t),c(Oe.$$.fragment,t),c(tl.$$.fragment,t),c(al.$$.fragment,t),c(nl.$$.fragment,t),c(ol.$$.fragment,t),c(pl.$$.fragment,t),c(ml.$$.fragment,t),c(dl.$$.fragment,t),c(cl.$$.fragment,t),c(Tl.$$.fragment,t),c(Jl.$$.fragment,t),c(Ul.$$.fragment,t),c(jl.$$.fragment,t),c(ql.$$.fragment,t),c(Zl.$$.fragment,t),c(Gl.$$.fragment,t),Gn=!1},d(t){t&&(l(y),l(o),l(g),l(T),l(j),l($),l(Z),l(_),l(v),l(U),l(Il),l(lt),l(Wl),l(at),l(Fl),l(st),l(Vl),l(xl),l(it),l(Bl),l(ot),l(Xl),l(Rl),l(pt),l(El),l(mt),l(Nl),l(F),l(Hl),l(ut),l(Ll),l(Al),l(ft),l(Yl),l(ht),l(Pl),l(ct),l(Sl),l(Dl),l(bt),l(Kl),l(gt),l(Ol),l(ta),l(Tt),l(ea),l(la),l($t),l(aa),l(Jt),l(sa),l(na),l(ia),l(Ut),l(oa),l(jt),l(ra),l(_t),l(pa),l(ma),l(qt),l(ua),l(da),l(kt),l(fa),l(ha),l(zt),l(ca),l(Ma),l(It),l(ba),l(ga),l(ya),l(Vt),l(Ta),l(wa),l($a),l(Ja),l(Bt),l(va),l(Ua),l(Rt),l(ja),l(_a),l(Ca),l(qa),l(Za),l(Ht),l(ka),l(Lt),l(Ga),l(za),l(Yt),l(Qa),l(Ia),l(St),l(Wa),l(Fa),l(Kt),l(Va),l(xa),l(te),l(Ba),l(Xa),l(Ra),l(le),l(Ea),l(Na),l(se),l(Ha),l(La),l(ie),l(Aa),l(Ya),l(Pa),l(pe),l(Sa),l(Da),l(Ka),l(ue),l(Oa),l(ts),l(es),l(he),l(ls),l(ce),l(as),l(ss),l(Me),l(ns),l(is),l(os),l(be),l(rs),l(ps),l(ye),l(ms),l(us),l(ds),l(fs),l($e),l(hs),l(cs),l(ve),l(Ms),l(bs),l(je),l(gs),l(ys),l(Ce),l(Ts),l(ws),l($s),l(ke),l(Js),l(Ge),l(vs),l(Us),l(js),l(Ie),l(_s),l(Cs),l(qs),l(Ve),l(Zs),l(ks),l(Gs),l(Be),l(zs),l(Qs),l(Re),l(Is),l(Ws),l(Fs),l(He),l(Vs),l(xs),l(Ae),l(Bs),l(Xs),l(Pe),l(Rs),l(Es),l(Ns),l(Ke),l(Hs),l(Ls),l(As),l(el),l(Ys),l(ll),l(Ps),l(Ss),l(sl),l(Ds),l(Ks),l(il),l(Os),l(tn),l(rl),l(en),l(ln),l(an),l(ul),l(sn),l(nn),l(fl),l(on),l(S),l(rn),l(D),l(pn),l(hl),l(mn),l(un),l(Ml),l(dn),l(K),l(fn),l(bl),l(hn),l(O),l(cn),l(gl),l(Mn),l(yl),l(bn),l(tt),l(gn),l(yn),l(wl),l(Tn),l($l),l(wn),l($n),l(vl),l(Jn),l(vn),l(Un),l(_l),l(jn),l(Cl),l(_n),l(Cn),l(qn),l(kl),l(Zn),l(kn),l(Ql)),l(i),M(b,t),M(k,t),M(z,t),M(Q,t),M(nt,t),M(rt,t),M(dt,t),M(Mt,t),M(yt,t),M(wt,t),M(vt,t),M(V,t),M(Ct,t),M(Zt,t),M(Gt,t),M(Qt,t),M(Wt,t),M(Ft,t),M(x,t),M(B,t),M(xt,t),M(Xt,t),M(Et,t),M(X,t),M(Nt,t),M(R,t),M(At,t),M(Pt,t),M(Dt,t),M(Ot,t),M(ee,t),M(E,t),M(ae,t),M(ne,t),M(oe,t),M(re,t),M(me,t),M(N,t),M(de,t),M(fe,t),M(H,t),M(L,t),M(A,t),M(ge,t),M(Te,t),M(we,t),M(Y,t),M(Je,t),M(Ue,t),M(_e,t),M(qe,t),M(Ze,t),M(ze,t),M(Qe,t),M(We,t),M(Fe,t),M(xe,t),M(P,t),M(Xe,t),M(Ee,t),M(Ne,t),M(Le,t),M(Ye,t),M(Se,t),M(De,t),M(Oe,t),M(tl,t),M(al,t),M(nl,t),M(ol,t),M(pl,t),M(ml,t),M(dl,t),M(cl,t),M(Tl,t),M(Jl,t),M(Ul,t),M(jl,t),M(ql,t),M(Zl,t),M(Gl,t)}}}const So='{"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},{"title":"Dequantizing bitsandbytes models","local":"dequantizing-bitsandbytes-models","sections":[],"depth":3}],"depth":2},{"title":"EETQ","local":"eetq","sections":[],"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},{"title":"HQQ","local":"hqq","sections":[{"title":"Optimized Runtime","local":"optimized-runtime","sections":[],"depth":3}],"depth":2}],"depth":1}';function Do(J){return Jo(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class sr extends vo{constructor(i){super(),Uo(this,i,Do,Po,$o,{})}}export{sr as component};
