import{s as Me,n as Le,o as Pe}from"../chunks/scheduler.4cd3e004.js";import{S as ze,i as Oe,e as r,s as a,c as H,h as He,a as s,d as n,b as i,f as ie,g as q,j as p,k as re,l as d,m as o,n as U,t as N,o as E,p as D}from"../chunks/index.b664cb2d.js";import{D as ke}from"../chunks/Docstring.9ceb4334.js";import{H as ce,E as qe}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.179b63f8.js";function Ue(fe){let c,R,F,B,u,j,h,ue='<a href="https://huggingface.co/papers/2407.19342" rel="nofollow">C3A</a> is a parameter-efficient fine-tuning technique that leverages Circular Convolution to achieve high rank adaptation within reasonable resource limits.',S,g,he="Note that you should use a much larger learning rate (LR) for C3A than for other methods. For example, a LR of 1e-1 for C3A is a good starting point. Besides, a much smaller weight decay should be used. You can refer to the <code>method_comparison</code> folder for more details.",Q,_,ge="For the <code>block_size</code>, it affects tunable parameters and performance. To start with, you can choose a $\\mathrm{gcd}(d_1,d_2)$ near $\\frac{\\sqrt{d_1\\times d_2}}{r}$, where $r$ is the rank for LoRA you would use for this task.",V,C,_e="C3A currently has the following constraints:",G,v,Ce="<li>Only <code>nn.Linear</code> layers are supported.</li> <li>Quantized layers are not supported.</li> <li>The block size should be a common divisor of both the input and output sizes of target layers.</li>",K,b,ve="If these constraints don’t work for your use case, consider other methods instead.",W,x,be="The abstract from the paper is:",Y,y,xe="<p>Low-Rank Adaptation (LoRA) has gained popularity for fine-tuning large foundation models, leveraging low-rank matrices $\\mathbf{A}$ and $\\mathbf{B}$ to represent weight changes (i.e., $\\Delta \\mathbf{W} = \\mathbf{B} \\mathbf{A}$). This method reduces trainable parameters and mitigates heavy memory consumption associated with full delta matrices by sequentially multiplying $\\mathbf{A}$ and $\\mathbf{B}$ with the activation. Despite its success, the intrinsic low-rank characteristic may limit its performance. Although several variants have been proposed to address this issue, they often overlook the crucial computational and memory efficiency brought by LoRA. In this paper, we propose Circular Convolution Adaptation (C3A), which not only achieves high-rank adaptation with enhanced performance but also excels in both computational power and memory utilization. Extensive experiments demonstrate that C3A consistently outperforms LoRA and its variants across various fine-tuning tasks.</p>",J,$,X,f,A,se,M,ye='This is the configuration class to store the configuration of a <a href="/docs/peft/main/en/package_reference/c3a#peft.C3AModel">C3AModel</a>.',Z,w,ee,l,T,le,L,$e="Creates C3A model from a pretrained transformers model.",pe,P,Ae="The method is described in detail in [TODO].",de,z,we="<strong>Attributes</strong>:",me,O,Te='<li><strong>model</strong> (<a href="https://huggingface.co/docs/transformers/main/en/main_classes/model#transformers.PreTrainedModel" rel="nofollow">PreTrainedModel</a>) — The model to be adapted.</li> <li><strong>peft_config</strong> (<a href="/docs/peft/main/en/package_reference/c3a#peft.C3AConfig">C3AConfig</a>): The configuration of the C3A model.</li>',te,k,ne,I,oe;return u=new ce({props:{title:"C3A: Parameter-Efficient Fine-Tuning via Circular Convolution",local:"c3a-parameter-efficient-fine-tuning-via-circular-convolution",headingTag:"h1"}}),$=new ce({props:{title:"C3AConfig",local:"peft.C3AConfig",headingTag:"h2"}}),A=new ke({props:{name:"class peft.C3AConfig",anchor:"peft.C3AConfig",parameters:[{name:"task_type",val:": Optional[Union[str, TaskType]] = None"},{name:"peft_type",val:": Optional[Union[str, PeftType]] = None"},{name:"auto_mapping",val:": Optional[dict] = None"},{name:"peft_version",val:": Optional[str] = None"},{name:"base_model_name_or_path",val:": Optional[str] = None"},{name:"revision",val:": Optional[str] = None"},{name:"inference_mode",val:": bool = False"},{name:"block_size",val:": int = 256"},{name:"target_modules",val:": Optional[Union[list[str], str]] = None"},{name:"bias",val:": str = 'none'"},{name:"modules_to_save",val:": Optional[list[str]] = None"},{name:"layers_to_transform",val:": Optional[Union[list[int], int]] = None"},{name:"layers_pattern",val:": Optional[Union[list[str], str]] = None"},{name:"block_size_pattern",val:": Optional[dict] = <factory>"},{name:"init_weights",val:": Optional[Union[bool, Literal['gaussian', 'kaiming_uniform', 'xavier_uniform']]] = 'xavier_uniform'"}],parametersDescription:[{anchor:"peft.C3AConfig.block_size",description:`<strong>block_size</strong> (<code>int</code>) &#x2014;
block size for C3A, must be divisible by both the input size and the output size of the target layer. If
you have no idea what block_size you should use, set it to the greatest common divisor of all input &amp;
output sizes of your target layers. Increasing this would result in less parameters.`,name:"block_size"},{anchor:"peft.C3AConfig.target_modules",description:"<strong>target_modules</strong> (<code>Union[list[str],str]</code>) &#x2014; The names of the modules to apply C3A to.",name:"target_modules"},{anchor:"peft.C3AConfig.bias",description:`<strong>bias</strong> (<code>str</code>) &#x2014; Bias type for C3A. Can be &#x2018;none&#x2019;, &#x2018;all&#x2019; or &#x2018;c3a_only&#x2019;. If &#x2018;all&#x2019; or &#x2018;c3a_only&#x2019;, the
corresponding biases will be updated during training. Be aware that this means that, even when disabling
the adapters, the model will not produce the same output as the base model would have without adaptation.`,name:"bias"},{anchor:"peft.C3AConfig.modules_to_save",description:`<strong>modules_to_save</strong> (<code>list[str]</code>) &#x2014;list of modules apart from C3A layers to be set as trainable
and saved in the final checkpoint.`,name:"modules_to_save"},{anchor:"peft.C3AConfig.layers_to_transform",description:`<strong>layers_to_transform</strong> (<code>Union[list[int],int]</code>) &#x2014;
The layer indexes to transform, if this argument is specified, it will apply C3A on the layer indexes that
are specified in this list. If a single integer is passed, it will apply C3A on the layer at this index.`,name:"layers_to_transform"},{anchor:"peft.C3AConfig.layers_pattern",description:`<strong>layers_pattern</strong> (<code>str</code>) &#x2014;
The layer pattern name, used only if <code>layers_to_transform</code> is different from <code>None</code> and if the layer
pattern is not in the common layers pattern.`,name:"layers_pattern"},{anchor:"peft.C3AConfig.block_size_pattern",description:`<strong>block_size_pattern</strong> (<code>dict</code>) &#x2014;
The mapping from layer names or regexp expression to block_size which are different from the default
specified. For example, <code>{&quot;model.decoder.layers.0.encoder_attn.k_proj&quot;: 1280</code>}`,name:"block_size_pattern"},{anchor:"peft.C3AConfig.init_weights",description:`<strong>init_weights</strong> (<code>Union[bool, Literal[&quot;gaussian&quot;, &quot;kaiming_uniform&quot;, &quot;xavier_uniform&quot;]]</code>) &#x2014;
Defaults to &#x2018;xavier_uniform&#x2019;. Setting this to <code>False</code> also uses &#x2018;xavier_uniform&#x2019;. To set the weights to
zeros (thus making C3A a no-op), set the value to <code>True</code>.`,name:"init_weights"}],source:"https://github.com/huggingface/peft/blob/main/src/peft/tuners/c3a/config.py#L25"}}),w=new ce({props:{title:"C3AModel",local:"peft.C3AModel",headingTag:"h2"}}),T=new ke({props:{name:"class peft.C3AModel",anchor:"peft.C3AModel",parameters:[{name:"model",val:""},{name:"peft_config",val:": Union[PeftConfig, dict[str, PeftConfig]]"},{name:"adapter_name",val:": str"},{name:"low_cpu_mem_usage",val:": bool = False"},{name:"state_dict",val:": Optional[dict[str, torch.Tensor]] = None"}],parametersDescription:[{anchor:"peft.C3AModel.model",description:"<strong>model</strong> (<code>torch.nn.Module</code>) &#x2014; The model to be adapted.",name:"model"},{anchor:"peft.C3AModel.config",description:'<strong>config</strong> (<a href="/docs/peft/main/en/package_reference/c3a#peft.C3AConfig">C3AConfig</a>) &#x2014; The configuration of the C3A model.',name:"config"},{anchor:"peft.C3AModel.adapter_name",description:"<strong>adapter_name</strong> (<code>str</code>) &#x2014; The name of the adapter, defaults to <code>&quot;default&quot;</code>.",name:"adapter_name"}],source:"https://github.com/huggingface/peft/blob/main/src/peft/tuners/c3a/model.py#L29",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>The C3A model.</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>torch.nn.Module</code></p>
`}}),k=new qe({props:{source:"https://github.com/huggingface/peft/blob/main/docs/source/package_reference/c3a.md"}}),{c(){c=r("meta"),R=a(),F=r("p"),B=a(),H(u.$$.fragment),j=a(),h=r("p"),h.innerHTML=ue,S=a(),g=r("p"),g.innerHTML=he,Q=a(),_=r("p"),_.innerHTML=ge,V=a(),C=r("p"),C.textContent=_e,G=a(),v=r("ul"),v.innerHTML=Ce,K=a(),b=r("p"),b.textContent=ve,W=a(),x=r("p"),x.textContent=be,Y=a(),y=r("blockquote"),y.innerHTML=xe,J=a(),H($.$$.fragment),X=a(),f=r("div"),H(A.$$.fragment),se=a(),M=r("p"),M.innerHTML=ye,Z=a(),H(w.$$.fragment),ee=a(),l=r("div"),H(T.$$.fragment),le=a(),L=r("p"),L.textContent=$e,pe=a(),P=r("p"),P.textContent=Ae,de=a(),z=r("p"),z.innerHTML=we,me=a(),O=r("ul"),O.innerHTML=Te,te=a(),H(k.$$.fragment),ne=a(),I=r("p"),this.h()},l(e){const t=He("svelte-u9bgzb",document.head);c=s(t,"META",{name:!0,content:!0}),t.forEach(n),R=i(e),F=s(e,"P",{}),ie(F).forEach(n),B=i(e),q(u.$$.fragment,e),j=i(e),h=s(e,"P",{"data-svelte-h":!0}),p(h)!=="svelte-176me16"&&(h.innerHTML=ue),S=i(e),g=s(e,"P",{"data-svelte-h":!0}),p(g)!=="svelte-k0duw2"&&(g.innerHTML=he),Q=i(e),_=s(e,"P",{"data-svelte-h":!0}),p(_)!=="svelte-1si0dt5"&&(_.innerHTML=ge),V=i(e),C=s(e,"P",{"data-svelte-h":!0}),p(C)!=="svelte-1drsmrd"&&(C.textContent=_e),G=i(e),v=s(e,"UL",{"data-svelte-h":!0}),p(v)!=="svelte-1k3lv1f"&&(v.innerHTML=Ce),K=i(e),b=s(e,"P",{"data-svelte-h":!0}),p(b)!=="svelte-hr8j55"&&(b.textContent=ve),W=i(e),x=s(e,"P",{"data-svelte-h":!0}),p(x)!=="svelte-1cwsb16"&&(x.textContent=be),Y=i(e),y=s(e,"BLOCKQUOTE",{"data-svelte-h":!0}),p(y)!=="svelte-1g9m7ok"&&(y.innerHTML=xe),J=i(e),q($.$$.fragment,e),X=i(e),f=s(e,"DIV",{class:!0});var ae=ie(f);q(A.$$.fragment,ae),se=i(ae),M=s(ae,"P",{"data-svelte-h":!0}),p(M)!=="svelte-1qp1vi"&&(M.innerHTML=ye),ae.forEach(n),Z=i(e),q(w.$$.fragment,e),ee=i(e),l=s(e,"DIV",{class:!0});var m=ie(l);q(T.$$.fragment,m),le=i(m),L=s(m,"P",{"data-svelte-h":!0}),p(L)!=="svelte-1t8bppl"&&(L.textContent=$e),pe=i(m),P=s(m,"P",{"data-svelte-h":!0}),p(P)!=="svelte-1jpn2f4"&&(P.textContent=Ae),de=i(m),z=s(m,"P",{"data-svelte-h":!0}),p(z)!=="svelte-1xx6nm4"&&(z.innerHTML=we),me=i(m),O=s(m,"UL",{"data-svelte-h":!0}),p(O)!=="svelte-1xwau62"&&(O.innerHTML=Te),m.forEach(n),te=i(e),q(k.$$.fragment,e),ne=i(e),I=s(e,"P",{}),ie(I).forEach(n),this.h()},h(){re(c,"name","hf:doc:metadata"),re(c,"content",Ne),re(f,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),re(l,"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,t){d(document.head,c),o(e,R,t),o(e,F,t),o(e,B,t),U(u,e,t),o(e,j,t),o(e,h,t),o(e,S,t),o(e,g,t),o(e,Q,t),o(e,_,t),o(e,V,t),o(e,C,t),o(e,G,t),o(e,v,t),o(e,K,t),o(e,b,t),o(e,W,t),o(e,x,t),o(e,Y,t),o(e,y,t),o(e,J,t),U($,e,t),o(e,X,t),o(e,f,t),U(A,f,null),d(f,se),d(f,M),o(e,Z,t),U(w,e,t),o(e,ee,t),o(e,l,t),U(T,l,null),d(l,le),d(l,L),d(l,pe),d(l,P),d(l,de),d(l,z),d(l,me),d(l,O),o(e,te,t),U(k,e,t),o(e,ne,t),o(e,I,t),oe=!0},p:Le,i(e){oe||(N(u.$$.fragment,e),N($.$$.fragment,e),N(A.$$.fragment,e),N(w.$$.fragment,e),N(T.$$.fragment,e),N(k.$$.fragment,e),oe=!0)},o(e){E(u.$$.fragment,e),E($.$$.fragment,e),E(A.$$.fragment,e),E(w.$$.fragment,e),E(T.$$.fragment,e),E(k.$$.fragment,e),oe=!1},d(e){e&&(n(R),n(F),n(B),n(j),n(h),n(S),n(g),n(Q),n(_),n(V),n(C),n(G),n(v),n(K),n(b),n(W),n(x),n(Y),n(y),n(J),n(X),n(f),n(Z),n(ee),n(l),n(te),n(ne),n(I)),n(c),D(u,e),D($,e),D(A),D(w,e),D(T),D(k,e)}}}const Ne='{"title":"C3A: Parameter-Efficient Fine-Tuning via Circular Convolution","local":"c3a-parameter-efficient-fine-tuning-via-circular-convolution","sections":[{"title":"C3AConfig","local":"peft.C3AConfig","sections":[],"depth":2},{"title":"C3AModel","local":"peft.C3AModel","sections":[],"depth":2}],"depth":1}';function Ee(fe){return Pe(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Be extends ze{constructor(c){super(),Oe(this,c,Ee,Ue,Me,{})}}export{Be as component};
