import{s as Wt,o as Bt,n as vt}from"../chunks/scheduler.8c3d61f6.js";import{S as It,i as Ct,g as r,s,r as y,A as kt,h as m,f as l,c as i,j as jt,u as M,x as u,k as Ae,y as Qt,a,v as h,d as J,t as w,w as b}from"../chunks/index.da70eac4.js";import{C as pe}from"../chunks/CodeBlock.a9c4becf.js";import{H as oe,E as qt}from"../chunks/getInferenceSnippets.cb466318.js";import{H as _t,a as Gt}from"../chunks/HfOption.6c3b4e77.js";function $t(U){let p,T="Use <code>.images[0]</code> to access the generated image output.",c,f,o;return f=new pe({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwRGlmZnVzaW9uUGlwZWxpbmUlMEElMEFwaXBlbGluZSUyMCUzRCUyMERpZmZ1c2lvblBpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjJRd2VuJTJGUXdlbi1JbWFnZSUyMiUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guYmZsb2F0MTYlMkMlMjBkZXZpY2VfbWFwJTNEJTIyY3VkYSUyMiUwQSklMEElMEFwcm9tcHQlMjAlM0QlMjAlMjIlMjIlMjIlMEFjaW5lbWF0aWMlMjBmaWxtJTIwc3RpbGwlMjBvZiUyMGElMjBjYXQlMjBzaXBwaW5nJTIwYSUyMG1hcmdhcml0YSUyMGluJTIwYSUyMHBvb2wlMjBpbiUyMFBhbG0lMjBTcHJpbmdzJTJDJTIwQ2FsaWZvcm5pYSUwQWhpZ2hseSUyMGRldGFpbGVkJTJDJTIwaGlnaCUyMGJ1ZGdldCUyMGhvbGx5d29vZCUyMG1vdmllJTJDJTIwY2luZW1hc2NvcGUlMkMlMjBtb29keSUyQyUyMGVwaWMlMkMlMjBnb3JnZW91cyUyQyUyMGZpbG0lMjBncmFpbiUwQSUyMiUyMiUyMiUwQXBpcGVsaW5lKHByb21wdCkuaW1hZ2VzJTVCMCU1RA==",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DiffusionPipeline

pipeline = DiffusionPipeline.from_pretrained(
  <span class="hljs-string">&quot;Qwen/Qwen-Image&quot;</span>, torch_dtype=torch.bfloat16, device_map=<span class="hljs-string">&quot;cuda&quot;</span>
)

prompt = <span class="hljs-string">&quot;&quot;&quot;
cinematic film still of a cat sipping a margarita in a pool in Palm Springs, California
highly detailed, high budget hollywood movie, cinemascope, moody, epic, gorgeous, film grain
&quot;&quot;&quot;</span>
pipeline(prompt).images[<span class="hljs-number">0</span>]`,wrap:!1}}),{c(){p=r("p"),p.innerHTML=T,c=s(),y(f.$$.fragment)},l(n){p=m(n,"P",{"data-svelte-h":!0}),u(p)!=="svelte-1spi3an"&&(p.innerHTML=T),c=i(n),M(f.$$.fragment,n)},m(n,d){a(n,p,d),a(n,c,d),h(f,n,d),o=!0},p:vt,i(n){o||(J(f.$$.fragment,n),o=!0)},o(n){w(f.$$.fragment,n),o=!1},d(n){n&&(l(p),l(c)),b(f,n)}}}function Yt(U){let p,T='Use <code>.frames[0]</code> to access the generated video output and <a href="/docs/diffusers/main/en/api/utilities#diffusers.utils.export_to_video">export_to_video()</a> to save the video.',c,f,o;return f=new pe({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwQXV0b2VuY29kZXJLTFdhbiUyQyUyMERpZmZ1c2lvblBpcGVsaW5lJTBBZnJvbSUyMGRpZmZ1c2Vycy5xdWFudGl6ZXJzJTIwaW1wb3J0JTIwUGlwZWxpbmVRdWFudGl6YXRpb25Db25maWclMEFmcm9tJTIwZGlmZnVzZXJzLnV0aWxzJTIwaW1wb3J0JTIwZXhwb3J0X3RvX3ZpZGVvJTBBJTBBdmFlJTIwJTNEJTIwQXV0b2VuY29kZXJLTFdhbi5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIyV2FuLUFJJTJGV2FuMi4yLVQyVi1BMTRCLURpZmZ1c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wQVJpcHBsZXMlMjBzaGltbWVyJTIwYXMlMjBhJTIwd2FybSUyMGRlc2VydCUyMGJyZWV6ZSUyMHN0aXJzJTIwdGhlJTIwd2F0ZXIlMkMlMjBibGVuZGluZyUyMGx1eHVyeSUyMGFuZCUyMHBsYXlmdWwlMjBjaGFybSUyMGluJTIwYW4lMjBlcGljJTJDJTIwZ29yZ2VvdXNseSUyMGNvbXBvc2VkJTIwZnJhbWUuJTBBJTIyJTIyJTIyJTBBdmlkZW8lMjAlM0QlMjBwaXBlbGluZShwcm9tcHQlM0Rwcm9tcHQlMkMlMjBudW1fZnJhbWVzJTNEODElMkMlMjBudW1faW5mZXJlbmNlX3N0ZXBzJTNENDApLmZyYW1lcyU1QjAlNUQlMEFleHBvcnRfdG9fdmlkZW8odmlkZW8lMkMlMjAlMjJvdXRwdXQubXA0JTIyJTJDJTIwZnBzJTNEMTYp",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> AutoencoderKLWan, DiffusionPipeline
<span class="hljs-keyword">from</span> diffusers.quantizers <span class="hljs-keyword">import</span> PipelineQuantizationConfig
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> export_to_video

vae = AutoencoderKLWan.from_pretrained(
  <span class="hljs-string">&quot;Wan-AI/Wan2.2-T2V-A14B-Diffusers&quot;</span>,
  subfolder=<span class="hljs-string">&quot;vae&quot;</span>,
  torch_dtype=torch.float32
)
pipeline = DiffusionPipeline.from_pretrained(
  <span class="hljs-string">&quot;Wan-AI/Wan2.2-T2V-A14B-Diffusers&quot;</span>,
  vae=vae
  torch_dtype=torch.bfloat16,
  device_map=<span class="hljs-string">&quot;cuda&quot;</span>
)

prompt = <span class="hljs-string">&quot;&quot;&quot;
Cinematic video of a sleek cat lounging on a colorful inflatable in a crystal-clear turquoise pool in Palm Springs, 
sipping a salt-rimmed margarita through a straw. Golden-hour sunlight glows over mid-century modern homes and swaying palms. 
Shot in rich Sony a7S III: with moody, glamorous color grading, subtle lens flares, and soft vintage film grain. 
Ripples shimmer as a warm desert breeze stirs the water, blending luxury and playful charm in an epic, gorgeously composed frame.
&quot;&quot;&quot;</span>
video = pipeline(prompt=prompt, num_frames=<span class="hljs-number">81</span>, num_inference_steps=<span class="hljs-number">40</span>).frames[<span class="hljs-number">0</span>]
export_to_video(video, <span class="hljs-string">&quot;output.mp4&quot;</span>, fps=<span class="hljs-number">16</span>)`,wrap:!1}}),{c(){p=r("p"),p.innerHTML=T,c=s(),y(f.$$.fragment)},l(n){p=m(n,"P",{"data-svelte-h":!0}),u(p)!=="svelte-u41lat"&&(p.innerHTML=T),c=i(n),M(f.$$.fragment,n)},m(n,d){a(n,p,d),a(n,c,d),h(f,n,d),o=!0},p:vt,i(n){o||(J(f.$$.fragment,n),o=!0)},o(n){w(f.$$.fragment,n),o=!1},d(n){n&&(l(p),l(c)),b(f,n)}}}function Xt(U){let p,T,c,f;return p=new Gt({props:{id:"diffusionpipeline",option:"text-to-image",$$slots:{default:[$t]},$$scope:{ctx:U}}}),c=new Gt({props:{id:"diffusionpipeline",option:"text-to-video",$$slots:{default:[Yt]},$$scope:{ctx:U}}}),{c(){y(p.$$.fragment),T=s(),y(c.$$.fragment)},l(o){M(p.$$.fragment,o),T=i(o),M(c.$$.fragment,o)},m(o,n){h(p,o,n),a(o,T,n),h(c,o,n),f=!0},p(o,n){const d={};n&2&&(d.$$scope={dirty:n,ctx:o}),p.$set(d);const re={};n&2&&(re.$$scope={dirty:n,ctx:o}),c.$set(re)},i(o){f||(J(p.$$.fragment,o),J(c.$$.fragment,o),f=!0)},o(o){w(p.$$.fragment,o),w(c.$$.fragment,o),f=!1},d(o){o&&l(T),b(p,o),b(c,o)}}}function Vt(U){let p,T,c,f,o,n,d,re="Diffusers is a library for developers and researchers that provides an easy inference API for generating images, videos and audio, as well as the building blocks for implementing new workflows.",ue,G,Ke="Diffusers provides many optimizations out-of-the-box that makes it possible to load and run large models on setups with limited memory or to accelerate inference.",fe,v,Oe="This Quickstart will give you an overview of Diffusers and get you up and generating quickly.",ce,g,et='<p>Before you begin, make sure you have a Hugging Face <a href="https://huggingface.co/join" rel="nofollow">account</a> in order to use gated models like <a href="https://huggingface.co/black-forest-labs/FLUX.1-dev" rel="nofollow">Flux</a>.</p>',de,W,tt='Follow the <a href="./installation">Installation</a> guide to install Diffusers if it’s not already installed.',ye,B,Me,I,lt="A diffusion model combines multiple components to generate outputs in any modality based on an input, such as a text description, image or both.",he,C,at="For a standard text-to-image model:",Je,k,st="<li><p>A text encoder turns a prompt into embeddings that guide the denoising process. Some models have more than one text encoder.</p></li> <li><p>A scheduler contains the algorithmic specifics for gradually denoising initial random noise into clean outputs. Different schedulers affect generation speed and quality.</p></li> <li><p>A UNet or diffusion transformer (DiT) is the workhorse of a diffusion model.</p> <p>At each step, it performs the denoising predictions, such as how much noise to remove or the general direction in which to steer the noise to generate better quality outputs.</p> <p>The UNet or DiT repeats this loop for a set amount of steps to generate the final output.</p></li> <li><p>A variational autoencoder (VAE) encodes and decodes pixels to a spatially compressed latent-space. <em>Latents</em> are compressed representations of an image and are more efficient to work with. The UNet or DiT operates on latents, and the clean latents at the end are decoded back into images.</p></li>",we,Q,it='The <a href="/docs/diffusers/main/en/api/pipelines/overview#diffusers.DiffusionPipeline">DiffusionPipeline</a> packages all these components into a single class for inference. There are several arguments in <code>__call__()</code> you can change, such as <code>num_inference_steps</code>, that affect the diffusion process. Try different values and arguments to see how they change generation quality or speed.',be,q,nt='Load a model with <a href="/docs/diffusers/main/en/api/pipelines/overview#diffusers.DiffusionPipeline.from_pretrained">from_pretrained()</a> and describe what you’d like to generate. The example below uses the default argument values.',Te,Z,Ue,_,ge,$,ot='Adapters insert a small number of trainable parameters to the original base model. Only the inserted parameters are fine-tuned while the rest of the model weights remain frozen. This makes it fast and cheap to fine-tune a model on a new style. Among adapters, <a href="./tutorials/using_peft_for_inference">LoRA’s</a> are the most popular.',Ze,Y,pt='Add a LoRA to a pipeline with the <a href="/docs/diffusers/main/en/api/loaders/lora#diffusers.loaders.QwenImageLoraLoaderMixin.load_lora_weights">load_lora_weights()</a> method. Some LoRA’s require a special word to trigger it, such as <code>Realism</code>, in the example below. Check a LoRA’s model card to see if it requires a trigger word.',je,X,Ge,V,rt='Check out the <a href="./tutorials/using_peft_for_inference">LoRA</a> docs or Adapters section to learn more.',ve,x,We,z,mt='<a href="./quantization/overview">Quantization</a> stores data in fewer bits to reduce memory usage. It may also speed up inference because it takes less time to perform calculations with fewer bits.',Be,F,ut='Diffusers provides several quantization backends and picking one depends on your use case. For example, <a href="./quantization/bitsandbytes">bitsandbytes</a> and <a href="./quantization/torchao">torchao</a> are both simple and easy to use for inference, but torchao supports more <a href="./quantization/torchao#supported-quantization-types">quantization types</a> like fp8.',Ie,H,ft='Configure <a href="/docs/diffusers/main/en/api/quantization#diffusers.PipelineQuantizationConfig">PipelineQuantizationConfig</a> with the backend to use, the specific arguments (refer to the <a href="./api/quantization">API</a> reference for available arguments) for that backend, and which components to quantize. The example below quantizes the model to 4-bits and only uses 14.93GB of memory.',Ce,S,ke,R,ct='Take a look at the <a href="./quantization/overview">Quantization</a> section for more details.',Qe,E,qe,j,dt='<p>Optimization is dependent on hardware specs such as memory. Use this <a href="https://huggingface.co/spaces/diffusers/optimized-diffusers-code" rel="nofollow">Space</a> to generate code examples that include all of Diffusers’ available memory and speed optimization techniques for any model you’re using.</p>',_e,N,yt="Modern diffusion models are very large and have billions of parameters. The iterative denoising process is also computationally intensive and slow. Diffusers provides techniques for reducing memory usage and boosting inference speed. These techniques can be combined with quantization to optimize for both memory usage and inference speed.",$e,L,Ye,D,Mt="The text encoders and UNet or DiT can use up as much as ~30GB of memory, exceeding the amount available on many free-tier or consumer GPUs.",Xe,P,ht='Offloading stores weights that aren’t currently used on the CPU and only moves them to the GPU when they’re needed. There are a few offloading types and the example below uses <a href="./optimization/memory#model-offloading">model offloading</a>. This moves an entire model, like a text encoder or transformer, to the CPU when it isn’t actively being used.',Ve,A,Jt='Call <a href="/docs/diffusers/main/en/api/pipelines/overview#diffusers.DiffusionPipeline.enable_model_cpu_offload">enable_model_cpu_offload()</a> to activate it. By combining quantization and offloading, the following example only requires ~12.54GB of memory.',xe,K,ze,O,wt='Refer to the <a href="./optimization/memory">Reduce memory usage</a> docs to learn more about other memory reducing techniques.',Fe,ee,He,te,bt='The denoising loop performs a lot of computations and can be slow. Methods like <a href="./optimization/fp16#torchcompile">torch.compile</a> increases inference speed by compiling the computations into an optimized kernel. Compilation is slow for the first generation but successive generations should be much faster.',Se,le,Tt='The example below uses <a href="./optimization/fp16#regional-compilation">regional compilation</a> to only compile small regions of a model. It reduces cold-start latency while also providing a runtime speed up.',Re,ae,Ut='Call <a href="/docs/diffusers/main/en/api/models/overview#diffusers.ModelMixin.compile_repeated_blocks">compile_repeated_blocks()</a> on the model to activate it.',Ee,se,Ne,ie,gt='Check out the <a href="./optimization/fp16">Accelerate inference</a> or <a href="./optimization/cache">Caching</a> docs for more methods that speed up inference.',Le,ne,De,me,Pe;return o=new oe({props:{title:"Quickstart",local:"quickstart",headingTag:"h1"}}),B=new oe({props:{title:"DiffusionPipeline",local:"diffusionpipeline",headingTag:"h2"}}),Z=new _t({props:{id:"diffusionpipeline",options:["text-to-image","text-to-video"],$$slots:{default:[Xt]},$$scope:{ctx:U}}}),_=new oe({props:{title:"LoRA",local:"lora",headingTag:"h2"}}),X=new pe({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwRGlmZnVzaW9uUGlwZWxpbmUlMEElMEFwaXBlbGluZSUyMCUzRCUyMERpZmZ1c2lvblBpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjJRd2VuJTJGUXdlbi1JbWFnZSUyMiUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guYmZsb2F0MTYlMkMlMjBkZXZpY2VfbWFwJTNEJTIyY3VkYSUyMiUwQSklMEFwaXBlbGluZS5sb2FkX2xvcmFfd2VpZ2h0cyglMEElMjAlMjAlMjJmbHlteS1haSUyRnF3ZW4taW1hZ2UtcmVhbGlzbS1sb3JhJTIyJTJDJTBBKSUwQSUwQXByb21wdCUyMCUzRCUyMCUyMiUyMiUyMiUwQXN1cGVyJTIwUmVhbGlzbSUyMGNpbmVtYXRpYyUyMGZpbG0lMjBzdGlsbCUyMG9mJTIwYSUyMGNhdCUyMHNpcHBpbmclMjBhJTIwbWFyZ2FyaXRhJTIwaW4lMjBhJTIwcG9vbCUyMGluJTIwUGFsbSUyMFNwcmluZ3MlMjBpbiUyMHRoZSUyMHN0eWxlJTIwb2YlMjB1bWVtcGFydCUyQyUyMENhbGlmb3JuaWElMEFoaWdobHklMjBkZXRhaWxlZCUyQyUyMGhpZ2glMjBidWRnZXQlMjBob2xseXdvb2QlMjBtb3ZpZSUyQyUyMGNpbmVtYXNjb3BlJTJDJTIwbW9vZHklMkMlMjBlcGljJTJDJTIwZ29yZ2VvdXMlMkMlMjBmaWxtJTIwZ3JhaW4lMEElMjIlMjIlMjIlMEFwaXBlbGluZShwcm9tcHQpLmltYWdlcyU1QjAlNUQ=",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DiffusionPipeline

pipeline = DiffusionPipeline.from_pretrained(
  <span class="hljs-string">&quot;Qwen/Qwen-Image&quot;</span>, torch_dtype=torch.bfloat16, device_map=<span class="hljs-string">&quot;cuda&quot;</span>
)
pipeline.load_lora_weights(
  <span class="hljs-string">&quot;flymy-ai/qwen-image-realism-lora&quot;</span>,
)

prompt = <span class="hljs-string">&quot;&quot;&quot;
super Realism cinematic film still of a cat sipping a margarita in a pool in Palm Springs in the style of umempart, California
highly detailed, high budget hollywood movie, cinemascope, moody, epic, gorgeous, film grain
&quot;&quot;&quot;</span>
pipeline(prompt).images[<span class="hljs-number">0</span>]`,wrap:!1}}),x=new oe({props:{title:"Quantization",local:"quantization",headingTag:"h2"}}),S=new pe({props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ml0YSUyMGluJTIwYSUyMHBvb2wlMjBpbiUyMFBhbG0lMjBTcHJpbmdzJTJDJTIwQ2FsaWZvcm5pYSUwQWhpZ2hseSUyMGRldGFpbGVkJTJDJTIwaGlnaCUyMGJ1ZGdldCUyMGhvbGx5d29vZCUyMG1vdmllJTJDJTIwY2luZW1hc2NvcGUlMkMlMjBtb29keSUyQyUyMGVwaWMlMkMlMjBnb3JnZW91cyUyQyUyMGZpbG0lMjBncmFpbiUwQSUyMiUyMiUyMiUwQXBpcGVsaW5lKHByb21wdCkuaW1hZ2VzJTVCMCU1RCUwQXByaW50KGYlMjJNYXglMjBtZW1vcnklMjByZXNlcnZlZCUzQSUyMCU3QnRvcmNoLmN1ZGEubWF4X21lbW9yeV9hbGxvY2F0ZWQoKSUyMCUyRiUyMDEwMjQqKjMlM0EuMmYlN0QlMjBHQiUyMik=",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DiffusionPipeline
<span class="hljs-keyword">from</span> diffusers.quantizers <span class="hljs-keyword">import</span> PipelineQuantizationConfig

quant_config = PipelineQuantizationConfig(
  quant_backend=<span class="hljs-string">&quot;bitsandbytes_4bit&quot;</span>,
  quant_kwargs={<span class="hljs-string">&quot;load_in_4bit&quot;</span>: <span class="hljs-literal">True</span>, <span class="hljs-string">&quot;bnb_4bit_quant_type&quot;</span>: <span class="hljs-string">&quot;nf4&quot;</span>, <span class="hljs-string">&quot;bnb_4bit_compute_dtype&quot;</span>: torch.bfloat16},
  components_to_quantize=[<span class="hljs-string">&quot;transformer&quot;</span>, <span class="hljs-string">&quot;text_encoder&quot;</span>],
)
pipeline = DiffusionPipeline.from_pretrained(
  <span class="hljs-string">&quot;Qwen/Qwen-Image&quot;</span>,
  torch_dtype=torch.bfloat16,
  quantization_config=quant_config,
  device_map=<span class="hljs-string">&quot;cuda&quot;</span>
)

prompt = <span class="hljs-string">&quot;&quot;&quot;
cinematic film still of a cat sipping a margarita in a pool in Palm Springs, California
highly detailed, high budget hollywood movie, cinemascope, moody, epic, gorgeous, film grain
&quot;&quot;&quot;</span>
pipeline(prompt).images[<span class="hljs-number">0</span>]
<span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;Max memory reserved: <span class="hljs-subst">{torch.cuda.max_memory_allocated() / <span class="hljs-number">1024</span>**<span class="hljs-number">3</span>:<span class="hljs-number">.2</span>f}</span> GB&quot;</span>)`,wrap:!1}}),E=new oe({props:{title:"Optimizations",local:"optimizations",headingTag:"h2"}}),L=new oe({props:{title:"Memory usage",local:"memory-usage",headingTag:"h3"}}),K=new pe({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwRGlmZnVzaW9uUGlwZWxpbmUlMEFmcm9tJTIwZGlmZnVzZXJzLnF1YW50aXplcnMlMjBpbXBvcnQlMjBQaXBlbGluZVF1YW50aXphdGlvbkNvbmZpZyUwQSUwQXF1YW50X2NvbmZpZyUyMCUzRCUyMFBpcGVsaW5lUXVhbnRpemF0aW9uQ29uZmlnKCUwQSUyMCUyMHF1YW50X2JhY2tlbmQlM0QlMjJiaXRzYW5kYnl0ZXNfNGJpdCUyMiUyQyUwQSUyMCUyMHF1YW50X2t3YXJncyUzRCU3QiUyMmxvYWRfaW5fNGJpdCUyMiUzQSUyMFRydWUlMkMlMjAlMjJibmJfNGJpdF9xdWFudF90eXBlJTIyJTNBJTIwJTIybmY0JTIyJTJDJTIwJTIyYm5iXzRiaXRfY29tcHV0ZV9kdHlwZSUyMiUzQSUyMHRvcmNoLmJmbG9hdDE2JTdEJTJDJTBBJTIwJTIwY29tcG9uZW50c190b19xdWFudGl6ZSUzRCU1QiUyMnRyYW5zZm9ybWVyJTIyJTJDJTIwJTIydGV4dF9lbmNvZGVyJTIyJTVEJTJDJTBBKSUwQXBpcGVsaW5lJTIwJTNEJTIwRGlmZnVzaW9uUGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKCUwQSUyMCUyMCUyMlF3ZW4lMkZRd2VuLUltYWdlJTIyJTJDJTBBJTIwJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5iZmxvYXQxNiUyQyUwQSUyMCUyMHF1YW50aXphdGlvbl9jb25maWclM0RxdWFudF9jb25maWclMkMlMEElMjAlMjBkZXZpY2VfbWFwJTNEJTIyY3VkYSUyMiUwQSklMEFwaXBlbGluZS5lbmFibGVfbW9kZWxfY3B1X29mZmxvYWQoKSUwQSUwQXByb21wdCUyMCUzRCUyMCUyMiUyMiUyMiUwQWNpbmVtYXRpYyUyMGZpbG0lMjBzdGlsbCUyMG9mJTIwYSUyMGNhdCUyMHNpcHBpbmclMjBhJTIwbWFyZ2FyaXRhJTIwaW4lMjBhJTIwcG9vbCUyMGluJTIwUGFsbSUyMFNwcmluZ3MlMkMlMjBDYWxpZm9ybmlhJTBBaGlnaGx5JTIwZGV0YWlsZWQlMkMlMjBoaWdoJTIwYnVkZ2V0JTIwaG9sbHl3b29kJTIwbW92aWUlMkMlMjBjaW5lbWFzY29wZSUyQyUyMG1vb2R5JTJDJTIwZXBpYyUyQyUyMGdvcmdlb3VzJTJDJTIwZmlsbSUyMGdyYWluJTBBJTIyJTIyJTIyJTBBcGlwZWxpbmUocHJvbXB0KS5pbWFnZXMlNUIwJTVEJTBBcHJpbnQoZiUyMk1heCUyMG1lbW9yeSUyMHJlc2VydmVkJTNBJTIwJTdCdG9yY2guY3VkYS5tYXhfbWVtb3J5X2FsbG9jYXRlZCgpJTIwJTJGJTIwMTAyNCoqMyUzQS4yZiU3RCUyMEdCJTIyKQ==",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DiffusionPipeline
<span class="hljs-keyword">from</span> diffusers.quantizers <span class="hljs-keyword">import</span> PipelineQuantizationConfig

quant_config = PipelineQuantizationConfig(
  quant_backend=<span class="hljs-string">&quot;bitsandbytes_4bit&quot;</span>,
  quant_kwargs={<span class="hljs-string">&quot;load_in_4bit&quot;</span>: <span class="hljs-literal">True</span>, <span class="hljs-string">&quot;bnb_4bit_quant_type&quot;</span>: <span class="hljs-string">&quot;nf4&quot;</span>, <span class="hljs-string">&quot;bnb_4bit_compute_dtype&quot;</span>: torch.bfloat16},
  components_to_quantize=[<span class="hljs-string">&quot;transformer&quot;</span>, <span class="hljs-string">&quot;text_encoder&quot;</span>],
)
pipeline = DiffusionPipeline.from_pretrained(
  <span class="hljs-string">&quot;Qwen/Qwen-Image&quot;</span>,
  torch_dtype=torch.bfloat16,
  quantization_config=quant_config,
  device_map=<span class="hljs-string">&quot;cuda&quot;</span>
)
pipeline.enable_model_cpu_offload()

prompt = <span class="hljs-string">&quot;&quot;&quot;
cinematic film still of a cat sipping a margarita in a pool in Palm Springs, California
highly detailed, high budget hollywood movie, cinemascope, moody, epic, gorgeous, film grain
&quot;&quot;&quot;</span>
pipeline(prompt).images[<span class="hljs-number">0</span>]
<span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;Max memory reserved: <span class="hljs-subst">{torch.cuda.max_memory_allocated() / <span class="hljs-number">1024</span>**<span class="hljs-number">3</span>:<span class="hljs-number">.2</span>f}</span> GB&quot;</span>)`,wrap:!1}}),ee=new oe({props:{title:"Inference speed",local:"inference-speed",headingTag:"h3"}}),se=new pe({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwRGlmZnVzaW9uUGlwZWxpbmUlMEElMEFwaXBlbGluZSUyMCUzRCUyMERpZmZ1c2lvblBpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjJRd2VuJTJGUXdlbi1JbWFnZSUyMiUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guYmZsb2F0MTYlMkMlMjBkZXZpY2VfbWFwJTNEJTIyY3VkYSUyMiUwQSklMEElMEFwaXBlbGluZS50cmFuc2Zvcm1lci5jb21waWxlX3JlcGVhdGVkX2Jsb2NrcyglMEElMjAlMjAlMjAlMjBmdWxsZ3JhcGglM0RUcnVlJTJDJTBBKSUwQXByb21wdCUyMCUzRCUyMCUyMiUyMiUyMiUwQWNpbmVtYXRpYyUyMGZpbG0lMjBzdGlsbCUyMG9mJTIwYSUyMGNhdCUyMHNpcHBpbmclMjBhJTIwbWFyZ2FyaXRhJTIwaW4lMjBhJTIwcG9vbCUyMGluJTIwUGFsbSUyMFNwcmluZ3MlMkMlMjBDYWxpZm9ybmlhJTBBaGlnaGx5JTIwZGV0YWlsZWQlMkMlMjBoaWdoJTIwYnVkZ2V0JTIwaG9sbHl3b29kJTIwbW92aWUlMkMlMjBjaW5lbWFzY29wZSUyQyUyMG1vb2R5JTJDJTIwZXBpYyUyQyUyMGdvcmdlb3VzJTJDJTIwZmlsbSUyMGdyYWluJTBBJTIyJTIyJTIyJTBBcGlwZWxpbmUocHJvbXB0KS5pbWFnZXMlNUIwJTVE",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DiffusionPipeline

pipeline = DiffusionPipeline.from_pretrained(
  <span class="hljs-string">&quot;Qwen/Qwen-Image&quot;</span>, torch_dtype=torch.bfloat16, device_map=<span class="hljs-string">&quot;cuda&quot;</span>
)

pipeline.transformer.compile_repeated_blocks(
    fullgraph=<span class="hljs-literal">True</span>,
)
prompt = <span class="hljs-string">&quot;&quot;&quot;
cinematic film still of a cat sipping a margarita in a pool in Palm Springs, California
highly detailed, high budget hollywood movie, cinemascope, moody, epic, gorgeous, film grain
&quot;&quot;&quot;</span>
pipeline(prompt).images[<span class="hljs-number">0</span>]`,wrap:!1}}),ne=new qt({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/quicktour.md"}}),{c(){p=r("meta"),T=s(),c=r("p"),f=s(),y(o.$$.fragment),n=s(),d=r("p"),d.textContent=re,ue=s(),G=r("p"),G.textContent=Ke,fe=s(),v=r("p"),v.textContent=Oe,ce=s(),g=r("blockquote"),g.innerHTML=et,de=s(),W=r("p"),W.innerHTML=tt,ye=s(),y(B.$$.fragment),Me=s(),I=r("p"),I.textContent=lt,he=s(),C=r("p"),C.textContent=at,Je=s(),k=r("ol"),k.innerHTML=st,we=s(),Q=r("p"),Q.innerHTML=it,be=s(),q=r("p"),q.innerHTML=nt,Te=s(),y(Z.$$.fragment),Ue=s(),y(_.$$.fragment),ge=s(),$=r("p"),$.innerHTML=ot,Ze=s(),Y=r("p"),Y.innerHTML=pt,je=s(),y(X.$$.fragment),Ge=s(),V=r("p"),V.innerHTML=rt,ve=s(),y(x.$$.fragment),We=s(),z=r("p"),z.innerHTML=mt,Be=s(),F=r("p"),F.innerHTML=ut,Ie=s(),H=r("p"),H.innerHTML=ft,Ce=s(),y(S.$$.fragment),ke=s(),R=r("p"),R.innerHTML=ct,Qe=s(),y(E.$$.fragment),qe=s(),j=r("blockquote"),j.innerHTML=dt,_e=s(),N=r("p"),N.textContent=yt,$e=s(),y(L.$$.fragment),Ye=s(),D=r("p"),D.textContent=Mt,Xe=s(),P=r("p"),P.innerHTML=ht,Ve=s(),A=r("p"),A.innerHTML=Jt,xe=s(),y(K.$$.fragment),ze=s(),O=r("p"),O.innerHTML=wt,Fe=s(),y(ee.$$.fragment),He=s(),te=r("p"),te.innerHTML=bt,Se=s(),le=r("p"),le.innerHTML=Tt,Re=s(),ae=r("p"),ae.innerHTML=Ut,Ee=s(),y(se.$$.fragment),Ne=s(),ie=r("p"),ie.innerHTML=gt,Le=s(),y(ne.$$.fragment),De=s(),me=r("p"),this.h()},l(e){const t=kt("svelte-u9bgzb",document.head);p=m(t,"META",{name:!0,content:!0}),t.forEach(l),T=i(e),c=m(e,"P",{}),jt(c).forEach(l),f=i(e),M(o.$$.fragment,e),n=i(e),d=m(e,"P",{"data-svelte-h":!0}),u(d)!=="svelte-56xior"&&(d.textContent=re),ue=i(e),G=m(e,"P",{"data-svelte-h":!0}),u(G)!=="svelte-st2d2w"&&(G.textContent=Ke),fe=i(e),v=m(e,"P",{"data-svelte-h":!0}),u(v)!=="svelte-ty6z9h"&&(v.textContent=Oe),ce=i(e),g=m(e,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),u(g)!=="svelte-w6bpb7"&&(g.innerHTML=et),de=i(e),W=m(e,"P",{"data-svelte-h":!0}),u(W)!=="svelte-1mbmwu"&&(W.innerHTML=tt),ye=i(e),M(B.$$.fragment,e),Me=i(e),I=m(e,"P",{"data-svelte-h":!0}),u(I)!=="svelte-1uey2wy"&&(I.textContent=lt),he=i(e),C=m(e,"P",{"data-svelte-h":!0}),u(C)!=="svelte-1p4ihn"&&(C.textContent=at),Je=i(e),k=m(e,"OL",{"data-svelte-h":!0}),u(k)!=="svelte-107s2nd"&&(k.innerHTML=st),we=i(e),Q=m(e,"P",{"data-svelte-h":!0}),u(Q)!=="svelte-1qjx1u4"&&(Q.innerHTML=it),be=i(e),q=m(e,"P",{"data-svelte-h":!0}),u(q)!=="svelte-10q00fi"&&(q.innerHTML=nt),Te=i(e),M(Z.$$.fragment,e),Ue=i(e),M(_.$$.fragment,e),ge=i(e),$=m(e,"P",{"data-svelte-h":!0}),u($)!=="svelte-jua4gq"&&($.innerHTML=ot),Ze=i(e),Y=m(e,"P",{"data-svelte-h":!0}),u(Y)!=="svelte-1hfi3jb"&&(Y.innerHTML=pt),je=i(e),M(X.$$.fragment,e),Ge=i(e),V=m(e,"P",{"data-svelte-h":!0}),u(V)!=="svelte-1ghzmtu"&&(V.innerHTML=rt),ve=i(e),M(x.$$.fragment,e),We=i(e),z=m(e,"P",{"data-svelte-h":!0}),u(z)!=="svelte-ba18t5"&&(z.innerHTML=mt),Be=i(e),F=m(e,"P",{"data-svelte-h":!0}),u(F)!=="svelte-hvktkn"&&(F.innerHTML=ut),Ie=i(e),H=m(e,"P",{"data-svelte-h":!0}),u(H)!=="svelte-1kz2xjb"&&(H.innerHTML=ft),Ce=i(e),M(S.$$.fragment,e),ke=i(e),R=m(e,"P",{"data-svelte-h":!0}),u(R)!=="svelte-lj8jhg"&&(R.innerHTML=ct),Qe=i(e),M(E.$$.fragment,e),qe=i(e),j=m(e,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),u(j)!=="svelte-1vyk5nr"&&(j.innerHTML=dt),_e=i(e),N=m(e,"P",{"data-svelte-h":!0}),u(N)!=="svelte-17bpo15"&&(N.textContent=yt),$e=i(e),M(L.$$.fragment,e),Ye=i(e),D=m(e,"P",{"data-svelte-h":!0}),u(D)!=="svelte-1bcil2"&&(D.textContent=Mt),Xe=i(e),P=m(e,"P",{"data-svelte-h":!0}),u(P)!=="svelte-1udfe87"&&(P.innerHTML=ht),Ve=i(e),A=m(e,"P",{"data-svelte-h":!0}),u(A)!=="svelte-15somwy"&&(A.innerHTML=Jt),xe=i(e),M(K.$$.fragment,e),ze=i(e),O=m(e,"P",{"data-svelte-h":!0}),u(O)!=="svelte-ad4p4e"&&(O.innerHTML=wt),Fe=i(e),M(ee.$$.fragment,e),He=i(e),te=m(e,"P",{"data-svelte-h":!0}),u(te)!=="svelte-1cvq90h"&&(te.innerHTML=bt),Se=i(e),le=m(e,"P",{"data-svelte-h":!0}),u(le)!=="svelte-1teo5ea"&&(le.innerHTML=Tt),Re=i(e),ae=m(e,"P",{"data-svelte-h":!0}),u(ae)!=="svelte-17t31gw"&&(ae.innerHTML=Ut),Ee=i(e),M(se.$$.fragment,e),Ne=i(e),ie=m(e,"P",{"data-svelte-h":!0}),u(ie)!=="svelte-1f7t84p"&&(ie.innerHTML=gt),Le=i(e),M(ne.$$.fragment,e),De=i(e),me=m(e,"P",{}),jt(me).forEach(l),this.h()},h(){Ae(p,"name","hf:doc:metadata"),Ae(p,"content",xt),Ae(g,"class","tip"),Ae(j,"class","tip")},m(e,t){Qt(document.head,p),a(e,T,t),a(e,c,t),a(e,f,t),h(o,e,t),a(e,n,t),a(e,d,t),a(e,ue,t),a(e,G,t),a(e,fe,t),a(e,v,t),a(e,ce,t),a(e,g,t),a(e,de,t),a(e,W,t),a(e,ye,t),h(B,e,t),a(e,Me,t),a(e,I,t),a(e,he,t),a(e,C,t),a(e,Je,t),a(e,k,t),a(e,we,t),a(e,Q,t),a(e,be,t),a(e,q,t),a(e,Te,t),h(Z,e,t),a(e,Ue,t),h(_,e,t),a(e,ge,t),a(e,$,t),a(e,Ze,t),a(e,Y,t),a(e,je,t),h(X,e,t),a(e,Ge,t),a(e,V,t),a(e,ve,t),h(x,e,t),a(e,We,t),a(e,z,t),a(e,Be,t),a(e,F,t),a(e,Ie,t),a(e,H,t),a(e,Ce,t),h(S,e,t),a(e,ke,t),a(e,R,t),a(e,Qe,t),h(E,e,t),a(e,qe,t),a(e,j,t),a(e,_e,t),a(e,N,t),a(e,$e,t),h(L,e,t),a(e,Ye,t),a(e,D,t),a(e,Xe,t),a(e,P,t),a(e,Ve,t),a(e,A,t),a(e,xe,t),h(K,e,t),a(e,ze,t),a(e,O,t),a(e,Fe,t),h(ee,e,t),a(e,He,t),a(e,te,t),a(e,Se,t),a(e,le,t),a(e,Re,t),a(e,ae,t),a(e,Ee,t),h(se,e,t),a(e,Ne,t),a(e,ie,t),a(e,Le,t),h(ne,e,t),a(e,De,t),a(e,me,t),Pe=!0},p(e,[t]){const Zt={};t&2&&(Zt.$$scope={dirty:t,ctx:e}),Z.$set(Zt)},i(e){Pe||(J(o.$$.fragment,e),J(B.$$.fragment,e),J(Z.$$.fragment,e),J(_.$$.fragment,e),J(X.$$.fragment,e),J(x.$$.fragment,e),J(S.$$.fragment,e),J(E.$$.fragment,e),J(L.$$.fragment,e),J(K.$$.fragment,e),J(ee.$$.fragment,e),J(se.$$.fragment,e),J(ne.$$.fragment,e),Pe=!0)},o(e){w(o.$$.fragment,e),w(B.$$.fragment,e),w(Z.$$.fragment,e),w(_.$$.fragment,e),w(X.$$.fragment,e),w(x.$$.fragment,e),w(S.$$.fragment,e),w(E.$$.fragment,e),w(L.$$.fragment,e),w(K.$$.fragment,e),w(ee.$$.fragment,e),w(se.$$.fragment,e),w(ne.$$.fragment,e),Pe=!1},d(e){e&&(l(T),l(c),l(f),l(n),l(d),l(ue),l(G),l(fe),l(v),l(ce),l(g),l(de),l(W),l(ye),l(Me),l(I),l(he),l(C),l(Je),l(k),l(we),l(Q),l(be),l(q),l(Te),l(Ue),l(ge),l($),l(Ze),l(Y),l(je),l(Ge),l(V),l(ve),l(We),l(z),l(Be),l(F),l(Ie),l(H),l(Ce),l(ke),l(R),l(Qe),l(qe),l(j),l(_e),l(N),l($e),l(Ye),l(D),l(Xe),l(P),l(Ve),l(A),l(xe),l(ze),l(O),l(Fe),l(He),l(te),l(Se),l(le),l(Re),l(ae),l(Ee),l(Ne),l(ie),l(Le),l(De),l(me)),l(p),b(o,e),b(B,e),b(Z,e),b(_,e),b(X,e),b(x,e),b(S,e),b(E,e),b(L,e),b(K,e),b(ee,e),b(se,e),b(ne,e)}}}const xt='{"title":"Quickstart","local":"quickstart","sections":[{"title":"DiffusionPipeline","local":"diffusionpipeline","sections":[],"depth":2},{"title":"LoRA","local":"lora","sections":[],"depth":2},{"title":"Quantization","local":"quantization","sections":[],"depth":2},{"title":"Optimizations","local":"optimizations","sections":[{"title":"Memory usage","local":"memory-usage","sections":[],"depth":3},{"title":"Inference speed","local":"inference-speed","sections":[],"depth":3}],"depth":2}],"depth":1}';function zt(U){return Bt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Nt extends It{constructor(p){super(),Ct(this,p,zt,Vt,Wt,{})}}export{Nt as component};
