Buckets:

download
raw
19 kB
import"../chunks/DsnmJJEf.js";import{i as j,h as G,C as W,H as s,a as w,D as o,E as R,s as I}from"../chunks/BtE7mKSK.js";import{p as B,o as z,s as e,f as E,a as V,b as F,c as t,d as X,n,r as i}from"../chunks/jDjavuwI.js";const Y='{"title":"LTX2VideoDiffusionDecoderModel","local":"ltx2videodiffusiondecodermodel","sections":[{"title":"Attention backends","local":"attention-backends","sections":[],"depth":2},{"title":"Tiling","local":"tiling","sections":[],"depth":2},{"title":"LTX2VideoDiffusionDecoderModel","local":"diffusers.LTX2VideoDiffusionDecoderModel","sections":[],"depth":2}],"depth":1}';var H=X('<meta name="hf:doc:metadata"/>'),C=X(`<p></p> <!> <!> <p>The diffusion video decoder introduced in LTX-2.5 by Lightricks. Neighborhood-attention stages
upsample the latent into a context volume, and a final stage denoises pixels conditioned on that context.</p> <p>It is a decoder, not an autoencoder: encoding stays with <a href="/docs/diffusers/pr_14386/en/api/models/autoencoderkl_ltx_2#diffusers.AutoencoderKLLTX2Video">AutoencoderKLLTX2Video</a>, whose latent space this
consumes unchanged, so latents are interchangeable between the convolutional decoder and this one. Because it is
itself a diffusion model it is driven by <a href="/docs/diffusers/pr_14386/en/api/pipelines/ltx2#diffusers.LTX2VideoDiffusionDecodePipeline">LTX2VideoDiffusionDecodePipeline</a> rather than being passed as a
pipeline’s <code>vae</code>: run any LTX-2 pipeline with <code>output_type="latent"</code>, then decode.</p> <!> <p><code>vae</code> is an optional component on the decode pipeline: it is only consulted for the latent statistics when <code>denormalize=True</code>, and the decoder carries its own, so a decode-only workflow does not have to load a second
autoencoder.</p> <!> <p>The neighborhood-attention window is expressed as a <code>BlockMask</code>, so the decoder runs on the <code>flex</code> attention
backend by default and needs no extra dependency. PyTorch does not compile <code>flex_attention</code> unless you ask it to,
and uncompiled it materializes the full score matrix — which is impractical at full-resolution sequence lengths.
For those, either compile the decoder or switch to <a href="https://github.com/SHI-Labs/NATTEN" rel="nofollow">NATTEN</a>’s kernels, which
are also what the original implementation uses. The processor fetches NATTEN from the Hub
(<a href="https://huggingface.co/shi-labs/natten" rel="nofollow"><code>shi-labs/natten</code></a>) through the <a href="https://github.com/huggingface/kernels" rel="nofollow"><code>kernels</code></a> package, so it needs <code>pip install kernels</code> rather than a local
NATTEN build:</p> <!> <p>Fetching the kernel downloads code from the Hub, so the processor raises when remote code is disabled globally with <code>DIFFUSERS_DISABLE_REMOTE_CODE=true</code>.</p> <p>Every attention module in the decoder is the same neighborhood attention (per-stage differences like the kernel
size live on the module, not the processor), so <code>set_attn_processor</code> swaps them all with one shared instance.</p> <p>Switching the <em>backend</em> (<code>decoder.set_attention_backend(...)</code>) to anything but <code>flex</code> raises: no other backend
accepts the <code>BlockMask</code>. Use the NATTEN processor above instead.</p> <!> <p><code>decoder.enable_tiling()</code> decodes in overlapping tiles that are blended back together, bounding peak memory by the
tile size instead of the video size. The cheap early upsampling stages still see the full latent — only the last
upsampling stage and the diffusion stage, which dominate decode memory, run per tile — so tiling changes the output
only near tile borders. Because the diffusion stage denoises each tile separately, a tiled decode does not
reproduce the untiled result exactly; the default tile and overlap sizes match the reference implementation’s.
Neighborhood attention rejects any grid smaller than its kernel, so a trailing remnant tile is merged into its
neighbor rather than decoded on its own.</p> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>The LTX-2 diffusion video decoder, introduced in LTX-2.5.</p> <p>This is a decoder, not an autoencoder: it has no encoder and cannot produce latents. Encoding stays with <a href="/docs/diffusers/pr_14386/en/api/models/autoencoderkl_ltx_2#diffusers.AutoencoderKLLTX2Video">AutoencoderKLLTX2Video</a>, whose latent space this consumes unchanged, so latents are interchangeable between the
convolutional decoder and this one.</p> <p>It is also a diffusion model rather than a deterministic decoder — it denoises pixels conditioned on a context
volume built from the latents — which is why it is driven by <a href="/docs/diffusers/pr_14386/en/api/pipelines/ltx2#diffusers.LTX2VideoDiffusionDecodePipeline">LTX2VideoDiffusionDecodePipeline</a> rather than being
passed as a pipeline’s <code>vae</code>.</p> <p>The latent statistics are carried here as buffers so the decode pipeline can denormalize without loading a second
autoencoder just for two vectors.</p> <p>This model inherits from <a href="/docs/diffusers/pr_14386/en/api/models/overview#diffusers.ModelMixin">ModelMixin</a>. Check the superclass documentation for it’s generic methods implemented
for all models (such as downloading or saving).</p> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Decode a batch of latents.</p> <p><code>z</code> is expected to be denormalized already (the pipeline applies <code>latents_mean</code> / <code>latents_std</code>), matching <a href="/docs/diffusers/pr_14386/en/api/models/autoencoderkl_ltx_2#diffusers.AutoencoderKLLTX2Video">AutoencoderKLLTX2Video</a>. This decoder denoises, so pass <code>generator</code> for reproducibility.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Enable tiled decoding. The deterministic upsampling stages before the last one always process the full latent
(they run at low resolution and are cheap); the last stage and the stage-5 diffusion blocks — which dominate
decode memory — run on overlapping tiles whose seams are blended linearly.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Disable tiled decoding, returning to decoding the whole video in one pass.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Decode a batch of latents with the last deterministic stage and the diffusion stage running per tile.</p> <p>Tiles live on the grid entering the last deterministic stage, where one cell maps to a fixed block of output
pixels; the <code>tile_sample_*</code> sizes are converted to that grid, so they should be multiples of the cell size (8
px spatially and 2 frames temporally for the production config). Temporal tiles follow the causal frame
mapping: the tile containing t=0 drops the temporal upsample’s duplicate leading frame and only the tile
containing the video end carries the NATTEN border padding.</p></div></div> <!> <p></p>`,1);function q(k,D){B(D,!1),z(()=>{new URLSearchParams(window.location.search).get("fw")}),j();var p=C();G("qizexe",T=>{var M=H();I(M,"content",Y),V(T,M)});var h=e(E(p),2);W(h,{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"});var m=e(h,2);s(m,{title:"LTX2VideoDiffusionDecoderModel",local:"ltx2videodiffusiondecodermodel",headingTag:"h1"});var u=e(m,6);w(u,{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwTFRYMlBpcGVsaW5lJTJDJTIwTFRYMlZpZGVvRGlmZnVzaW9uRGVjb2RlUGlwZWxpbmUlMkMlMjBMVFgyVmlkZW9EaWZmdXNpb25EZWNvZGVyTW9kZWwlMEElMEFwaXBlJTIwJTNEJTIwTFRYMlBpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMjJMaWdodHJpY2tzJTJGTFRYLTIuNS1EaWZmdXNlcnMlMjIlMkMlMjBkdHlwZSUzRHRvcmNoLmJmbG9hdDE2KS50byglMjJjdWRhJTIyKSUwQWxhdGVudHMlMjAlM0QlMjBwaXBlKHByb21wdCUzRCUyMmElMjBwb3R0ZXIlMjBzaGFwaW5nJTIwYSUyMGNsYXklMjB2YXNlJTIyJTJDJTIwb3V0cHV0X3R5cGUlM0QlMjJsYXRlbnQlMjIpLmZyYW1lcyUwQSUwQWRlY29kZXIlMjAlM0QlMjBMVFgyVmlkZW9EaWZmdXNpb25EZWNvZGVyTW9kZWwuZnJvbV9wcmV0cmFpbmVkKCUwQSUyMCUyMCUyMCUyMCUyMkxpZ2h0cmlja3MlMkZMVFgtMi41LURpZmZ1c2VycyUyMiUyQyUyMHN1YmZvbGRlciUzRCUyMmRpZmZ1c2lvbl9kZWNvZGVyJTIyJTJDJTIwZHR5cGUlM0R0b3JjaC5iZmxvYXQxNiUwQSkudG8oJTIyY3VkYSUyMiklMEFkZWNvZGVfcGlwZSUyMCUzRCUyMExUWDJWaWRlb0RpZmZ1c2lvbkRlY29kZVBpcGVsaW5lKGRpZmZ1c2lvbl9kZWNvZGVyJTNEZGVjb2RlciUyQyUyMHNjaGVkdWxlciUzRHBpcGUuc2NoZWR1bGVyKSUwQSUwQSUyMyUyMCU2MGRlbm9ybWFsaXplJTNERmFsc2UlNjAlM0ElMjAlNjBvdXRwdXRfdHlwZSUzRCUyMmxhdGVudCUyMiU2MCUyMGFscmVhZHklMjBhcHBsaWVkJTIwdGhlJTIwbGF0ZW50JTIwc3RhdGlzdGljcyUyQyUyMHNvJTIwYXBwbHlpbmclMjB0aGVtJTBBJTIzJTIwYWdhaW4lMjBoZXJlJTIwd291bGQlMjBzY2FsZSUyMGV2ZXJ5JTIwY2hhbm5lbCUyMGJ5JTIwaXRzJTIwc3RkJTIwYSUyMHNlY29uZCUyMHRpbWUuJTBBJTIzJTIwVGhlJTIwZGVjb2RlciUyMGFsc28lMjBkcmF3cyUyMHRoZSUyMG5vaXNlJTIwaXQlMjBkZW5vaXNlcyUyQyUyMHNvJTIwZGVjb2RpbmclMjBpcyUyMG9ubHklMjByZXByb2R1Y2libGUlMjB3aXRoJTIwYSUyMGdlbmVyYXRvci4lMEF2aWRlbyUyMCUzRCUyMGRlY29kZV9waXBlKCUwQSUyMCUyMCUyMCUyMGxhdGVudHMlMkMlMjBnZW5lcmF0b3IlM0R0b3JjaC5HZW5lcmF0b3IoJTIyY3VkYSUyMikubWFudWFsX3NlZWQoMCklMkMlMjBkZW5vcm1hbGl6ZSUzREZhbHNlJTBBKS5mcmFtZXMlNUIwJTVE",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> LTX2Pipeline, LTX2VideoDiffusionDecodePipeline, LTX2VideoDiffusionDecoderModel
pipe = LTX2Pipeline.from_pretrained(<span class="hljs-string">&quot;Lightricks/LTX-2.5-Diffusers&quot;</span>, dtype=torch.bfloat16).to(<span class="hljs-string">&quot;cuda&quot;</span>)
latents = pipe(prompt=<span class="hljs-string">&quot;a potter shaping a clay vase&quot;</span>, output_type=<span class="hljs-string">&quot;latent&quot;</span>).frames
decoder = LTX2VideoDiffusionDecoderModel.from_pretrained(
<span class="hljs-string">&quot;Lightricks/LTX-2.5-Diffusers&quot;</span>, subfolder=<span class="hljs-string">&quot;diffusion_decoder&quot;</span>, dtype=torch.bfloat16
).to(<span class="hljs-string">&quot;cuda&quot;</span>)
decode_pipe = LTX2VideoDiffusionDecodePipeline(diffusion_decoder=decoder, scheduler=pipe.scheduler)
<span class="hljs-comment"># \`denormalize=False\`: \`output_type=&quot;latent&quot;\` already applied the latent statistics, so applying them</span>
<span class="hljs-comment"># again here would scale every channel by its std a second time.</span>
<span class="hljs-comment"># The decoder also draws the noise it denoises, so decoding is only reproducible with a generator.</span>
video = decode_pipe(
latents, generator=torch.Generator(<span class="hljs-string">&quot;cuda&quot;</span>).manual_seed(<span class="hljs-number">0</span>), denormalize=<span class="hljs-literal">False</span>
).frames[<span class="hljs-number">0</span>]`,lang:"python",wrap:!1});var f=e(u,4);s(f,{title:"Attention backends",local:"attention-backends",headingTag:"h2"});var _=e(f,4);w(_,{code:"ZnJvbSUyMGRpZmZ1c2Vycy5tb2RlbHMuYXV0b2VuY29kZXJzLmx0eDJfZGlmZnVzaW9uX2RlY29kZXIlMjBpbXBvcnQlMjBMVFgyVmlkZW9WYWVOZWlnaGJvcmhvb2ROYXR0ZW5Qcm9jZXNzb3IlMEElMEFkZWNvZGVyLnNldF9hdHRuX3Byb2Nlc3NvcihMVFgyVmlkZW9WYWVOZWlnaGJvcmhvb2ROYXR0ZW5Qcm9jZXNzb3IoKSk=",highlighted:`<span class="hljs-keyword">from</span> diffusers.models.autoencoders.ltx2_diffusion_decoder <span class="hljs-keyword">import</span> LTX2VideoVaeNeighborhoodNattenProcessor
decoder.set_attn_processor(LTX2VideoVaeNeighborhoodNattenProcessor())`,lang:"python",wrap:!1});var g=e(_,8);s(g,{title:"Tiling",local:"tiling",headingTag:"h2"});var b=e(g,4);s(b,{title:"LTX2VideoDiffusionDecoderModel",local:"diffusers.LTX2VideoDiffusionDecoderModel",headingTag:"h2"});var a=e(b,2),y=t(a);o(y,{name:"class diffusers.LTX2VideoDiffusionDecoderModel",anchor:"diffusers.LTX2VideoDiffusionDecoderModel",source:"https://github.com/huggingface/diffusers/blob/vr_14386/src/diffusers/models/autoencoders/ltx2_diffusion_decoder.py#L700",parameters:[{name:"out_channels",val:": int = 3"},{name:"latent_channels",val:": int = 128"},{name:"patch_size",val:": int = 4"},{name:"scaling_factor",val:": float = 1.0"},{name:"decoder_head_dim",val:": int = 64"},{name:"decoder_stage_channels",val:": tuple = (2048, 1024, 512, 512, 256)"},{name:"decoder_stage_depths",val:": tuple = (4, 6, 4, 2, 8)"},{name:"decoder_stage_kernels",val:": tuple = ((3, 7, 7), (3, 7, 7), (3, 5, 5), (3, 5, 5))"},{name:"decoder_upsample_strides",val:": tuple = ((1, 2, 2), (2, 1, 1), (2, 2, 2), (2, 2, 2))"},{name:"decoder_upsample_channel_reductions",val:": tuple = (2, 2, 1, 2)"},{name:"decoder_stage5_kernel",val:": tuple = (11, 11, 11)"},{name:"decoder_t_emb_dim",val:": int = 384"},{name:"decoder_timestep_scale_multiplier",val:": float = 1000.0"},{name:"decoder_model_output_type",val:": str = 'x0'"},{name:"decoder_num_inference_steps",val:": int = 1"},{name:"spatial_compression_ratio",val:": int = 32"},{name:"temporal_compression_ratio",val:": int = 8"}]});var d=e(y,12),Z=t(d);o(Z,{name:"decode",anchor:"diffusers.LTX2VideoDiffusionDecoderModel.decode",source:"https://github.com/huggingface/diffusers/blob/vr_14386/src/diffusers/models/autoencoders/ltx2_diffusion_decoder.py#L988",parameters:[{name:"z",val:": Tensor"},{name:"generator",val:": typing.Optional[torch.Generator] = None"},{name:"num_inference_steps",val:": int | None = None"},{name:"return_dict",val:": bool = True"}]}),n(4),i(d);var l=e(d,2),L=t(l);o(L,{name:"enable_tiling",anchor:"diffusers.LTX2VideoDiffusionDecoderModel.enable_tiling",source:"https://github.com/huggingface/diffusers/blob/vr_14386/src/diffusers/models/autoencoders/ltx2_diffusion_decoder.py#L787",parameters:[{name:"tile_sample_min_height",val:": int | None = None"},{name:"tile_sample_min_width",val:": int | None = None"},{name:"tile_sample_min_num_frames",val:": int | None = None"},{name:"tile_sample_stride_height",val:": int | None = None"},{name:"tile_sample_stride_width",val:": int | None = None"},{name:"tile_sample_stride_num_frames",val:": int | None = None"}],parametersDescription:[{anchor:"diffusers.LTX2VideoDiffusionDecoderModel.enable_tiling.tile_sample_min_height",description:`<strong>tile_sample_min_height</strong> (<code>int</code>, <em>optional</em>) &#x2014;
The height of one decoded tile, in pixels.`,name:"tile_sample_min_height"},{anchor:"diffusers.LTX2VideoDiffusionDecoderModel.enable_tiling.tile_sample_min_width",description:`<strong>tile_sample_min_width</strong> (<code>int</code>, <em>optional</em>) &#x2014;
The width of one decoded tile, in pixels.`,name:"tile_sample_min_width"},{anchor:"diffusers.LTX2VideoDiffusionDecoderModel.enable_tiling.tile_sample_min_num_frames",description:`<strong>tile_sample_min_num_frames</strong> (<code>int</code>, <em>optional</em>) &#x2014;
The number of frames of one decoded tile.`,name:"tile_sample_min_num_frames"},{anchor:"diffusers.LTX2VideoDiffusionDecoderModel.enable_tiling.tile_sample_stride_height",description:`<strong>tile_sample_stride_height</strong> (<code>int</code>, <em>optional</em>) &#x2014;
The distance in pixels between the tops of two consecutive vertical tiles; the difference to
<code>tile_sample_min_height</code> is the blended overlap.`,name:"tile_sample_stride_height"},{anchor:"diffusers.LTX2VideoDiffusionDecoderModel.enable_tiling.tile_sample_stride_width",description:`<strong>tile_sample_stride_width</strong> (<code>int</code>, <em>optional</em>) &#x2014;
The distance in pixels between the left edges of two consecutive horizontal tiles.`,name:"tile_sample_stride_width"},{anchor:"diffusers.LTX2VideoDiffusionDecoderModel.enable_tiling.tile_sample_stride_num_frames",description:`<strong>tile_sample_stride_num_frames</strong> (<code>int</code>, <em>optional</em>) &#x2014;
The distance in frames between the starts of two consecutive temporal tiles.`,name:"tile_sample_stride_num_frames"}]}),n(2),i(l);var r=e(l,2),x=t(r);o(x,{name:"disable_tiling",anchor:"diffusers.LTX2VideoDiffusionDecoderModel.disable_tiling",source:"https://github.com/huggingface/diffusers/blob/vr_14386/src/diffusers/models/autoencoders/ltx2_diffusion_decoder.py#L824",parameters:[]}),n(2),i(r);var c=e(r,2),N=t(c);o(N,{name:"forward",anchor:"diffusers.LTX2VideoDiffusionDecoderModel.forward",source:"https://github.com/huggingface/diffusers/blob/vr_14386/src/diffusers/models/autoencoders/ltx2_diffusion_decoder.py#L1017",parameters:[{name:"z",val:": Tensor"},{name:"generator",val:": typing.Optional[torch.Generator] = None"},{name:"num_inference_steps",val:": int | None = None"},{name:"return_dict",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.LTX2VideoDiffusionDecoderModel.forward.z",description:`<strong>z</strong> (<code>torch.Tensor</code>) &#x2014;
Latents of shape <code>(B, C, F, H, W)</code>, expected to be denormalized already (the pipeline applies
<code>latents_mean</code> / <code>latents_std</code>), matching <a href="/docs/diffusers/pr_14386/en/api/models/autoencoderkl_ltx_2#diffusers.AutoencoderKLLTX2Video">AutoencoderKLLTX2Video</a>.`,name:"z"},{anchor:"diffusers.LTX2VideoDiffusionDecoderModel.forward.generator",description:`<strong>generator</strong> (<code>torch.Generator</code>, <em>optional</em>) &#x2014;
This decoder denoises, so pass a generator to make decoding reproducible.`,name:"generator"},{anchor:"diffusers.LTX2VideoDiffusionDecoderModel.forward.num_inference_steps",description:`<strong>num_inference_steps</strong> (<code>int</code>, <em>optional</em>) &#x2014;
Number of denoising steps. Defaults to the decoder&#x2019;s <code>decoder_num_inference_steps</code> config value.`,name:"num_inference_steps"},{anchor:"diffusers.LTX2VideoDiffusionDecoderModel.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to return a <a href="/docs/diffusers/pr_14386/en/api/models/autoencoderkl#diffusers.models.autoencoders.vae.DecoderOutput">DecoderOutput</a> instead of a plain tuple.`,name:"return_dict"}],returnType:`<script context="module">export const metadata = 'undefined';<\/script>
<p><a
href="/docs/diffusers/pr_14386/en/api/models/autoencoderkl#diffusers.models.autoencoders.vae.DecoderOutput"
>DecoderOutput</a> or <code>tuple</code></p>
`}),i(c);var v=e(c,2),U=t(v);o(U,{name:"tiled_decode",anchor:"diffusers.LTX2VideoDiffusionDecoderModel.tiled_decode",source:"https://github.com/huggingface/diffusers/blob/vr_14386/src/diffusers/models/autoencoders/ltx2_diffusion_decoder.py#L855",parameters:[{name:"z",val:": Tensor"},{name:"generator",val:": typing.Optional[torch.Generator] = None"},{name:"num_inference_steps",val:": int | None = None"}]}),n(4),i(v),i(a);var J=e(a,2);R(J,{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/models/ltx2_diffusion_decoder.md"}),n(2),V(k,p),F()}export{q as component};

Xet Storage Details

Size:
19 kB
·
Xet hash:
2811b0a2c64433b34e3530c533343b88272cb4eed9740ac0ebe2b8bb829b45b5

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.