import{s as Rt,o as Vt,n as it}from"../chunks/scheduler.8c3d61f6.js";import{S as Xt,i as Nt,g as d,s as l,r,A as It,h as m,f as n,c as a,j as xt,u as c,x as b,k as Bt,y as Yt,a as s,v as f,d as u,t as M,w as y}from"../chunks/index.da70eac4.js";import{T as qt}from"../chunks/Tip.1d9b8c37.js";import{C as $}from"../chunks/CodeBlock.a9c4becf.js";import{H as Z,E as Ht}from"../chunks/getInferenceSnippets.cd165132.js";import{H as Qt,a as kt}from"../chunks/HfOption.6c3b4e77.js";function zt(g){let o,h="The <code>collection</code> parameter is optional but makes it easier to organize and manage components.";return{c(){o=d("p"),o.innerHTML=h},l(i){o=m(i,"P",{"data-svelte-h":!0}),b(o)!=="svelte-16u3huf"&&(o.innerHTML=h)},m(i,_){s(i,o,_)},p:it,d(i){i&&n(o)}}}function Lt(g){let o,h;return o=new $({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyME1vZHVsYXJQaXBlbGluZSUyQyUyMENvbXBvbmVudHNNYW5hZ2VyJTBBJTBBY29tcCUyMCUzRCUyMENvbXBvbmVudHNNYW5hZ2VyKCklMEFwaXBlJTIwJTNEJTIwTW9kdWxhclBpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMjJZaVlpWHUlMkZtb2R1bGFyLWRlbW8tYXV0byUyMiUyQyUyMGNvbXBvbmVudHNfbWFuYWdlciUzRGNvbXAlMkMlMjBjb2xsZWN0aW9uJTNEJTIydGVzdDElMjIp",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> ModularPipeline, ComponentsManager

comp = ComponentsManager()
pipe = ModularPipeline.from_pretrained(<span class="hljs-string">&quot;YiYiXu/modular-demo-auto&quot;</span>, components_manager=comp, collection=<span class="hljs-string">&quot;test1&quot;</span>)`,wrap:!1}}),{c(){r(o.$$.fragment)},l(i){c(o.$$.fragment,i)},m(i,_){f(o,i,_),h=!0},p:it,i(i){h||(u(o.$$.fragment,i),h=!0)},o(i){M(o.$$.fragment,i),h=!1},d(i){y(o,i)}}}function Et(g){let o,h;return o=new $({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMENvbXBvbmVudHNNYW5hZ2VyJTBBZnJvbSUyMGRpZmZ1c2Vycy5tb2R1bGFyX3BpcGVsaW5lcyUyMGltcG9ydCUyMFNlcXVlbnRpYWxQaXBlbGluZUJsb2NrcyUwQWZyb20lMjBkaWZmdXNlcnMubW9kdWxhcl9waXBlbGluZXMuc3RhYmxlX2RpZmZ1c2lvbl94bCUyMGltcG9ydCUyMFRFWFQySU1BR0VfQkxPQ0tTJTBBJTBBdDJpX2Jsb2NrcyUyMCUzRCUyMFNlcXVlbnRpYWxQaXBlbGluZUJsb2Nrcy5mcm9tX2Jsb2Nrc19kaWN0KFRFWFQySU1BR0VfQkxPQ0tTKSUwQSUwQW1vZHVsYXJfcmVwb19pZCUyMCUzRCUyMCUyMllpWWlYdSUyRm1vZHVsYXItbG9hZGVyLXQyaS0wNzA0JTIyJTBBY29tcG9uZW50cyUyMCUzRCUyMENvbXBvbmVudHNNYW5hZ2VyKCklMEF0MmlfcGlwZWxpbmUlMjAlM0QlMjB0MmlfYmxvY2tzLmluaXRfcGlwZWxpbmUobW9kdWxhcl9yZXBvX2lkJTJDJTIwY29tcG9uZW50c19tYW5hZ2VyJTNEY29tcG9uZW50cyk=",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> ComponentsManager
<span class="hljs-keyword">from</span> diffusers.modular_pipelines <span class="hljs-keyword">import</span> SequentialPipelineBlocks
<span class="hljs-keyword">from</span> diffusers.modular_pipelines.stable_diffusion_xl <span class="hljs-keyword">import</span> TEXT2IMAGE_BLOCKS

t2i_blocks = SequentialPipelineBlocks.from_blocks_dict(TEXT2IMAGE_BLOCKS)

modular_repo_id = <span class="hljs-string">&quot;YiYiXu/modular-loader-t2i-0704&quot;</span>
components = ComponentsManager()
t2i_pipeline = t2i_blocks.init_pipeline(modular_repo_id, components_manager=components)`,wrap:!1}}),{c(){r(o.$$.fragment)},l(i){c(o.$$.fragment,i)},m(i,_){f(o,i,_),h=!0},p:it,i(i){h||(u(o.$$.fragment,i),h=!0)},o(i){M(o.$$.fragment,i),h=!1},d(i){y(o,i)}}}function St(g){let o,h,i,_;return o=new kt({props:{id:"create",option:"from_pretrained",$$slots:{default:[Lt]},$$scope:{ctx:g}}}),i=new kt({props:{id:"create",option:"init_pipeline",$$slots:{default:[Et]},$$scope:{ctx:g}}}),{c(){r(o.$$.fragment),h=l(),r(i.$$.fragment)},l(p){c(o.$$.fragment,p),h=a(p),c(i.$$.fragment,p)},m(p,T){f(o,p,T),s(p,h,T),f(i,p,T),_=!0},p(p,T){const w={};T&2&&(w.$$scope={dirty:T,ctx:p}),o.$set(w);const ue={};T&2&&(ue.$$scope={dirty:T,ctx:p}),i.$set(ue)},i(p){_||(u(o.$$.fragment,p),u(i.$$.fragment,p),_=!0)},o(p){M(o.$$.fragment,p),M(i.$$.fragment,p),_=!1},d(p){p&&n(h),y(o,p),y(i,p)}}}function Ft(g){let o,h,i,_,p,T,w,ue='The <a href="/docs/diffusers/main/en/api/modular_diffusers/pipeline_components#diffusers.ComponentsManager">ComponentsManager</a> is a model registry and management system for Modular Diffusers. It adds and tracks models, stores useful metadata (model size, device placement, adapters), prevents duplicate model instances, and supports offloading.',ye,J,pt='This guide will show you how to use <a href="/docs/diffusers/main/en/api/modular_diffusers/pipeline_components#diffusers.ComponentsManager">ComponentsManager</a> to manage components and device memory.',be,C,he,v,dt='The <a href="/docs/diffusers/main/en/api/modular_diffusers/pipeline_components#diffusers.ComponentsManager">ComponentsManager</a> should be created alongside a <a href="/docs/diffusers/main/en/api/modular_diffusers/pipeline#diffusers.ModularPipeline">ModularPipeline</a> in either <a href="/docs/diffusers/main/en/api/modular_diffusers/pipeline#diffusers.ModularPipeline.from_pretrained">from_pretrained()</a> or <a href="/docs/diffusers/main/en/api/modular_diffusers/pipeline_blocks#diffusers.ModularPipelineBlocks.init_pipeline">init_pipeline()</a>.',_e,U,Te,j,$e,G,mt='Components are only loaded and registered when using <a href="/docs/diffusers/main/en/api/modular_diffusers/pipeline#diffusers.ModularPipeline.load_components">load_components()</a> or <a href="/docs/diffusers/main/en/api/modular_diffusers/pipeline#diffusers.ModularPipeline.load_components">load_components()</a>. The example below uses <a href="/docs/diffusers/main/en/api/modular_diffusers/pipeline#diffusers.ModularPipeline.load_components">load_components()</a> to create a second pipeline that reuses all the components from the first one, and assigns it to a different collection',ge,W,we,x,rt='Use the <code>null_component_names</code> property to identify any components that need to be loaded, retrieve them with <a href="/docs/diffusers/main/en/api/modular_diffusers/pipeline_components#diffusers.ComponentsManager.get_components_by_names">get_components_by_names()</a>, and then call <a href="/docs/diffusers/main/en/api/modular_diffusers/pipeline#diffusers.ModularPipeline.update_components">update_components()</a> to add the missing components.',Ue,B,je,k,ct='To add individual components, use the <a href="/docs/diffusers/main/en/api/modular_diffusers/pipeline_components#diffusers.ComponentsManager.add">add()</a> method. This registers a component with a unique id.',Ze,R,Je,V,ft='Use <a href="/docs/diffusers/main/en/api/modular_diffusers/pipeline_components#diffusers.ComponentsManager.remove">remove()</a> to remove a component using their id.',Ce,X,ve,N,Ge,I,ut='The <a href="/docs/diffusers/main/en/api/modular_diffusers/pipeline_components#diffusers.ComponentsManager">ComponentsManager</a> provides several methods to retrieve registered components.',We,Y,xe,q,Mt='The <a href="/docs/diffusers/main/en/api/modular_diffusers/pipeline_components#diffusers.ComponentsManager.get_one">get_one()</a> method returns a single component and supports pattern matching for the <code>name</code> parameter. If multiple components match, <a href="/docs/diffusers/main/en/api/modular_diffusers/pipeline_components#diffusers.ComponentsManager.get_one">get_one()</a> returns an error.',Be,H,yt="<thead><tr><th>Pattern</th> <th>Example</th> <th>Description</th></tr></thead> <tbody><tr><td>exact</td> <td><code>comp.get_one(name=&quot;unet&quot;)</code></td> <td>exact name match</td></tr> <tr><td>wildcard</td> <td><code>comp.get_one(name=&quot;unet*&quot;)</code></td> <td>names starting with “unet”</td></tr> <tr><td>exclusion</td> <td><code>comp.get_one(name=&quot;!unet&quot;)</code></td> <td>exclude components named “unet”</td></tr> <tr><td>or</td> <td><code>comp.get_one(name=&quot;unet|vae&quot;)</code></td> <td>name is “unet” or “vae”</td></tr></tbody>",ke,Q,bt='<a href="/docs/diffusers/main/en/api/modular_diffusers/pipeline_components#diffusers.ComponentsManager.get_one">get_one()</a> also filters components by the <code>collection</code> argument or <code>load_id</code> argument.',Re,z,Ve,L,Xe,E,ht='The <a href="/docs/diffusers/main/en/api/modular_diffusers/pipeline_components#diffusers.ComponentsManager.get_components_by_names">get_components_by_names()</a> method accepts a list of names and returns a dictionary mapping names to components. This is especially useful with <a href="/docs/diffusers/main/en/api/modular_diffusers/pipeline#diffusers.ModularPipeline">ModularPipeline</a> since they provide lists of required component names and the returned dictionary can be passed directly to <a href="/docs/diffusers/main/en/api/modular_diffusers/pipeline#diffusers.ModularPipeline.update_components">update_components()</a>.',Ne,S,Ie,F,Ye,P,_t='It is recommended to load model components with <a href="/docs/diffusers/main/en/api/modular_diffusers/pipeline_components#diffusers.ComponentSpec">ComponentSpec</a> to assign components with a unique id that encodes their loading parameters. This allows <a href="/docs/diffusers/main/en/api/modular_diffusers/pipeline_components#diffusers.ComponentsManager">ComponentsManager</a> to automatically detect and prevent duplicate model instances even when different objects represent the same underlying checkpoint.',qe,A,He,D,Tt="This returns a warning with instructions for removing the duplicate.",Qe,K,ze,O,$t='You could also add a component without using <a href="/docs/diffusers/main/en/api/modular_diffusers/pipeline_components#diffusers.ComponentSpec">ComponentSpec</a> and duplicate detection still works in most cases even if you’re adding the same component under a different name.',Le,ee,gt='However, <code>ComponentManager</code> can’t detect duplicates when you load the same component into different objects. In this case, you should load a model with <a href="/docs/diffusers/main/en/api/modular_diffusers/pipeline_components#diffusers.ComponentSpec">ComponentSpec</a>.',Ee,te,Se,ne,Fe,se,wt='Collections are labels assigned to components for better organization and management. Add a component to a collection with the <code>collection</code> argument in <a href="/docs/diffusers/main/en/api/modular_diffusers/pipeline_components#diffusers.ComponentsManager.add">add()</a>.',Pe,le,Ut="Only one component per name is allowed in each collection. Adding a second component with the same name automatically removes the first component.",Ae,ae,De,oe,jt="This makes it convenient to work with node-based systems because you can:",Ke,ie,Zt="<li>Mark all models as loaded from one node with the <code>collection</code> label.</li> <li>Automatically replace models when new checkpoints are loaded under the same name.</li> <li>Batch delete all models in a collection when a node is removed.</li>",Oe,pe,et,de,Jt='The <a href="/docs/diffusers/main/en/api/modular_diffusers/pipeline_components#diffusers.ComponentsManager.enable_auto_cpu_offload">enable_auto_cpu_offload()</a> method is a global offloading strategy that works across all models regardless of which pipeline is using them. Once enabled, you don’t need to worry about device placement if you add or remove components.',tt,me,nt,re,Ct='All models begin on the CPU and <a href="/docs/diffusers/main/en/api/modular_diffusers/pipeline_components#diffusers.ComponentsManager">ComponentsManager</a> moves them to the appropriate device right before they’re needed, and moves other models back to the CPU when GPU memory is low.',st,ce,vt="You can set your own rules for which models to offload first.",lt,fe,at,Me,ot;return p=new Z({props:{title:"ComponentsManager",local:"componentsmanager",headingTag:"h1"}}),C=new Z({props:{title:"Add a component",local:"add-a-component",headingTag:"h2"}}),U=new qt({props:{warning:!1,$$slots:{default:[zt]},$$scope:{ctx:g}}}),j=new Qt({props:{id:"create",options:["from_pretrained","init_pipeline"],$$slots:{default:[St]},$$scope:{ctx:g}}}),W=new $({props:{code:"cGlwZS5sb2FkX2NvbXBvbmVudHMoKSUwQXBpcGUyJTIwJTNEJTIwTW9kdWxhclBpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMjJZaVlpWHUlMkZtb2R1bGFyLWRlbW8tYXV0byUyMiUyQyUyMGNvbXBvbmVudHNfbWFuYWdlciUzRGNvbXAlMkMlMjBjb2xsZWN0aW9uJTNEJTIydGVzdDIlMjIp",highlighted:`pipe.load_components()
pipe2 = ModularPipeline.from_pretrained(<span class="hljs-string">&quot;YiYiXu/modular-demo-auto&quot;</span>, components_manager=comp, collection=<span class="hljs-string">&quot;test2&quot;</span>)`,wrap:!1}}),B=new $({props:{code:"cGlwZTIubnVsbF9jb21wb25lbnRfbmFtZXMlMjAlMEElNUIndGV4dF9lbmNvZGVyJyUyQyUyMCd0ZXh0X2VuY29kZXJfMiclMkMlMjAndG9rZW5pemVyJyUyQyUyMCd0b2tlbml6ZXJfMiclMkMlMjAnaW1hZ2VfZW5jb2RlciclMkMlMjAndW5ldCclMkMlMjAndmFlJyUyQyUyMCdzY2hlZHVsZXInJTJDJTIwJ2NvbnRyb2xuZXQnJTVEJTBBJTBBY29tcF9kaWN0JTIwJTNEJTIwY29tcC5nZXRfY29tcG9uZW50c19ieV9uYW1lcyhuYW1lcyUzRHBpcGUyLm51bGxfY29tcG9uZW50X25hbWVzKSUwQXBpcGUyLnVwZGF0ZV9jb21wb25lbnRzKCoqY29tcF9kaWN0KQ==",highlighted:`pipe2.null_component_names 
[<span class="hljs-string">&#x27;text_encoder&#x27;</span>, <span class="hljs-string">&#x27;text_encoder_2&#x27;</span>, <span class="hljs-string">&#x27;tokenizer&#x27;</span>, <span class="hljs-string">&#x27;tokenizer_2&#x27;</span>, <span class="hljs-string">&#x27;image_encoder&#x27;</span>, <span class="hljs-string">&#x27;unet&#x27;</span>, <span class="hljs-string">&#x27;vae&#x27;</span>, <span class="hljs-string">&#x27;scheduler&#x27;</span>, <span class="hljs-string">&#x27;controlnet&#x27;</span>]

comp_dict = comp.get_components_by_names(names=pipe2.null_component_names)
pipe2.update_components(**comp_dict)`,wrap:!1}}),R=new $({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMEF1dG9Nb2RlbCUwQSUwQXRleHRfZW5jb2RlciUyMCUzRCUyMEF1dG9Nb2RlbC5mcm9tX3ByZXRyYWluZWQoJTIyc3RhYmlsaXR5YWklMkZzdGFibGUtZGlmZnVzaW9uLXhsLWJhc2UtMS4wJTIyJTJDJTIwc3ViZm9sZGVyJTNEJTIydGV4dF9lbmNvZGVyJTIyKSUwQWNvbXBvbmVudF9pZCUyMCUzRCUyMGNvbXAuYWRkKCUyMnRleHRfZW5jb2RlciUyMiUyQyUyMHRleHRfZW5jb2RlciklMEFjb21w",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> AutoModel

text_encoder = AutoModel.from_pretrained(<span class="hljs-string">&quot;stabilityai/stable-diffusion-xl-base-1.0&quot;</span>, subfolder=<span class="hljs-string">&quot;text_encoder&quot;</span>)
component_id = comp.add(<span class="hljs-string">&quot;text_encoder&quot;</span>, text_encoder)
comp`,wrap:!1}}),X=new $({props:{code:"Y29tcC5yZW1vdmUoJTIydGV4dF9lbmNvZGVyXzEzOTkxNzczMzA0Mjg2NCUyMik=",highlighted:'comp.remove(<span class="hljs-string">&quot;text_encoder_139917733042864&quot;</span>)',wrap:!1}}),N=new Z({props:{title:"Retrieve a component",local:"retrieve-a-component",headingTag:"h2"}}),Y=new Z({props:{title:"get_one",local:"getone",headingTag:"h3"}}),z=new $({props:{code:"Y29tcC5nZXRfb25lKG5hbWUlM0QlMjJ1bmV0JTIyJTJDJTIwY29sbGVjdGlvbiUzRCUyMnNkeGwlMjIp",highlighted:'comp.get_one(name=<span class="hljs-string">&quot;unet&quot;</span>, collection=<span class="hljs-string">&quot;sdxl&quot;</span>)',wrap:!1}}),L=new Z({props:{title:"get_components_by_names",local:"getcomponentsbynames",headingTag:"h3"}}),S=new $({props:{code:"Y29tcG9uZW50X2RpY3QlMjAlM0QlMjBjb21wLmdldF9jb21wb25lbnRzX2J5X25hbWVzKG5hbWVzJTNEJTVCJTIydGV4dF9lbmNvZGVyJTIyJTJDJTIwJTIydW5ldCUyMiUyQyUyMCUyMnZhZSUyMiU1RCklMEElN0IlMjJ0ZXh0X2VuY29kZXIlMjIlM0ElMjBjb21wb25lbnQxJTJDJTIwJTIydW5ldCUyMiUzQSUyMGNvbXBvbmVudDIlMkMlMjAlMjJ2YWUlMjIlM0ElMjBjb21wb25lbnQzJTdE",highlighted:`component_dict = comp.get_components_by_names(names=[<span class="hljs-string">&quot;text_encoder&quot;</span>, <span class="hljs-string">&quot;unet&quot;</span>, <span class="hljs-string">&quot;vae&quot;</span>])
{<span class="hljs-string">&quot;text_encoder&quot;</span>: component1, <span class="hljs-string">&quot;unet&quot;</span>: component2, <span class="hljs-string">&quot;vae&quot;</span>: component3}`,wrap:!1}}),F=new Z({props:{title:"Duplicate detection",local:"duplicate-detection",headingTag:"h2"}}),A=new $({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMENvbXBvbmVudFNwZWMlMkMlMjBDb21wb25lbnRzTWFuYWdlciUwQWZyb20lMjB0cmFuc2Zvcm1lcnMlMjBpbXBvcnQlMjBDTElQVGV4dE1vZGVsJTBBJTBBY29tcCUyMCUzRCUyMENvbXBvbmVudHNNYW5hZ2VyKCklMEElMEElMjMlMjBDcmVhdGUlMjBDb21wb25lbnRTcGVjJTIwZm9yJTIwdGhlJTIwZmlyc3QlMjB0ZXh0JTIwZW5jb2RlciUwQXNwZWMlMjAlM0QlMjBDb21wb25lbnRTcGVjKG5hbWUlM0QlMjJ0ZXh0X2VuY29kZXIlMjIlMkMlMjByZXBvJTNEJTIyc3RhYmlsaXR5YWklMkZzdGFibGUtZGlmZnVzaW9uLXhsLWJhc2UtMS4wJTIyJTJDJTIwc3ViZm9sZGVyJTNEJTIydGV4dF9lbmNvZGVyJTIyJTJDJTIwdHlwZV9oaW50JTNEQXV0b01vZGVsKSUwQSUyMyUyMENyZWF0ZSUyMENvbXBvbmVudFNwZWMlMjBmb3IlMjBhJTIwZHVwbGljYXRlJTIwdGV4dCUyMGVuY29kZXIlMjAoaXQlMjBpcyUyMHNhbWUlMjBjaGVja3BvaW50JTJDJTIwZnJvbSUyMHRoZSUyMHNhbWUlMjByZXBvJTJGc3ViZm9sZGVyKSUwQXNwZWNfZHVwbGljYXRlZCUyMCUzRCUyMENvbXBvbmVudFNwZWMobmFtZSUzRCUyMnRleHRfZW5jb2Rlcl9kdXBsaWNhdGVkJTIyJTJDJTIwcmVwbyUzRCUyMnN0YWJpbGl0eWFpJTJGc3RhYmxlLWRpZmZ1c2lvbi14bC1iYXNlLTEuMCUyMiUyQyUyMHN1YmZvbGRlciUzRCUyMnRleHRfZW5jb2RlciUyMiUyQyUyMHR5cGVfaGludCUzRENMSVBUZXh0TW9kZWwpJTBBJTBBJTIzJTIwTG9hZCUyMGFuZCUyMGFkZCUyMGJvdGglMjBjb21wb25lbnRzJTIwLSUyMHRoZSUyMG1hbmFnZXIlMjB3aWxsJTIwZGV0ZWN0JTIwdGhleSdyZSUyMHRoZSUyMHNhbWUlMjBtb2RlbCUwQWNvbXAuYWRkKCUyMnRleHRfZW5jb2RlciUyMiUyQyUyMHNwZWMubG9hZCgpKSUwQWNvbXAuYWRkKCUyMnRleHRfZW5jb2Rlcl9kdXBsaWNhdGVkJTIyJTJDJTIwc3BlY19kdXBsaWNhdGVkLmxvYWQoKSk=",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> ComponentSpec, ComponentsManager
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> CLIPTextModel

comp = ComponentsManager()

<span class="hljs-comment"># Create ComponentSpec for the first text encoder</span>
spec = ComponentSpec(name=<span class="hljs-string">&quot;text_encoder&quot;</span>, repo=<span class="hljs-string">&quot;stabilityai/stable-diffusion-xl-base-1.0&quot;</span>, subfolder=<span class="hljs-string">&quot;text_encoder&quot;</span>, type_hint=AutoModel)
<span class="hljs-comment"># Create ComponentSpec for a duplicate text encoder (it is same checkpoint, from the same repo/subfolder)</span>
spec_duplicated = ComponentSpec(name=<span class="hljs-string">&quot;text_encoder_duplicated&quot;</span>, repo=<span class="hljs-string">&quot;stabilityai/stable-diffusion-xl-base-1.0&quot;</span>, subfolder=<span class="hljs-string">&quot;text_encoder&quot;</span>, type_hint=CLIPTextModel)

<span class="hljs-comment"># Load and add both components - the manager will detect they&#x27;re the same model</span>
comp.add(<span class="hljs-string">&quot;text_encoder&quot;</span>, spec.load())
comp.add(<span class="hljs-string">&quot;text_encoder_duplicated&quot;</span>, spec_duplicated.load())`,wrap:!1}}),K=new $({props:{code:"Q29tcG9uZW50c01hbmFnZXIlM0ElMjBhZGRpbmclMjBjb21wb25lbnQlMjAndGV4dF9lbmNvZGVyX2R1cGxpY2F0ZWRfMTM5OTE3NTgwNjgyNjcyJyUyQyUyMGJ1dCUyMGl0JTIwaGFzJTIwZHVwbGljYXRlJTIwbG9hZF9pZCUyMCdzdGFiaWxpdHlhaSUyRnN0YWJsZS1kaWZmdXNpb24teGwtYmFzZS0xLjAlN0N0ZXh0X2VuY29kZXIlN0NudWxsJTdDbnVsbCclMjB3aXRoJTIwZXhpc3RpbmclMjBjb21wb25lbnRzJTNBJTIwdGV4dF9lbmNvZGVyXzEzOTkxODUwNjI0NjgzMi4lMjBUbyUyMHJlbW92ZSUyMGElMjBkdXBsaWNhdGUlMkMlMjBjYWxsJTIwJTYwY29tcG9uZW50c19tYW5hZ2VyLnJlbW92ZSgnJTNDY29tcG9uZW50X2lkJTNFJyklNjAuJTBBJ3RleHRfZW5jb2Rlcl9kdXBsaWNhdGVkXzEzOTkxNzU4MDY4MjY3Mic=",highlighted:'ComponentsManager: adding component <span class="hljs-string">&#x27;text_encoder_duplicated_139917580682672&#x27;</span>, but it has duplicate load_id <span class="hljs-string">&#x27;stabilityai/stable-diffusion-xl-base-1.0|text_encoder|null|null&#x27;</span> <span class="hljs-keyword">with</span> existing components: text_encoder_139918506246832. To remove a duplicate, call `components_manager.remove(<span class="hljs-string">&#x27;&lt;component_id&gt;&#x27;</span>)`.\n<span class="hljs-string">&#x27;text_encoder_duplicated_139917580682672&#x27;</span>',wrap:!1}}),te=new $({props:{code:"dGV4dF9lbmNvZGVyXzIlMjAlM0QlMjBBdXRvTW9kZWwuZnJvbV9wcmV0cmFpbmVkKCUyMnN0YWJpbGl0eWFpJTJGc3RhYmxlLWRpZmZ1c2lvbi14bC1iYXNlLTEuMCUyMiUyQyUyMHN1YmZvbGRlciUzRCUyMnRleHRfZW5jb2RlciUyMiklMEFjb21wLmFkZCglMjJ0ZXh0X2VuY29kZXIlMjIlMkMlMjB0ZXh0X2VuY29kZXJfMiklMEEndGV4dF9lbmNvZGVyXzEzOTkxNzczMjk4MzY2NCc=",highlighted:`text_encoder_2 = AutoModel.from_pretrained(<span class="hljs-string">&quot;stabilityai/stable-diffusion-xl-base-1.0&quot;</span>, subfolder=<span class="hljs-string">&quot;text_encoder&quot;</span>)
comp.add(<span class="hljs-string">&quot;text_encoder&quot;</span>, text_encoder_2)
<span class="hljs-string">&#x27;text_encoder_139917732983664&#x27;</span>`,wrap:!1}}),ne=new Z({props:{title:"Collections",local:"collections",headingTag:"h2"}}),ae=new $({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMENvbXBvbmVudFNwZWMlMkMlMjBDb21wb25lbnRzTWFuYWdlciUwQSUwQWNvbXAlMjAlM0QlMjBDb21wb25lbnRzTWFuYWdlcigpJTBBJTIzJTIwQ3JlYXRlJTIwQ29tcG9uZW50U3BlYyUyMGZvciUyMHRoZSUyMGZpcnN0JTIwVU5ldCUwQXNwZWMlMjAlM0QlMjBDb21wb25lbnRTcGVjKG5hbWUlM0QlMjJ1bmV0JTIyJTJDJTIwcmVwbyUzRCUyMnN0YWJpbGl0eWFpJTJGc3RhYmxlLWRpZmZ1c2lvbi14bC1iYXNlLTEuMCUyMiUyQyUyMHN1YmZvbGRlciUzRCUyMnVuZXQlMjIlMkMlMjB0eXBlX2hpbnQlM0RBdXRvTW9kZWwpJTBBJTIzJTIwQ3JlYXRlJTIwQ29tcG9uZW50U3BlYyUyMGZvciUyMGElMjBkaWZmZXJlbnQlMjBVTmV0JTBBc3BlYzIlMjAlM0QlMjBDb21wb25lbnRTcGVjKG5hbWUlM0QlMjJ1bmV0JTIyJTJDJTIwcmVwbyUzRCUyMlJ1bkRpZmZ1c2lvbiUyRkp1Z2dlcm5hdXQtWEwtdjklMjIlMkMlMjBzdWJmb2xkZXIlM0QlMjJ1bmV0JTIyJTJDJTIwdHlwZV9oaW50JTNEQXV0b01vZGVsJTJDJTIwdmFyaWFudCUzRCUyMmZwMTYlMjIpJTBBJTBBJTIzJTIwQWRkJTIwYm90aCUyMFVOZXRzJTIwdG8lMjB0aGUlMjBzYW1lJTIwY29sbGVjdGlvbiUyMC0lMjB0aGUlMjBzZWNvbmQlMjBvbmUlMjB3aWxsJTIwcmVwbGFjZSUyMHRoZSUyMGZpcnN0JTBBY29tcC5hZGQoJTIydW5ldCUyMiUyQyUyMHNwZWMubG9hZCgpJTJDJTIwY29sbGVjdGlvbiUzRCUyMnNkeGwlMjIpJTBBY29tcC5hZGQoJTIydW5ldCUyMiUyQyUyMHNwZWMyLmxvYWQoKSUyQyUyMGNvbGxlY3Rpb24lM0QlMjJzZHhsJTIyKQ==",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> ComponentSpec, ComponentsManager

comp = ComponentsManager()
<span class="hljs-comment"># Create ComponentSpec for the first UNet</span>
spec = ComponentSpec(name=<span class="hljs-string">&quot;unet&quot;</span>, repo=<span class="hljs-string">&quot;stabilityai/stable-diffusion-xl-base-1.0&quot;</span>, subfolder=<span class="hljs-string">&quot;unet&quot;</span>, type_hint=AutoModel)
<span class="hljs-comment"># Create ComponentSpec for a different UNet</span>
spec2 = ComponentSpec(name=<span class="hljs-string">&quot;unet&quot;</span>, repo=<span class="hljs-string">&quot;RunDiffusion/Juggernaut-XL-v9&quot;</span>, subfolder=<span class="hljs-string">&quot;unet&quot;</span>, type_hint=AutoModel, variant=<span class="hljs-string">&quot;fp16&quot;</span>)

<span class="hljs-comment"># Add both UNets to the same collection - the second one will replace the first</span>
comp.add(<span class="hljs-string">&quot;unet&quot;</span>, spec.load(), collection=<span class="hljs-string">&quot;sdxl&quot;</span>)
comp.add(<span class="hljs-string">&quot;unet&quot;</span>, spec2.load(), collection=<span class="hljs-string">&quot;sdxl&quot;</span>)`,wrap:!1}}),pe=new Z({props:{title:"Offloading",local:"offloading",headingTag:"h2"}}),me=new $({props:{code:"Y29tcC5lbmFibGVfYXV0b19jcHVfb2ZmbG9hZChkZXZpY2UlM0QlMjJjdWRhJTIyKQ==",highlighted:'comp.enable_auto_cpu_offload(device=<span class="hljs-string">&quot;cuda&quot;</span>)',wrap:!1}}),fe=new Ht({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/modular_diffusers/components_manager.md"}}),{c(){o=d("meta"),h=l(),i=d("p"),_=l(),r(p.$$.fragment),T=l(),w=d("p"),w.innerHTML=ue,ye=l(),J=d("p"),J.innerHTML=pt,be=l(),r(C.$$.fragment),he=l(),v=d("p"),v.innerHTML=dt,_e=l(),r(U.$$.fragment),Te=l(),r(j.$$.fragment),$e=l(),G=d("p"),G.innerHTML=mt,ge=l(),r(W.$$.fragment),we=l(),x=d("p"),x.innerHTML=rt,Ue=l(),r(B.$$.fragment),je=l(),k=d("p"),k.innerHTML=ct,Ze=l(),r(R.$$.fragment),Je=l(),V=d("p"),V.innerHTML=ft,Ce=l(),r(X.$$.fragment),ve=l(),r(N.$$.fragment),Ge=l(),I=d("p"),I.innerHTML=ut,We=l(),r(Y.$$.fragment),xe=l(),q=d("p"),q.innerHTML=Mt,Be=l(),H=d("table"),H.innerHTML=yt,ke=l(),Q=d("p"),Q.innerHTML=bt,Re=l(),r(z.$$.fragment),Ve=l(),r(L.$$.fragment),Xe=l(),E=d("p"),E.innerHTML=ht,Ne=l(),r(S.$$.fragment),Ie=l(),r(F.$$.fragment),Ye=l(),P=d("p"),P.innerHTML=_t,qe=l(),r(A.$$.fragment),He=l(),D=d("p"),D.textContent=Tt,Qe=l(),r(K.$$.fragment),ze=l(),O=d("p"),O.innerHTML=$t,Le=l(),ee=d("p"),ee.innerHTML=gt,Ee=l(),r(te.$$.fragment),Se=l(),r(ne.$$.fragment),Fe=l(),se=d("p"),se.innerHTML=wt,Pe=l(),le=d("p"),le.textContent=Ut,Ae=l(),r(ae.$$.fragment),De=l(),oe=d("p"),oe.textContent=jt,Ke=l(),ie=d("ul"),ie.innerHTML=Zt,Oe=l(),r(pe.$$.fragment),et=l(),de=d("p"),de.innerHTML=Jt,tt=l(),r(me.$$.fragment),nt=l(),re=d("p"),re.innerHTML=Ct,st=l(),ce=d("p"),ce.textContent=vt,lt=l(),r(fe.$$.fragment),at=l(),Me=d("p"),this.h()},l(e){const t=It("svelte-u9bgzb",document.head);o=m(t,"META",{name:!0,content:!0}),t.forEach(n),h=a(e),i=m(e,"P",{}),xt(i).forEach(n),_=a(e),c(p.$$.fragment,e),T=a(e),w=m(e,"P",{"data-svelte-h":!0}),b(w)!=="svelte-9uf8uk"&&(w.innerHTML=ue),ye=a(e),J=m(e,"P",{"data-svelte-h":!0}),b(J)!=="svelte-1y5l2l7"&&(J.innerHTML=pt),be=a(e),c(C.$$.fragment,e),he=a(e),v=m(e,"P",{"data-svelte-h":!0}),b(v)!=="svelte-pdeopn"&&(v.innerHTML=dt),_e=a(e),c(U.$$.fragment,e),Te=a(e),c(j.$$.fragment,e),$e=a(e),G=m(e,"P",{"data-svelte-h":!0}),b(G)!=="svelte-bdfj5s"&&(G.innerHTML=mt),ge=a(e),c(W.$$.fragment,e),we=a(e),x=m(e,"P",{"data-svelte-h":!0}),b(x)!=="svelte-kdv1s4"&&(x.innerHTML=rt),Ue=a(e),c(B.$$.fragment,e),je=a(e),k=m(e,"P",{"data-svelte-h":!0}),b(k)!=="svelte-1ubukmm"&&(k.innerHTML=ct),Ze=a(e),c(R.$$.fragment,e),Je=a(e),V=m(e,"P",{"data-svelte-h":!0}),b(V)!=="svelte-19la0qo"&&(V.innerHTML=ft),Ce=a(e),c(X.$$.fragment,e),ve=a(e),c(N.$$.fragment,e),Ge=a(e),I=m(e,"P",{"data-svelte-h":!0}),b(I)!=="svelte-il4qhx"&&(I.innerHTML=ut),We=a(e),c(Y.$$.fragment,e),xe=a(e),q=m(e,"P",{"data-svelte-h":!0}),b(q)!=="svelte-f9fqys"&&(q.innerHTML=Mt),Be=a(e),H=m(e,"TABLE",{"data-svelte-h":!0}),b(H)!=="svelte-og9roo"&&(H.innerHTML=yt),ke=a(e),Q=m(e,"P",{"data-svelte-h":!0}),b(Q)!=="svelte-o0owme"&&(Q.innerHTML=bt),Re=a(e),c(z.$$.fragment,e),Ve=a(e),c(L.$$.fragment,e),Xe=a(e),E=m(e,"P",{"data-svelte-h":!0}),b(E)!=="svelte-prs5dm"&&(E.innerHTML=ht),Ne=a(e),c(S.$$.fragment,e),Ie=a(e),c(F.$$.fragment,e),Ye=a(e),P=m(e,"P",{"data-svelte-h":!0}),b(P)!=="svelte-1sexv1e"&&(P.innerHTML=_t),qe=a(e),c(A.$$.fragment,e),He=a(e),D=m(e,"P",{"data-svelte-h":!0}),b(D)!=="svelte-2xqk7h"&&(D.textContent=Tt),Qe=a(e),c(K.$$.fragment,e),ze=a(e),O=m(e,"P",{"data-svelte-h":!0}),b(O)!=="svelte-org9jt"&&(O.innerHTML=$t),Le=a(e),ee=m(e,"P",{"data-svelte-h":!0}),b(ee)!=="svelte-1b6ht9h"&&(ee.innerHTML=gt),Ee=a(e),c(te.$$.fragment,e),Se=a(e),c(ne.$$.fragment,e),Fe=a(e),se=m(e,"P",{"data-svelte-h":!0}),b(se)!=="svelte-ly7aah"&&(se.innerHTML=wt),Pe=a(e),le=m(e,"P",{"data-svelte-h":!0}),b(le)!=="svelte-ro604y"&&(le.textContent=Ut),Ae=a(e),c(ae.$$.fragment,e),De=a(e),oe=m(e,"P",{"data-svelte-h":!0}),b(oe)!=="svelte-1052a30"&&(oe.textContent=jt),Ke=a(e),ie=m(e,"UL",{"data-svelte-h":!0}),b(ie)!=="svelte-cfrf4q"&&(ie.innerHTML=Zt),Oe=a(e),c(pe.$$.fragment,e),et=a(e),de=m(e,"P",{"data-svelte-h":!0}),b(de)!=="svelte-15jrgvl"&&(de.innerHTML=Jt),tt=a(e),c(me.$$.fragment,e),nt=a(e),re=m(e,"P",{"data-svelte-h":!0}),b(re)!=="svelte-1n0s05u"&&(re.innerHTML=Ct),st=a(e),ce=m(e,"P",{"data-svelte-h":!0}),b(ce)!=="svelte-r508zh"&&(ce.textContent=vt),lt=a(e),c(fe.$$.fragment,e),at=a(e),Me=m(e,"P",{}),xt(Me).forEach(n),this.h()},h(){Bt(o,"name","hf:doc:metadata"),Bt(o,"content",Pt)},m(e,t){Yt(document.head,o),s(e,h,t),s(e,i,t),s(e,_,t),f(p,e,t),s(e,T,t),s(e,w,t),s(e,ye,t),s(e,J,t),s(e,be,t),f(C,e,t),s(e,he,t),s(e,v,t),s(e,_e,t),f(U,e,t),s(e,Te,t),f(j,e,t),s(e,$e,t),s(e,G,t),s(e,ge,t),f(W,e,t),s(e,we,t),s(e,x,t),s(e,Ue,t),f(B,e,t),s(e,je,t),s(e,k,t),s(e,Ze,t),f(R,e,t),s(e,Je,t),s(e,V,t),s(e,Ce,t),f(X,e,t),s(e,ve,t),f(N,e,t),s(e,Ge,t),s(e,I,t),s(e,We,t),f(Y,e,t),s(e,xe,t),s(e,q,t),s(e,Be,t),s(e,H,t),s(e,ke,t),s(e,Q,t),s(e,Re,t),f(z,e,t),s(e,Ve,t),f(L,e,t),s(e,Xe,t),s(e,E,t),s(e,Ne,t),f(S,e,t),s(e,Ie,t),f(F,e,t),s(e,Ye,t),s(e,P,t),s(e,qe,t),f(A,e,t),s(e,He,t),s(e,D,t),s(e,Qe,t),f(K,e,t),s(e,ze,t),s(e,O,t),s(e,Le,t),s(e,ee,t),s(e,Ee,t),f(te,e,t),s(e,Se,t),f(ne,e,t),s(e,Fe,t),s(e,se,t),s(e,Pe,t),s(e,le,t),s(e,Ae,t),f(ae,e,t),s(e,De,t),s(e,oe,t),s(e,Ke,t),s(e,ie,t),s(e,Oe,t),f(pe,e,t),s(e,et,t),s(e,de,t),s(e,tt,t),f(me,e,t),s(e,nt,t),s(e,re,t),s(e,st,t),s(e,ce,t),s(e,lt,t),f(fe,e,t),s(e,at,t),s(e,Me,t),ot=!0},p(e,[t]){const Gt={};t&2&&(Gt.$$scope={dirty:t,ctx:e}),U.$set(Gt);const Wt={};t&2&&(Wt.$$scope={dirty:t,ctx:e}),j.$set(Wt)},i(e){ot||(u(p.$$.fragment,e),u(C.$$.fragment,e),u(U.$$.fragment,e),u(j.$$.fragment,e),u(W.$$.fragment,e),u(B.$$.fragment,e),u(R.$$.fragment,e),u(X.$$.fragment,e),u(N.$$.fragment,e),u(Y.$$.fragment,e),u(z.$$.fragment,e),u(L.$$.fragment,e),u(S.$$.fragment,e),u(F.$$.fragment,e),u(A.$$.fragment,e),u(K.$$.fragment,e),u(te.$$.fragment,e),u(ne.$$.fragment,e),u(ae.$$.fragment,e),u(pe.$$.fragment,e),u(me.$$.fragment,e),u(fe.$$.fragment,e),ot=!0)},o(e){M(p.$$.fragment,e),M(C.$$.fragment,e),M(U.$$.fragment,e),M(j.$$.fragment,e),M(W.$$.fragment,e),M(B.$$.fragment,e),M(R.$$.fragment,e),M(X.$$.fragment,e),M(N.$$.fragment,e),M(Y.$$.fragment,e),M(z.$$.fragment,e),M(L.$$.fragment,e),M(S.$$.fragment,e),M(F.$$.fragment,e),M(A.$$.fragment,e),M(K.$$.fragment,e),M(te.$$.fragment,e),M(ne.$$.fragment,e),M(ae.$$.fragment,e),M(pe.$$.fragment,e),M(me.$$.fragment,e),M(fe.$$.fragment,e),ot=!1},d(e){e&&(n(h),n(i),n(_),n(T),n(w),n(ye),n(J),n(be),n(he),n(v),n(_e),n(Te),n($e),n(G),n(ge),n(we),n(x),n(Ue),n(je),n(k),n(Ze),n(Je),n(V),n(Ce),n(ve),n(Ge),n(I),n(We),n(xe),n(q),n(Be),n(H),n(ke),n(Q),n(Re),n(Ve),n(Xe),n(E),n(Ne),n(Ie),n(Ye),n(P),n(qe),n(He),n(D),n(Qe),n(ze),n(O),n(Le),n(ee),n(Ee),n(Se),n(Fe),n(se),n(Pe),n(le),n(Ae),n(De),n(oe),n(Ke),n(ie),n(Oe),n(et),n(de),n(tt),n(nt),n(re),n(st),n(ce),n(lt),n(at),n(Me)),n(o),y(p,e),y(C,e),y(U,e),y(j,e),y(W,e),y(B,e),y(R,e),y(X,e),y(N,e),y(Y,e),y(z,e),y(L,e),y(S,e),y(F,e),y(A,e),y(K,e),y(te,e),y(ne,e),y(ae,e),y(pe,e),y(me,e),y(fe,e)}}}const Pt='{"title":"ComponentsManager","local":"componentsmanager","sections":[{"title":"Add a component","local":"add-a-component","sections":[],"depth":2},{"title":"Retrieve a component","local":"retrieve-a-component","sections":[{"title":"get_one","local":"getone","sections":[],"depth":3},{"title":"get_components_by_names","local":"getcomponentsbynames","sections":[],"depth":3}],"depth":2},{"title":"Duplicate detection","local":"duplicate-detection","sections":[],"depth":2},{"title":"Collections","local":"collections","sections":[],"depth":2},{"title":"Offloading","local":"offloading","sections":[],"depth":2}],"depth":1}';function At(g){return Vt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class sn extends Xt{constructor(o){super(),Nt(this,o,At,Ft,Rt,{})}}export{sn as component};
