import{s as te,n as ae,o as ne}from"../chunks/scheduler.4cd3e004.js";import{S as oe,i as ie,e as l,s as o,c as w,h as re,a as d,d as a,b as i,f as V,g as R,j as W,k as j,l as G,m as n,n as y,t as x,o as T,p as C}from"../chunks/index.b664cb2d.js";import{D as ee}from"../chunks/Docstring.9ceb4334.js";import{H as B,E as se}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.179b63f8.js";function le(J){let r,z,M,A,p,P,m,K='<a href="https://arxiv.org/pdf/2409.00119" rel="nofollow">RoAd</a> is a parameter‑efficient fine‑tuning technique that adapts large language models by learning a small set of 2×2 rotation matrices (and optional scaling factors) applied to pairs of hidden dimensions. RoAd achieves competitive or superior performance compared to other PEFT methods with under 0.1% trainable parameters. Unlike LoRA’s batched low‑rank updates, RoAd’s sparse rotations reformulate to simple element‑wise operations, yielding significantly higher serving throughput when handling heterogeneous requests in the same batch, i.e. serving multiple adapters simulatenously. Moreover, RoAd integrates seamlessly into a distributed interchange intervention framework, interpreting its sparse 2D rotations as task-specific interventions within learned subspaces of hidden representations. These orthogonal subspaces can be composed to merge multiple task-specific behaviors—like multilingual capabilities or instruction following—without additional fine-tuning, enabling modular, interpretable adaptations in LLMs.',k,f,Q="Finetuning with RoAd typically requires higher learning rate compared to LoRA or similar methods, around 1e-3. Currently RoAd only supports linear layers and it can be used on models quantized with bitsandbytes (4-bit or 8-bit).",U,h,X='For running inference with different RoAd adapters in the same batch see <a href="../developer_guides/lora#inference-with-different-lora-adapters-in-the-same-batch">Inference with different LoRA adapters in the same batch</a>.',O,c,N,s,u,S,$,Y=`This is the configuration class to store the configuration of a <a href="/docs/peft/main/en/package_reference/road#peft.RoadModel">RoadModel</a>. RoAd adapter is proposed in
<a href="https://arxiv.org/pdf/2409.00119" rel="nofollow">https://arxiv.org/pdf/2409.00119</a>.`,E,g,D,_,v,H,b,I,L,q;return p=new B({props:{title:"RoAd",local:"road",headingTag:"h1"}}),c=new B({props:{title:"RoadConfig",local:"peft.RoadConfig",headingTag:"h2"}}),u=new ee({props:{name:"class peft.RoadConfig",anchor:"peft.RoadConfig",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:"variant",val:": Union[str, RoadVariant] = 'road_1'"},{name:"group_size",val:": int = 64"},{name:"init_weights",val:": bool = True"},{name:"target_modules",val:": Optional[Union[list[str], str]] = None"},{name:"modules_to_save",val:": Optional[list[str]] = None"}],parametersDescription:[{anchor:"peft.RoadConfig.variant",description:`<strong>variant</strong> (Union[<code>RoadVariant</code>, <code>str</code>]) &#x2014;
The variant of the Road model to use. It can be one of road_1, road_2, or road_4. Refer to the paper for
more details.<ul>
<li>road_1: Uses the same scale and angle for all pairs of elements.
This variant has lowest number of parameters, it stores a number equal to the output hidden size of
parameters for each layer that RoAd is applied to.</li>
<li>road_2: Uses the same scale and angle for each element.
This variant has 2x the number of parameters compared to road_1.</li>
<li>road_4: Uses two different scales and angles for each ellement.
This variant has 4x the number of parameters compared to road_1.</li>
</ul>`,name:"variant"},{anchor:"peft.RoadConfig.group_size",description:`<strong>group_size</strong> (<code>int</code>) &#x2014;
Group size defines how elements are grouped together into 2D vectors for rotation. Within each group
element 0 is paired with element group_size/2, then element 1 is paired with element group_size/2+1 and so
on. This has no effect on the model performance, since elements are unordered, however it has some effect
on inference speed when used in e.g. VLLM. For best speed group size of at least 32 or 64 (the default) is
recommended. Note that model hidden size (or hidden size per partition when used with tensor parallelism)
must be divisible by group_size, so for very small models you might need to reduce this parameter.`,name:"group_size"},{anchor:"peft.RoadConfig.init_weights",description:`<strong>init_weights</strong> (<code>bool</code>) &#x2014;
Whether to perform initialization of RoAd weights.`,name:"init_weights"},{anchor:"peft.RoadConfig.target_modules",description:`<strong>target_modules</strong> (<code>Optional[Union[List[str], str]]</code>) &#x2014;
The names of the modules to apply the adapter to. If this is specified, only the modules with the specified
names will be replaced. When passing a string, a regex match will be performed. When passing a list of
strings, either an exact match will be performed or it is checked if the name of the module ends with any
of the passed strings. If this is specified as &#x2018;all-linear&#x2019;, then all linear/Conv1D modules are chosen (if
the model is a PreTrainedModel, the output layer excluded). If this is not specified, modules will be
chosen according to the model architecture. If the architecture is not known, an error will be raised &#x2014; in
this case, you should specify the target modules manually.`,name:"target_modules"},{anchor:"peft.RoadConfig.modules_to_save",description:`<strong>modules_to_save</strong> (<code>List[str]</code>) &#x2014;
List of modules apart from Road layers to be set as trainable and saved in the final checkpoint.`,name:"modules_to_save"}],source:"https://github.com/huggingface/peft/blob/main/src/peft/tuners/road/config.py#L28"}}),g=new B({props:{title:"RoadModel",local:"peft.RoadModel",headingTag:"h2"}}),v=new ee({props:{name:"class peft.RoadModel",anchor:"peft.RoadModel",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"}],source:"https://github.com/huggingface/peft/blob/main/src/peft/tuners/road/model.py#L38"}}),b=new se({props:{source:"https://github.com/huggingface/peft/blob/main/docs/source/package_reference/road.md"}}),{c(){r=l("meta"),z=o(),M=l("p"),A=o(),w(p.$$.fragment),P=o(),m=l("p"),m.innerHTML=K,k=o(),f=l("p"),f.textContent=Q,U=o(),h=l("p"),h.innerHTML=X,O=o(),w(c.$$.fragment),N=o(),s=l("div"),w(u.$$.fragment),S=o(),$=l("p"),$.innerHTML=Y,E=o(),w(g.$$.fragment),D=o(),_=l("div"),w(v.$$.fragment),H=o(),w(b.$$.fragment),I=o(),L=l("p"),this.h()},l(e){const t=re("svelte-u9bgzb",document.head);r=d(t,"META",{name:!0,content:!0}),t.forEach(a),z=i(e),M=d(e,"P",{}),V(M).forEach(a),A=i(e),R(p.$$.fragment,e),P=i(e),m=d(e,"P",{"data-svelte-h":!0}),W(m)!=="svelte-11z67jw"&&(m.innerHTML=K),k=i(e),f=d(e,"P",{"data-svelte-h":!0}),W(f)!=="svelte-15mje69"&&(f.textContent=Q),U=i(e),h=d(e,"P",{"data-svelte-h":!0}),W(h)!=="svelte-1x12tsl"&&(h.innerHTML=X),O=i(e),R(c.$$.fragment,e),N=i(e),s=d(e,"DIV",{class:!0});var F=V(s);R(u.$$.fragment,F),S=i(F),$=d(F,"P",{"data-svelte-h":!0}),W($)!=="svelte-1anqem6"&&($.innerHTML=Y),F.forEach(a),E=i(e),R(g.$$.fragment,e),D=i(e),_=d(e,"DIV",{class:!0});var Z=V(_);R(v.$$.fragment,Z),Z.forEach(a),H=i(e),R(b.$$.fragment,e),I=i(e),L=d(e,"P",{}),V(L).forEach(a),this.h()},h(){j(r,"name","hf:doc:metadata"),j(r,"content",de),j(s,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),j(_,"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){G(document.head,r),n(e,z,t),n(e,M,t),n(e,A,t),y(p,e,t),n(e,P,t),n(e,m,t),n(e,k,t),n(e,f,t),n(e,U,t),n(e,h,t),n(e,O,t),y(c,e,t),n(e,N,t),n(e,s,t),y(u,s,null),G(s,S),G(s,$),n(e,E,t),y(g,e,t),n(e,D,t),n(e,_,t),y(v,_,null),n(e,H,t),y(b,e,t),n(e,I,t),n(e,L,t),q=!0},p:ae,i(e){q||(x(p.$$.fragment,e),x(c.$$.fragment,e),x(u.$$.fragment,e),x(g.$$.fragment,e),x(v.$$.fragment,e),x(b.$$.fragment,e),q=!0)},o(e){T(p.$$.fragment,e),T(c.$$.fragment,e),T(u.$$.fragment,e),T(g.$$.fragment,e),T(v.$$.fragment,e),T(b.$$.fragment,e),q=!1},d(e){e&&(a(z),a(M),a(A),a(P),a(m),a(k),a(f),a(U),a(h),a(O),a(N),a(s),a(E),a(D),a(_),a(H),a(I),a(L)),a(r),C(p,e),C(c,e),C(u),C(g,e),C(v),C(b,e)}}}const de='{"title":"RoAd","local":"road","sections":[{"title":"RoadConfig","local":"peft.RoadConfig","sections":[],"depth":2},{"title":"RoadModel","local":"peft.RoadModel","sections":[],"depth":2}],"depth":1}';function pe(J){return ne(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ue extends oe{constructor(r){super(),ie(this,r,pe,le,te,{})}}export{ue as component};
