1import{s as Fe,J as ae,K as je,f as o,a as l,g as s,D as r,c as a,h as ne,d as n,j as De,i,v as it,C as Be}from"../chunks/scheduler.e2b5ccef.js";import{S as Ue,i as Ge,b as lt,d as at,m as ot,a as st,t as rt,e as ut}from"../chunks/index.67416819.js";import{g as Je,a as qe}from"../chunks/spread.8a54911c.js";import{P as Ke}from"../chunks/post.dcc11f0c.js";import{H as ft}from"../chunks/Highlight.4389c7ab.js";import{p as ie}from"../chunks/python.1e6a822e.js";import{b as le}from"../chunks/bash.fc9795b7.js";function We(f){let u,g="A New Era of AI Customization",h,d,p="Todayâs AI services must cater to a vast range of usersâeach with unique requirements and preferences. Customizing large language models for individual customers or speakers has traditionally been a resource-intensive and time-consuming task.",m,v,vt="LoRA adapters have proven transformative in customizing large AI models for specific tasks without requiring resource-intensive fine-tuning. MultiLoRA changes the game by enabling seamless integration of lightweight adapters, allowing models to adapt dynamically to different contexts and customers. With ONNX Runtime as its foundation, MultiLoRA offers unparalleled performance, ensuring efficient memory usage.",pt,C,oe="Streamlined Integration with Olive",ht,_,se="MultiLoRA relies on the existing Olive toolchain to generate adapted ONNX models.",gt,w,re="This ensures:",xt,c,ue="<li>A unified pipeline for creating LoRA-adapted models.</li> <li>Consistent handling of versioning and metadata across models and adapters.</li>",Ct,y,pe="By standardizing around Olive, MultiLoRA simplifies workflows and eliminates compatibility concerns with third-party sources.",_t,A,me="ONNX Runtime Adaptations",wt,$,de="Simplified Adapter Activation and Loading",ct,L,fe="<li><p><strong>Dynamic Activation API:</strong> A single API, <code>SetActiveAdapters(string[] adapters)</code>, allows activating or deactivating adapters at runtime.</p> <ul><li><strong>Empty Input:</strong> Resets the model to its base state, running without any adapters.</li> <li><strong>Multi-Adapter Support:</strong> Simultaneously activate multiple adapters to meet complex customer requirements.</li></ul></li> <li><p><strong>Generative Loop Support:</strong></p> <ul><li>Active adapters remain loaded as long as the <code>GeneratorParams</code> instance persists, ensuring efficient memory use.</li> <li>References are automatically released when the instance is destroyed, avoiding resource leaks.</li></ul></li>",yt,b,ve="Adapter Management Without Generative Loops",At,M,he="For models not tied to user prompts or generative processes, a new <code>Run()</code> API is introduced:",$t,R,Lt,H,ge="<li><strong>RunOptions Class:</strong> Facilitates seamless execution of base models or adapter-enhanced variants.</li> <li><strong>Shared Adapter Loading:</strong> Adapters are stored within the model instance, allowing efficient reuse across multiple sessions.</li>",bt,N,xe="Language Bindings Expansion",Mt,P,Ce="The current MultiLoRA implementation offers bindings for Python, C, C++, C#, and Java.",Rt,k,_e="Memory Management",Ht,O,we="Our implementation memory maps LoRA parameters from disk, which improves memory management.",Nt,T,ce="How MultiLoRA Works",Pt,I,ye="Generate the ONNX Models and Adapters",kt,z,Ae="If you have an existing base model and adapter in Hugging Face PEFT format, you can automatically create optimized ONNX models that will run efficie
1ntly on the ONNX runtime using the MultiLoRA paradigm by leveraging the following command:",Ot,S,Tt,X,$e="You can then add additional adapters that exist on Hugging Face (or local disk) for the same base model by converting them into the ONNX adapter format using:",It,j,zt,q,Le="Alternatively, you can fine-tune your own adapter using:",St,E,Xt,F,be="Run the ONNX Models and Switch Adapters",jt,x,D,mt,Me="<strong>Load Adapters:</strong> Dynamically load adapters for the base model:",Zt,B,te,U,dt,Re="<strong>Set Active Adapter:</strong> Switch adapters on the fly based on customer requests:",ee,G,qt,J,He="Looking Ahead",Et,K,Ne="<strong>In Development:</strong>",Ft,W,Pe="<li><strong>Batching Support:</strong> Enhancing ONNX Runtime kernels for adapter-aware batching.</li> <li><strong>Expanded Bindings:</strong> Introducing language bindings for broader adoption.</li> <li><strong>Memory Features:</strong> Additional memory management improvements.</li>",Dt,Y,ke="Your Feedback Matters",Bt,Q,Oe="As MultiLoRA evolves, we invite developers to test the feature, provide insights, and shape its roadmap. By working together, we aim to create a flexible, powerful foundation for AI adaptation.",Ut,V,Te="Conclusion",Gt,Z,Ie="MultiLoRA is more than an enhancement to ONNX Runtimeâitâs a step forward in making AI systems modular, adaptable, and accessible. By addressing technical challenges like memory management, batching, and data format inefficiencies, MultiLoRA lays the groundwork for a new era of AI deployment.",Jt,tt,ze="Letâs build the future of adaptable AI together. Join us in exploring MultiLoRA with ONNX Runtime!",Kt,et,Se="Resources",Wt,nt,Xe='<li><strong>ONNX Runtime Tutorial:</strong> <a href="https://onnxruntime.ai/docs/genai/tutorials/finetune.html" rel="nofollow">Run with LoRA adapters</a></li> <li><strong>Python API docs:</strong> <a href="https://onnxruntime.ai/docs/genai/api/python.html#adapter-class" rel="nofollow">Python API</a></li> <li><strong>Olive Example:</strong> <a href="https://github.com/microsoft/Olive/blob/main/examples/llama2/llama2_multilora.ipynb" rel="nofollow">Finetune and Deploy</a></li>',Yt;return R=new ft({props:{language:ie,code:f[0]}}),S=new ft({props:{language:le,code:f[1]}}),j=new ft({props:{language:le,code:f[2]}}),E=new ft({props:{language:le,code:f[3]}}),B=new ft({props:{language:ie,code:f[4]}}),G=new ft({props:{language:ie,code:f[5]}}),{c(){u=o("h2"),u.textContent=g,h=l(),d=o("p"),d.textContent=p,m=l(),v=o("p"),v.textContent=vt,pt=l(),C=o("h2"),C.textContent=oe,ht=l(),_=o("p"),_.textContent=se,gt=l(),w=o("p"),w.textContent=re,xt=l(),c=o("ul"),c.innerHTML=ue,Ct=l(),y=o("p"),y.textContent=pe,_t=l(),A=o("h2"),A.textContent=me,wt=l(),$=o("h3"),$.textContent=de,ct=l(),L=o("ul"),L.innerHTML=fe,yt=l(),b=o("h3"),b.textContent=ve,At=l(),M=o("p"),M.innerHTML=he,$t=l(),lt(R.$$.fragment),Lt=l(),H=o("ul"),H.innerHTML=ge,bt=l(),N=o("h3"),N.textContent=xe,Mt=l(),P=o("p"),P.textContent=Ce,Rt=l(),k=o("h3"),k.textContent=_e,Ht=l(),O=o("p"),O.textContent=we,Nt=l(),T=o("h2"),T.textContent=ce,Pt=l(),I=o("h3"),I.textContent=ye,kt=l(),z=o("p"),z.textContent=Ae,Ot=l(),lt(S.$$.fragment),Tt=l(),X=o("p"),X.textContent=$e,It=l(),lt(j.$$.fragment),zt=l(),q=o("p"),q.textContent=Le,St=l(),lt(E.$$.fragment),Xt=l(),F=o("h2"),F.textContent=be,jt=l(),x=o("ol"),D=o("li"),mt=o("p"),mt.innerHTML=Me,Zt=l(),lt(B.$$.fragment),te=l(),U=o("li"),dt=o("p"),dt.innerHTML=Re,ee=l(),lt(G.$$.fragment),qt=l(),J=o("h2"),J.textContent=He,Et=l(),K=o("p"),K.innerHTML=Ne,Ft=l(),W=o("ul"),W.innerHTML=Pe,Dt=l(),Y=o("h2"),Y.textContent=ke,Bt=l(),Q=o("p"),Q.textContent=Oe,Ut=l(),V=o("h2"),V.textContent=Te,Gt=l(),Z=o("p"),Z.textContent=Ie,Jt=l(),tt=o("p"),tt.textContent=ze,Kt=l(),et=o("h2"),et.textContent=Se,Wt=l(),nt=o("ul"),nt.innerHTML=Xe,this.h()},l(t){u=s(t,"H2",{"data-svelte-h":!0}),r(u)!=="svelte-141ueuj"&&(u.textContent=g),h=a(t),d=s(t,"P",{"data-svelte-h":!0}),r(d)!=="svelte-1xif8hp"&&(d.textContent=p),m=a(t),v=s(t,"P",{"data-svelte-h":!0}),r(v)!=="svelte-1gglzp2"&&(v.textContent=vt),pt=a(t),C=s(t,"H2",{"data-svelte-h":!0}),r(C)!=="svelte-et9ta1"&&(C.textContent=oe),ht=a(t),_=s(t,"P",{"data-svelte-h":!0}),r(_)!=="svelte-1boltaa"&&(_.textContent=se),gt=a(t),w=s(t,"P",{"data-svelte-h":!0}),r(w)!=="svelte-1ivwx0j"&&(w.textContent=re),xt=a(t),c=s(t,"UL",{"data-svelte-h":!0}),r(c)!=="svelte-138yry3"&&(c.innerHTML=ue),Ct=a(t),y=s(t,"P",{"data-svelte-h":!0}),r(y)!=="svelte-19ikvk2"&&(y.textContent=pe),_t=a(t),A=s(t,"H2",{"data-svelte-h":!0}),r(A)!=="svelte-gzf75f"&&(A.textContent=me),wt=a(t),$=s(t,"H3",{"data-svelte-h":!0}),r($)!=="svelte-1mpaeyo"&&($.textContent=de),ct=a(t),L=s(t,"UL",{"data-svelte-h":!0}),r(L)!=="svelte-1olfvcv"&&(L.innerHTML=fe),yt=a(t),b=s(t,"H3",{"data-svelte-h":!0}),r(b)!=="svelte-gmx57j"&&(b.textContent=ve),At=a(t),M=s(t,"P",{"data-svelte-h":!0}),r(M)!=="svelte-1axzbdg"&&(M.innerHTML=he),$t=a(t),at(R.$$.fragment,t),Lt=a(t),H=s(t,"UL",{"data-svelte-h":!0}),r(H)!=="svelte-betvgp"&&(H.innerHTML=ge),bt=a(t),N=s(t,"H3",{"data-svelte-h":!0}),r(N)!=="svelte-bc5zwd"&&(N.textContent=xe),Mt=a(t),P=s(t,"P",{"data-svelte-h":!0}),r(P)!=="svelte-whx5p0"&&(P.textContent=Ce),Rt=a(t),k=s(t,"H3",{"data-svelte-h":!0}),r(k)!=="svelte-1hitbd0"&&(k.textContent=_e),Ht=a(t),O=s(t,"P",{"data-svelte-h":!0}),r(O)!=="svelte-1j471qj"&&(O.textContent=we),Nt=a(t),T=s(t,"H2",{"data-svelte-h":!0}),r(T)!=="svelte-159yjtt"&&(T.textContent=ce),Pt=a(t),I=s(t,"H3",{"data-svelte-h":!0}),r(I)!=="svelte-1ox1etw"&&(I.textContent=ye),kt=a(t),z=s(t,"P",{"data-svelte-h":!0}),r(z)!=="svelte-5yk8p7"&&(z.textContent=Ae),Ot=a(t),at(S.$$.fragment,t),Tt=a(t),X=s(t,"P",{"data-svelte-h":!0}),r(X)!=="svelte-wqvs09"&&(X.textContent=$e),It=a(t),at(j.$$.fragment,t),zt=a(t),q=s(t,"P",{"data-svelte-h":!0}),r(q)!=="svelte-6ds38m"&&(q.textContent=Le),St=a(t),at(E.$$.fragment,t),Xt=a(t),F=s(t,"H2",{"data-svelte-h":!0}),r(F)!=="svelte-1md5j4i"&&(F.textContent=be),jt=a(t),x=s(t,"OL",{class:!0});var e=ne(x);D=s(e,"LI",{});var Qt=ne(D);mt=s(Qt,"P",{"data-svelte-h":!0}),r(mt)!=="svelte-1b6x86i"&&(mt.innerHTML=Me),Zt=a(Qt),at(B.$$.fragment,Qt),Qt.forEach(n),te=a(e),U=s(e,"LI",{});var Vt=ne(U);dt=s(Vt,"P",{"data-svelte-h":!0}),r(dt)!=="svelte-10jvzfn"&&(dt.innerHTML=Re),ee=a(Vt),at(G.$$.fragment,Vt),Vt.forEach(n),e.forEach(n),qt=a(t),J=s(t,"H2",{"data-svelte-h":!0}),r(J)!=="svelte-ww8em2"&&(J.textContent=He),Et=a(t),K=s(t,"P",{"data-svelte-h":!0}),r(K)!=="svelte-bfq6d5"&&(K.innerHTML=Ne),Ft=a(t),W=s(t,"UL",{"data-svelte-h":!0}),r(W)!=="svelte-1sslbi9"&&(W.innerHTML=Pe),Dt=a(t),Y=s(t,"H2",{"data-svelte-h":!0}),r(Y)!=="svelte-1laxhty"&&(Y.textContent=ke),Bt=a(t),Q=s(t,"P",{"data-svelte-h":!0}),r(Q)!=="svelte-1laqs34"&&(Q.textContent=Oe),Ut=a(t),V=s(t,"H2",{"data-svelte-h":!0}
1),r(V)!=="svelte-grw4hp"&&(V.textContent=Te),Gt=a(t),Z=s(t,"P",{"data-svelte-h":!0}),r(Z)!=="svelte-1rioptw"&&(Z.textContent=Ie),Jt=a(t),tt=s(t,"P",{"data-svelte-h":!0}),r(tt)!=="svelte-1y62hs"&&(tt.textContent=ze),Kt=a(t),et=s(t,"H2",{"data-svelte-h":!0}),r(et)!=="svelte-jeimfp"&&(et.textContent=Se),Wt=a(t),nt=s(t,"UL",{"data-svelte-h":!0}),r(nt)!=="svelte-10nccp5"&&(nt.innerHTML=Xe),this.h()},h(){De(x,"class","svelte-d7szzl")},m(t,e){i(t,u,e),i(t,h,e),i(t,d,e),i(t,m,e),i(t,v,e),i(t,pt,e),i(t,C,e),i(t,ht,e),i(t,_,e),i(t,gt,e),i(t,w,e),i(t,xt,e),i(t,c,e),i(t,Ct,e),i(t,y,e),i(t,_t,e),i(t,A,e),i(t,wt,e),i(t,$,e),i(t,ct,e),i(t,L,e),i(t,yt,e),i(t,b,e),i(t,At,e),i(t,M,e),i(t,$t,e),ot(R,t,e),i(t,Lt,e),i(t,H,e),i(t,bt,e),i(t,N,e),i(t,Mt,e),i(t,P,e),i(t,Rt,e),i(t,k,e),i(t,Ht,e),i(t,O,e),i(t,Nt,e),i(t,T,e),i(t,Pt,e),i(t,I,e),i(t,kt,e),i(t,z,e),i(t,Ot,e),ot(S,t,e),i(t,Tt,e),i(t,X,e),i(t,It,e),ot(j,t,e),i(t,zt,e),i(t,q,e),i(t,St,e),ot(E,t,e),i(t,Xt,e),i(t,F,e),i(t,jt,e),i(t,x,e),it(x,D),it(D,mt),it(D,Zt),ot(B,D,null),it(x,te),it(x,U),it(U,dt),it(U,ee),ot(G,U,null),i(t,qt,e),i(t,J,e),i(t,Et,e),i(t,K,e),i(t,Ft,e),i(t,W,e),i(t,Dt,e),i(t,Y,e),i(t,Bt,e),i(t,Q,e),i(t,Ut,e),i(t,V,e),i(t,Gt,e),i(t,Z,e),i(t,Jt,e),i(t,tt,e),i(t,Kt,e),i(t,et,e),i(t,Wt,e),i(t,nt,e),Yt=!0},p:Be,i(t){Yt||(st(R.$$.fragment,t),st(S.$$.fragment,t),st(j.$$.fragment,t),st(E.$$.fragment,t),st(B.$$.fragment,t),st(G.$$.fragment,t),Yt=!0)},o(t){rt(R.$$.fragment,t),rt(S.$$.fragment,t),rt(j.$$.fragment,t),rt(E.$$.fragment,t),rt(B.$$.fragment,t),rt(G.$$.fragment,t),Yt=!1},d(t){t&&(n(u),n(h),n(d),n(m),n(v),n(pt),n(C),n(ht),n(_),n(gt),n(w),n(xt),n(c),n(Ct),n(y),n(_t),n(A),n(wt),n($),n(ct),n(L),n(yt),n(b),n(At),n(M),n($t),n(Lt),n(H),n(bt),n(N),n(Mt),n(P),n(Rt),n(k),n(Ht),n(O),n(Nt),n(T),n(Pt),n(I),n(kt),n(z),n(Ot),n(Tt),n(X),n(It),n(zt),n(q),n(St),n(Xt),n(F),n(jt),n(x),n(qt),n(J),n(Et),n(K),n(Ft),n(W),n(Dt),n(Y),n(Bt),n(Q),n(Ut),n(V),n(Gt),n(Z),n(Jt),n(tt),n(Kt),n(et),n(Wt),n(nt)),ut(R,t),ut(S,t),ut(j,t),ut(E,t),ut(B),ut(G)}}}function Ye(f){let u,g;const h=[f[6],Ee];let d={$$slots:{default:[We]},$$scope:{ctx:f}};for(let p=0;p<h.length;p+=1)d=ae(d,h[p]);return u=new Ke({props:d}),{c(){lt(u.$$.fragment)},l(p){at(u.$$.fragment,p)},m(p,m){ot(u,p,m),g=!0},p(p,[m]){const v=m&64?Je(h,[m&64&&qe(p[6]),m&0&&qe(Ee)]):{};m&128&&(v.$$scope={dirty:m,ctx:p}),u.$set(v)},i(p){g||(st(u.$$.fragment,p),g=!0)},o(p){rt(u.$$.fragment,p),g=!1},d(p){ut(u,p)}}}const Ee={title:"Announcing MultiLoRA with ONNX Runtime: Revolutionizing AI Customization",date:"20th November, 2024",description:"MultiLoRA with ONNX Runtime brings flexible, efficient AI customization by enabling easy integration of LoRA adapters for dynamic, personalized models with minimal resource demands.",keywords:"MultiLoRA, LoRA, ONNX Runtime, AI customization, LoRA adapters, Olive toolchain, large language models, model personalization, model optimization, Hugging Face, AI deployment, AI performance",authors:["Dmitri Smirnov","Jambay Kinley","Natalie Kershaw","Parinita Rahi","Pranav Sharma","Devang Patel","Samuel Kemp"],authorsLink:["https://www.linkedin.com/in/yuslepukhinlinkedin/","https://www.linkedin.com/in/jambayk/","https://www.linkedin.com/in/natkershaw/","https://www.linkedin.com/in/parinitaparinita/","https://www.linkedin.com/in/pranavli/","https://www.linkedin.com/in/devangpatel/","https://www.linkedin.com/in/samuel-kemp-a9253724/"],image:"https://iili.io/25Mlea9.png",imageSquare:"https://iili.io/25Mlea9.png",url:"https://onnxruntime.ai/blogs/multilora"};function Qe(f,u,g){let h="Results = Run(RunOptions, input_names[], input_data[], output_names[]); ",d="olive auto-opt -m <path to model> -a <example adapter> -o <output folder> --device cpu|gpu --provider <execution provider>",p="olive convert-adapters -a <adapter> -o <output>",m=`# Step 1: finetune (output a PyTorch model and PEFT adapter) 2olive fine-tune --method qlora -m <model> -d <dataset> -o models/ft 3# Step 2 : Optimize base model and adapter into ONNX format 4olive auto-opt -m models/ft/model -a models/ft/adapter -o <output folder> --device cpu|gpu --provider <execution provider> `,v=`adapters = oga.Adapters(model)
5adapters.load("file", "name")`,vt='generator.set_active_adapter(adapters, "name") ';return f.$$set=pt=>{g(6,u=ae(ae({},u),je(pt)))},u=je(u),[h,d,p,m,v,vt,u]}class on extends Ue{constructor(u){super(),Ge(this,u,Qe,Ye,Fe,{})}}export{on as component};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.