import{s as z,n as D,o as O}from"../chunks/scheduler.78382b47.js";import{S as K,i as ee,e as n,s,c as w,h as te,a as p,d as a,b as o,f as q,g,j as $,k as Q,l as ae,m as l,n as x,t as J,o as v,p as Z}from"../chunks/index.6dd35eb6.js";import{C as le,H as V,E as se}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.fed9dfe4.js";import{C as oe}from"../chunks/CodeBlock.af1ec02e.js";function ie(U){let i,L,y,j,d,P,r,R,f,Y='Normally, it isn’t possible to mix different adapter types in 🤗 PEFT. You can create a PEFT model with two different LoRA adapters (which can have different config options), but it is not possible to combine a LoRA and LoHa adapter. With <a href="/docs/peft/main/en/package_reference/peft_model#peft.PeftMixedModel">PeftMixedModel</a> however, this works as long as the adapter types are compatible. The main purpose of allowing mixed adapter types is to combine trained adapters for inference. While it is possible to train a mixed adapter model, this has not been tested and is not recommended.',H,m,A='To load different adapter types into a PEFT model, use <a href="/docs/peft/main/en/package_reference/peft_model#peft.PeftMixedModel">PeftMixedModel</a> instead of <a href="/docs/peft/main/en/package_reference/peft_model#peft.PeftModel">PeftModel</a>:',W,c,I,h,X='The <a href="/docs/peft/main/en/package_reference/peft_model#peft.PeftMixedModel.set_adapter">set_adapter()</a> method is necessary to activate both adapters, otherwise only the first adapter would be active. You can keep adding more adapters by calling <a href="/docs/peft/main/en/package_reference/peft_model#peft.PeftModel.add_adapter">add_adapter()</a> repeatedly.',k,u,N='<a href="/docs/peft/main/en/package_reference/peft_model#peft.PeftMixedModel">PeftMixedModel</a> does not support saving and loading mixed adapters. The adapters should already be trained, and loading the model requires a script to be run each time.',B,M,F,b,S='<li>Not all adapter types can be combined. See <a href="https://github.com/huggingface/peft/blob/1c1c7fdaa6e6abaa53939b865dee1eded82ad032/src/peft/tuners/mixed/model.py#L35" rel="nofollow"><code>peft.tuners.mixed.COMPATIBLE_TUNER_TYPES</code></a> for a list of compatible types. An error will be raised if you try to combine incompatible adapter types.</li> <li>It is possible to mix multiple adapters of the same type which can be useful for combining adapters with very different configs.</li> <li>If you want to combine a lot of different adapters, the most performant way to do it is to consecutively add the same adapter types. For example, add LoRA1, LoRA2, LoHa1, LoHa2 in this order, instead of LoRA1, LoHa1, LoRA2, and LoHa2. While the order can affect the output, there is no inherently <em>best</em> order, so it is best to choose the fastest one.</li>',C,_,E,T,G;return d=new le({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),r=new V({props:{title:"Mixed adapter types",local:"mixed-adapter-types",headingTag:"h1"}}),c=new oe({props:{code:"ZnJvbSUyMHBlZnQlMjBpbXBvcnQlMjBQZWZ0TWl4ZWRNb2RlbCUwQSUwQWJhc2VfbW9kZWwlMjAlM0QlMjAuLi4lMjAlMjAlMjMlMjBsb2FkJTIwdGhlJTIwYmFzZSUyMG1vZGVsJTJDJTIwZS5nLiUyMGZyb20lMjB0cmFuc2Zvcm1lcnMlMEElMjMlMjBsb2FkJTIwZmlyc3QlMjBhZGFwdGVyJTJDJTIwd2hpY2glMjB3aWxsJTIwYmUlMjBjYWxsZWQlMjAlMjJkZWZhdWx0JTIyJTBBcGVmdF9tb2RlbCUyMCUzRCUyMFBlZnRNaXhlZE1vZGVsLmZyb21fcHJldHJhaW5lZChiYXNlX21vZGVsJTJDJTIwJTNDcGF0aF90b19hZGFwdGVyMSUzRSklMEFwZWZ0X21vZGVsLmxvYWRfYWRhcHRlciglM0NwYXRoX3RvX2FkYXB0ZXIyJTNFJTJDJTIwYWRhcHRlcl9uYW1lJTNEJTIyb3RoZXIlMjIpJTBBcGVmdF9tb2RlbC5zZXRfYWRhcHRlciglNUIlMjJkZWZhdWx0JTIyJTJDJTIwJTIyb3RoZXIlMjIlNUQp",highlighted:`<span class="hljs-keyword">from</span> peft <span class="hljs-keyword">import</span> PeftMixedModel

base_model = ...  <span class="hljs-comment"># load the base model, e.g. from transformers</span>
<span class="hljs-comment"># load first adapter, which will be called &quot;default&quot;</span>
peft_model = PeftMixedModel.from_pretrained(base_model, &lt;path_to_adapter1&gt;)
peft_model.load_adapter(&lt;path_to_adapter2&gt;, adapter_name=<span class="hljs-string">&quot;other&quot;</span>)
peft_model.set_adapter([<span class="hljs-string">&quot;default&quot;</span>, <span class="hljs-string">&quot;other&quot;</span>])`,wrap:!1}}),M=new V({props:{title:"Tips",local:"tips",headingTag:"h2"}}),_=new se({props:{source:"https://github.com/huggingface/peft/blob/main/docs/source/developer_guides/mixed_models.md"}}),{c(){i=n("meta"),L=s(),y=n("p"),j=s(),w(d.$$.fragment),P=s(),w(r.$$.fragment),R=s(),f=n("p"),f.innerHTML=Y,H=s(),m=n("p"),m.innerHTML=A,W=s(),w(c.$$.fragment),I=s(),h=n("p"),h.innerHTML=X,k=s(),u=n("p"),u.innerHTML=N,B=s(),w(M.$$.fragment),F=s(),b=n("ul"),b.innerHTML=S,C=s(),w(_.$$.fragment),E=s(),T=n("p"),this.h()},l(e){const t=te("svelte-u9bgzb",document.head);i=p(t,"META",{name:!0,content:!0}),t.forEach(a),L=o(e),y=p(e,"P",{}),q(y).forEach(a),j=o(e),g(d.$$.fragment,e),P=o(e),g(r.$$.fragment,e),R=o(e),f=p(e,"P",{"data-svelte-h":!0}),$(f)!=="svelte-123yn85"&&(f.innerHTML=Y),H=o(e),m=p(e,"P",{"data-svelte-h":!0}),$(m)!=="svelte-prqfoh"&&(m.innerHTML=A),W=o(e),g(c.$$.fragment,e),I=o(e),h=p(e,"P",{"data-svelte-h":!0}),$(h)!=="svelte-zr8d6f"&&(h.innerHTML=X),k=o(e),u=p(e,"P",{"data-svelte-h":!0}),$(u)!=="svelte-4gvw5x"&&(u.innerHTML=N),B=o(e),g(M.$$.fragment,e),F=o(e),b=p(e,"UL",{"data-svelte-h":!0}),$(b)!=="svelte-ruw7am"&&(b.innerHTML=S),C=o(e),g(_.$$.fragment,e),E=o(e),T=p(e,"P",{}),q(T).forEach(a),this.h()},h(){Q(i,"name","hf:doc:metadata"),Q(i,"content",ne)},m(e,t){ae(document.head,i),l(e,L,t),l(e,y,t),l(e,j,t),x(d,e,t),l(e,P,t),x(r,e,t),l(e,R,t),l(e,f,t),l(e,H,t),l(e,m,t),l(e,W,t),x(c,e,t),l(e,I,t),l(e,h,t),l(e,k,t),l(e,u,t),l(e,B,t),x(M,e,t),l(e,F,t),l(e,b,t),l(e,C,t),x(_,e,t),l(e,E,t),l(e,T,t),G=!0},p:D,i(e){G||(J(d.$$.fragment,e),J(r.$$.fragment,e),J(c.$$.fragment,e),J(M.$$.fragment,e),J(_.$$.fragment,e),G=!0)},o(e){v(d.$$.fragment,e),v(r.$$.fragment,e),v(c.$$.fragment,e),v(M.$$.fragment,e),v(_.$$.fragment,e),G=!1},d(e){e&&(a(L),a(y),a(j),a(P),a(R),a(f),a(H),a(m),a(W),a(I),a(h),a(k),a(u),a(B),a(F),a(b),a(C),a(E),a(T)),a(i),Z(d,e),Z(r,e),Z(c,e),Z(M,e),Z(_,e)}}}const ne='{"title":"Mixed adapter types","local":"mixed-adapter-types","sections":[{"title":"Tips","local":"tips","sections":[],"depth":2}],"depth":1}';function pe(U){return O(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ce extends K{constructor(i){super(),ee(this,i,pe,ie,z,{})}}export{ce as component};
