import{s as ee,o as te,n as Q}from"../chunks/scheduler.d627b047.js";import{S as ne,i as le,g as U,s as u,r as h,A as se,h as P,f as r,c as g,j as X,u as w,x as S,k as B,y as ie,a,v as b,d as T,t as L,w as C}from"../chunks/index.73c51727.js";import{T as K}from"../chunks/Tip.a82942ec.js";import{C as I}from"../chunks/CodeBlock.5f78c87f.js";import{H as Y,E as re}from"../chunks/index.8df1db42.js";import{H as ae,a as q}from"../chunks/HfOption.d6c7dc54.js";function oe(H){let t,d="Section under construction. Feel free to contribute!";return{c(){t=U("p"),t.textContent=d},l(o){t=P(o,"P",{"data-svelte-h":!0}),S(t)!=="svelte-txx63b"&&(t.textContent=d)},m(o,p){a(o,t,p)},p:Q,d(o){o&&r(t)}}}function pe(H){let t,d="Then, enable it by passing <code>use_vllm=True</code> in the training arguments.",o,p,s;return p=new I({props:{code:"ZnJvbSUyMHRybCUyMGltcG9ydCUyME9ubGluZURQT0NvbmZpZyUwQSUwQXRyYWluaW5nX2FyZ3MlMjAlM0QlMjBPbmxpbmVEUE9Db25maWcoLi4uJTJDJTIwdXNlX3ZsbG0lM0RUcnVlKQ==",highlighted:`<span class="hljs-keyword">from</span> trl <span class="hljs-keyword">import</span> OnlineDPOConfig

training_args = OnlineDPOConfig(..., use_vllm=<span class="hljs-literal">True</span>)`,wrap:!1}}),{c(){t=U("p"),t.innerHTML=d,o=u(),h(p.$$.fragment)},l(i){t=P(i,"P",{"data-svelte-h":!0}),S(t)!=="svelte-on5a24"&&(t.innerHTML=d),o=g(i),w(p.$$.fragment,i)},m(i,m){a(i,t,m),a(i,o,m),b(p,i,m),s=!0},p:Q,i(i){s||(T(p.$$.fragment,i),s=!0)},o(i){L(p.$$.fragment,i),s=!1},d(i){i&&(r(t),r(o)),C(p,i)}}}function fe(H){let t,d="When using vLLM, ensure that the GPUs assigned for training and generation are separate to avoid resource conflicts. For instance, if you plan to use 4 GPUs for training and another 4 for vLLM generation, you can specify GPU allocation using <code>CUDA_VISIBLE_DEVICES</code>.",o,p,s="Set GPUs <strong>0-3</strong> for vLLM generation:",i,m,M,$,J="And GPUs <strong>4-7</strong> for training:",v,x,y;return m=new I({props:{code:"Q1VEQV9WSVNJQkxFX0RFVklDRVMlM0QwJTJDMSUyQzIlMkMzJTIwdHJsJTIwdmxsbS1zZXJ2ZSUyMC0tbW9kZWwlMjAlM0Ntb2RlbF9uYW1lJTNF",highlighted:"CUDA_VISIBLE_DEVICES=0,1,2,3 trl vllm-serve --model &lt;model_name&gt;",wrap:!1}}),x=new I({props:{code:"Q1VEQV9WSVNJQkxFX0RFVklDRVMlM0Q0JTJDNSUyQzYlMkM3JTIwYWNjZWxlcmF0ZSUyMGxhdW5jaCUyMHRyYWluLnB5",highlighted:"CUDA_VISIBLE_DEVICES=4,5,6,7 accelerate launch train.py",wrap:!1}}),{c(){t=U("p"),t.innerHTML=d,o=u(),p=U("p"),p.innerHTML=s,i=u(),h(m.$$.fragment),M=u(),$=U("p"),$.innerHTML=J,v=u(),h(x.$$.fragment)},l(n){t=P(n,"P",{"data-svelte-h":!0}),S(t)!=="svelte-nkjvvw"&&(t.innerHTML=d),o=g(n),p=P(n,"P",{"data-svelte-h":!0}),S(p)!=="svelte-2wptiu"&&(p.innerHTML=s),i=g(n),w(m.$$.fragment,n),M=g(n),$=P(n,"P",{"data-svelte-h":!0}),S($)!=="svelte-102mliw"&&($.innerHTML=J),v=g(n),w(x.$$.fragment,n)},m(n,_){a(n,t,_),a(n,o,_),a(n,p,_),a(n,i,_),b(m,n,_),a(n,M,_),a(n,$,_),a(n,v,_),b(x,n,_),y=!0},p:Q,i(n){y||(T(m.$$.fragment,n),T(x.$$.fragment,n),y=!0)},o(n){L(m.$$.fragment,n),L(x.$$.fragment,n),y=!1},d(n){n&&(r(t),r(o),r(p),r(i),r(M),r($),r(v)),C(m,n),C(x,n)}}}function me(H){let t,d="First, start a vLLM server by running:",o,p,s,i,m="Then, run the training script and pass <code>use_vllm=True</code> in the training arguments.",M,$,J,v,x='You can customize the server configuration by passing additional arguments. For more information, see <a href="vllm_integration">vLLM integration</a>.',y,n,_;return p=new I({props:{code:"dHJsJTIwdmxsbS1zZXJ2ZSUyMC0tbW9kZWwlMjAlM0Ntb2RlbF9uYW1lJTNF",highlighted:"trl vllm-serve --model &lt;model_name&gt;",wrap:!1}}),$=new I({props:{code:"ZnJvbSUyMHRybCUyMGltcG9ydCUyMEdSUE9Db25maWclMEElMEF0cmFpbmluZ19hcmdzJTIwJTNEJTIwR1JQT0NvbmZpZyguLi4lMkMlMjB1c2VfdmxsbSUzRFRydWUp",highlighted:`<span class="hljs-keyword">from</span> trl <span class="hljs-keyword">import</span> GRPOConfig

training_args = GRPOConfig(..., use_vllm=<span class="hljs-literal">True</span>)`,wrap:!1}}),n=new K({props:{warning:!0,$$slots:{default:[fe]},$$scope:{ctx:H}}}),{c(){t=U("p"),t.textContent=d,o=u(),h(p.$$.fragment),s=u(),i=U("p"),i.innerHTML=m,M=u(),h($.$$.fragment),J=u(),v=U("p"),v.innerHTML=x,y=u(),h(n.$$.fragment)},l(l){t=P(l,"P",{"data-svelte-h":!0}),S(t)!=="svelte-1ppj39r"&&(t.textContent=d),o=g(l),w(p.$$.fragment,l),s=g(l),i=P(l,"P",{"data-svelte-h":!0}),S(i)!=="svelte-1azzz5f"&&(i.innerHTML=m),M=g(l),w($.$$.fragment,l),J=g(l),v=P(l,"P",{"data-svelte-h":!0}),S(v)!=="svelte-1amid1u"&&(v.innerHTML=x),y=g(l),w(n.$$.fragment,l)},m(l,c){a(l,t,c),a(l,o,c),b(p,l,c),a(l,s,c),a(l,i,c),a(l,M,c),b($,l,c),a(l,J,c),a(l,v,c),a(l,y,c),b(n,l,c),_=!0},p(l,c){const G={};c&2&&(G.$$scope={dirty:c,ctx:l}),n.$set(G)},i(l){_||(T(p.$$.fragment,l),T($.$$.fragment,l),T(n.$$.fragment,l),_=!0)},o(l){L(p.$$.fragment,l),L($.$$.fragment,l),L(n.$$.fragment,l),_=!1},d(l){l&&(r(t),r(o),r(s),r(i),r(M),r(J),r(v),r(y)),C(p,l),C($,l),C(n,l)}}}function $e(H){let t,d,o,p;return t=new q({props:{id:"vllm examples",option:"Online DPO",$$slots:{default:[pe]},$$scope:{ctx:H}}}),o=new q({props:{id:"vllm examples",option:"GRPO",$$slots:{default:[me]},$$scope:{ctx:H}}}),{c(){h(t.$$.fragment),d=u(),h(o.$$.fragment)},l(s){w(t.$$.fragment,s),d=g(s),w(o.$$.fragment,s)},m(s,i){b(t,s,i),a(s,d,i),b(o,s,i),p=!0},p(s,i){const m={};i&2&&(m.$$scope={dirty:i,ctx:s}),t.$set(m);const M={};i&2&&(M.$$scope={dirty:i,ctx:s}),o.$set(M)},i(s){p||(T(t.$$.fragment,s),T(o.$$.fragment,s),p=!0)},o(s){L(t.$$.fragment,s),L(o.$$.fragment,s),p=!1},d(s){s&&r(d),C(t,s),C(o,s)}}}function ue(H){let t,d,o,p,s,i,m,M,$,J,v,x=`Online methods such as GRPO or Online DPO require the model to generate completions, which is often a slow process and can significantly impact training time.
To speed up generation, you can use <a href="https://github.com/vllm-project/vllm" rel="nofollow">vLLM</a>, a library that enables fast generation through, among other things, PagedAttention. TRL’s online trainers support vLLM, greatly improving training speed.`,y,n,_='To use <a href="https://github.com/vllm-project/vllm" rel="nofollow">vLLM</a>, first install it using:',l,c,G,k,z="or",Z,R,F,E,O,j,V,W,D;return s=new Y({props:{title:"Speeding Up Training",local:"speeding-up-training",headingTag:"h1"}}),m=new K({props:{warning:!0,$$slots:{default:[oe]},$$scope:{ctx:H}}}),$=new Y({props:{title:"vLLM for fast generation in online methods",local:"vllm-for-fast-generation-in-online-methods",headingTag:"h2"}}),c=new I({props:{code:"cGlwJTIwaW5zdGFsbCUyMHZsbG0=",highlighted:"pip install vllm",wrap:!1}}),R=new I({props:{code:"cGlwJTIwaW5zdGFsbCUyMCUyMnRybCU1QnZsbG0lNUQlMjI=",highlighted:'pip install <span class="hljs-string">&quot;trl[vllm]&quot;</span>',wrap:!1}}),E=new ae({props:{id:"vllm examples",options:["Online DPO","GRPO"],$$slots:{default:[$e]},$$scope:{ctx:H}}}),j=new re({props:{source:"https://github.com/huggingface/trl/blob/main/docs/source/speeding_up_training.md"}}),{c(){t=U("meta"),d=u(),o=U("p"),p=u(),h(s.$$.fragment),i=u(),h(m.$$.fragment),M=u(),h($.$$.fragment),J=u(),v=U("p"),v.innerHTML=x,y=u(),n=U("p"),n.innerHTML=_,l=u(),h(c.$$.fragment),G=u(),k=U("p"),k.textContent=z,Z=u(),h(R.$$.fragment),F=u(),h(E.$$.fragment),O=u(),h(j.$$.fragment),V=u(),W=U("p"),this.h()},l(e){const f=se("svelte-u9bgzb",document.head);t=P(f,"META",{name:!0,content:!0}),f.forEach(r),d=g(e),o=P(e,"P",{}),X(o).forEach(r),p=g(e),w(s.$$.fragment,e),i=g(e),w(m.$$.fragment,e),M=g(e),w($.$$.fragment,e),J=g(e),v=P(e,"P",{"data-svelte-h":!0}),S(v)!=="svelte-p8jraw"&&(v.innerHTML=x),y=g(e),n=P(e,"P",{"data-svelte-h":!0}),S(n)!=="svelte-vi9l6d"&&(n.innerHTML=_),l=g(e),w(c.$$.fragment,e),G=g(e),k=P(e,"P",{"data-svelte-h":!0}),S(k)!=="svelte-lor7bv"&&(k.textContent=z),Z=g(e),w(R.$$.fragment,e),F=g(e),w(E.$$.fragment,e),O=g(e),w(j.$$.fragment,e),V=g(e),W=P(e,"P",{}),X(W).forEach(r),this.h()},h(){B(t,"name","hf:doc:metadata"),B(t,"content",ge)},m(e,f){ie(document.head,t),a(e,d,f),a(e,o,f),a(e,p,f),b(s,e,f),a(e,i,f),b(m,e,f),a(e,M,f),b($,e,f),a(e,J,f),a(e,v,f),a(e,y,f),a(e,n,f),a(e,l,f),b(c,e,f),a(e,G,f),a(e,k,f),a(e,Z,f),b(R,e,f),a(e,F,f),b(E,e,f),a(e,O,f),b(j,e,f),a(e,V,f),a(e,W,f),D=!0},p(e,[f]){const N={};f&2&&(N.$$scope={dirty:f,ctx:e}),m.$set(N);const A={};f&2&&(A.$$scope={dirty:f,ctx:e}),E.$set(A)},i(e){D||(T(s.$$.fragment,e),T(m.$$.fragment,e),T($.$$.fragment,e),T(c.$$.fragment,e),T(R.$$.fragment,e),T(E.$$.fragment,e),T(j.$$.fragment,e),D=!0)},o(e){L(s.$$.fragment,e),L(m.$$.fragment,e),L($.$$.fragment,e),L(c.$$.fragment,e),L(R.$$.fragment,e),L(E.$$.fragment,e),L(j.$$.fragment,e),D=!1},d(e){e&&(r(d),r(o),r(p),r(i),r(M),r(J),r(v),r(y),r(n),r(l),r(G),r(k),r(Z),r(F),r(O),r(V),r(W)),r(t),C(s,e),C(m,e),C($,e),C(c,e),C(R,e),C(E,e),C(j,e)}}}const ge='{"title":"Speeding Up Training","local":"speeding-up-training","sections":[{"title":"vLLM for fast generation in online methods","local":"vllm-for-fast-generation-in-online-methods","sections":[],"depth":2}],"depth":1}';function ce(H){return te(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class be extends ne{constructor(t){super(),le(this,t,ce,ue,ee,{})}}export{be as component};
