import{s as It,o as Ct,n as Bt}from"../chunks/scheduler.53228c21.js";import{S as $t,i as kt,e as r,s,c as d,h as Qt,a as m,d as l,b as i,f as vt,g as M,j as u,k as Ke,l as qt,m as a,n as h,t as J,o as w,p as b}from"../chunks/index.100fac89.js";import{C as _t}from"../chunks/CopyLLMTxtMenu.2cdbb51f.js";import{C as me}from"../chunks/CodeBlock.d30a6509.js";import{H as re,E as Yt}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.3fcbbc76.js";import{H as Xt,a as Wt}from"../chunks/HfOption.fad27e59.js";function Vt(U){let p,T="Use <code>.images[0]</code> to access the generated image output.",y,f,o;return f=new me({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,y=s(),d(f.$$.fragment)},l(n){p=m(n,"P",{"data-svelte-h":!0}),u(p)!=="svelte-1spi3an"&&(p.innerHTML=T),y=i(n),M(f.$$.fragment,n)},m(n,c){a(n,p,c),a(n,y,c),h(f,n,c),o=!0},p:Bt,i(n){o||(J(f.$$.fragment,n),o=!0)},o(n){w(f.$$.fragment,n),o=!1},d(n){n&&(l(p),l(y)),b(f,n)}}}function xt(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.',y,f,o;return f=new me({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwQXV0b2VuY29kZXJLTFdhbiUyQyUyMERpZmZ1c2lvblBpcGVsaW5lJTBBZnJvbSUyMGRpZmZ1c2Vycy5xdWFudGl6ZXJzJTIwaW1wb3J0JTIwUGlwZWxpbmVRdWFudGl6YXRpb25Db25maWclMEFmcm9tJTIwZGlmZnVzZXJzLnV0aWxzJTIwaW1wb3J0JTIwZXhwb3J0X3RvX3ZpZGVvJTBBJTBBdmFlJTIwJTNEJTIwQXV0b2VuY29kZXJLTFdhbi5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIyV2FuLUFJJTJGV2FuMi4yLVQyVi1BMTRCLURpZmZ1c2VycyUyMiUyQyUwQSUyMCUyMHN1YmZvbGRlciUzRCUyMnZhZSUyMiUyQyUwQSUyMCUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQzMiUwQSklMEFwaXBlbGluZSUyMCUzRCUyMERpZmZ1c2lvblBpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjJXYW4tQUklMkZXYW4yLjItVDJWLUExNEItRGlmZnVzZXJzJTIyJTJDJTBBJTIwJTIwdmFlJTNEdmFlJTBBJTIwJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5iZmxvYXQxNiUyQyUwQSUyMCUyMGRldmljZV9tYXAlM0QlMjJjdWRhJTIyJTBBKSUwQSUwQXByb21wdCUyMCUzRCUyMCUyMiUyMiUyMiUwQUNpbmVtYXRpYyUyMHZpZGVvJTIwb2YlMjBhJTIwc2xlZWslMjBjYXQlMjBsb3VuZ2luZyUyMG9uJTIwYSUyMGNvbG9yZnVsJTIwaW5mbGF0YWJsZSUyMGluJTIwYSUyMGNyeXN0YWwtY2xlYXIlMjB0dXJxdW9pc2UlMjBwb29sJTIwaW4lMjBQYWxtJTIwU3ByaW5ncyUyQyUyMCUwQXNpcHBpbmclMjBhJTIwc2FsdC1yaW1tZWQlMjBtYXJnYXJpdGElMjB0aHJvdWdoJTIwYSUyMHN0cmF3LiUyMEdvbGRlbi1ob3VyJTIwc3VubGlnaHQlMjBnbG93cyUyMG92ZXIlMjBtaWQtY2VudHVyeSUyMG1vZGVybiUyMGhvbWVzJTIwYW5kJTIwc3dheWluZyUyMHBhbG1zLiUyMCUwQVNob3QlMjBpbiUyMHJpY2glMjBTb255JTIwYTdTJTIwSUlJJTNBJTIwd2l0aCUyMG1vb2R5JTJDJTIwZ2xhbW9yb3VzJTIwY29sb3IlMjBncmFkaW5nJTJDJTIwc3VidGxlJTIwbGVucyUyMGZsYXJlcyUyQyUyMGFuZCUyMHNvZnQlMjB2aW50YWdlJTIwZmlsbSUyMGdyYWluLiUyMCUwQVJpcHBsZXMlMjBzaGltbWVyJTIwYXMlMjBhJTIwd2FybSUyMGRlc2VydCUyMGJyZWV6ZSUyMHN0aXJzJTIwdGhlJTIwd2F0ZXIlMkMlMjBibGVuZGluZyUyMGx1eHVyeSUyMGFuZCUyMHBsYXlmdWwlMjBjaGFybSUyMGluJTIwYW4lMjBlcGljJTJDJTIwZ29yZ2VvdXNseSUyMGNvbXBvc2VkJTIwZnJhbWUuJTBBJTIyJTIyJTIyJTBBdmlkZW8lMjAlM0QlMjBwaXBlbGluZShwcm9tcHQlM0Rwcm9tcHQlMkMlMjBudW1fZnJhbWVzJTNEODElMkMlMjBudW1faW5mZXJlbmNlX3N0ZXBzJTNENDApLmZyYW1lcyU1QjAlNUQlMEFleHBvcnRfdG9fdmlkZW8odmlkZW8lMkMlMjAlMjJvdXRwdXQubXA0JTIyJTJDJTIwZnBzJTNEMTYp",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,y=s(),d(f.$$.fragment)},l(n){p=m(n,"P",{"data-svelte-h":!0}),u(p)!=="svelte-u41lat"&&(p.innerHTML=T),y=i(n),M(f.$$.fragment,n)},m(n,c){a(n,p,c),a(n,y,c),h(f,n,c),o=!0},p:Bt,i(n){o||(J(f.$$.fragment,n),o=!0)},o(n){w(f.$$.fragment,n),o=!1},d(n){n&&(l(p),l(y)),b(f,n)}}}function zt(U){let p,T,y,f;return p=new Wt({props:{id:"diffusionpipeline",option:"text-to-image",$$slots:{default:[Vt]},$$scope:{ctx:U}}}),y=new Wt({props:{id:"diffusionpipeline",option:"text-to-video",$$slots:{default:[xt]},$$scope:{ctx:U}}}),{c(){d(p.$$.fragment),T=s(),d(y.$$.fragment)},l(o){M(p.$$.fragment,o),T=i(o),M(y.$$.fragment,o)},m(o,n){h(p,o,n),a(o,T,n),h(y,o,n),f=!0},p(o,n){const c={};n&2&&(c.$$scope={dirty:n,ctx:o}),p.$set(c);const G={};n&2&&(G.$$scope={dirty:n,ctx:o}),y.$set(G)},i(o){f||(J(p.$$.fragment,o),J(y.$$.fragment,o),f=!0)},o(o){w(p.$$.fragment,o),w(y.$$.fragment,o),f=!1},d(o){o&&l(T),b(p,o),b(y,o)}}}function Ft(U){let p,T,y,f,o,n,c,G,v,Oe="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.",fe,W,et="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.",ye,B,tt="This Quickstart will give you an overview of Diffusers and get you up and generating quickly.",ce,g,lt='<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,I,at='Follow the <a href="./installation">Installation</a> guide to install Diffusers if it’s not already installed.',Me,C,he,$,st="A diffusion model combines multiple components to generate outputs in any modality based on an input, such as a text description, image or both.",Je,k,it="For a standard text-to-image model:",we,Q,nt="<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>",be,q,ot='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.',Te,_,pt='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.',Ue,Z,ge,Y,Ze,X,rt='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.',je,V,mt='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.',Ge,x,ve,z,ut='Check out the <a href="./tutorials/using_peft_for_inference">LoRA</a> docs or Adapters section to learn more.',We,F,Be,H,ft='<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.',Ie,S,yt='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.',Ce,R,ct='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.',$e,E,ke,N,dt='Take a look at the <a href="./quantization/overview">Quantization</a> section for more details.',Qe,L,qe,j,Mt='<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,D,ht="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.",Ye,P,Xe,A,Jt="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.",Ve,K,wt='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.',xe,O,bt='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.',ze,ee,Fe,te,Tt='Refer to the <a href="./optimization/memory">Reduce memory usage</a> docs to learn more about other memory reducing techniques.',He,le,Se,ae,Ut='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.',Re,se,gt='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.',Ee,ie,Zt='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.',Ne,ne,Le,oe,jt='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.',De,pe,Pe,ue,Ae;return o=new _t({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),c=new re({props:{title:"Quickstart",local:"quickstart",headingTag:"h1"}}),C=new re({props:{title:"DiffusionPipeline",local:"diffusionpipeline",headingTag:"h2"}}),Z=new Xt({props:{id:"diffusionpipeline",options:["text-to-image","text-to-video"],$$slots:{default:[zt]},$$scope:{ctx:U}}}),Y=new re({props:{title:"LoRA",local:"lora",headingTag:"h2"}}),x=new me({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}}),F=new re({props:{title:"Quantization",local:"quantization",headingTag:"h2"}}),E=new me({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwRGlmZnVzaW9uUGlwZWxpbmUlMEFmcm9tJTIwZGlmZnVzZXJzLnF1YW50aXplcnMlMjBpbXBvcnQlMjBQaXBlbGluZVF1YW50aXphdGlvbkNvbmZpZyUwQSUwQXF1YW50X2NvbmZpZyUyMCUzRCUyMFBpcGVsaW5lUXVhbnRpemF0aW9uQ29uZmlnKCUwQSUyMCUyMHF1YW50X2JhY2tlbmQlM0QlMjJiaXRzYW5kYnl0ZXNfNGJpdCUyMiUyQyUwQSUyMCUyMHF1YW50X2t3YXJncyUzRCU3QiUyMmxvYWRfaW5fNGJpdCUyMiUzQSUyMFRydWUlMkMlMjAlMjJibmJfNGJpdF9xdWFudF90eXBlJTIyJTNBJTIwJTIybmY0JTIyJTJDJTIwJTIyYm5iXzRiaXRfY29tcHV0ZV9kdHlwZSUyMiUzQSUyMHRvcmNoLmJmbG9hdDE2JTdEJTJDJTBBJTIwJTIwY29tcG9uZW50c190b19xdWFudGl6ZSUzRCU1QiUyMnRyYW5zZm9ybWVyJTIyJTJDJTIwJTIydGV4dF9lbmNvZGVyJTIyJTVEJTJDJTBBKSUwQXBpcGVsaW5lJTIwJTNEJTIwRGlmZnVzaW9uUGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKCUwQSUyMCUyMCUyMlF3ZW4lMkZRd2VuLUltYWdlJTIyJTJDJTBBJTIwJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5iZmxvYXQxNiUyQyUwQSUyMCUyMHF1YW50aXphdGlvbl9jb25maWclM0RxdWFudF9jb25maWclMkMlMEElMjAlMjBkZXZpY2VfbWFwJTNEJTIyY3VkYSUyMiUwQSklMEElMEFwcm9tcHQlMjAlM0QlMjAlMjIlMjIlMjIlMEFjaW5lbWF0aWMlMjBmaWxtJTIwc3RpbGwlMjBvZiUyMGElMjBjYXQlMjBzaXBwaW5nJTIwYSUyMG1hcmdhcml0YSUyMGluJTIwYSUyMHBvb2wlMjBpbiUyMFBhbG0lMjBTcHJpbmdzJTJDJTIwQ2FsaWZvcm5pYSUwQWhpZ2hseSUyMGRldGFpbGVkJTJDJTIwaGlnaCUyMGJ1ZGdldCUyMGhvbGx5d29vZCUyMG1vdmllJTJDJTIwY2luZW1hc2NvcGUlMkMlMjBtb29keSUyQyUyMGVwaWMlMkMlMjBnb3JnZW91cyUyQyUyMGZpbG0lMjBncmFpbiUwQSUyMiUyMiUyMiUwQXBpcGVsaW5lKHByb21wdCkuaW1hZ2VzJTVCMCU1RCUwQXByaW50KGYlMjJNYXglMjBtZW1vcnklMjByZXNlcnZlZCUzQSUyMCU3QnRvcmNoLmN1ZGEubWF4X21lbW9yeV9hbGxvY2F0ZWQoKSUyMCUyRiUyMDEwMjQqKjMlM0EuMmYlN0QlMjBHQiUyMik=",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}}),L=new re({props:{title:"Optimizations",local:"optimizations",headingTag:"h2"}}),P=new re({props:{title:"Memory usage",local:"memory-usage",headingTag:"h3"}}),ee=new me({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}}),le=new re({props:{title:"Inference speed",local:"inference-speed",headingTag:"h3"}}),ne=new me({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}}),pe=new Yt({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/quicktour.md"}}),{c(){p=r("meta"),T=s(),y=r("p"),f=s(),d(o.$$.fragment),n=s(),d(c.$$.fragment),G=s(),v=r("p"),v.textContent=Oe,fe=s(),W=r("p"),W.textContent=et,ye=s(),B=r("p"),B.textContent=tt,ce=s(),g=r("blockquote"),g.innerHTML=lt,de=s(),I=r("p"),I.innerHTML=at,Me=s(),d(C.$$.fragment),he=s(),$=r("p"),$.textContent=st,Je=s(),k=r("p"),k.textContent=it,we=s(),Q=r("ol"),Q.innerHTML=nt,be=s(),q=r("p"),q.innerHTML=ot,Te=s(),_=r("p"),_.innerHTML=pt,Ue=s(),d(Z.$$.fragment),ge=s(),d(Y.$$.fragment),Ze=s(),X=r("p"),X.innerHTML=rt,je=s(),V=r("p"),V.innerHTML=mt,Ge=s(),d(x.$$.fragment),ve=s(),z=r("p"),z.innerHTML=ut,We=s(),d(F.$$.fragment),Be=s(),H=r("p"),H.innerHTML=ft,Ie=s(),S=r("p"),S.innerHTML=yt,Ce=s(),R=r("p"),R.innerHTML=ct,$e=s(),d(E.$$.fragment),ke=s(),N=r("p"),N.innerHTML=dt,Qe=s(),d(L.$$.fragment),qe=s(),j=r("blockquote"),j.innerHTML=Mt,_e=s(),D=r("p"),D.textContent=ht,Ye=s(),d(P.$$.fragment),Xe=s(),A=r("p"),A.textContent=Jt,Ve=s(),K=r("p"),K.innerHTML=wt,xe=s(),O=r("p"),O.innerHTML=bt,ze=s(),d(ee.$$.fragment),Fe=s(),te=r("p"),te.innerHTML=Tt,He=s(),d(le.$$.fragment),Se=s(),ae=r("p"),ae.innerHTML=Ut,Re=s(),se=r("p"),se.innerHTML=gt,Ee=s(),ie=r("p"),ie.innerHTML=Zt,Ne=s(),d(ne.$$.fragment),Le=s(),oe=r("p"),oe.innerHTML=jt,De=s(),d(pe.$$.fragment),Pe=s(),ue=r("p"),this.h()},l(e){const t=Qt("svelte-u9bgzb",document.head);p=m(t,"META",{name:!0,content:!0}),t.forEach(l),T=i(e),y=m(e,"P",{}),vt(y).forEach(l),f=i(e),M(o.$$.fragment,e),n=i(e),M(c.$$.fragment,e),G=i(e),v=m(e,"P",{"data-svelte-h":!0}),u(v)!=="svelte-56xior"&&(v.textContent=Oe),fe=i(e),W=m(e,"P",{"data-svelte-h":!0}),u(W)!=="svelte-st2d2w"&&(W.textContent=et),ye=i(e),B=m(e,"P",{"data-svelte-h":!0}),u(B)!=="svelte-ty6z9h"&&(B.textContent=tt),ce=i(e),g=m(e,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),u(g)!=="svelte-w6bpb7"&&(g.innerHTML=lt),de=i(e),I=m(e,"P",{"data-svelte-h":!0}),u(I)!=="svelte-1mbmwu"&&(I.innerHTML=at),Me=i(e),M(C.$$.fragment,e),he=i(e),$=m(e,"P",{"data-svelte-h":!0}),u($)!=="svelte-1uey2wy"&&($.textContent=st),Je=i(e),k=m(e,"P",{"data-svelte-h":!0}),u(k)!=="svelte-1p4ihn"&&(k.textContent=it),we=i(e),Q=m(e,"OL",{"data-svelte-h":!0}),u(Q)!=="svelte-107s2nd"&&(Q.innerHTML=nt),be=i(e),q=m(e,"P",{"data-svelte-h":!0}),u(q)!=="svelte-1qjx1u4"&&(q.innerHTML=ot),Te=i(e),_=m(e,"P",{"data-svelte-h":!0}),u(_)!=="svelte-10q00fi"&&(_.innerHTML=pt),Ue=i(e),M(Z.$$.fragment,e),ge=i(e),M(Y.$$.fragment,e),Ze=i(e),X=m(e,"P",{"data-svelte-h":!0}),u(X)!=="svelte-jua4gq"&&(X.innerHTML=rt),je=i(e),V=m(e,"P",{"data-svelte-h":!0}),u(V)!=="svelte-1hfi3jb"&&(V.innerHTML=mt),Ge=i(e),M(x.$$.fragment,e),ve=i(e),z=m(e,"P",{"data-svelte-h":!0}),u(z)!=="svelte-1ghzmtu"&&(z.innerHTML=ut),We=i(e),M(F.$$.fragment,e),Be=i(e),H=m(e,"P",{"data-svelte-h":!0}),u(H)!=="svelte-ba18t5"&&(H.innerHTML=ft),Ie=i(e),S=m(e,"P",{"data-svelte-h":!0}),u(S)!=="svelte-hvktkn"&&(S.innerHTML=yt),Ce=i(e),R=m(e,"P",{"data-svelte-h":!0}),u(R)!=="svelte-1kz2xjb"&&(R.innerHTML=ct),$e=i(e),M(E.$$.fragment,e),ke=i(e),N=m(e,"P",{"data-svelte-h":!0}),u(N)!=="svelte-lj8jhg"&&(N.innerHTML=dt),Qe=i(e),M(L.$$.fragment,e),qe=i(e),j=m(e,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),u(j)!=="svelte-1vyk5nr"&&(j.innerHTML=Mt),_e=i(e),D=m(e,"P",{"data-svelte-h":!0}),u(D)!=="svelte-17bpo15"&&(D.textContent=ht),Ye=i(e),M(P.$$.fragment,e),Xe=i(e),A=m(e,"P",{"data-svelte-h":!0}),u(A)!=="svelte-1bcil2"&&(A.textContent=Jt),Ve=i(e),K=m(e,"P",{"data-svelte-h":!0}),u(K)!=="svelte-1udfe87"&&(K.innerHTML=wt),xe=i(e),O=m(e,"P",{"data-svelte-h":!0}),u(O)!=="svelte-15somwy"&&(O.innerHTML=bt),ze=i(e),M(ee.$$.fragment,e),Fe=i(e),te=m(e,"P",{"data-svelte-h":!0}),u(te)!=="svelte-ad4p4e"&&(te.innerHTML=Tt),He=i(e),M(le.$$.fragment,e),Se=i(e),ae=m(e,"P",{"data-svelte-h":!0}),u(ae)!=="svelte-1cvq90h"&&(ae.innerHTML=Ut),Re=i(e),se=m(e,"P",{"data-svelte-h":!0}),u(se)!=="svelte-1teo5ea"&&(se.innerHTML=gt),Ee=i(e),ie=m(e,"P",{"data-svelte-h":!0}),u(ie)!=="svelte-17t31gw"&&(ie.innerHTML=Zt),Ne=i(e),M(ne.$$.fragment,e),Le=i(e),oe=m(e,"P",{"data-svelte-h":!0}),u(oe)!=="svelte-1f7t84p"&&(oe.innerHTML=jt),De=i(e),M(pe.$$.fragment,e),Pe=i(e),ue=m(e,"P",{}),vt(ue).forEach(l),this.h()},h(){Ke(p,"name","hf:doc:metadata"),Ke(p,"content",Ht),Ke(g,"class","tip"),Ke(j,"class","tip")},m(e,t){qt(document.head,p),a(e,T,t),a(e,y,t),a(e,f,t),h(o,e,t),a(e,n,t),h(c,e,t),a(e,G,t),a(e,v,t),a(e,fe,t),a(e,W,t),a(e,ye,t),a(e,B,t),a(e,ce,t),a(e,g,t),a(e,de,t),a(e,I,t),a(e,Me,t),h(C,e,t),a(e,he,t),a(e,$,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),a(e,_,t),a(e,Ue,t),h(Z,e,t),a(e,ge,t),h(Y,e,t),a(e,Ze,t),a(e,X,t),a(e,je,t),a(e,V,t),a(e,Ge,t),h(x,e,t),a(e,ve,t),a(e,z,t),a(e,We,t),h(F,e,t),a(e,Be,t),a(e,H,t),a(e,Ie,t),a(e,S,t),a(e,Ce,t),a(e,R,t),a(e,$e,t),h(E,e,t),a(e,ke,t),a(e,N,t),a(e,Qe,t),h(L,e,t),a(e,qe,t),a(e,j,t),a(e,_e,t),a(e,D,t),a(e,Ye,t),h(P,e,t),a(e,Xe,t),a(e,A,t),a(e,Ve,t),a(e,K,t),a(e,xe,t),a(e,O,t),a(e,ze,t),h(ee,e,t),a(e,Fe,t),a(e,te,t),a(e,He,t),h(le,e,t),a(e,Se,t),a(e,ae,t),a(e,Re,t),a(e,se,t),a(e,Ee,t),a(e,ie,t),a(e,Ne,t),h(ne,e,t),a(e,Le,t),a(e,oe,t),a(e,De,t),h(pe,e,t),a(e,Pe,t),a(e,ue,t),Ae=!0},p(e,[t]){const Gt={};t&2&&(Gt.$$scope={dirty:t,ctx:e}),Z.$set(Gt)},i(e){Ae||(J(o.$$.fragment,e),J(c.$$.fragment,e),J(C.$$.fragment,e),J(Z.$$.fragment,e),J(Y.$$.fragment,e),J(x.$$.fragment,e),J(F.$$.fragment,e),J(E.$$.fragment,e),J(L.$$.fragment,e),J(P.$$.fragment,e),J(ee.$$.fragment,e),J(le.$$.fragment,e),J(ne.$$.fragment,e),J(pe.$$.fragment,e),Ae=!0)},o(e){w(o.$$.fragment,e),w(c.$$.fragment,e),w(C.$$.fragment,e),w(Z.$$.fragment,e),w(Y.$$.fragment,e),w(x.$$.fragment,e),w(F.$$.fragment,e),w(E.$$.fragment,e),w(L.$$.fragment,e),w(P.$$.fragment,e),w(ee.$$.fragment,e),w(le.$$.fragment,e),w(ne.$$.fragment,e),w(pe.$$.fragment,e),Ae=!1},d(e){e&&(l(T),l(y),l(f),l(n),l(G),l(v),l(fe),l(W),l(ye),l(B),l(ce),l(g),l(de),l(I),l(Me),l(he),l($),l(Je),l(k),l(we),l(Q),l(be),l(q),l(Te),l(_),l(Ue),l(ge),l(Ze),l(X),l(je),l(V),l(Ge),l(ve),l(z),l(We),l(Be),l(H),l(Ie),l(S),l(Ce),l(R),l($e),l(ke),l(N),l(Qe),l(qe),l(j),l(_e),l(D),l(Ye),l(Xe),l(A),l(Ve),l(K),l(xe),l(O),l(ze),l(Fe),l(te),l(He),l(Se),l(ae),l(Re),l(se),l(Ee),l(ie),l(Ne),l(Le),l(oe),l(De),l(Pe),l(ue)),l(p),b(o,e),b(c,e),b(C,e),b(Z,e),b(Y,e),b(x,e),b(F,e),b(E,e),b(L,e),b(P,e),b(ee,e),b(le,e),b(ne,e),b(pe,e)}}}const Ht='{"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 St(U){return Ct(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class At extends $t{constructor(p){super(),kt(this,p,St,Ft,It,{})}}export{At as component};
