import{s as qt,o as Rt,n as Bt}from"../chunks/scheduler.53228c21.js";import{S as Ft,i as Gt,e as l,s,c as p,h as Ht,a as d,d as o,b as a,f as k,g as m,j as b,k as I,l as r,m as n,n as f,t as c,o as u,p as g}from"../chunks/index.100fac89.js";import{C as Wt}from"../chunks/CopyLLMTxtMenu.2cdbb51f.js";import{D as U}from"../chunks/Docstring.d46840f1.js";import{C as Et}from"../chunks/CodeBlock.d30a6509.js";import{E as Dt}from"../chunks/ExampleCodeBlock.220b4f6e.js";import{H as J,E as zt}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.3fcbbc76.js";function Xt(me){let h,C="Example:",$,_,v;return _=new Et({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwQ29nVmlkZW9YVHJhbnNmb3JtZXIzRE1vZGVsJTBBJTBBdHJhbnNmb3JtZXIlMjAlM0QlMjBDb2dWaWRlb1hUcmFuc2Zvcm1lcjNETW9kZWwuZnJvbV9wcmV0cmFpbmVkKCUwQSUyMCUyMCUyMCUyMG1vZGVsX2lkJTJDJTIwc3ViZm9sZGVyJTNEJTIydHJhbnNmb3JtZXIlMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmJmbG9hdDE2JTBBKSUwQSUwQWFwcGx5X2xheWVyd2lzZV9jYXN0aW5nKCUwQSUyMCUyMCUyMCUyMHRyYW5zZm9ybWVyJTJDJTBBJTIwJTIwJTIwJTIwc3RvcmFnZV9kdHlwZSUzRHRvcmNoLmZsb2F0OF9lNG0zZm4lMkMlMEElMjAlMjAlMjAlMjBjb21wdXRlX2R0eXBlJTNEdG9yY2guYmZsb2F0MTYlMkMlMEElMjAlMjAlMjAlMjBza2lwX21vZHVsZXNfcGF0dGVybiUzRCU1QiUyMnBhdGNoX2VtYmVkJTIyJTJDJTIwJTIybm9ybSUyMiUyQyUyMCUyMnByb2pfb3V0JTIyJTVEJTJDJTBBJTIwJTIwJTIwJTIwbm9uX2Jsb2NraW5nJTNEVHJ1ZSUyQyUwQSk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> CogVideoXTransformer3DModel

<span class="hljs-meta">&gt;&gt;&gt; </span>transformer = CogVideoXTransformer3DModel.from_pretrained(
<span class="hljs-meta">... </span>    model_id, subfolder=<span class="hljs-string">&quot;transformer&quot;</span>, torch_dtype=torch.bfloat16
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>apply_layerwise_casting(
<span class="hljs-meta">... </span>    transformer,
<span class="hljs-meta">... </span>    storage_dtype=torch.float8_e4m3fn,
<span class="hljs-meta">... </span>    compute_dtype=torch.bfloat16,
<span class="hljs-meta">... </span>    skip_modules_pattern=[<span class="hljs-string">&quot;patch_embed&quot;</span>, <span class="hljs-string">&quot;norm&quot;</span>, <span class="hljs-string">&quot;proj_out&quot;</span>],
<span class="hljs-meta">... </span>    non_blocking=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>)`,wrap:!1}}),{c(){h=l("p"),h.textContent=C,$=s(),p(_.$$.fragment)},l(i){h=d(i,"P",{"data-svelte-h":!0}),b(h)!=="svelte-11lpom8"&&(h.textContent=C),$=a(i),m(_.$$.fragment,i)},m(i,w){n(i,h,w),n(i,$,w),f(_,i,w),v=!0},p:Bt,i(i){v||(c(_.$$.fragment,i),v=!0)},o(i){u(_.$$.fragment,i),v=!1},d(i){i&&(o(h),o($)),g(_,i)}}}function St(me){let h,C="Example:",$,_,v;return _=new Et({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMENvZ1ZpZGVvWFRyYW5zZm9ybWVyM0RNb2RlbCUwQWZyb20lMjBkaWZmdXNlcnMuaG9va3MlMjBpbXBvcnQlMjBhcHBseV9ncm91cF9vZmZsb2FkaW5nJTBBJTBBdHJhbnNmb3JtZXIlMjAlM0QlMjBDb2dWaWRlb1hUcmFuc2Zvcm1lcjNETW9kZWwuZnJvbV9wcmV0cmFpbmVkKCUwQSUyMCUyMCUyMCUyMCUyMlRIVURNJTJGQ29nVmlkZW9YLTViJTIyJTJDJTIwc3ViZm9sZGVyJTNEJTIydHJhbnNmb3JtZXIlMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmJmbG9hdDE2JTBBKSUwQSUwQWFwcGx5X2dyb3VwX29mZmxvYWRpbmcoJTBBJTIwJTIwJTIwJTIwdHJhbnNmb3JtZXIlMkMlMEElMjAlMjAlMjAlMjBvbmxvYWRfZGV2aWNlJTNEdG9yY2guZGV2aWNlKCUyMmN1ZGElMjIpJTJDJTBBJTIwJTIwJTIwJTIwb2ZmbG9hZF9kZXZpY2UlM0R0b3JjaC5kZXZpY2UoJTIyY3B1JTIyKSUyQyUwQSUyMCUyMCUyMCUyMG9mZmxvYWRfdHlwZSUzRCUyMmJsb2NrX2xldmVsJTIyJTJDJTBBJTIwJTIwJTIwJTIwbnVtX2Jsb2Nrc19wZXJfZ3JvdXAlM0QyJTJDJTBBJTIwJTIwJTIwJTIwdXNlX3N0cmVhbSUzRFRydWUlMkMlMEEp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> CogVideoXTransformer3DModel
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> diffusers.hooks <span class="hljs-keyword">import</span> apply_group_offloading

<span class="hljs-meta">&gt;&gt;&gt; </span>transformer = CogVideoXTransformer3DModel.from_pretrained(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;THUDM/CogVideoX-5b&quot;</span>, subfolder=<span class="hljs-string">&quot;transformer&quot;</span>, torch_dtype=torch.bfloat16
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>apply_group_offloading(
<span class="hljs-meta">... </span>    transformer,
<span class="hljs-meta">... </span>    onload_device=torch.device(<span class="hljs-string">&quot;cuda&quot;</span>),
<span class="hljs-meta">... </span>    offload_device=torch.device(<span class="hljs-string">&quot;cpu&quot;</span>),
<span class="hljs-meta">... </span>    offload_type=<span class="hljs-string">&quot;block_level&quot;</span>,
<span class="hljs-meta">... </span>    num_blocks_per_group=<span class="hljs-number">2</span>,
<span class="hljs-meta">... </span>    use_stream=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>)`,wrap:!1}}),{c(){h=l("p"),h.textContent=C,$=s(),p(_.$$.fragment)},l(i){h=d(i,"P",{"data-svelte-h":!0}),b(h)!=="svelte-11lpom8"&&(h.textContent=C),$=a(i),m(_.$$.fragment,i)},m(i,w){n(i,h,w),n(i,$,w),f(_,i,w),v=!0},p:Bt,i(i){v||(c(_.$$.fragment,i),v=!0)},o(i){u(_.$$.fragment,i),v=!1},d(i){i&&(o(h),o($)),g(_,i)}}}function At(me){let h,C,$,_,v,i,w,Ce,q,vt="Utility and helper functions for working with 🤗 Diffusers.",Ue,R,je,j,F,st,fe,$t="Convert a numpy image or a batch of images to a PIL image.",Le,G,Ze,L,H,at,ce,wt="Convert a torch image to a PIL image.",Pe,W,Ne,Z,z,nt,ue,Tt="Loads <code>image</code> to a PIL Image.",Ve,X,De,P,S,it,ge,xt="Loads <code>video</code> to a list of PIL Image.",Be,A,Ee,Q,Y,qe,O,Re,x,K,rt,he,kt=`quality:
Video output quality. Default is 5. Uses variable bit rate. Highest quality is 10, lowest is 0. Set to None to
prevent variable bitrate flags to FFMPEG so you can manually specify them using output_params instead.
Specifying a fixed bitrate using <code>bitrate</code> disables this parameter.`,lt,_e,It=`bitrate:
Set a constant bitrate for the video encoding. Default is None causing <code>quality</code> parameter to be used instead.
Better quality videos with smaller file sizes will result from using the <code>quality</code> variable bitrate parameter
rather than specifying a fixed bitrate with this parameter.`,dt,ye,Mt=`macro_block_size:
Size constraint for video. Width and height, must be divisible by this number. If not divisible by this number
imageio will tell ffmpeg to scale the image up to the next closest size divisible by this number. Most codecs
are compatible with a macroblock size of 16 (default), some can go smaller (4, 8). To disable this automatic
feature set it to None or 1, however be warned many players can’t decode videos that are odd in size and some
codecs will produce poor results or fail. See <a href="https://en.wikipedia.org/wiki/Macroblock" rel="nofollow">https://en.wikipedia.org/wiki/Macroblock</a>.`,Fe,ee,Ge,N,te,pt,be,Jt="Prepares a single grid of images. Useful for visualization purposes.",He,oe,We,V,se,mt,ve,Ct=`A helper function to create random tensors on the desired <code>device</code> with the desired <code>dtype</code>. When
passing a list of generators, you can seed each batch size individually. If CPU generators are passed, the tensor
is always created on the CPU.`,ze,ae,Xe,M,ne,ft,$e,Ut=`Applies layerwise casting to a given module. The module expected here is a Diffusers ModelMixin but it can be any
nn.Module using diffusers layers or pytorch primitives.`,ct,D,Se,ie,Ae,y,re,ut,we,jt=`Applies group offloading to the internal layers of a torch.nn.Module. To understand what group offloading is, and
where it is beneficial, we need to first provide some context on how other supported offloading methods work.`,gt,Te,Lt="Typically, offloading is done at two levels:",ht,xe,Zt=`<li>Module-level: In Diffusers, this can be enabled using the <code>ModelMixin::enable_model_cpu_offload()</code> method. It
works by offloading each component of a pipeline to the CPU for storage, and onloading to the accelerator device
when needed for computation. This method is more memory-efficient than keeping all components on the accelerator,
but the memory requirements are still quite high. For this method to work, one needs memory equivalent to size of
the model in runtime dtype + size of largest intermediate activation tensors to be able to complete the forward
pass.</li> <li>Leaf-level: In Diffusers, this can be enabled using the <code>ModelMixin::enable_sequential_cpu_offload()</code> method. It
works by offloading the lowest leaf-level parameters of the computation graph to the CPU for storage, and
onloading only the leafs to the accelerator device for computation. This uses the lowest amount of accelerator
memory, but can be slower due to the excessive number of device synchronizations.</li>`,_t,ke,Pt=`Group offloading is a middle ground between the two methods. It works by offloading groups of internal layers,
(either <code>torch.nn.ModuleList</code> or <code>torch.nn.Sequential</code>). This method uses lower memory than module-level
offloading. It is also faster than leaf-level/sequential offloading, as the number of device synchronizations is
reduced.`,yt,Ie,Nt=`Another supported feature (for CUDA devices with support for asynchronous data transfer streams) is the ability to
overlap data transfer and computation to reduce the overall execution time compared to sequential offloading. This
is enabled using layer prefetching with streams, i.e., the layer that is to be executed next starts onloading to
the accelerator device while the current layer is being executed - this increases the memory requirements slightly.
Note that this implementation also supports leaf-level offloading but can be made much faster when using streams.`,bt,B,Qe,le,Ye,Je,Oe;return v=new Wt({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),w=new J({props:{title:"Utilities",local:"utilities",headingTag:"h1"}}),R=new J({props:{title:"numpy_to_pil",local:"diffusers.utils.numpy_to_pil",headingTag:"h2"}}),F=new U({props:{name:"diffusers.utils.numpy_to_pil",anchor:"diffusers.utils.numpy_to_pil",parameters:[{name:"images",val:""}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/utils/pil_utils.py#L37"}}),G=new J({props:{title:"pt_to_pil",local:"diffusers.utils.pt_to_pil",headingTag:"h2"}}),H=new U({props:{name:"diffusers.utils.pt_to_pil",anchor:"diffusers.utils.pt_to_pil",parameters:[{name:"images",val:""}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/utils/pil_utils.py#L27"}}),W=new J({props:{title:"load_image",local:"diffusers.utils.load_image",headingTag:"h2"}}),z=new U({props:{name:"diffusers.utils.load_image",anchor:"diffusers.utils.load_image",parameters:[{name:"image",val:": typing.Union[str, PIL.Image.Image]"},{name:"convert_method",val:": typing.Optional[typing.Callable[[PIL.Image.Image], PIL.Image.Image]] = None"}],parametersDescription:[{anchor:"diffusers.utils.load_image.image",description:`<strong>image</strong> (<code>str</code> or <code>PIL.Image.Image</code>) &#x2014;
The image to convert to the PIL Image format.`,name:"image"},{anchor:"diffusers.utils.load_image.convert_method",description:`<strong>convert_method</strong> (Callable[[PIL.Image.Image], PIL.Image.Image], <em>optional</em>) &#x2014;
A conversion method to apply to the image after loading it. When set to <code>None</code> the image will be converted
&#x201C;RGB&#x201D;.`,name:"convert_method"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/utils/loading_utils.py#L14",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>A PIL Image.</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>PIL.Image.Image</code></p>
`}}),X=new J({props:{title:"load_video",local:"diffusers.utils.load_video",headingTag:"h2"}}),S=new U({props:{name:"diffusers.utils.load_video",anchor:"diffusers.utils.load_video",parameters:[{name:"video",val:": str"},{name:"convert_method",val:": typing.Optional[typing.Callable[[typing.List[PIL.Image.Image]], typing.List[PIL.Image.Image]]] = None"}],parametersDescription:[{anchor:"diffusers.utils.load_video.video",description:`<strong>video</strong> (<code>str</code>) &#x2014;
A URL or Path to a video to convert to a list of PIL Image format.`,name:"video"},{anchor:"diffusers.utils.load_video.convert_method",description:`<strong>convert_method</strong> (Callable[[List[PIL.Image.Image]], List[PIL.Image.Image]], <em>optional</em>) &#x2014;
A conversion method to apply to the video after loading it. When set to <code>None</code> the images will be converted
to &#x201C;RGB&#x201D;.`,name:"convert_method"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/utils/loading_utils.py#L57",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>The video as a list of PIL images.</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>List[PIL.Image.Image]</code></p>
`}}),A=new J({props:{title:"export_to_gif",local:"diffusers.utils.export_to_gif",headingTag:"h2"}}),Y=new U({props:{name:"diffusers.utils.export_to_gif",anchor:"diffusers.utils.export_to_gif",parameters:[{name:"image",val:": typing.List[PIL.Image.Image]"},{name:"output_gif_path",val:": str = None"},{name:"fps",val:": int = 10"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/utils/export_utils.py#L28"}}),O=new J({props:{title:"export_to_video",local:"diffusers.utils.export_to_video",headingTag:"h2"}}),K=new U({props:{name:"diffusers.utils.export_to_video",anchor:"diffusers.utils.export_to_video",parameters:[{name:"video_frames",val:": typing.Union[typing.List[numpy.ndarray], typing.List[PIL.Image.Image]]"},{name:"output_video_path",val:": str = None"},{name:"fps",val:": int = 10"},{name:"quality",val:": float = 5.0"},{name:"bitrate",val:": typing.Optional[int] = None"},{name:"macro_block_size",val:": typing.Optional[int] = 16"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/utils/export_utils.py#L141"}}),ee=new J({props:{title:"make_image_grid",local:"diffusers.utils.make_image_grid",headingTag:"h2"}}),te=new U({props:{name:"diffusers.utils.make_image_grid",anchor:"diffusers.utils.make_image_grid",parameters:[{name:"images",val:": typing.List[PIL.Image.Image]"},{name:"rows",val:": int"},{name:"cols",val:": int"},{name:"resize",val:": int = None"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/utils/pil_utils.py#L53"}}),oe=new J({props:{title:"randn_tensor",local:"diffusers.utils.torch_utils.randn_tensor",headingTag:"h2"}}),se=new U({props:{name:"diffusers.utils.torch_utils.randn_tensor",anchor:"diffusers.utils.torch_utils.randn_tensor",parameters:[{name:"shape",val:": typing.Union[typing.Tuple, typing.List]"},{name:"generator",val:": typing.Union[typing.List[ForwardRef('torch.Generator')], ForwardRef('torch.Generator'), NoneType] = None"},{name:"device",val:": typing.Union[str, ForwardRef('torch.device'), NoneType] = None"},{name:"dtype",val:": typing.Optional[ForwardRef('torch.dtype')] = None"},{name:"layout",val:": typing.Optional[ForwardRef('torch.layout')] = None"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/utils/torch_utils.py#L146"}}),ae=new J({props:{title:"apply_layerwise_casting",local:"diffusers.hooks.apply_layerwise_casting",headingTag:"h2"}}),ne=new U({props:{name:"diffusers.hooks.apply_layerwise_casting",anchor:"diffusers.hooks.apply_layerwise_casting",parameters:[{name:"module",val:": Module"},{name:"storage_dtype",val:": dtype"},{name:"compute_dtype",val:": dtype"},{name:"skip_modules_pattern",val:": typing.Union[str, typing.Tuple[str, ...]] = 'auto'"},{name:"skip_modules_classes",val:": typing.Optional[typing.Tuple[typing.Type[torch.nn.modules.module.Module], ...]] = None"},{name:"non_blocking",val:": bool = False"}],parametersDescription:[{anchor:"diffusers.hooks.apply_layerwise_casting.module",description:`<strong>module</strong> (<code>torch.nn.Module</code>) &#x2014;
The module whose leaf modules will be cast to a high precision dtype for computation, and to a low
precision dtype for storage.`,name:"module"},{anchor:"diffusers.hooks.apply_layerwise_casting.storage_dtype",description:`<strong>storage_dtype</strong> (<code>torch.dtype</code>) &#x2014;
The dtype to cast the module to before/after the forward pass for storage.`,name:"storage_dtype"},{anchor:"diffusers.hooks.apply_layerwise_casting.compute_dtype",description:`<strong>compute_dtype</strong> (<code>torch.dtype</code>) &#x2014;
The dtype to cast the module to during the forward pass for computation.`,name:"compute_dtype"},{anchor:"diffusers.hooks.apply_layerwise_casting.skip_modules_pattern",description:`<strong>skip_modules_pattern</strong> (<code>Tuple[str, ...]</code>, defaults to <code>&quot;auto&quot;</code>) &#x2014;
A list of patterns to match the names of the modules to skip during the layerwise casting process. If set
to <code>&quot;auto&quot;</code>, the default patterns are used. If set to <code>None</code>, no modules are skipped. If set to <code>None</code>
alongside <code>skip_modules_classes</code> being <code>None</code>, the layerwise casting is applied directly to the module
instead of its internal submodules.`,name:"skip_modules_pattern"},{anchor:"diffusers.hooks.apply_layerwise_casting.skip_modules_classes",description:`<strong>skip_modules_classes</strong> (<code>Tuple[Type[torch.nn.Module], ...]</code>, defaults to <code>None</code>) &#x2014;
A list of module classes to skip during the layerwise casting process.`,name:"skip_modules_classes"},{anchor:"diffusers.hooks.apply_layerwise_casting.non_blocking",description:`<strong>non_blocking</strong> (<code>bool</code>, defaults to <code>False</code>) &#x2014;
If <code>True</code>, the weight casting operations are non-blocking.`,name:"non_blocking"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/hooks/layerwise_casting.py#L101"}}),D=new Dt({props:{anchor:"diffusers.hooks.apply_layerwise_casting.example",$$slots:{default:[Xt]},$$scope:{ctx:me}}}),ie=new J({props:{title:"apply_group_offloading",local:"diffusers.hooks.apply_group_offloading",headingTag:"h2"}}),re=new U({props:{name:"diffusers.hooks.apply_group_offloading",anchor:"diffusers.hooks.apply_group_offloading",parameters:[{name:"module",val:": Module"},{name:"onload_device",val:": typing.Union[str, torch.device]"},{name:"offload_device",val:": typing.Union[str, torch.device] = device(type='cpu')"},{name:"offload_type",val:": typing.Union[str, diffusers.hooks.group_offloading.GroupOffloadingType] = 'block_level'"},{name:"num_blocks_per_group",val:": typing.Optional[int] = None"},{name:"non_blocking",val:": bool = False"},{name:"use_stream",val:": bool = False"},{name:"record_stream",val:": bool = False"},{name:"low_cpu_mem_usage",val:": bool = False"},{name:"offload_to_disk_path",val:": typing.Optional[str] = None"}],parametersDescription:[{anchor:"diffusers.hooks.apply_group_offloading.module",description:`<strong>module</strong> (<code>torch.nn.Module</code>) &#x2014;
The module to which group offloading is applied.`,name:"module"},{anchor:"diffusers.hooks.apply_group_offloading.onload_device",description:`<strong>onload_device</strong> (<code>torch.device</code>) &#x2014;
The device to which the group of modules are onloaded.`,name:"onload_device"},{anchor:"diffusers.hooks.apply_group_offloading.offload_device",description:`<strong>offload_device</strong> (<code>torch.device</code>, defaults to <code>torch.device(&quot;cpu&quot;)</code>) &#x2014;
The device to which the group of modules are offloaded. This should typically be the CPU. Default is CPU.`,name:"offload_device"},{anchor:"diffusers.hooks.apply_group_offloading.offload_type",description:`<strong>offload_type</strong> (<code>str</code> or <code>GroupOffloadingType</code>, defaults to &#x201C;block_level&#x201D;) &#x2014;
The type of offloading to be applied. Can be one of &#x201C;block_level&#x201D; or &#x201C;leaf_level&#x201D;. Default is
&#x201C;block_level&#x201D;.`,name:"offload_type"},{anchor:"diffusers.hooks.apply_group_offloading.offload_to_disk_path",description:`<strong>offload_to_disk_path</strong> (<code>str</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
The path to the directory where parameters will be offloaded. Setting this option can be useful in limited
RAM environment settings where a reasonable speed-memory trade-off is desired.`,name:"offload_to_disk_path"},{anchor:"diffusers.hooks.apply_group_offloading.num_blocks_per_group",description:`<strong>num_blocks_per_group</strong> (<code>int</code>, <em>optional</em>) &#x2014;
The number of blocks per group when using offload_type=&#x201C;block_level&#x201D;. This is required when using
offload_type=&#x201C;block_level&#x201D;.`,name:"num_blocks_per_group"},{anchor:"diffusers.hooks.apply_group_offloading.non_blocking",description:`<strong>non_blocking</strong> (<code>bool</code>, defaults to <code>False</code>) &#x2014;
If True, offloading and onloading is done with non-blocking data transfer.`,name:"non_blocking"},{anchor:"diffusers.hooks.apply_group_offloading.use_stream",description:`<strong>use_stream</strong> (<code>bool</code>, defaults to <code>False</code>) &#x2014;
If True, offloading and onloading is done asynchronously using a CUDA stream. This can be useful for
overlapping computation and data transfer.`,name:"use_stream"},{anchor:"diffusers.hooks.apply_group_offloading.record_stream",description:`<strong>record_stream</strong> (<code>bool</code>, defaults to <code>False</code>) &#x2014; When enabled with <code>use_stream</code>, it marks the current tensor
as having been used by this stream. It is faster at the expense of slightly more memory usage. Refer to the
<a href="https://pytorch.org/docs/stable/generated/torch.Tensor.record_stream.html" rel="nofollow">PyTorch official docs</a> more
details.`,name:"record_stream"},{anchor:"diffusers.hooks.apply_group_offloading.low_cpu_mem_usage",description:`<strong>low_cpu_mem_usage</strong> (<code>bool</code>, defaults to <code>False</code>) &#x2014;
If True, the CPU memory usage is minimized by pinning tensors on-the-fly instead of pre-pinning them. This
option only matters when using streamed CPU offloading (i.e. <code>use_stream=True</code>). This can be useful when
the CPU memory is a bottleneck but may counteract the benefits of using streams.`,name:"low_cpu_mem_usage"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/hooks/group_offloading.py#L445"}}),B=new Dt({props:{anchor:"diffusers.hooks.apply_group_offloading.example",$$slots:{default:[St]},$$scope:{ctx:me}}}),le=new zt({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/utilities.md"}}),{c(){h=l("meta"),C=s(),$=l("p"),_=s(),p(v.$$.fragment),i=s(),p(w.$$.fragment),Ce=s(),q=l("p"),q.textContent=vt,Ue=s(),p(R.$$.fragment),je=s(),j=l("div"),p(F.$$.fragment),st=s(),fe=l("p"),fe.textContent=$t,Le=s(),p(G.$$.fragment),Ze=s(),L=l("div"),p(H.$$.fragment),at=s(),ce=l("p"),ce.textContent=wt,Pe=s(),p(W.$$.fragment),Ne=s(),Z=l("div"),p(z.$$.fragment),nt=s(),ue=l("p"),ue.innerHTML=Tt,Ve=s(),p(X.$$.fragment),De=s(),P=l("div"),p(S.$$.fragment),it=s(),ge=l("p"),ge.innerHTML=xt,Be=s(),p(A.$$.fragment),Ee=s(),Q=l("div"),p(Y.$$.fragment),qe=s(),p(O.$$.fragment),Re=s(),x=l("div"),p(K.$$.fragment),rt=s(),he=l("p"),he.innerHTML=kt,lt=s(),_e=l("p"),_e.innerHTML=It,dt=s(),ye=l("p"),ye.innerHTML=Mt,Fe=s(),p(ee.$$.fragment),Ge=s(),N=l("div"),p(te.$$.fragment),pt=s(),be=l("p"),be.textContent=Jt,He=s(),p(oe.$$.fragment),We=s(),V=l("div"),p(se.$$.fragment),mt=s(),ve=l("p"),ve.innerHTML=Ct,ze=s(),p(ae.$$.fragment),Xe=s(),M=l("div"),p(ne.$$.fragment),ft=s(),$e=l("p"),$e.textContent=Ut,ct=s(),p(D.$$.fragment),Se=s(),p(ie.$$.fragment),Ae=s(),y=l("div"),p(re.$$.fragment),ut=s(),we=l("p"),we.textContent=jt,gt=s(),Te=l("p"),Te.textContent=Lt,ht=s(),xe=l("ul"),xe.innerHTML=Zt,_t=s(),ke=l("p"),ke.innerHTML=Pt,yt=s(),Ie=l("p"),Ie.textContent=Nt,bt=s(),p(B.$$.fragment),Qe=s(),p(le.$$.fragment),Ye=s(),Je=l("p"),this.h()},l(e){const t=Ht("svelte-u9bgzb",document.head);h=d(t,"META",{name:!0,content:!0}),t.forEach(o),C=a(e),$=d(e,"P",{}),k($).forEach(o),_=a(e),m(v.$$.fragment,e),i=a(e),m(w.$$.fragment,e),Ce=a(e),q=d(e,"P",{"data-svelte-h":!0}),b(q)!=="svelte-sj662i"&&(q.textContent=vt),Ue=a(e),m(R.$$.fragment,e),je=a(e),j=d(e,"DIV",{class:!0});var de=k(j);m(F.$$.fragment,de),st=a(de),fe=d(de,"P",{"data-svelte-h":!0}),b(fe)!=="svelte-49eriv"&&(fe.textContent=$t),de.forEach(o),Le=a(e),m(G.$$.fragment,e),Ze=a(e),L=d(e,"DIV",{class:!0});var pe=k(L);m(H.$$.fragment,pe),at=a(pe),ce=d(pe,"P",{"data-svelte-h":!0}),b(ce)!=="svelte-haxfgr"&&(ce.textContent=wt),pe.forEach(o),Pe=a(e),m(W.$$.fragment,e),Ne=a(e),Z=d(e,"DIV",{class:!0});var Ke=k(Z);m(z.$$.fragment,Ke),nt=a(Ke),ue=d(Ke,"P",{"data-svelte-h":!0}),b(ue)!=="svelte-suegrh"&&(ue.innerHTML=Tt),Ke.forEach(o),Ve=a(e),m(X.$$.fragment,e),De=a(e),P=d(e,"DIV",{class:!0});var et=k(P);m(S.$$.fragment,et),it=a(et),ge=d(et,"P",{"data-svelte-h":!0}),b(ge)!=="svelte-1p7eej6"&&(ge.innerHTML=xt),et.forEach(o),Be=a(e),m(A.$$.fragment,e),Ee=a(e),Q=d(e,"DIV",{class:!0});var Vt=k(Q);m(Y.$$.fragment,Vt),Vt.forEach(o),qe=a(e),m(O.$$.fragment,e),Re=a(e),x=d(e,"DIV",{class:!0});var E=k(x);m(K.$$.fragment,E),rt=a(E),he=d(E,"P",{"data-svelte-h":!0}),b(he)!=="svelte-1gg2c2d"&&(he.innerHTML=kt),lt=a(E),_e=d(E,"P",{"data-svelte-h":!0}),b(_e)!=="svelte-fx26ue"&&(_e.innerHTML=It),dt=a(E),ye=d(E,"P",{"data-svelte-h":!0}),b(ye)!=="svelte-15zmktc"&&(ye.innerHTML=Mt),E.forEach(o),Fe=a(e),m(ee.$$.fragment,e),Ge=a(e),N=d(e,"DIV",{class:!0});var tt=k(N);m(te.$$.fragment,tt),pt=a(tt),be=d(tt,"P",{"data-svelte-h":!0}),b(be)!=="svelte-rk2372"&&(be.textContent=Jt),tt.forEach(o),He=a(e),m(oe.$$.fragment,e),We=a(e),V=d(e,"DIV",{class:!0});var ot=k(V);m(se.$$.fragment,ot),mt=a(ot),ve=d(ot,"P",{"data-svelte-h":!0}),b(ve)!=="svelte-11ct46x"&&(ve.innerHTML=Ct),ot.forEach(o),ze=a(e),m(ae.$$.fragment,e),Xe=a(e),M=d(e,"DIV",{class:!0});var Me=k(M);m(ne.$$.fragment,Me),ft=a(Me),$e=d(Me,"P",{"data-svelte-h":!0}),b($e)!=="svelte-owzrds"&&($e.textContent=Ut),ct=a(Me),m(D.$$.fragment,Me),Me.forEach(o),Se=a(e),m(ie.$$.fragment,e),Ae=a(e),y=d(e,"DIV",{class:!0});var T=k(y);m(re.$$.fragment,T),ut=a(T),we=d(T,"P",{"data-svelte-h":!0}),b(we)!=="svelte-7b2e3l"&&(we.textContent=jt),gt=a(T),Te=d(T,"P",{"data-svelte-h":!0}),b(Te)!=="svelte-1b92jfk"&&(Te.textContent=Lt),ht=a(T),xe=d(T,"UL",{"data-svelte-h":!0}),b(xe)!=="svelte-k3tp1z"&&(xe.innerHTML=Zt),_t=a(T),ke=d(T,"P",{"data-svelte-h":!0}),b(ke)!=="svelte-18cbdz5"&&(ke.innerHTML=Pt),yt=a(T),Ie=d(T,"P",{"data-svelte-h":!0}),b(Ie)!=="svelte-17duuep"&&(Ie.textContent=Nt),bt=a(T),m(B.$$.fragment,T),T.forEach(o),Qe=a(e),m(le.$$.fragment,e),Ye=a(e),Je=d(e,"P",{}),k(Je).forEach(o),this.h()},h(){I(h,"name","hf:doc:metadata"),I(h,"content",Qt),I(j,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),I(L,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),I(Z,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),I(P,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),I(Q,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),I(x,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),I(N,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),I(V,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),I(M,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),I(y,"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){r(document.head,h),n(e,C,t),n(e,$,t),n(e,_,t),f(v,e,t),n(e,i,t),f(w,e,t),n(e,Ce,t),n(e,q,t),n(e,Ue,t),f(R,e,t),n(e,je,t),n(e,j,t),f(F,j,null),r(j,st),r(j,fe),n(e,Le,t),f(G,e,t),n(e,Ze,t),n(e,L,t),f(H,L,null),r(L,at),r(L,ce),n(e,Pe,t),f(W,e,t),n(e,Ne,t),n(e,Z,t),f(z,Z,null),r(Z,nt),r(Z,ue),n(e,Ve,t),f(X,e,t),n(e,De,t),n(e,P,t),f(S,P,null),r(P,it),r(P,ge),n(e,Be,t),f(A,e,t),n(e,Ee,t),n(e,Q,t),f(Y,Q,null),n(e,qe,t),f(O,e,t),n(e,Re,t),n(e,x,t),f(K,x,null),r(x,rt),r(x,he),r(x,lt),r(x,_e),r(x,dt),r(x,ye),n(e,Fe,t),f(ee,e,t),n(e,Ge,t),n(e,N,t),f(te,N,null),r(N,pt),r(N,be),n(e,He,t),f(oe,e,t),n(e,We,t),n(e,V,t),f(se,V,null),r(V,mt),r(V,ve),n(e,ze,t),f(ae,e,t),n(e,Xe,t),n(e,M,t),f(ne,M,null),r(M,ft),r(M,$e),r(M,ct),f(D,M,null),n(e,Se,t),f(ie,e,t),n(e,Ae,t),n(e,y,t),f(re,y,null),r(y,ut),r(y,we),r(y,gt),r(y,Te),r(y,ht),r(y,xe),r(y,_t),r(y,ke),r(y,yt),r(y,Ie),r(y,bt),f(B,y,null),n(e,Qe,t),f(le,e,t),n(e,Ye,t),n(e,Je,t),Oe=!0},p(e,[t]){const de={};t&2&&(de.$$scope={dirty:t,ctx:e}),D.$set(de);const pe={};t&2&&(pe.$$scope={dirty:t,ctx:e}),B.$set(pe)},i(e){Oe||(c(v.$$.fragment,e),c(w.$$.fragment,e),c(R.$$.fragment,e),c(F.$$.fragment,e),c(G.$$.fragment,e),c(H.$$.fragment,e),c(W.$$.fragment,e),c(z.$$.fragment,e),c(X.$$.fragment,e),c(S.$$.fragment,e),c(A.$$.fragment,e),c(Y.$$.fragment,e),c(O.$$.fragment,e),c(K.$$.fragment,e),c(ee.$$.fragment,e),c(te.$$.fragment,e),c(oe.$$.fragment,e),c(se.$$.fragment,e),c(ae.$$.fragment,e),c(ne.$$.fragment,e),c(D.$$.fragment,e),c(ie.$$.fragment,e),c(re.$$.fragment,e),c(B.$$.fragment,e),c(le.$$.fragment,e),Oe=!0)},o(e){u(v.$$.fragment,e),u(w.$$.fragment,e),u(R.$$.fragment,e),u(F.$$.fragment,e),u(G.$$.fragment,e),u(H.$$.fragment,e),u(W.$$.fragment,e),u(z.$$.fragment,e),u(X.$$.fragment,e),u(S.$$.fragment,e),u(A.$$.fragment,e),u(Y.$$.fragment,e),u(O.$$.fragment,e),u(K.$$.fragment,e),u(ee.$$.fragment,e),u(te.$$.fragment,e),u(oe.$$.fragment,e),u(se.$$.fragment,e),u(ae.$$.fragment,e),u(ne.$$.fragment,e),u(D.$$.fragment,e),u(ie.$$.fragment,e),u(re.$$.fragment,e),u(B.$$.fragment,e),u(le.$$.fragment,e),Oe=!1},d(e){e&&(o(C),o($),o(_),o(i),o(Ce),o(q),o(Ue),o(je),o(j),o(Le),o(Ze),o(L),o(Pe),o(Ne),o(Z),o(Ve),o(De),o(P),o(Be),o(Ee),o(Q),o(qe),o(Re),o(x),o(Fe),o(Ge),o(N),o(He),o(We),o(V),o(ze),o(Xe),o(M),o(Se),o(Ae),o(y),o(Qe),o(Ye),o(Je)),o(h),g(v,e),g(w,e),g(R,e),g(F),g(G,e),g(H),g(W,e),g(z),g(X,e),g(S),g(A,e),g(Y),g(O,e),g(K),g(ee,e),g(te),g(oe,e),g(se),g(ae,e),g(ne),g(D),g(ie,e),g(re),g(B),g(le,e)}}}const Qt='{"title":"Utilities","local":"utilities","sections":[{"title":"numpy_to_pil","local":"diffusers.utils.numpy_to_pil","sections":[],"depth":2},{"title":"pt_to_pil","local":"diffusers.utils.pt_to_pil","sections":[],"depth":2},{"title":"load_image","local":"diffusers.utils.load_image","sections":[],"depth":2},{"title":"load_video","local":"diffusers.utils.load_video","sections":[],"depth":2},{"title":"export_to_gif","local":"diffusers.utils.export_to_gif","sections":[],"depth":2},{"title":"export_to_video","local":"diffusers.utils.export_to_video","sections":[],"depth":2},{"title":"make_image_grid","local":"diffusers.utils.make_image_grid","sections":[],"depth":2},{"title":"randn_tensor","local":"diffusers.utils.torch_utils.randn_tensor","sections":[],"depth":2},{"title":"apply_layerwise_casting","local":"diffusers.hooks.apply_layerwise_casting","sections":[],"depth":2},{"title":"apply_group_offloading","local":"diffusers.hooks.apply_group_offloading","sections":[],"depth":2}],"depth":1}';function Yt(me){return Rt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class no extends Ft{constructor(h){super(),Gt(this,h,Yt,At,qt,{})}}export{no as component};
