import{s as z,o as E,n as H}from"../chunks/scheduler.01eeda35.js";import{S as Y,i as P,g as M,s as i,r as Q,A as W,h as y,f as a,c as o,j,u as R,x,k as G,y as A,a as n,v as J,d as k,t as q,w as X}from"../chunks/index.6dd51b66.js";import{T as I}from"../chunks/Tip.de9bae2b.js";import{C as N}from"../chunks/CodeBlock.19ec9b8c.js";import{H as K,E as D}from"../chunks/index.58fe8f9d.js";function O(U){let s,p='To quantize a model with SpQR, refer to the <a href="https://github.com/Vahe1994/SpQR" rel="nofollow">Vahe1994/SpQR</a> repository.';return{c(){s=M("p"),s.innerHTML=p},l(r){s=y(r,"P",{"data-svelte-h":!0}),x(s)!=="svelte-1oniykr"&&(s.innerHTML=p)},m(r,$){n(r,s,$)},p:H,d(r){r&&a(s)}}}function tt(U){let s,p,r,$,u,_,c,L='The <a href="(https://hf.co/papers/2306.03078)">SpQR</a> quantization algorithm involves a 16x16 tiled bi-level group 3-bit quantization structure with sparse outliers.',g,l,F='<img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/spqr-diagram.png"/>',v,m,b,f,Z='Load a SpQR-quantized model with <a href="/docs/transformers/main/en/main_classes/model#transformers.PreTrainedModel.from_pretrained">from_pretrained()</a>.',w,d,C,h,S,T,V;return u=new K({props:{title:"SpQR",local:"spqr",headingTag:"h1"}}),m=new I({props:{warning:!1,$$slots:{default:[O]},$$scope:{ctx:U}}}),d=new N({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBBdXRvTW9kZWxGb3JDYXVzYWxMTSUwQWltcG9ydCUyMHRvcmNoJTBBJTBBcXVhbnRpemVkX21vZGVsJTIwJTNEJTIwQXV0b01vZGVsRm9yQ2F1c2FsTE0uZnJvbV9wcmV0cmFpbmVkKCUwQSUyMCUyMCUyMCUyMCUyMmVsdmlyY3JuJTJGTGxhbWEtMi03Yi1TUFFSLTNCaXQtMTZ4MTYtcmVkX3BhamFtYS1oZiUyMiUyQyUwQSUyMCUyMCUyMCUyMHRvcmNoX2R0eXBlJTNEdG9yY2guaGFsZiUyQyUwQSUyMCUyMCUyMCUyMGRldmljZV9tYXAlM0QlMjJhdXRvJTIyJTBBKSUwQXRva2VuaXplciUyMCUzRCUyMEF1dG9Ub2tlbml6ZXIuZnJvbV9wcmV0cmFpbmVkKCUyMmVsdmlyY3JuJTJGTGxhbWEtMi03Yi1TUFFSLTNCaXQtMTZ4MTYtcmVkX3BhamFtYS1oZiUyMik=",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, AutoModelForCausalLM
<span class="hljs-keyword">import</span> torch

quantized_model = AutoModelForCausalLM.from_pretrained(
    <span class="hljs-string">&quot;elvircrn/Llama-2-7b-SPQR-3Bit-16x16-red_pajama-hf&quot;</span>,
    torch_dtype=torch.half,
    device_map=<span class="hljs-string">&quot;auto&quot;</span>
)
tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;elvircrn/Llama-2-7b-SPQR-3Bit-16x16-red_pajama-hf&quot;</span>)`,wrap:!1}}),h=new D({props:{source:"https://github.com/huggingface/transformers/blob/main/docs/source/en/quantization/spqr.md"}}),{c(){s=M("meta"),p=i(),r=M("p"),$=i(),Q(u.$$.fragment),_=i(),c=M("p"),c.innerHTML=L,g=i(),l=M("div"),l.innerHTML=F,v=i(),Q(m.$$.fragment),b=i(),f=M("p"),f.innerHTML=Z,w=i(),Q(d.$$.fragment),C=i(),Q(h.$$.fragment),S=i(),T=M("p"),this.h()},l(t){const e=W("svelte-u9bgzb",document.head);s=y(e,"META",{name:!0,content:!0}),e.forEach(a),p=o(t),r=y(t,"P",{}),j(r).forEach(a),$=o(t),R(u.$$.fragment,t),_=o(t),c=y(t,"P",{"data-svelte-h":!0}),x(c)!=="svelte-r8pu9s"&&(c.innerHTML=L),g=o(t),l=y(t,"DIV",{class:!0,"data-svelte-h":!0}),x(l)!=="svelte-138opda"&&(l.innerHTML=F),v=o(t),R(m.$$.fragment,t),b=o(t),f=y(t,"P",{"data-svelte-h":!0}),x(f)!=="svelte-mot5dm"&&(f.innerHTML=Z),w=o(t),R(d.$$.fragment,t),C=o(t),R(h.$$.fragment,t),S=o(t),T=y(t,"P",{}),j(T).forEach(a),this.h()},h(){G(s,"name","hf:doc:metadata"),G(s,"content",et),G(l,"class","flex justify-center")},m(t,e){A(document.head,s),n(t,p,e),n(t,r,e),n(t,$,e),J(u,t,e),n(t,_,e),n(t,c,e),n(t,g,e),n(t,l,e),n(t,v,e),J(m,t,e),n(t,b,e),n(t,f,e),n(t,w,e),J(d,t,e),n(t,C,e),J(h,t,e),n(t,S,e),n(t,T,e),V=!0},p(t,[e]){const B={};e&2&&(B.$$scope={dirty:e,ctx:t}),m.$set(B)},i(t){V||(k(u.$$.fragment,t),k(m.$$.fragment,t),k(d.$$.fragment,t),k(h.$$.fragment,t),V=!0)},o(t){q(u.$$.fragment,t),q(m.$$.fragment,t),q(d.$$.fragment,t),q(h.$$.fragment,t),V=!1},d(t){t&&(a(p),a(r),a($),a(_),a(c),a(g),a(l),a(v),a(b),a(f),a(w),a(C),a(S),a(T)),a(s),X(u,t),X(m,t),X(d,t),X(h,t)}}}const et='{"title":"SpQR","local":"spqr","sections":[],"depth":1}';function at(U){return E(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class lt extends Y{constructor(s){super(),P(this,s,at,tt,z,{})}}export{lt as component};
