import{s as It,o as Rt,n as Wt}from"../chunks/scheduler.78382b47.js";import{S as Vt,i as Xt,e as d,s as l,c as w,h as Et,a as m,d as a,b as o,f as ct,g as f,j as J,k as ht,l as i,m as s,n as u,t as M,o as g,p as y}from"../chunks/index.6dd35eb6.js";import{C as Ht,H as P,E as Lt}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.fed9dfe4.js";import{D as xt}from"../chunks/Docstring.32e826ec.js";import{C as Jt}from"../chunks/CodeBlock.af1ec02e.js";import{E as Qt}from"../chunks/ExampleCodeBlock.7f184f2e.js";function At(q){let p,G="Example:",j,b,T;return b=new Jt({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQXV0b01vZGVsRm9yQ2F1c2FsTE0lMEFmcm9tJTIwcGVmdCUyMGltcG9ydCUyMFBlZnRNb2RlbCUwQWZyb20lMjBwZWZ0LnV0aWxzLmhvdHN3YXAlMjBpbXBvcnQlMjBob3Rzd2FwX2FkYXB0ZXIlMEElMEFtb2RlbF9pZCUyMCUzRCUyMC4uLiUwQWlucHV0cyUyMCUzRCUyMC4uLiUwQWRldmljZSUyMCUzRCUyMC4uLiUwQW1vZGVsJTIwJTNEJTIwQXV0b01vZGVsRm9yQ2F1c2FsTE0uZnJvbV9wcmV0cmFpbmVkKG1vZGVsX2lkKS50byhkZXZpY2UpJTBBJTBBJTIzJTIwbG9hZCUyMGxvcmElMjAwJTBBbW9kZWwlMjAlM0QlMjBQZWZ0TW9kZWwuZnJvbV9wcmV0cmFpbmVkKG1vZGVsJTJDJTIwJTIycGF0aC1hZGFwdGVyLTAlMjIpJTBBbW9kZWwlMjAlM0QlMjB0b3JjaC5jb21waWxlKG1vZGVsKSUyMCUyMCUyMyUyMG9wdGlvbmFsbHklMjBjb21waWxlJTIwdGhlJTIwbW9kZWwlMEF3aXRoJTIwdG9yY2guaW5mZXJlbmNlX21vZGUoKSUzQSUwQSUyMCUyMCUyMCUyMG91dHB1dF9hZGFwdGVyXzAlMjAlM0QlMjBtb2RlbChpbnB1dHMpJTBBJTBBJTIzJTIwcmVwbGFjZSUyMHRoZSUyMCUyMmRlZmF1bHQlMjIlMjBsb3JhJTIwYWRhcHRlciUyMHdpdGglMjB0aGUlMjBuZXclMjBvbmUlMEFob3Rzd2FwX2FkYXB0ZXIobW9kZWwlMkMlMjAlMjJwYXRoLWFkYXB0ZXItMSUyMiUyQyUyMGFkYXB0ZXJfbmFtZSUzRCUyMmRlZmF1bHQlMjIlMkMlMjB0b3JjaF9kZXZpY2UlM0RkZXZpY2UpJTBBd2l0aCUyMHRvcmNoLmluZmVyZW5jZV9tb2RlKCklM0ElMEElMjAlMjAlMjAlMjBvdXRwdXRfYWRhcHRlcl8xJTIwJTNEJTIwbW9kZWwoaW5wdXRzKS5sb2dpdHM=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForCausalLM
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> peft <span class="hljs-keyword">import</span> PeftModel
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> peft.utils.hotswap <span class="hljs-keyword">import</span> hotswap_adapter

<span class="hljs-meta">&gt;&gt;&gt; </span>model_id = ...
<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = ...
<span class="hljs-meta">&gt;&gt;&gt; </span>device = ...
<span class="hljs-meta">&gt;&gt;&gt; </span>model = AutoModelForCausalLM.from_pretrained(model_id).to(device)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># load lora 0</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = PeftModel.from_pretrained(model, <span class="hljs-string">&quot;path-adapter-0&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = torch.<span class="hljs-built_in">compile</span>(model)  <span class="hljs-comment"># optionally compile the model</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">with</span> torch.inference_mode():
<span class="hljs-meta">... </span>    output_adapter_0 = model(inputs)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># replace the &quot;default&quot; lora adapter with the new one</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>hotswap_adapter(model, <span class="hljs-string">&quot;path-adapter-1&quot;</span>, adapter_name=<span class="hljs-string">&quot;default&quot;</span>, torch_device=device)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">with</span> torch.inference_mode():
<span class="hljs-meta">... </span>    output_adapter_1 = model(inputs).logits`,wrap:!1}}),{c(){p=d("p"),p.textContent=G,j=l(),w(b.$$.fragment)},l(n){p=m(n,"P",{"data-svelte-h":!0}),J(p)!=="svelte-11lpom8"&&(p.textContent=G),j=o(n),f(b.$$.fragment,n)},m(n,_){s(n,p,_),s(n,j,_),u(b,n,_),T=!0},p:Wt,i(n){T||(M(b.$$.fragment,n),T=!0)},o(n){g(b.$$.fragment,n),T=!1},d(n){n&&(a(p),a(j)),y(b,n)}}}function Yt(q){let p,G,j,b,T,n,_,K,U,_t="The idea of hotswapping an adapter is the following: We can already load multiple adapters, e.g. two LoRAs, at the same time. But sometimes, we want to load one LoRA and then replace its weights in-place with the LoRA weights of another adapter. This is now possible the <code>hotswap_adapter</code> function.",D,C,jt="In general, this should be faster than deleting one adapter and loading the adapter in its place, which would be the how to achieve the same final outcome without hotswapping. Another advantage of hotswapping is that it prevents re-compilation in case the PEFT model is already compiled using <code>torch.compile</code>. This can save quite a lot of time.",O,B,tt,k,et,$,at,F,st,x,lt,I,Zt="Hotswapping works with transformers models and diffusers models. However, there are some caveats:",ot,R,vt="<li>Right now, only LoRA is properly supported.</li> <li>It only works for the same PEFT method, so no swapping LoRA and LoHa, for example.</li> <li>The adapter that is being swapped in must target the same layers as the previous adapter or a subset of those layers. It cannot target new layers. Therefore, if possible, start with the adapter that targets most layers.</li>",nt,W,pt,r,V,wt,H,Gt="Substitute old adapter data with new adapter data, keeping the rest the same.",ft,L,Ut="As of now, only LoRA is supported.",ut,Q,Ct=`This function is useful when you want to replace the loaded adapter with a new adapter. The adapter name will
remain the same, but the weights and other parameters will be swapped out.`,Mt,A,Bt=`If the adapters are incomptabile, e.g. targeting different layers or having different alpha values, an error will
be raised.`,gt,Z,rt,h,X,yt,Y,kt="Swap out the adapter weights from the model with the weights from state_dict.",bt,z,$t="As of now, only LoRA is supported.",Tt,N,Ft=`This is a low-level function that assumes that the adapters have been checked for compatibility and that the
state_dict has been correctly mapped to work with PEFT. For a high level function that performs this work for you,
use <code>hotswap_adapter</code> instead.`,dt,E,mt,S,it;return T=new Ht({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),_=new P({props:{title:"Hotswapping adapters",local:"hotswapping-adapters",headingTag:"h1"}}),B=new P({props:{title:"Example without torch.compile",local:"example-without-torchcompile",headingTag:"h2"}}),k=new Jt({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQXV0b01vZGVsRm9yQ2F1c2FsTE0lMEFmcm9tJTIwcGVmdCUyMGltcG9ydCUyMFBlZnRNb2RlbCUwQWZyb20lMjBwZWZ0LnV0aWxzLmhvdHN3YXAlMjBpbXBvcnQlMjBob3Rzd2FwX2FkYXB0ZXIlMEElMEFtb2RlbF9pZCUyMCUzRCUyMC4uLiUwQWlucHV0cyUyMCUzRCUyMC4uLiUwQWRldmljZSUyMCUzRCUyMC4uLiUwQW1vZGVsJTIwJTNEJTIwQXV0b01vZGVsRm9yQ2F1c2FsTE0uZnJvbV9wcmV0cmFpbmVkKG1vZGVsX2lkKS50byhkZXZpY2UpJTBBJTBBJTIzJTIwbG9hZCUyMGxvcmElMjAwJTBBbW9kZWwlMjAlM0QlMjBQZWZ0TW9kZWwuZnJvbV9wcmV0cmFpbmVkKG1vZGVsJTJDJTIwJTNDcGF0aC1hZGFwdGVyLTAlM0UpJTBBd2l0aCUyMHRvcmNoLmluZmVyZW5jZV9tb2RlKCklM0ElMEElMjAlMjAlMjAlMjBvdXRwdXRfYWRhcHRlcl8wJTIwJTNEJTIwbW9kZWwoaW5wdXRzKSUwQSUwQSUyMyUyMHJlcGxhY2UlMjB0aGUlMjAlMjJkZWZhdWx0JTIyJTIwbG9yYSUyMGFkYXB0ZXIlMjB3aXRoJTIwdGhlJTIwbmV3JTIwb25lJTBBaG90c3dhcF9hZGFwdGVyKG1vZGVsJTJDJTIwJTNDcGF0aC1hZGFwdGVyLTElM0UlMkMlMjBhZGFwdGVyX25hbWUlM0QlMjJkZWZhdWx0JTIyJTJDJTIwdG9yY2hfZGV2aWNlJTNEZGV2aWNlKSUwQXdpdGglMjB0b3JjaC5pbmZlcmVuY2VfbW9kZSgpJTNBJTBBJTIwJTIwJTIwJTIwb3V0cHV0X2FkYXB0ZXJfMSUyMCUzRCUyMG1vZGVsKGlucHV0cykubG9naXRz",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForCausalLM
<span class="hljs-keyword">from</span> peft <span class="hljs-keyword">import</span> PeftModel
<span class="hljs-keyword">from</span> peft.utils.hotswap <span class="hljs-keyword">import</span> hotswap_adapter

model_id = ...
inputs = ...
device = ...
model = AutoModelForCausalLM.from_pretrained(model_id).to(device)

<span class="hljs-comment"># load lora 0</span>
model = PeftModel.from_pretrained(model, &lt;path-adapter-<span class="hljs-number">0</span>&gt;)
<span class="hljs-keyword">with</span> torch.inference_mode():
    output_adapter_0 = model(inputs)

<span class="hljs-comment"># replace the &quot;default&quot; lora adapter with the new one</span>
hotswap_adapter(model, &lt;path-adapter-<span class="hljs-number">1</span>&gt;, adapter_name=<span class="hljs-string">&quot;default&quot;</span>, torch_device=device)
<span class="hljs-keyword">with</span> torch.inference_mode():
    output_adapter_1 = model(inputs).logits`,wrap:!1}}),$=new P({props:{title:"Example with torch.compile",local:"example-with-torchcompile",headingTag:"h2"}}),F=new Jt({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQXV0b01vZGVsRm9yQ2F1c2FsTE0lMEFmcm9tJTIwcGVmdCUyMGltcG9ydCUyMFBlZnRNb2RlbCUwQWZyb20lMjBwZWZ0LnV0aWxzLmhvdHN3YXAlMjBpbXBvcnQlMjBob3Rzd2FwX2FkYXB0ZXIlMkMlMjBwcmVwYXJlX21vZGVsX2Zvcl9jb21waWxlZF9ob3Rzd2FwJTBBJTBBbW9kZWxfaWQlMjAlM0QlMjAuLi4lMEFpbnB1dHMlMjAlM0QlMjAuLi4lMEFkZXZpY2UlMjAlM0QlMjAuLi4lMEFtYXhfcmFuayUyMCUzRCUyMC4uLiUyMCUyMCUyMyUyMG1heGltdW0lMjByYW5rJTIwYW1vbmclMjBhbGwlMjBMb1JBJTIwYWRhcHRlcnMlMjB0aGF0JTIwd2lsbCUyMGJlJTIwdXNlZCUwQW1vZGVsJTIwJTNEJTIwQXV0b01vZGVsRm9yQ2F1c2FsTE0uZnJvbV9wcmV0cmFpbmVkKG1vZGVsX2lkKS50byhkZXZpY2UpJTBBJTBBJTIzJTIwbG9hZCUyMGxvcmElMjAwJTBBbW9kZWwlMjAlM0QlMjBQZWZ0TW9kZWwuZnJvbV9wcmV0cmFpbmVkKG1vZGVsJTJDJTIwJTNDcGF0aC1hZGFwdGVyLTAlM0UpJTBBJTIzJTIwUHJlcGFyZSUyMHRoZSUyMG1vZGVsJTIwdG8lMjBhbGxvdyUyMGhvdHN3YXBwaW5nJTIwZXZlbiUyMGlmJTIwcmFua3MlMkZzY2FsaW5ncyUyMG9mJTIwMm5kJTIwYWRhcHRlciUyMGRpZmZlci4lMEElMjMlMjBZb3UlMjBjYW4lMjBza2lwJTIwdGhpcyUyMHN0ZXAlMjBpZiUyMGFsbCUyMHJhbmtzJTIwYW5kJTIwc2NhbGluZ3MlMjBhcmUlMjBpZGVudGljYWwuJTBBcHJlcGFyZV9tb2RlbF9mb3JfY29tcGlsZWRfaG90c3dhcChtb2RlbCUyQyUyMHRhcmdldF9yYW5rJTNEbWF4X3JhbmspJTBBbW9kZWwlMjAlM0QlMjB0b3JjaC5jb21waWxlKG1vZGVsKSUwQXdpdGglMjB0b3JjaC5pbmZlcmVuY2VfbW9kZSgpJTNBJTBBJTIwJTIwJTIwJTIwb3V0cHV0X2FkYXB0ZXJfMCUyMCUzRCUyMG1vZGVsKGlucHV0cyklMEElMEElMjMlMjByZXBsYWNlJTIwdGhlJTIwJTIyZGVmYXVsdCUyMiUyMGxvcmElMjBhZGFwdGVyJTIwd2l0aCUyMHRoZSUyMG5ldyUyMG9uZSUwQWhvdHN3YXBfYWRhcHRlcihtb2RlbCUyQyUyMCUzQ3BhdGgtYWRhcHRlci0xJTNFJTJDJTIwYWRhcHRlcl9uYW1lJTNEJTIyZGVmYXVsdCUyMiUyQyUyMHRvcmNoX2RldmljZSUzRGRldmljZSklMEF3aXRoJTIwdG9yY2guaW5mZXJlbmNlX21vZGUoKSUzQSUwQSUyMCUyMCUyMCUyMG91dHB1dF9hZGFwdGVyXzElMjAlM0QlMjBtb2RlbChpbnB1dHMpLmxvZ2l0cw==",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForCausalLM
<span class="hljs-keyword">from</span> peft <span class="hljs-keyword">import</span> PeftModel
<span class="hljs-keyword">from</span> peft.utils.hotswap <span class="hljs-keyword">import</span> hotswap_adapter, prepare_model_for_compiled_hotswap

model_id = ...
inputs = ...
device = ...
max_rank = ...  <span class="hljs-comment"># maximum rank among all LoRA adapters that will be used</span>
model = AutoModelForCausalLM.from_pretrained(model_id).to(device)

<span class="hljs-comment"># load lora 0</span>
model = PeftModel.from_pretrained(model, &lt;path-adapter-<span class="hljs-number">0</span>&gt;)
<span class="hljs-comment"># Prepare the model to allow hotswapping even if ranks/scalings of 2nd adapter differ.</span>
<span class="hljs-comment"># You can skip this step if all ranks and scalings are identical.</span>
prepare_model_for_compiled_hotswap(model, target_rank=max_rank)
model = torch.<span class="hljs-built_in">compile</span>(model)
<span class="hljs-keyword">with</span> torch.inference_mode():
    output_adapter_0 = model(inputs)

<span class="hljs-comment"># replace the &quot;default&quot; lora adapter with the new one</span>
hotswap_adapter(model, &lt;path-adapter-<span class="hljs-number">1</span>&gt;, adapter_name=<span class="hljs-string">&quot;default&quot;</span>, torch_device=device)
<span class="hljs-keyword">with</span> torch.inference_mode():
    output_adapter_1 = model(inputs).logits`,wrap:!1}}),x=new P({props:{title:"Caveats",local:"caveats",headingTag:"h2"}}),W=new P({props:{title:"API",local:"peft.utils.hotswap.hotswap_adapter",headingTag:"h2"}}),V=new xt({props:{name:"peft.utils.hotswap.hotswap_adapter",anchor:"peft.utils.hotswap.hotswap_adapter",parameters:[{name:"model",val:""},{name:"model_name_or_path",val:""},{name:"adapter_name",val:""},{name:"torch_device",val:" = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"peft.utils.hotswap.hotswap_adapter.model",description:`<strong>model</strong> (<a href="/docs/peft/main/en/package_reference/peft_model#peft.PeftModel">~PeftModel</a>) &#x2014;
The PEFT model with the loaded adapter.`,name:"model"},{anchor:"peft.utils.hotswap.hotswap_adapter.model_name_or_path",description:`<strong>model_name_or_path</strong> (<code>str</code>) &#x2014;
The name or path of the model to load the new adapter from.`,name:"model_name_or_path"},{anchor:"peft.utils.hotswap.hotswap_adapter.adapter_name",description:`<strong>adapter_name</strong> (<code>str</code>) &#x2014;
The name of the adapter to swap, e.g. <code>&quot;default&quot;</code>. The name will stay the same after swapping.`,name:"adapter_name"},{anchor:"peft.utils.hotswap.hotswap_adapter.torch_device",description:`<strong>torch_device</strong> &#x2014; (<code>str</code>, <em>optional</em>, defaults to None):
The device to load the new adapter onto.`,name:"torch_device"},{anchor:"peft.utils.hotswap.hotswap_adapter.*kwargs",description:`*<strong>*kwargs</strong> (<code>optional</code>) &#x2014;
Additional keyword arguments used for loading the config and weights.`,name:"*kwargs"}],source:"https://github.com/huggingface/peft/blob/main/src/peft/utils/hotswap.py#L545"}}),Z=new Qt({props:{anchor:"peft.utils.hotswap.hotswap_adapter.example",$$slots:{default:[At]},$$scope:{ctx:q}}}),X=new xt({props:{name:"peft.utils.hotswap.hotswap_adapter_from_state_dict",anchor:"peft.utils.hotswap.hotswap_adapter_from_state_dict",parameters:[{name:"model",val:": torch.nn.Module"},{name:"state_dict",val:": dict[str, torch.Tensor]"},{name:"adapter_name",val:": str"},{name:"config",val:": LoraConfig"},{name:"parameter_prefix",val:": str = 'lora_'"}],parametersDescription:[{anchor:"peft.utils.hotswap.hotswap_adapter_from_state_dict.model",description:`<strong>model</strong> (<code>nn.Module</code>) &#x2014;
The model with the loaded adapter.`,name:"model"},{anchor:"peft.utils.hotswap.hotswap_adapter_from_state_dict.state_dict",description:`<strong>state_dict</strong> (<code>dict[str, torch.Tensor]</code>) &#x2014;
The state dict of the new adapter, which needs to be compatible (targeting same modules etc.).`,name:"state_dict"},{anchor:"peft.utils.hotswap.hotswap_adapter_from_state_dict.adapter_name",description:`<strong>adapter_name</strong> (<code>str</code>) &#x2014;
The name of the adapter that should be hot-swapped, e.g. <code>&quot;default&quot;</code>. The name will remain the same after
swapping.`,name:"adapter_name"},{anchor:"peft.utils.hotswap.hotswap_adapter_from_state_dict.config",description:`<strong>config</strong> (<code>LoraConfig</code>) &#x2014;
The config of the LoRA adapter. This is used to determine the scaling and rank of the adapter.`,name:"config"},{anchor:"peft.utils.hotswap.hotswap_adapter_from_state_dict.parameter_prefix",description:`<strong>parameter_prefix</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;lora_&quot;</code>) &#x2014;
The prefix used to identify the adapter&#x2019;s keys in the state dict. For LoRA, this would be <code>&quot;lora_&quot;</code> (the
default).`,name:"parameter_prefix"}],source:"https://github.com/huggingface/peft/blob/main/src/peft/utils/hotswap.py#L369",raiseDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<ul>
<li><code>RuntimeError</code> —
If the old and the new adapter are not compatible, a RuntimeError is raised.</li>
</ul>
`,raiseType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>RuntimeError</code></p>
`}}),E=new Lt({props:{source:"https://github.com/huggingface/peft/blob/main/docs/source/package_reference/hotswap.md"}}),{c(){p=d("meta"),G=l(),j=d("p"),b=l(),w(T.$$.fragment),n=l(),w(_.$$.fragment),K=l(),U=d("p"),U.innerHTML=_t,D=l(),C=d("p"),C.innerHTML=jt,O=l(),w(B.$$.fragment),tt=l(),w(k.$$.fragment),et=l(),w($.$$.fragment),at=l(),w(F.$$.fragment),st=l(),w(x.$$.fragment),lt=l(),I=d("p"),I.textContent=Zt,ot=l(),R=d("ul"),R.innerHTML=vt,nt=l(),w(W.$$.fragment),pt=l(),r=d("div"),w(V.$$.fragment),wt=l(),H=d("p"),H.textContent=Gt,ft=l(),L=d("p"),L.textContent=Ut,ut=l(),Q=d("p"),Q.textContent=Ct,Mt=l(),A=d("p"),A.textContent=Bt,gt=l(),w(Z.$$.fragment),rt=l(),h=d("div"),w(X.$$.fragment),yt=l(),Y=d("p"),Y.textContent=kt,bt=l(),z=d("p"),z.textContent=$t,Tt=l(),N=d("p"),N.innerHTML=Ft,dt=l(),w(E.$$.fragment),mt=l(),S=d("p"),this.h()},l(t){const e=Et("svelte-u9bgzb",document.head);p=m(e,"META",{name:!0,content:!0}),e.forEach(a),G=o(t),j=m(t,"P",{}),ct(j).forEach(a),b=o(t),f(T.$$.fragment,t),n=o(t),f(_.$$.fragment,t),K=o(t),U=m(t,"P",{"data-svelte-h":!0}),J(U)!=="svelte-1r4koev"&&(U.innerHTML=_t),D=o(t),C=m(t,"P",{"data-svelte-h":!0}),J(C)!=="svelte-2f3tnn"&&(C.innerHTML=jt),O=o(t),f(B.$$.fragment,t),tt=o(t),f(k.$$.fragment,t),et=o(t),f($.$$.fragment,t),at=o(t),f(F.$$.fragment,t),st=o(t),f(x.$$.fragment,t),lt=o(t),I=m(t,"P",{"data-svelte-h":!0}),J(I)!=="svelte-1904uk3"&&(I.textContent=Zt),ot=o(t),R=m(t,"UL",{"data-svelte-h":!0}),J(R)!=="svelte-1ybjwin"&&(R.innerHTML=vt),nt=o(t),f(W.$$.fragment,t),pt=o(t),r=m(t,"DIV",{class:!0});var c=ct(r);f(V.$$.fragment,c),wt=o(c),H=m(c,"P",{"data-svelte-h":!0}),J(H)!=="svelte-9ihruw"&&(H.textContent=Gt),ft=o(c),L=m(c,"P",{"data-svelte-h":!0}),J(L)!=="svelte-10f33xj"&&(L.textContent=Ut),ut=o(c),Q=m(c,"P",{"data-svelte-h":!0}),J(Q)!=="svelte-rl33pg"&&(Q.textContent=Ct),Mt=o(c),A=m(c,"P",{"data-svelte-h":!0}),J(A)!=="svelte-1e6bpeq"&&(A.textContent=Bt),gt=o(c),f(Z.$$.fragment,c),c.forEach(a),rt=o(t),h=m(t,"DIV",{class:!0});var v=ct(h);f(X.$$.fragment,v),yt=o(v),Y=m(v,"P",{"data-svelte-h":!0}),J(Y)!=="svelte-1sueth6"&&(Y.textContent=kt),bt=o(v),z=m(v,"P",{"data-svelte-h":!0}),J(z)!=="svelte-10f33xj"&&(z.textContent=$t),Tt=o(v),N=m(v,"P",{"data-svelte-h":!0}),J(N)!=="svelte-1dqtnq6"&&(N.innerHTML=Ft),v.forEach(a),dt=o(t),f(E.$$.fragment,t),mt=o(t),S=m(t,"P",{}),ct(S).forEach(a),this.h()},h(){ht(p,"name","hf:doc:metadata"),ht(p,"content",zt),ht(r,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),ht(h,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(t,e){i(document.head,p),s(t,G,e),s(t,j,e),s(t,b,e),u(T,t,e),s(t,n,e),u(_,t,e),s(t,K,e),s(t,U,e),s(t,D,e),s(t,C,e),s(t,O,e),u(B,t,e),s(t,tt,e),u(k,t,e),s(t,et,e),u($,t,e),s(t,at,e),u(F,t,e),s(t,st,e),u(x,t,e),s(t,lt,e),s(t,I,e),s(t,ot,e),s(t,R,e),s(t,nt,e),u(W,t,e),s(t,pt,e),s(t,r,e),u(V,r,null),i(r,wt),i(r,H),i(r,ft),i(r,L),i(r,ut),i(r,Q),i(r,Mt),i(r,A),i(r,gt),u(Z,r,null),s(t,rt,e),s(t,h,e),u(X,h,null),i(h,yt),i(h,Y),i(h,bt),i(h,z),i(h,Tt),i(h,N),s(t,dt,e),u(E,t,e),s(t,mt,e),s(t,S,e),it=!0},p(t,[e]){const c={};e&2&&(c.$$scope={dirty:e,ctx:t}),Z.$set(c)},i(t){it||(M(T.$$.fragment,t),M(_.$$.fragment,t),M(B.$$.fragment,t),M(k.$$.fragment,t),M($.$$.fragment,t),M(F.$$.fragment,t),M(x.$$.fragment,t),M(W.$$.fragment,t),M(V.$$.fragment,t),M(Z.$$.fragment,t),M(X.$$.fragment,t),M(E.$$.fragment,t),it=!0)},o(t){g(T.$$.fragment,t),g(_.$$.fragment,t),g(B.$$.fragment,t),g(k.$$.fragment,t),g($.$$.fragment,t),g(F.$$.fragment,t),g(x.$$.fragment,t),g(W.$$.fragment,t),g(V.$$.fragment,t),g(Z.$$.fragment,t),g(X.$$.fragment,t),g(E.$$.fragment,t),it=!1},d(t){t&&(a(G),a(j),a(b),a(n),a(K),a(U),a(D),a(C),a(O),a(tt),a(et),a(at),a(st),a(lt),a(I),a(ot),a(R),a(nt),a(pt),a(r),a(rt),a(h),a(dt),a(mt),a(S)),a(p),y(T,t),y(_,t),y(B,t),y(k,t),y($,t),y(F,t),y(x,t),y(W,t),y(V),y(Z),y(X),y(E,t)}}}const zt='{"title":"Hotswapping adapters","local":"hotswapping-adapters","sections":[{"title":"Example without torch.compile","local":"example-without-torchcompile","sections":[],"depth":2},{"title":"Example with torch.compile","local":"example-with-torchcompile","sections":[],"depth":2},{"title":"Caveats","local":"caveats","sections":[],"depth":2},{"title":"API","local":"peft.utils.hotswap.hotswap_adapter","sections":[],"depth":2}],"depth":1}';function Nt(q){return Rt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class te extends Vt{constructor(p){super(),Xt(this,p,Nt,Yt,It,{})}}export{te as component};
