import{s as re,o as ce,n as de}from"../chunks/scheduler.8c3d61f6.js";import{S as me,i as ue,g as o,s as n,r as x,A as Me,h as p,f as a,c as i,j as ie,u as k,x as c,k as oe,y as fe,a as s,v as C,d as E,t as H,w as A}from"../chunks/index.da70eac4.js";import{T as he}from"../chunks/Tip.1d9b8c37.js";import{C as pe}from"../chunks/CodeBlock.a9c4becf.js";import{H as be,E as je}from"../chunks/getInferenceSnippets.a8672208.js";function ye(P){let l,m="🧪 <strong>Experimental Feature</strong>: Modular Diffusers is an experimental feature we are actively developing. The API may be subject to breaking changes.";return{c(){l=o("p"),l.innerHTML=m},l(r){l=p(r,"P",{"data-svelte-h":!0}),c(l)!=="svelte-11qh5l3"&&(l.innerHTML=m)},m(r,g){s(r,l,g)},p:de,d(r){r&&a(l)}}}function $e(P){let l,m,r,g,u,L,d,Q,M,X="In Modular Diffusers, <code>PipelineState</code> and <code>BlockState</code> are the core data structures that enable blocks to communicate and share data. The concept is fundamental to understand how blocks interact with each other and the pipeline system.",J,f,q="In the modular diffusers system, <code>PipelineState</code> acts as the global state container that all pipeline blocks operate on. It maintains the complete runtime state of the pipeline and provides a structured way for blocks to read from and write to shared data.",Z,h,K="A <code>PipelineState</code> consists of two distinct states:",B,b,O="<li><p><strong>The immutable state</strong> (i.e. the <code>inputs</code> dict) contains a copy of values provided by users. Once a value is added to the immutable state, it cannot be changed. Blocks can read from the immutable state but cannot write to it.</p></li> <li><p><strong>The mutable state</strong> (i.e. the <code>intermediates</code> dict) contains variables that are passed between blocks and can be modified by them.</p></li>",z,j,ee="Here’s an example of what a <code>PipelineState</code> looks like:",W,y,I,$,te="Each pipeline blocks define what parts of that state they can read from and write to through their <code>inputs</code>, <code>intermediate_inputs</code>, and <code>intermediate_outputs</code> properties. At run time, they gets a local view (<code>BlockState</code>) of the relevant variables it needs from <code>PipelineState</code>, performs its operations, and then updates <code>PipelineState</code> with any changes.",G,_,ae="For example, if a block defines an input <code>image</code>, inside the block’s <code>__call__</code> method, the <code>BlockState</code> would contain:",F,w,V,v,se="You can access the variables directly as attributes: <code>block_state.image</code>.",R,T,le='We will explore more on how blocks interact with pipeline state through their <code>inputs</code>, <code>intermediate_inputs</code>, and <code>intermediate_outputs</code> properties, see the <a href="./pipeline_block.md">PipelineBlock guide</a>.',D,U,N,S,Y;return u=new be({props:{title:"PipelineState and BlockState",local:"pipelinestate-and-blockstate",headingTag:"h1"}}),d=new he({props:{warning:!0,$$slots:{default:[ye]},$$scope:{ctx:P}}}),y=new pe({props:{code:"UGlwZWxpbmVTdGF0ZSglMEElMjAlMjBpbnB1dHMlM0QlN0IlMEElMjAlMjAlMjAlMjAncHJvbXB0JyUzQSUyMCdhJTIwY2F0JyUwQSUyMCUyMCUyMCUyMCdndWlkYW5jZV9zY2FsZSclM0ElMjA3LjAlMEElMjAlMjAlMjAlMjAnbnVtX2luZmVyZW5jZV9zdGVwcyclM0ElMjAyNSUwQSUyMCUyMCU3RCUyQyUwQSUyMCUyMGludGVybWVkaWF0ZXMlM0QlN0IlMEElMjAlMjAlMjAlMjAncHJvbXB0X2VtYmVkcyclM0ElMjBUZW5zb3IoZHR5cGUlM0R0b3JjaC5mbG9hdDMyJTJDJTIwc2hhcGUlM0R0b3JjaC5TaXplKCU1QjElMkMlMjAxJTJDJTIwMSUyQyUyMDElNUQpKSUwQSUyMCUyMCUyMCUyMCduZWdhdGl2ZV9wcm9tcHRfZW1iZWRzJyUzQSUyME5vbmUlMEElMjAlMjAlN0QlMkMlMEEp",highlighted:`PipelineState(
  inputs={
    <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>
  },
  intermediates={
    <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 pe({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}}),U=new je({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/modular_diffusers/modular_diffusers_states.md"}}),{c(){l=o("meta"),m=n(),r=o("p"),g=n(),x(u.$$.fragment),L=n(),x(d.$$.fragment),Q=n(),M=o("p"),M.innerHTML=X,J=n(),f=o("p"),f.innerHTML=q,Z=n(),h=o("p"),h.innerHTML=K,B=n(),b=o("ul"),b.innerHTML=O,z=n(),j=o("p"),j.innerHTML=ee,W=n(),x(y.$$.fragment),I=n(),$=o("p"),$.innerHTML=te,G=n(),_=o("p"),_.innerHTML=ae,F=n(),x(w.$$.fragment),V=n(),v=o("p"),v.innerHTML=se,R=n(),T=o("p"),T.innerHTML=le,D=n(),x(U.$$.fragment),N=n(),S=o("p"),this.h()},l(e){const t=Me("svelte-u9bgzb",document.head);l=p(t,"META",{name:!0,content:!0}),t.forEach(a),m=i(e),r=p(e,"P",{}),ie(r).forEach(a),g=i(e),k(u.$$.fragment,e),L=i(e),k(d.$$.fragment,e),Q=i(e),M=p(e,"P",{"data-svelte-h":!0}),c(M)!=="svelte-13lc8n3"&&(M.innerHTML=X),J=i(e),f=p(e,"P",{"data-svelte-h":!0}),c(f)!=="svelte-16ugulg"&&(f.innerHTML=q),Z=i(e),h=p(e,"P",{"data-svelte-h":!0}),c(h)!=="svelte-1jzmnng"&&(h.innerHTML=K),B=i(e),b=p(e,"UL",{"data-svelte-h":!0}),c(b)!=="svelte-px7ek8"&&(b.innerHTML=O),z=i(e),j=p(e,"P",{"data-svelte-h":!0}),c(j)!=="svelte-1s8s8ju"&&(j.innerHTML=ee),W=i(e),k(y.$$.fragment,e),I=i(e),$=p(e,"P",{"data-svelte-h":!0}),c($)!=="svelte-shvjz2"&&($.innerHTML=te),G=i(e),_=p(e,"P",{"data-svelte-h":!0}),c(_)!=="svelte-epavrq"&&(_.innerHTML=ae),F=i(e),k(w.$$.fragment,e),V=i(e),v=p(e,"P",{"data-svelte-h":!0}),c(v)!=="svelte-1dcten9"&&(v.innerHTML=se),R=i(e),T=p(e,"P",{"data-svelte-h":!0}),c(T)!=="svelte-qjrj8y"&&(T.innerHTML=le),D=i(e),k(U.$$.fragment,e),N=i(e),S=p(e,"P",{}),ie(S).forEach(a),this.h()},h(){oe(l,"name","hf:doc:metadata"),oe(l,"content",_e)},m(e,t){fe(document.head,l),s(e,m,t),s(e,r,t),s(e,g,t),C(u,e,t),s(e,L,t),C(d,e,t),s(e,Q,t),s(e,M,t),s(e,J,t),s(e,f,t),s(e,Z,t),s(e,h,t),s(e,B,t),s(e,b,t),s(e,z,t),s(e,j,t),s(e,W,t),C(y,e,t),s(e,I,t),s(e,$,t),s(e,G,t),s(e,_,t),s(e,F,t),C(w,e,t),s(e,V,t),s(e,v,t),s(e,R,t),s(e,T,t),s(e,D,t),C(U,e,t),s(e,N,t),s(e,S,t),Y=!0},p(e,[t]){const ne={};t&2&&(ne.$$scope={dirty:t,ctx:e}),d.$set(ne)},i(e){Y||(E(u.$$.fragment,e),E(d.$$.fragment,e),E(y.$$.fragment,e),E(w.$$.fragment,e),E(U.$$.fragment,e),Y=!0)},o(e){H(u.$$.fragment,e),H(d.$$.fragment,e),H(y.$$.fragment,e),H(w.$$.fragment,e),H(U.$$.fragment,e),Y=!1},d(e){e&&(a(m),a(r),a(g),a(L),a(Q),a(M),a(J),a(f),a(Z),a(h),a(B),a(b),a(z),a(j),a(W),a(I),a($),a(G),a(_),a(F),a(V),a(v),a(R),a(T),a(D),a(N),a(S)),a(l),A(u,e),A(d,e),A(y,e),A(w,e),A(U,e)}}}const _e='{"title":"PipelineState and BlockState","local":"pipelinestate-and-blockstate","sections":[],"depth":1}';function we(P){return ce(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class xe extends me{constructor(l){super(),ue(this,l,we,$e,re,{})}}export{xe as component};
