import{s as Xt,o as Nt,n as Vt}from"../chunks/scheduler.53228c21.js";import{S as It,i as Yt,e as m,s as l,c as r,h as qt,a as d,d as n,b as a,f as kt,g as c,j as b,k as pt,l as Ht,m as s,n as f,t as u,o as M,p as y}from"../chunks/index.100fac89.js";import{C as Qt}from"../chunks/CopyLLMTxtMenu.0ee1b69b.js";import{C as g}from"../chunks/CodeBlock.d30a6509.js";import{H as Z,E as zt}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.136ef3fd.js";import{H as Lt,a as Rt}from"../chunks/HfOption.fad27e59.js";function Et(w){let o,h;return o=new g({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:Vt,i(i){h||(u(o.$$.fragment,i),h=!0)},o(i){M(o.$$.fragment,i),h=!1},d(i){y(o,i)}}}function St(w){let o,h;return o=new g({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:Vt,i(i){h||(u(o.$$.fragment,i),h=!0)},o(i){M(o.$$.fragment,i),h=!1},d(i){y(o,i)}}}function Ft(w){let o,h,i,_;return o=new Rt({props:{id:"create",option:"from_pretrained",$$slots:{default:[Et]},$$scope:{ctx:w}}}),i=new Rt({props:{id:"create",option:"init_pipeline",$$slots:{default:[St]},$$scope:{ctx:w}}}),{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 $={};T&2&&($.$$scope={dirty:T,ctx:p}),o.$set($);const J={};T&2&&(J.$$scope={dirty:T,ctx:p}),i.$set(J)},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 Pt(w){let o,h,i,_,p,T,$,J,C,mt='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.',be,v,dt='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.',he,G,_e,W,rt='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>.',Te,U,ct="<p>The <code>collection</code> parameter is optional but makes it easier to organize and manage components.</p>",ge,j,$e,x,ft='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',we,B,Ue,k,ut='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.',je,R,Ze,V,Mt='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.',Je,X,Ce,N,yt='Use <a href="/docs/diffusers/main/en/api/modular_diffusers/pipeline_components#diffusers.ComponentsManager.remove">remove()</a> to remove a component using their id.',ve,I,Ge,Y,We,q,bt='The <a href="/docs/diffusers/main/en/api/modular_diffusers/pipeline_components#diffusers.ComponentsManager">ComponentsManager</a> provides several methods to retrieve registered components.',xe,H,Be,Q,ht='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.',ke,z,_t="<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>",Re,L,Tt='<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.',Ve,E,Xe,S,Ne,F,gt='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>.',Ie,P,Ye,A,qe,D,$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.',He,K,Qe,O,wt="This returns a warning with instructions for removing the duplicate.",ze,ee,Le,te,Ut='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.',Ee,ne,jt='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>.',Se,se,Fe,le,Pe,ae,Zt='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>.',Ae,oe,Jt="Only one component per name is allowed in each collection. Adding a second component with the same name automatically removes the first component.",De,ie,Ke,pe,Ct="This makes it convenient to work with node-based systems because you can:",Oe,me,vt="<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>",et,de,tt,re,Gt='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.',nt,ce,st,fe,Wt='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.',lt,ue,xt="You can set your own rules for which models to offload first.",at,Me,ot,ye,it;return p=new Qt({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),$=new Z({props:{title:"ComponentsManager",local:"componentsmanager",headingTag:"h1"}}),G=new Z({props:{title:"Add a component",local:"add-a-component",headingTag:"h2"}}),j=new Lt({props:{id:"create",options:["from_pretrained","init_pipeline"],$$slots:{default:[Ft]},$$scope:{ctx:w}}}),B=new g({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}}),R=new g({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}}),X=new g({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}}),I=new g({props:{code:"Y29tcC5yZW1vdmUoJTIydGV4dF9lbmNvZGVyXzEzOTkxNzczMzA0Mjg2NCUyMik=",highlighted:'comp.remove(<span class="hljs-string">&quot;text_encoder_139917733042864&quot;</span>)',wrap:!1}}),Y=new Z({props:{title:"Retrieve a component",local:"retrieve-a-component",headingTag:"h2"}}),H=new Z({props:{title:"get_one",local:"getone",headingTag:"h3"}}),E=new g({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}}),S=new Z({props:{title:"get_components_by_names",local:"getcomponentsbynames",headingTag:"h3"}}),P=new g({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}}),A=new Z({props:{title:"Duplicate detection",local:"duplicate-detection",headingTag:"h2"}}),K=new g({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}}),ee=new g({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}}),se=new g({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}}),le=new Z({props:{title:"Collections",local:"collections",headingTag:"h2"}}),ie=new g({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}}),de=new Z({props:{title:"Offloading",local:"offloading",headingTag:"h2"}}),ce=new g({props:{code:"Y29tcC5lbmFibGVfYXV0b19jcHVfb2ZmbG9hZChkZXZpY2UlM0QlMjJjdWRhJTIyKQ==",highlighted:'comp.enable_auto_cpu_offload(device=<span class="hljs-string">&quot;cuda&quot;</span>)',wrap:!1}}),Me=new zt({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/modular_diffusers/components_manager.md"}}),{c(){o=m("meta"),h=l(),i=m("p"),_=l(),r(p.$$.fragment),T=l(),r($.$$.fragment),J=l(),C=m("p"),C.innerHTML=mt,be=l(),v=m("p"),v.innerHTML=dt,he=l(),r(G.$$.fragment),_e=l(),W=m("p"),W.innerHTML=rt,Te=l(),U=m("blockquote"),U.innerHTML=ct,ge=l(),r(j.$$.fragment),$e=l(),x=m("p"),x.innerHTML=ft,we=l(),r(B.$$.fragment),Ue=l(),k=m("p"),k.innerHTML=ut,je=l(),r(R.$$.fragment),Ze=l(),V=m("p"),V.innerHTML=Mt,Je=l(),r(X.$$.fragment),Ce=l(),N=m("p"),N.innerHTML=yt,ve=l(),r(I.$$.fragment),Ge=l(),r(Y.$$.fragment),We=l(),q=m("p"),q.innerHTML=bt,xe=l(),r(H.$$.fragment),Be=l(),Q=m("p"),Q.innerHTML=ht,ke=l(),z=m("table"),z.innerHTML=_t,Re=l(),L=m("p"),L.innerHTML=Tt,Ve=l(),r(E.$$.fragment),Xe=l(),r(S.$$.fragment),Ne=l(),F=m("p"),F.innerHTML=gt,Ie=l(),r(P.$$.fragment),Ye=l(),r(A.$$.fragment),qe=l(),D=m("p"),D.innerHTML=$t,He=l(),r(K.$$.fragment),Qe=l(),O=m("p"),O.textContent=wt,ze=l(),r(ee.$$.fragment),Le=l(),te=m("p"),te.innerHTML=Ut,Ee=l(),ne=m("p"),ne.innerHTML=jt,Se=l(),r(se.$$.fragment),Fe=l(),r(le.$$.fragment),Pe=l(),ae=m("p"),ae.innerHTML=Zt,Ae=l(),oe=m("p"),oe.textContent=Jt,De=l(),r(ie.$$.fragment),Ke=l(),pe=m("p"),pe.textContent=Ct,Oe=l(),me=m("ul"),me.innerHTML=vt,et=l(),r(de.$$.fragment),tt=l(),re=m("p"),re.innerHTML=Gt,nt=l(),r(ce.$$.fragment),st=l(),fe=m("p"),fe.innerHTML=Wt,lt=l(),ue=m("p"),ue.textContent=xt,at=l(),r(Me.$$.fragment),ot=l(),ye=m("p"),this.h()},l(e){const t=qt("svelte-u9bgzb",document.head);o=d(t,"META",{name:!0,content:!0}),t.forEach(n),h=a(e),i=d(e,"P",{}),kt(i).forEach(n),_=a(e),c(p.$$.fragment,e),T=a(e),c($.$$.fragment,e),J=a(e),C=d(e,"P",{"data-svelte-h":!0}),b(C)!=="svelte-9uf8uk"&&(C.innerHTML=mt),be=a(e),v=d(e,"P",{"data-svelte-h":!0}),b(v)!=="svelte-1y5l2l7"&&(v.innerHTML=dt),he=a(e),c(G.$$.fragment,e),_e=a(e),W=d(e,"P",{"data-svelte-h":!0}),b(W)!=="svelte-pdeopn"&&(W.innerHTML=rt),Te=a(e),U=d(e,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),b(U)!=="svelte-1agrqp4"&&(U.innerHTML=ct),ge=a(e),c(j.$$.fragment,e),$e=a(e),x=d(e,"P",{"data-svelte-h":!0}),b(x)!=="svelte-bdfj5s"&&(x.innerHTML=ft),we=a(e),c(B.$$.fragment,e),Ue=a(e),k=d(e,"P",{"data-svelte-h":!0}),b(k)!=="svelte-kdv1s4"&&(k.innerHTML=ut),je=a(e),c(R.$$.fragment,e),Ze=a(e),V=d(e,"P",{"data-svelte-h":!0}),b(V)!=="svelte-1ubukmm"&&(V.innerHTML=Mt),Je=a(e),c(X.$$.fragment,e),Ce=a(e),N=d(e,"P",{"data-svelte-h":!0}),b(N)!=="svelte-19la0qo"&&(N.innerHTML=yt),ve=a(e),c(I.$$.fragment,e),Ge=a(e),c(Y.$$.fragment,e),We=a(e),q=d(e,"P",{"data-svelte-h":!0}),b(q)!=="svelte-il4qhx"&&(q.innerHTML=bt),xe=a(e),c(H.$$.fragment,e),Be=a(e),Q=d(e,"P",{"data-svelte-h":!0}),b(Q)!=="svelte-f9fqys"&&(Q.innerHTML=ht),ke=a(e),z=d(e,"TABLE",{"data-svelte-h":!0}),b(z)!=="svelte-og9roo"&&(z.innerHTML=_t),Re=a(e),L=d(e,"P",{"data-svelte-h":!0}),b(L)!=="svelte-o0owme"&&(L.innerHTML=Tt),Ve=a(e),c(E.$$.fragment,e),Xe=a(e),c(S.$$.fragment,e),Ne=a(e),F=d(e,"P",{"data-svelte-h":!0}),b(F)!=="svelte-prs5dm"&&(F.innerHTML=gt),Ie=a(e),c(P.$$.fragment,e),Ye=a(e),c(A.$$.fragment,e),qe=a(e),D=d(e,"P",{"data-svelte-h":!0}),b(D)!=="svelte-1sexv1e"&&(D.innerHTML=$t),He=a(e),c(K.$$.fragment,e),Qe=a(e),O=d(e,"P",{"data-svelte-h":!0}),b(O)!=="svelte-2xqk7h"&&(O.textContent=wt),ze=a(e),c(ee.$$.fragment,e),Le=a(e),te=d(e,"P",{"data-svelte-h":!0}),b(te)!=="svelte-org9jt"&&(te.innerHTML=Ut),Ee=a(e),ne=d(e,"P",{"data-svelte-h":!0}),b(ne)!=="svelte-1b6ht9h"&&(ne.innerHTML=jt),Se=a(e),c(se.$$.fragment,e),Fe=a(e),c(le.$$.fragment,e),Pe=a(e),ae=d(e,"P",{"data-svelte-h":!0}),b(ae)!=="svelte-ly7aah"&&(ae.innerHTML=Zt),Ae=a(e),oe=d(e,"P",{"data-svelte-h":!0}),b(oe)!=="svelte-ro604y"&&(oe.textContent=Jt),De=a(e),c(ie.$$.fragment,e),Ke=a(e),pe=d(e,"P",{"data-svelte-h":!0}),b(pe)!=="svelte-1052a30"&&(pe.textContent=Ct),Oe=a(e),me=d(e,"UL",{"data-svelte-h":!0}),b(me)!=="svelte-cfrf4q"&&(me.innerHTML=vt),et=a(e),c(de.$$.fragment,e),tt=a(e),re=d(e,"P",{"data-svelte-h":!0}),b(re)!=="svelte-15jrgvl"&&(re.innerHTML=Gt),nt=a(e),c(ce.$$.fragment,e),st=a(e),fe=d(e,"P",{"data-svelte-h":!0}),b(fe)!=="svelte-1n0s05u"&&(fe.innerHTML=Wt),lt=a(e),ue=d(e,"P",{"data-svelte-h":!0}),b(ue)!=="svelte-r508zh"&&(ue.textContent=xt),at=a(e),c(Me.$$.fragment,e),ot=a(e),ye=d(e,"P",{}),kt(ye).forEach(n),this.h()},h(){pt(o,"name","hf:doc:metadata"),pt(o,"content",At),pt(U,"class","tip")},m(e,t){Ht(document.head,o),s(e,h,t),s(e,i,t),s(e,_,t),f(p,e,t),s(e,T,t),f($,e,t),s(e,J,t),s(e,C,t),s(e,be,t),s(e,v,t),s(e,he,t),f(G,e,t),s(e,_e,t),s(e,W,t),s(e,Te,t),s(e,U,t),s(e,ge,t),f(j,e,t),s(e,$e,t),s(e,x,t),s(e,we,t),f(B,e,t),s(e,Ue,t),s(e,k,t),s(e,je,t),f(R,e,t),s(e,Ze,t),s(e,V,t),s(e,Je,t),f(X,e,t),s(e,Ce,t),s(e,N,t),s(e,ve,t),f(I,e,t),s(e,Ge,t),f(Y,e,t),s(e,We,t),s(e,q,t),s(e,xe,t),f(H,e,t),s(e,Be,t),s(e,Q,t),s(e,ke,t),s(e,z,t),s(e,Re,t),s(e,L,t),s(e,Ve,t),f(E,e,t),s(e,Xe,t),f(S,e,t),s(e,Ne,t),s(e,F,t),s(e,Ie,t),f(P,e,t),s(e,Ye,t),f(A,e,t),s(e,qe,t),s(e,D,t),s(e,He,t),f(K,e,t),s(e,Qe,t),s(e,O,t),s(e,ze,t),f(ee,e,t),s(e,Le,t),s(e,te,t),s(e,Ee,t),s(e,ne,t),s(e,Se,t),f(se,e,t),s(e,Fe,t),f(le,e,t),s(e,Pe,t),s(e,ae,t),s(e,Ae,t),s(e,oe,t),s(e,De,t),f(ie,e,t),s(e,Ke,t),s(e,pe,t),s(e,Oe,t),s(e,me,t),s(e,et,t),f(de,e,t),s(e,tt,t),s(e,re,t),s(e,nt,t),f(ce,e,t),s(e,st,t),s(e,fe,t),s(e,lt,t),s(e,ue,t),s(e,at,t),f(Me,e,t),s(e,ot,t),s(e,ye,t),it=!0},p(e,[t]){const Bt={};t&2&&(Bt.$$scope={dirty:t,ctx:e}),j.$set(Bt)},i(e){it||(u(p.$$.fragment,e),u($.$$.fragment,e),u(G.$$.fragment,e),u(j.$$.fragment,e),u(B.$$.fragment,e),u(R.$$.fragment,e),u(X.$$.fragment,e),u(I.$$.fragment,e),u(Y.$$.fragment,e),u(H.$$.fragment,e),u(E.$$.fragment,e),u(S.$$.fragment,e),u(P.$$.fragment,e),u(A.$$.fragment,e),u(K.$$.fragment,e),u(ee.$$.fragment,e),u(se.$$.fragment,e),u(le.$$.fragment,e),u(ie.$$.fragment,e),u(de.$$.fragment,e),u(ce.$$.fragment,e),u(Me.$$.fragment,e),it=!0)},o(e){M(p.$$.fragment,e),M($.$$.fragment,e),M(G.$$.fragment,e),M(j.$$.fragment,e),M(B.$$.fragment,e),M(R.$$.fragment,e),M(X.$$.fragment,e),M(I.$$.fragment,e),M(Y.$$.fragment,e),M(H.$$.fragment,e),M(E.$$.fragment,e),M(S.$$.fragment,e),M(P.$$.fragment,e),M(A.$$.fragment,e),M(K.$$.fragment,e),M(ee.$$.fragment,e),M(se.$$.fragment,e),M(le.$$.fragment,e),M(ie.$$.fragment,e),M(de.$$.fragment,e),M(ce.$$.fragment,e),M(Me.$$.fragment,e),it=!1},d(e){e&&(n(h),n(i),n(_),n(T),n(J),n(C),n(be),n(v),n(he),n(_e),n(W),n(Te),n(U),n(ge),n($e),n(x),n(we),n(Ue),n(k),n(je),n(Ze),n(V),n(Je),n(Ce),n(N),n(ve),n(Ge),n(We),n(q),n(xe),n(Be),n(Q),n(ke),n(z),n(Re),n(L),n(Ve),n(Xe),n(Ne),n(F),n(Ie),n(Ye),n(qe),n(D),n(He),n(Qe),n(O),n(ze),n(Le),n(te),n(Ee),n(ne),n(Se),n(Fe),n(Pe),n(ae),n(Ae),n(oe),n(De),n(Ke),n(pe),n(Oe),n(me),n(et),n(tt),n(re),n(nt),n(st),n(fe),n(lt),n(ue),n(at),n(ot),n(ye)),n(o),y(p,e),y($,e),y(G,e),y(j,e),y(B,e),y(R,e),y(X,e),y(I,e),y(Y,e),y(H,e),y(E,e),y(S,e),y(P,e),y(A,e),y(K,e),y(ee,e),y(se,e),y(le,e),y(ie,e),y(de,e),y(ce,e),y(Me,e)}}}const At='{"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 Dt(w){return Nt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ln extends It{constructor(o){super(),Yt(this,o,Dt,Pt,Xt,{})}}export{ln as component};
