import{s as Ue,n as $e,o as je}from"../chunks/scheduler.8c3d61f6.js";import{S as ke,i as we,g as n,s as l,r as o,A as ve,h as p,f as s,c as i,j as ye,u as f,x as d,k as Se,y as Te,a,v as c,d as u,t as m,w as M}from"../chunks/index.da70eac4.js";import{C as ne}from"../chunks/CodeBlock.a9c4becf.js";import{H as ie,E as ge}from"../chunks/getInferenceSnippets.cb466318.js";function Ce(pe){let r,G,A,L,_,E,h,de='Blocks rely on the <a href="/docs/diffusers/main/en/api/modular_diffusers/pipeline_states#diffusers.modular_pipelines.PipelineState">PipelineState</a> and <a href="/docs/diffusers/main/en/api/modular_diffusers/pipeline_states#diffusers.modular_pipelines.BlockState">BlockState</a> data structures for communicating and sharing data.',Q,b,re='<thead><tr><th>State</th> <th>Description</th></tr></thead> <tbody><tr><td><a href="/docs/diffusers/main/en/api/modular_diffusers/pipeline_states#diffusers.modular_pipelines.PipelineState">PipelineState</a></td> <td>Maintains the overall data required for a pipeline’s execution and allows blocks to read and update its data.</td></tr> <tr><td><a href="/docs/diffusers/main/en/api/modular_diffusers/pipeline_states#diffusers.modular_pipelines.BlockState">BlockState</a></td> <td>Allows each block to perform its computation with the necessary data from <code>inputs</code></td></tr></tbody>',z,y,oe="This guide explains how states work and how they connect blocks.",F,S,N,U,fe='The <a href="/docs/diffusers/main/en/api/modular_diffusers/pipeline_states#diffusers.modular_pipelines.PipelineState">PipelineState</a> is a global state container for all blocks. It maintains the complete runtime state of the pipeline and provides a structured way for blocks to read from and write to shared data.',R,$,ce='There are two dict’s in <a href="/docs/diffusers/main/en/api/modular_diffusers/pipeline_states#diffusers.modular_pipelines.PipelineState">PipelineState</a> for structuring data.',W,j,ue="<li>The <code>values</code> dict is a <strong>mutable</strong> state containing a copy of user provided input values and intermediate output values generated by blocks. If a block modifies an <code>input</code>, it will be reflected in the <code>values</code> dict after calling <code>set_block_state</code>.</li>",I,k,V,w,X,v,me='The <a href="/docs/diffusers/main/en/api/modular_diffusers/pipeline_states#diffusers.modular_pipelines.BlockState">BlockState</a> is a local view of the relevant variables an individual block needs from <a href="/docs/diffusers/main/en/api/modular_diffusers/pipeline_states#diffusers.modular_pipelines.PipelineState">PipelineState</a> for performing it’s computations.',Y,T,Me="Access these variables directly as attributes like <code>block_state.image</code>.",D,g,q,C,_e='When a block’s <code>__call__</code> method is executed, it retrieves the <code>BlockState</code> with <code>self.get_block_state(state)</code>, performs it’s operations, and updates <a href="/docs/diffusers/main/en/api/modular_diffusers/pipeline_states#diffusers.modular_pipelines.PipelineState">PipelineState</a> with <code>self.set_block_state(state, block_state)</code>.',K,x,O,H,ee,P,he='<a href="/docs/diffusers/main/en/api/modular_diffusers/pipeline_states#diffusers.modular_pipelines.PipelineState">PipelineState</a> and <a href="/docs/diffusers/main/en/api/modular_diffusers/pipeline_states#diffusers.modular_pipelines.BlockState">BlockState</a> interaction is defined by a block’s <code>inputs</code>, and <code>intermediate_outputs</code>.',te,B,be='<li><code>inputs</code>, a block can modify an input - like <code>block_state.image</code> - and this change can be propagated globally to <a href="/docs/diffusers/main/en/api/modular_diffusers/pipeline_states#diffusers.modular_pipelines.PipelineState">PipelineState</a> by calling <code>set_block_state</code>.</li> <li><code>intermediate_outputs</code>, is a new variable that a block creates. It is added to the <a href="/docs/diffusers/main/en/api/modular_diffusers/pipeline_states#diffusers.modular_pipelines.PipelineState">PipelineState</a>’s <code>values</code> dict and is available as for subsequent blocks or accessed by users as a final output from the pipeline.</li>',se,Z,ae,J,le;return _=new ie({props:{title:"States",local:"states",headingTag:"h1"}}),S=new ie({props:{title:"PipelineState",local:"pipelinestate",headingTag:"h2"}}),k=new ne({props:{code:"UGlwZWxpbmVTdGF0ZSglMEElMjAlMjB2YWx1ZXMlM0QlN0IlMEElMjAlMjAlMjAlMjAncHJvbXB0JyUzQSUyMCdhJTIwY2F0JyUwQSUyMCUyMCUyMCUyMCdndWlkYW5jZV9zY2FsZSclM0ElMjA3LjAlMEElMjAlMjAlMjAlMjAnbnVtX2luZmVyZW5jZV9zdGVwcyclM0ElMjAyNSUwQSUyMCUyMCUyMCUyMCdwcm9tcHRfZW1iZWRzJyUzQSUyMFRlbnNvcihkdHlwZSUzRHRvcmNoLmZsb2F0MzIlMkMlMjBzaGFwZSUzRHRvcmNoLlNpemUoJTVCMSUyQyUyMDElMkMlMjAxJTJDJTIwMSU1RCkpJTBBJTIwJTIwJTIwJTIwJ25lZ2F0aXZlX3Byb21wdF9lbWJlZHMnJTNBJTIwTm9uZSUwQSUyMCUyMCU3RCUyQyUwQSk=",highlighted:`PipelineState(
  values={
    <span class="hljs-string">&#x27;prompt&#x27;</span>: <span class="hljs-string">&#x27;a cat&#x27;</span>
    <span class="hljs-string">&#x27;guidance_scale&#x27;</span>: <span class="hljs-number">7.0</span>
    <span class="hljs-string">&#x27;num_inference_steps&#x27;</span>: <span class="hljs-number">25</span>
    <span class="hljs-string">&#x27;prompt_embeds&#x27;</span>: Tensor(dtype=torch.float32, shape=torch.Size([<span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>]))
    <span class="hljs-string">&#x27;negative_prompt_embeds&#x27;</span>: <span class="hljs-literal">None</span>
  },
)`,wrap:!1}}),w=new ie({props:{title:"BlockState",local:"blockstate",headingTag:"h2"}}),g=new ne({props:{code:"QmxvY2tTdGF0ZSglMEElMjAlMjAlMjAlMjBpbWFnZSUzQSUyMCUzQ1BJTC5JbWFnZS5JbWFnZSUyMGltYWdlJTIwbW9kZSUzRFJHQiUyMHNpemUlM0Q1MTJ4NTEyJTIwYXQlMjAweDdGM0VDQzQ5NDY0MCUzRSUwQSk=",highlighted:`BlockState(
    image: &lt;PIL.Image.Image image mode=RGB size=512x512 at <span class="hljs-number">0x7F3ECC494640</span>&gt;
)`,wrap:!1}}),x=new ne({props:{code:"ZGVmJTIwX19jYWxsX18oc2VsZiUyQyUyMGNvbXBvbmVudHMlMkMlMjBzdGF0ZSklM0ElMEElMjAlMjAlMjAlMjAlMjMlMjByZXRyaWV2ZSUyMEJsb2NrU3RhdGUlMEElMjAlMjAlMjAlMjBibG9ja19zdGF0ZSUyMCUzRCUyMHNlbGYuZ2V0X2Jsb2NrX3N0YXRlKHN0YXRlKSUwQSUwQSUyMCUyMCUyMCUyMCUyMyUyMGNvbXB1dGF0aW9uJTIwbG9naWMlMjBvbiUyMGlucHV0cyUwQSUwQSUyMCUyMCUyMCUyMCUyMyUyMHVwZGF0ZSUyMFBpcGVsaW5lU3RhdGUlMEElMjAlMjAlMjAlMjBzZWxmLnNldF9ibG9ja19zdGF0ZShzdGF0ZSUyQyUyMGJsb2NrX3N0YXRlKSUwQSUyMCUyMCUyMCUyMHJldHVybiUyMGNvbXBvbmVudHMlMkMlMjBzdGF0ZQ==",highlighted:`<span class="hljs-keyword">def</span> <span class="hljs-title function_">__call__</span>(<span class="hljs-params">self, components, state</span>):
    <span class="hljs-comment"># retrieve BlockState</span>
    block_state = self.get_block_state(state)

    <span class="hljs-comment"># computation logic on inputs</span>

    <span class="hljs-comment"># update PipelineState</span>
    self.set_block_state(state, block_state)
    <span class="hljs-keyword">return</span> components, state`,wrap:!1}}),H=new ie({props:{title:"State interaction",local:"state-interaction",headingTag:"h2"}}),Z=new ge({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/modular_diffusers/modular_diffusers_states.md"}}),{c(){r=n("meta"),G=l(),A=n("p"),L=l(),o(_.$$.fragment),E=l(),h=n("p"),h.innerHTML=de,Q=l(),b=n("table"),b.innerHTML=re,z=l(),y=n("p"),y.textContent=oe,F=l(),o(S.$$.fragment),N=l(),U=n("p"),U.innerHTML=fe,R=l(),$=n("p"),$.innerHTML=ce,W=l(),j=n("ul"),j.innerHTML=ue,I=l(),o(k.$$.fragment),V=l(),o(w.$$.fragment),X=l(),v=n("p"),v.innerHTML=me,Y=l(),T=n("p"),T.innerHTML=Me,D=l(),o(g.$$.fragment),q=l(),C=n("p"),C.innerHTML=_e,K=l(),o(x.$$.fragment),O=l(),o(H.$$.fragment),ee=l(),P=n("p"),P.innerHTML=he,te=l(),B=n("ul"),B.innerHTML=be,se=l(),o(Z.$$.fragment),ae=l(),J=n("p"),this.h()},l(e){const t=ve("svelte-u9bgzb",document.head);r=p(t,"META",{name:!0,content:!0}),t.forEach(s),G=i(e),A=p(e,"P",{}),ye(A).forEach(s),L=i(e),f(_.$$.fragment,e),E=i(e),h=p(e,"P",{"data-svelte-h":!0}),d(h)!=="svelte-t8b1o9"&&(h.innerHTML=de),Q=i(e),b=p(e,"TABLE",{"data-svelte-h":!0}),d(b)!=="svelte-9lsufo"&&(b.innerHTML=re),z=i(e),y=p(e,"P",{"data-svelte-h":!0}),d(y)!=="svelte-1mckhau"&&(y.textContent=oe),F=i(e),f(S.$$.fragment,e),N=i(e),U=p(e,"P",{"data-svelte-h":!0}),d(U)!=="svelte-1ibu1z8"&&(U.innerHTML=fe),R=i(e),$=p(e,"P",{"data-svelte-h":!0}),d($)!=="svelte-1udhu7d"&&($.innerHTML=ce),W=i(e),j=p(e,"UL",{"data-svelte-h":!0}),d(j)!=="svelte-1igxid9"&&(j.innerHTML=ue),I=i(e),f(k.$$.fragment,e),V=i(e),f(w.$$.fragment,e),X=i(e),v=p(e,"P",{"data-svelte-h":!0}),d(v)!=="svelte-mh2a63"&&(v.innerHTML=me),Y=i(e),T=p(e,"P",{"data-svelte-h":!0}),d(T)!=="svelte-1cqlcb3"&&(T.innerHTML=Me),D=i(e),f(g.$$.fragment,e),q=i(e),C=p(e,"P",{"data-svelte-h":!0}),d(C)!=="svelte-1a8xlol"&&(C.innerHTML=_e),K=i(e),f(x.$$.fragment,e),O=i(e),f(H.$$.fragment,e),ee=i(e),P=p(e,"P",{"data-svelte-h":!0}),d(P)!=="svelte-1n4lqx1"&&(P.innerHTML=he),te=i(e),B=p(e,"UL",{"data-svelte-h":!0}),d(B)!=="svelte-159d9f"&&(B.innerHTML=be),se=i(e),f(Z.$$.fragment,e),ae=i(e),J=p(e,"P",{}),ye(J).forEach(s),this.h()},h(){Se(r,"name","hf:doc:metadata"),Se(r,"content",xe)},m(e,t){Te(document.head,r),a(e,G,t),a(e,A,t),a(e,L,t),c(_,e,t),a(e,E,t),a(e,h,t),a(e,Q,t),a(e,b,t),a(e,z,t),a(e,y,t),a(e,F,t),c(S,e,t),a(e,N,t),a(e,U,t),a(e,R,t),a(e,$,t),a(e,W,t),a(e,j,t),a(e,I,t),c(k,e,t),a(e,V,t),c(w,e,t),a(e,X,t),a(e,v,t),a(e,Y,t),a(e,T,t),a(e,D,t),c(g,e,t),a(e,q,t),a(e,C,t),a(e,K,t),c(x,e,t),a(e,O,t),c(H,e,t),a(e,ee,t),a(e,P,t),a(e,te,t),a(e,B,t),a(e,se,t),c(Z,e,t),a(e,ae,t),a(e,J,t),le=!0},p:$e,i(e){le||(u(_.$$.fragment,e),u(S.$$.fragment,e),u(k.$$.fragment,e),u(w.$$.fragment,e),u(g.$$.fragment,e),u(x.$$.fragment,e),u(H.$$.fragment,e),u(Z.$$.fragment,e),le=!0)},o(e){m(_.$$.fragment,e),m(S.$$.fragment,e),m(k.$$.fragment,e),m(w.$$.fragment,e),m(g.$$.fragment,e),m(x.$$.fragment,e),m(H.$$.fragment,e),m(Z.$$.fragment,e),le=!1},d(e){e&&(s(G),s(A),s(L),s(E),s(h),s(Q),s(b),s(z),s(y),s(F),s(N),s(U),s(R),s($),s(W),s(j),s(I),s(V),s(X),s(v),s(Y),s(T),s(D),s(q),s(C),s(K),s(O),s(ee),s(P),s(te),s(B),s(se),s(ae),s(J)),s(r),M(_,e),M(S,e),M(k,e),M(w,e),M(g,e),M(x,e),M(H,e),M(Z,e)}}}const xe='{"title":"States","local":"states","sections":[{"title":"PipelineState","local":"pipelinestate","sections":[],"depth":2},{"title":"BlockState","local":"blockstate","sections":[],"depth":2},{"title":"State interaction","local":"state-interaction","sections":[],"depth":2}],"depth":1}';function He(pe){return je(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Je extends ke{constructor(r){super(),we(this,r,He,Ce,Ue,{})}}export{Je as component};
