import{s as ie,n as se,o as fe}from"../chunks/scheduler.53228c21.js";import{S as me,i as de,e as r,s as a,c as p,h as pe,a as i,d as n,b as o,f as q,g,j as Q,k as O,l as D,m as l,n as u,t as c,o as _,p as h}from"../chunks/index.100fac89.js";import{C as ge}from"../chunks/CopyLLMTxtMenu.0ee1b69b.js";import{D as ee}from"../chunks/Docstring.db856a1e.js";import{H as te,E as ue}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.136ef3fd.js";function ce(ne){let s,I,E,S,v,z,$,H,x,le='Parallelism strategies help speed up diffusion transformers by distributing computations across multiple devices, allowing for faster inference/training times. Refer to the <a href="../training/distributed_inference">Distributed inferece</a> guide to learn more.',U,C,j,f,b,X,M,ae="Configuration for applying different parallelisms.",V,y,A,m,P,Y,L,oe="Configuration for context parallelism.",R,d,N,Z,T,re="Apply context parallel on a model.",G,w,W,k,B;return v=new ge({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),$=new te({props:{title:"Parallelism",local:"parallelism",headingTag:"h1"}}),C=new te({props:{title:"ParallelConfig",local:"diffusers.ParallelConfig",headingTag:"h2"}}),b=new ee({props:{name:"class diffusers.ParallelConfig",anchor:"diffusers.ParallelConfig",parameters:[{name:"context_parallel_config",val:": typing.Optional[diffusers.models._modeling_parallel.ContextParallelConfig] = None"},{name:"_rank",val:": int = None"},{name:"_world_size",val:": int = None"},{name:"_device",val:": device = None"},{name:"_cp_mesh",val:": DeviceMesh = None"}],parametersDescription:[{anchor:"diffusers.ParallelConfig.context_parallel_config",description:`<strong>context_parallel_config</strong> (<code>ContextParallelConfig</code>, <em>optional</em>) &#x2014;
Configuration for context parallelism.`,name:"context_parallel_config"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/_modeling_parallel.py#L108"}}),y=new te({props:{title:"ContextParallelConfig",local:"diffusers.ContextParallelConfig",headingTag:"h2"}}),P=new ee({props:{name:"class diffusers.ContextParallelConfig",anchor:"diffusers.ContextParallelConfig",parameters:[{name:"ring_degree",val:": typing.Optional[int] = None"},{name:"ulysses_degree",val:": typing.Optional[int] = None"},{name:"convert_to_fp32",val:": bool = True"},{name:"rotate_method",val:": typing.Literal['allgather', 'alltoall'] = 'allgather'"},{name:"_rank",val:": int = None"},{name:"_world_size",val:": int = None"},{name:"_device",val:": device = None"},{name:"_mesh",val:": DeviceMesh = None"},{name:"_flattened_mesh",val:": DeviceMesh = None"},{name:"_ring_mesh",val:": DeviceMesh = None"},{name:"_ulysses_mesh",val:": DeviceMesh = None"},{name:"_ring_local_rank",val:": int = None"},{name:"_ulysses_local_rank",val:": int = None"}],parametersDescription:[{anchor:"diffusers.ContextParallelConfig.ring_degree",description:`<strong>ring_degree</strong> (<code>int</code>, <em>optional</em>, defaults to <code>1</code>) &#x2014;
Number of devices to use for ring attention within a context parallel region. Must be a divisor of the
total number of devices in the context parallel mesh.`,name:"ring_degree"},{anchor:"diffusers.ContextParallelConfig.ulysses_degree",description:`<strong>ulysses_degree</strong> (<code>int</code>, <em>optional</em>, defaults to <code>1</code>) &#x2014;
Number of devices to use for ulysses attention within a context parallel region. Must be a divisor of the
total number of devices in the context parallel mesh.`,name:"ulysses_degree"},{anchor:"diffusers.ContextParallelConfig.convert_to_fp32",description:`<strong>convert_to_fp32</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to convert output and LSE to float32 for ring attention numerical stability.`,name:"convert_to_fp32"},{anchor:"diffusers.ContextParallelConfig.rotate_method",description:`<strong>rotate_method</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;allgather&quot;</code>) &#x2014;
Method to use for rotating key/value states across devices in ring attention. Currently, only <code>&quot;allgather&quot;</code>
is supported.`,name:"rotate_method"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/_modeling_parallel.py#L41"}}),N=new ee({props:{name:"diffusers.hooks.apply_context_parallel",anchor:"diffusers.hooks.apply_context_parallel",parameters:[{name:"module",val:": Module"},{name:"parallel_config",val:": ContextParallelConfig"},{name:"plan",val:": typing.Dict[str, typing.Dict[str, typing.Union[typing.Dict[typing.Union[str, int], typing.Union[diffusers.models._modeling_parallel.ContextParallelInput, typing.List[diffusers.models._modeling_parallel.ContextParallelInput], typing.Tuple[diffusers.models._modeling_parallel.ContextParallelInput, ...]]], diffusers.models._modeling_parallel.ContextParallelOutput, typing.List[diffusers.models._modeling_parallel.ContextParallelOutput], typing.Tuple[diffusers.models._modeling_parallel.ContextParallelOutput, ...]]]]"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/hooks/context_parallel.py#L78"}}),w=new ue({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/parallel.md"}}),{c(){s=r("meta"),I=a(),E=r("p"),S=a(),p(v.$$.fragment),z=a(),p($.$$.fragment),H=a(),x=r("p"),x.innerHTML=le,U=a(),p(C.$$.fragment),j=a(),f=r("div"),p(b.$$.fragment),X=a(),M=r("p"),M.textContent=ae,V=a(),p(y.$$.fragment),A=a(),m=r("div"),p(P.$$.fragment),Y=a(),L=r("p"),L.textContent=oe,R=a(),d=r("div"),p(N.$$.fragment),Z=a(),T=r("p"),T.textContent=re,G=a(),p(w.$$.fragment),W=a(),k=r("p"),this.h()},l(e){const t=pe("svelte-u9bgzb",document.head);s=i(t,"META",{name:!0,content:!0}),t.forEach(n),I=o(e),E=i(e,"P",{}),q(E).forEach(n),S=o(e),g(v.$$.fragment,e),z=o(e),g($.$$.fragment,e),H=o(e),x=i(e,"P",{"data-svelte-h":!0}),Q(x)!=="svelte-cblplr"&&(x.innerHTML=le),U=o(e),g(C.$$.fragment,e),j=o(e),f=i(e,"DIV",{class:!0});var F=q(f);g(b.$$.fragment,F),X=o(F),M=i(F,"P",{"data-svelte-h":!0}),Q(M)!=="svelte-1xt9qrn"&&(M.textContent=ae),F.forEach(n),V=o(e),g(y.$$.fragment,e),A=o(e),m=i(e,"DIV",{class:!0});var J=q(m);g(P.$$.fragment,J),Y=o(J),L=i(J,"P",{"data-svelte-h":!0}),Q(L)!=="svelte-1ng6p0q"&&(L.textContent=oe),J.forEach(n),R=o(e),d=i(e,"DIV",{class:!0});var K=q(d);g(N.$$.fragment,K),Z=o(K),T=i(K,"P",{"data-svelte-h":!0}),Q(T)!=="svelte-jjn757"&&(T.textContent=re),K.forEach(n),G=o(e),g(w.$$.fragment,e),W=o(e),k=i(e,"P",{}),q(k).forEach(n),this.h()},h(){O(s,"name","hf:doc:metadata"),O(s,"content",_e),O(f,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),O(m,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),O(d,"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,s),l(e,I,t),l(e,E,t),l(e,S,t),u(v,e,t),l(e,z,t),u($,e,t),l(e,H,t),l(e,x,t),l(e,U,t),u(C,e,t),l(e,j,t),l(e,f,t),u(b,f,null),D(f,X),D(f,M),l(e,V,t),u(y,e,t),l(e,A,t),l(e,m,t),u(P,m,null),D(m,Y),D(m,L),l(e,R,t),l(e,d,t),u(N,d,null),D(d,Z),D(d,T),l(e,G,t),u(w,e,t),l(e,W,t),l(e,k,t),B=!0},p:se,i(e){B||(c(v.$$.fragment,e),c($.$$.fragment,e),c(C.$$.fragment,e),c(b.$$.fragment,e),c(y.$$.fragment,e),c(P.$$.fragment,e),c(N.$$.fragment,e),c(w.$$.fragment,e),B=!0)},o(e){_(v.$$.fragment,e),_($.$$.fragment,e),_(C.$$.fragment,e),_(b.$$.fragment,e),_(y.$$.fragment,e),_(P.$$.fragment,e),_(N.$$.fragment,e),_(w.$$.fragment,e),B=!1},d(e){e&&(n(I),n(E),n(S),n(z),n(H),n(x),n(U),n(j),n(f),n(V),n(A),n(m),n(R),n(d),n(G),n(W),n(k)),n(s),h(v,e),h($,e),h(C,e),h(b),h(y,e),h(P),h(N),h(w,e)}}}const _e='{"title":"Parallelism","local":"parallelism","sections":[{"title":"ParallelConfig","local":"diffusers.ParallelConfig","sections":[],"depth":2},{"title":"ContextParallelConfig","local":"diffusers.ContextParallelConfig","sections":[],"depth":2}],"depth":1}';function he(ne){return fe(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ye extends me{constructor(s){super(),de(this,s,he,ce,ie,{})}}export{ye as component};
