import{s as We,o as Be,n as Je}from"../chunks/scheduler.182ea377.js";import{S as Ke,i as Oe,g as n,s as a,r as _,A as Qe,h as s,f as i,c as r,j as M,u as b,x as p,k as L,y as t,a as c,v as x,d as P,t as w,w as T}from"../chunks/index.abf12888.js";import{T as Xe}from"../chunks/Tip.230e2334.js";import{D as re}from"../chunks/Docstring.93f6f462.js";import{H as Ne}from"../chunks/Heading.16916d63.js";function Ye(se){let f,C='Refer to <a href="../../tutorials/using_peft_for_inference.md">this doc</a> to get an overview of how to work with <code>peft</code> in Diffusers for inference.';return{c(){f=n("p"),f.innerHTML=C},l(m){f=s(m,"P",{"data-svelte-h":!0}),p(f)!=="svelte-19kmoqv"&&(f.innerHTML=C)},m(m,q){c(m,f,q)},p:Je,d(m){m&&i(f)}}}function Ze(se){let f,C,m,q,E,oe,A,Ae='Diffusers supports working with adapters (such as <a href="../../using-diffusers/loading_adapters">LoRA</a>) via the <a href="https://huggingface.co/docs/peft/index" rel="nofollow"><code>peft</code> library</a>. We provide a <code>PeftAdapterMixin</code> class to handle this for modeling classes in Diffusers (such as <a href="/docs/diffusers/main/en/api/models/unet2d-cond#diffusers.UNet2DConditionModel">UNet2DConditionModel</a>).',ie,y,de,H,le,o,F,ce,S,He=`A class containing all functions for loading and using adapters weights that are supported in PEFT library. For
more details about adapters and injecting them on a transformer-based model, check out the documentation of PEFT
library: <a href="https://huggingface.co/docs/peft/index" rel="nofollow">https://huggingface.co/docs/peft/index</a>.`,me,j,Fe="With this mixin, if the correct PEFT version is installed, it is possible to:",ue,z,De="<li>Attach new adapters in the model.</li> <li>Attach multiple adapters and iteratively activate / deactivate them.</li> <li>Activate / deactivate all adapters from the model.</li> <li>Get a list of the active adapters.</li>",he,u,D,ge,R,Ie="Gets the current list of active adapters of the model.",ve,G,ke=`If you are not familiar with adapters and PEFT methods, we invite you to read more about them on the PEFT
official documentation: <a href="https://huggingface.co/docs/peft" rel="nofollow">https://huggingface.co/docs/peft</a>`,$e,h,I,_e,N,Ue=`Adds a new adapter to the current model for training. If no adapter name is passed, a default name is assigned
to the adapter to follow the convention of the PEFT library.`,be,W,Ve=`If you are not familiar with adapters and PEFT methods, we invite you to read more about them in the PEFT
<a href="https://huggingface.co/docs/peft" rel="nofollow">documentation</a>.`,xe,g,k,Pe,B,qe="Disable all adapters attached to the model and fallback to inference with the base model only.",we,J,Se=`If you are not familiar with adapters and PEFT methods, we invite you to read more about them on the PEFT
official documentation: <a href="https://huggingface.co/docs/peft" rel="nofollow">https://huggingface.co/docs/peft</a>`,Te,v,U,ye,K,je=`Enable adapters that are attached to the model. The model will use <code>self.active_adapters()</code> to retrieve the
list of adapters to enable.`,Me,O,ze=`If you are not familiar with adapters and PEFT methods, we invite you to read more about them on the PEFT
official documentation: <a href="https://huggingface.co/docs/peft" rel="nofollow">https://huggingface.co/docs/peft</a>`,Le,$,V,Ce,Q,Re="Sets a specific adapter by forcing the model to only use that adapter and disables the other adapters.",Ee,X,Ge=`If you are not familiar with adapters and PEFT methods, we invite you to read more about them on the PEFT
official documentation: <a href="https://huggingface.co/docs/peft" rel="nofollow">https://huggingface.co/docs/peft</a>`,fe,ne,pe;return E=new Ne({props:{title:"PEFT",local:"peft",headingTag:"h1"}}),y=new Xe({props:{$$slots:{default:[Ye]},$$scope:{ctx:se}}}),H=new Ne({props:{title:"PeftAdapterMixin",local:"diffusers.loaders.PeftAdapterMixin",headingTag:"h2"}}),F=new re({props:{name:"class diffusers.loaders.PeftAdapterMixin",anchor:"diffusers.loaders.PeftAdapterMixin",parameters:[],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/loaders/peft.py#L20"}}),D=new re({props:{name:"active_adapters",anchor:"diffusers.loaders.PeftAdapterMixin.active_adapters",parameters:[],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/loaders/peft.py#L169"}}),I=new re({props:{name:"add_adapter",anchor:"diffusers.loaders.PeftAdapterMixin.add_adapter",parameters:[{name:"adapter_config",val:""},{name:"adapter_name",val:": str = 'default'"}],parametersDescription:[{anchor:"diffusers.loaders.PeftAdapterMixin.add_adapter.adapter_config",description:`<strong>adapter_config</strong> (<code>[~peft.PeftConfig]</code>) &#x2014;
The configuration of the adapter to add; supported adapters are non-prefix tuning and adaption prompt
methods.`,name:"adapter_config"},{anchor:"diffusers.loaders.PeftAdapterMixin.add_adapter.adapter_name",description:`<strong>adapter_name</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;default&quot;</code>) &#x2014;
The name of the adapter to add. If no name is passed, a default name is assigned to the adapter.`,name:"adapter_name"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/loaders/peft.py#L37"}}),k=new re({props:{name:"disable_adapters",anchor:"diffusers.loaders.PeftAdapterMixin.disable_adapters",parameters:[],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/loaders/peft.py#L124"}}),U=new re({props:{name:"enable_adapters",anchor:"diffusers.loaders.PeftAdapterMixin.enable_adapters",parameters:[],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/loaders/peft.py#L146"}}),V=new re({props:{name:"set_adapter",anchor:"diffusers.loaders.PeftAdapterMixin.set_adapter",parameters:[{name:"adapter_name",val:": typing.Union[str, typing.List[str]]"}],parametersDescription:[{anchor:"diffusers.loaders.PeftAdapterMixin.set_adapter.adapter_name",description:`<strong>adapter_name</strong> (Union[str, List[str]])) &#x2014;
The list of adapters to set or the adapter name in case of single adapter.`,name:"adapter_name"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/loaders/peft.py#L75"}}),{c(){f=n("meta"),C=a(),m=n("p"),q=a(),_(E.$$.fragment),oe=a(),A=n("p"),A.innerHTML=Ae,ie=a(),_(y.$$.fragment),de=a(),_(H.$$.fragment),le=a(),o=n("div"),_(F.$$.fragment),ce=a(),S=n("p"),S.innerHTML=He,me=a(),j=n("p"),j.textContent=Fe,ue=a(),z=n("ul"),z.innerHTML=De,he=a(),u=n("div"),_(D.$$.fragment),ge=a(),R=n("p"),R.textContent=Ie,ve=a(),G=n("p"),G.innerHTML=ke,$e=a(),h=n("div"),_(I.$$.fragment),_e=a(),N=n("p"),N.textContent=Ue,be=a(),W=n("p"),W.innerHTML=Ve,xe=a(),g=n("div"),_(k.$$.fragment),Pe=a(),B=n("p"),B.textContent=qe,we=a(),J=n("p"),J.innerHTML=Se,Te=a(),v=n("div"),_(U.$$.fragment),ye=a(),K=n("p"),K.innerHTML=je,Me=a(),O=n("p"),O.innerHTML=ze,Le=a(),$=n("div"),_(V.$$.fragment),Ce=a(),Q=n("p"),Q.textContent=Re,Ee=a(),X=n("p"),X.innerHTML=Ge,fe=a(),ne=n("p"),this.h()},l(e){const l=Qe("svelte-u9bgzb",document.head);f=s(l,"META",{name:!0,content:!0}),l.forEach(i),C=r(e),m=s(e,"P",{}),M(m).forEach(i),q=r(e),b(E.$$.fragment,e),oe=r(e),A=s(e,"P",{"data-svelte-h":!0}),p(A)!=="svelte-1cae1bu"&&(A.innerHTML=Ae),ie=r(e),b(y.$$.fragment,e),de=r(e),b(H.$$.fragment,e),le=r(e),o=s(e,"DIV",{class:!0});var d=M(o);b(F.$$.fragment,d),ce=r(d),S=s(d,"P",{"data-svelte-h":!0}),p(S)!=="svelte-c7xvle"&&(S.innerHTML=He),me=r(d),j=s(d,"P",{"data-svelte-h":!0}),p(j)!=="svelte-wzrwkl"&&(j.textContent=Fe),ue=r(d),z=s(d,"UL",{"data-svelte-h":!0}),p(z)!=="svelte-4ycqhy"&&(z.innerHTML=De),he=r(d),u=s(d,"DIV",{class:!0});var Y=M(u);b(D.$$.fragment,Y),ge=r(Y),R=s(Y,"P",{"data-svelte-h":!0}),p(R)!=="svelte-1i9yvzx"&&(R.textContent=Ie),ve=r(Y),G=s(Y,"P",{"data-svelte-h":!0}),p(G)!=="svelte-esrgfk"&&(G.innerHTML=ke),Y.forEach(i),$e=r(d),h=s(d,"DIV",{class:!0});var Z=M(h);b(I.$$.fragment,Z),_e=r(Z),N=s(Z,"P",{"data-svelte-h":!0}),p(N)!=="svelte-ayg1h"&&(N.textContent=Ue),be=r(Z),W=s(Z,"P",{"data-svelte-h":!0}),p(W)!=="svelte-m719pe"&&(W.innerHTML=Ve),Z.forEach(i),xe=r(d),g=s(d,"DIV",{class:!0});var ee=M(g);b(k.$$.fragment,ee),Pe=r(ee),B=s(ee,"P",{"data-svelte-h":!0}),p(B)!=="svelte-stjif2"&&(B.textContent=qe),we=r(ee),J=s(ee,"P",{"data-svelte-h":!0}),p(J)!=="svelte-esrgfk"&&(J.innerHTML=Se),ee.forEach(i),Te=r(d),v=s(d,"DIV",{class:!0});var te=M(v);b(U.$$.fragment,te),ye=r(te),K=s(te,"P",{"data-svelte-h":!0}),p(K)!=="svelte-1wx27ts"&&(K.innerHTML=je),Me=r(te),O=s(te,"P",{"data-svelte-h":!0}),p(O)!=="svelte-esrgfk"&&(O.innerHTML=ze),te.forEach(i),Le=r(d),$=s(d,"DIV",{class:!0});var ae=M($);b(V.$$.fragment,ae),Ce=r(ae),Q=s(ae,"P",{"data-svelte-h":!0}),p(Q)!=="svelte-1kp30gn"&&(Q.textContent=Re),Ee=r(ae),X=s(ae,"P",{"data-svelte-h":!0}),p(X)!=="svelte-esrgfk"&&(X.innerHTML=Ge),ae.forEach(i),d.forEach(i),fe=r(e),ne=s(e,"P",{}),M(ne).forEach(i),this.h()},h(){L(f,"name","hf:doc:metadata"),L(f,"content",et),L(u,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),L(h,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),L(g,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),L(v,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),L($,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),L(o,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(e,l){t(document.head,f),c(e,C,l),c(e,m,l),c(e,q,l),x(E,e,l),c(e,oe,l),c(e,A,l),c(e,ie,l),x(y,e,l),c(e,de,l),x(H,e,l),c(e,le,l),c(e,o,l),x(F,o,null),t(o,ce),t(o,S),t(o,me),t(o,j),t(o,ue),t(o,z),t(o,he),t(o,u),x(D,u,null),t(u,ge),t(u,R),t(u,ve),t(u,G),t(o,$e),t(o,h),x(I,h,null),t(h,_e),t(h,N),t(h,be),t(h,W),t(o,xe),t(o,g),x(k,g,null),t(g,Pe),t(g,B),t(g,we),t(g,J),t(o,Te),t(o,v),x(U,v,null),t(v,ye),t(v,K),t(v,Me),t(v,O),t(o,Le),t(o,$),x(V,$,null),t($,Ce),t($,Q),t($,Ee),t($,X),c(e,fe,l),c(e,ne,l),pe=!0},p(e,[l]){const d={};l&2&&(d.$$scope={dirty:l,ctx:e}),y.$set(d)},i(e){pe||(P(E.$$.fragment,e),P(y.$$.fragment,e),P(H.$$.fragment,e),P(F.$$.fragment,e),P(D.$$.fragment,e),P(I.$$.fragment,e),P(k.$$.fragment,e),P(U.$$.fragment,e),P(V.$$.fragment,e),pe=!0)},o(e){w(E.$$.fragment,e),w(y.$$.fragment,e),w(H.$$.fragment,e),w(F.$$.fragment,e),w(D.$$.fragment,e),w(I.$$.fragment,e),w(k.$$.fragment,e),w(U.$$.fragment,e),w(V.$$.fragment,e),pe=!1},d(e){e&&(i(C),i(m),i(q),i(oe),i(A),i(ie),i(de),i(le),i(o),i(fe),i(ne)),i(f),T(E,e),T(y,e),T(H,e),T(F),T(D),T(I),T(k),T(U),T(V)}}}const et='{"title":"PEFT","local":"peft","sections":[{"title":"PeftAdapterMixin","local":"diffusers.loaders.PeftAdapterMixin","sections":[],"depth":2}],"depth":1}';function tt(se){return Be(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class it extends Ke{constructor(f){super(),Oe(this,f,tt,Ze,We,{})}}export{it as component};
