---
title: wanvae
---

<div class="python-reference">
<a id="fastvideo.models.vaes.wanvae-classes"></a>
<a id="fastvideo.models.vaes.wanvae.AutoencoderKLWan-functions"></a>
<a id="fastvideo.models.vaes.wanvae.ParallelTiledVAE-functions"></a>
<a id="fastvideo.models.vaes.wanvae.WanResidualUpBlock-functions"></a>
<a id="fastvideo.models.vaes.wanvae.WanUpBlock-functions"></a>
<a id="fastvideo.models.vaes.wanvae"></a>
<p>Compatibility imports for the family-local Wan VAE.</p>
<p>Keep aliases, including the cache context variables, identical to the canonical
objects. New Wan code belongs in <code>fastvideo.models.wan.vae</code>.</p>
<h2 id="fastvideo.models.vaes.wanvae.AutoencoderKLWan"><code>fastvideo.models.vaes.wanvae.AutoencoderKLWan</code></h2>
<pre class="doc-signature"><code>AutoencoderKLWan(config: WanVAEConfig)</code></pre>
<p>A VAE model with KL loss for encoding videos into latents and decoding latent representations into videos.
Introduced in [Wan 2.1].</p>

<h3 id="fastvideo.models.vaes.wanvae.AutoencoderKLWan.clear_cache"><code>fastvideo.models.vaes.wanvae.AutoencoderKLWan.clear_cache</code></h3>
<pre class="doc-signature"><code>clear_cache() -&gt; None</code></pre>

<h3 id="fastvideo.models.vaes.wanvae.AutoencoderKLWan.optimize_memory_format"><code>fastvideo.models.vaes.wanvae.AutoencoderKLWan.optimize_memory_format</code></h3>
<pre class="doc-signature"><code>optimize_memory_format() -&gt; None</code></pre>
<p>Optional CUDA-only weight layout optimization used by MG3 LightVAE.</p>
<h3 id="fastvideo.models.vaes.wanvae.AutoencoderKLWan.encode"><code>fastvideo.models.vaes.wanvae.AutoencoderKLWan.encode</code></h3>
<pre class="doc-signature"><code>encode(x: torch.Tensor) -&gt; torch.Tensor</code></pre>

<h3 id="fastvideo.models.vaes.wanvae.AutoencoderKLWan.tiled_encode"><code>fastvideo.models.vaes.wanvae.AutoencoderKLWan.tiled_encode</code></h3>
<pre class="doc-signature"><code>tiled_encode(x: torch.Tensor) -&gt; torch.Tensor</code></pre>

<h3 id="fastvideo.models.vaes.wanvae.AutoencoderKLWan.spatial_tiled_encode"><code>fastvideo.models.vaes.wanvae.AutoencoderKLWan.spatial_tiled_encode</code></h3>
<pre class="doc-signature"><code>spatial_tiled_encode(x: torch.Tensor) -&gt; torch.Tensor</code></pre>

<h3 id="fastvideo.models.vaes.wanvae.AutoencoderKLWan.decode"><code>fastvideo.models.vaes.wanvae.AutoencoderKLWan.decode</code></h3>
<pre class="doc-signature"><code>decode(z: torch.Tensor) -&gt; torch.Tensor</code></pre>

<h3 id="fastvideo.models.vaes.wanvae.AutoencoderKLWan.tiled_decode"><code>fastvideo.models.vaes.wanvae.AutoencoderKLWan.tiled_decode</code></h3>
<pre class="doc-signature"><code>tiled_decode(z: torch.Tensor) -&gt; torch.Tensor</code></pre>

<h3 id="fastvideo.models.vaes.wanvae.AutoencoderKLWan.spatial_tiled_decode"><code>fastvideo.models.vaes.wanvae.AutoencoderKLWan.spatial_tiled_decode</code></h3>
<pre class="doc-signature"><code>spatial_tiled_decode(z: torch.Tensor) -&gt; torch.Tensor</code></pre>

<h3 id="fastvideo.models.vaes.wanvae.AutoencoderKLWan.parallel_tiled_decode"><code>fastvideo.models.vaes.wanvae.AutoencoderKLWan.parallel_tiled_decode</code></h3>
<pre class="doc-signature"><code>parallel_tiled_decode(z: torch.FloatTensor) -&gt; torch.FloatTensor</code></pre>

<h3 id="fastvideo.models.vaes.wanvae.AutoencoderKLWan.get_streaming_cache"><code>fastvideo.models.vaes.wanvae.AutoencoderKLWan.get_streaming_cache</code></h3>
<pre class="doc-signature"><code>get_streaming_cache() -&gt; list&#91;torch.Tensor | None&#93;</code></pre>

<h3 id="fastvideo.models.vaes.wanvae.AutoencoderKLWan.streaming_decode"><code>fastvideo.models.vaes.wanvae.AutoencoderKLWan.streaming_decode</code></h3>
<pre class="doc-signature"><code>streaming_decode(z: torch.Tensor, cache: list&#91;torch.Tensor | None&#93;, is_first_chunk: bool = False) -&gt; tuple&#91;torch.Tensor, list&#91;torch.Tensor | None&#93;&#93;</code></pre>
<h4>Parameters</h4>
<dl>
<dt><code>z: `torch.Tensor`</code></dt><dd><p>Latent tensor of shape [B, C, T, H, W].</p></dd>
<dt><code>cache: `list[torch.Tensor | None]`</code></dt><dd><p>The VAE cache.</p></dd>
<dt><code>is_first_chunk: `bool`</code></dt><dd><p>Whether this is the first chunk in the sequence.</p></dd>
</dl>
<h4>Returns</h4>
<dl>
<dt><code>tuple[torch.Tensor, list[torch.Tensor | None]]</code></dt><dd><p>A tuple of (decoded_frames, updated_cache).</p></dd>
</dl>
<h3 id="fastvideo.models.vaes.wanvae.AutoencoderKLWan.forward"><code>fastvideo.models.vaes.wanvae.AutoencoderKLWan.forward</code></h3>
<pre class="doc-signature"><code>forward(sample: torch.Tensor, sample_posterior: bool = False, generator: torch.Generator | None = None) -&gt; torch.Tensor</code></pre>
<h4>Parameters</h4>
<dl>
<dt><code>sample: `torch.Tensor`</code></dt><dd><p>Input sample.</p></dd>
<dt><code>return_dict: `bool`, *optional*, defaults to `True`</code></dt><dd><p>Whether or not to return a [<code>DecoderOutput</code>] instead of a plain tuple.</p></dd>
</dl>
<h2 id="fastvideo.models.vaes.wanvae.AvgDown3D"><code>fastvideo.models.vaes.wanvae.AvgDown3D</code></h2>
<pre class="doc-signature"><code>AvgDown3D(in_channels, out_channels, factor_t, factor_s = 1)</code></pre>


<h3 id="fastvideo.models.vaes.wanvae.AvgDown3D.forward"><code>fastvideo.models.vaes.wanvae.AvgDown3D.forward</code></h3>
<pre class="doc-signature"><code>forward(x: torch.Tensor) -&gt; torch.Tensor</code></pre>

<h2 id="fastvideo.models.vaes.wanvae.DiagonalGaussianDistribution"><code>fastvideo.models.vaes.wanvae.DiagonalGaussianDistribution</code></h2>
<pre class="doc-signature"><code>DiagonalGaussianDistribution(parameters: torch.Tensor, deterministic: bool = False)</code></pre>


<h3 id="fastvideo.models.vaes.wanvae.DiagonalGaussianDistribution.sample"><code>fastvideo.models.vaes.wanvae.DiagonalGaussianDistribution.sample</code></h3>
<pre class="doc-signature"><code>sample(generator: torch.Generator | None = None) -&gt; torch.Tensor</code></pre>

<h3 id="fastvideo.models.vaes.wanvae.DiagonalGaussianDistribution.kl"><code>fastvideo.models.vaes.wanvae.DiagonalGaussianDistribution.kl</code></h3>
<pre class="doc-signature"><code>kl(other: Optional&#91;DiagonalGaussianDistribution&#93; = None) -&gt; torch.Tensor</code></pre>

<h3 id="fastvideo.models.vaes.wanvae.DiagonalGaussianDistribution.nll"><code>fastvideo.models.vaes.wanvae.DiagonalGaussianDistribution.nll</code></h3>
<pre class="doc-signature"><code>nll(sample: torch.Tensor, dims: tuple&#91;int, ...&#93; = (1, 2, 3)) -&gt; torch.Tensor</code></pre>

<h3 id="fastvideo.models.vaes.wanvae.DiagonalGaussianDistribution.mode"><code>fastvideo.models.vaes.wanvae.DiagonalGaussianDistribution.mode</code></h3>
<pre class="doc-signature"><code>mode() -&gt; torch.Tensor</code></pre>

<h2 id="fastvideo.models.vaes.wanvae.DupUp3D"><code>fastvideo.models.vaes.wanvae.DupUp3D</code></h2>
<pre class="doc-signature"><code>DupUp3D(in_channels: int, out_channels: int, factor_t, factor_s = 1)</code></pre>


<h3 id="fastvideo.models.vaes.wanvae.DupUp3D.forward"><code>fastvideo.models.vaes.wanvae.DupUp3D.forward</code></h3>
<pre class="doc-signature"><code>forward(x: torch.Tensor) -&gt; torch.Tensor</code></pre>

<h2 id="fastvideo.models.vaes.wanvae.ParallelTiledVAE"><code>fastvideo.models.vaes.wanvae.ParallelTiledVAE</code></h2>
<pre class="doc-signature"><code>ParallelTiledVAE(config: VAEConfig, **kwargs)</code></pre>


<h3 id="fastvideo.models.vaes.wanvae.ParallelTiledVAE.to"><code>fastvideo.models.vaes.wanvae.ParallelTiledVAE.to</code></h3>
<pre class="doc-signature"><code>to(device) -&gt; ParallelTiledVAE</code></pre>

<h3 id="fastvideo.models.vaes.wanvae.ParallelTiledVAE.encode"><code>fastvideo.models.vaes.wanvae.ParallelTiledVAE.encode</code></h3>
<pre class="doc-signature"><code>encode(x: torch.Tensor) -&gt; torch.Tensor</code></pre>

<h3 id="fastvideo.models.vaes.wanvae.ParallelTiledVAE.decode"><code>fastvideo.models.vaes.wanvae.ParallelTiledVAE.decode</code></h3>
<pre class="doc-signature"><code>decode(z: torch.Tensor) -&gt; torch.Tensor</code></pre>

<h3 id="fastvideo.models.vaes.wanvae.ParallelTiledVAE.blend_v"><code>fastvideo.models.vaes.wanvae.ParallelTiledVAE.blend_v</code></h3>
<pre class="doc-signature"><code>blend_v(a: torch.Tensor, b: torch.Tensor, blend_extent: int) -&gt; torch.Tensor</code></pre>

<h3 id="fastvideo.models.vaes.wanvae.ParallelTiledVAE.blend_h"><code>fastvideo.models.vaes.wanvae.ParallelTiledVAE.blend_h</code></h3>
<pre class="doc-signature"><code>blend_h(a: torch.Tensor, b: torch.Tensor, blend_extent: int) -&gt; torch.Tensor</code></pre>

<h3 id="fastvideo.models.vaes.wanvae.ParallelTiledVAE.blend_t"><code>fastvideo.models.vaes.wanvae.ParallelTiledVAE.blend_t</code></h3>
<pre class="doc-signature"><code>blend_t(a: torch.Tensor, b: torch.Tensor, blend_extent: int) -&gt; torch.Tensor</code></pre>

<h3 id="fastvideo.models.vaes.wanvae.ParallelTiledVAE.spatial_tiled_encode"><code>fastvideo.models.vaes.wanvae.ParallelTiledVAE.spatial_tiled_encode</code></h3>
<pre class="doc-signature"><code>spatial_tiled_encode(x: torch.Tensor) -&gt; torch.Tensor</code></pre>
<p>Encode a batch of images using a tiled encoder.</p>
<h4>Parameters</h4>
<dl>
<dt><code>x: `torch.Tensor`</code></dt><dd><p>Input batch of videos.</p></dd>
</dl>
<h4>Returns</h4>
<dl>
<dt><code>torch.Tensor</code></dt><dd><p><code>torch.Tensor</code>:
The latent representation of the encoded videos.</p></dd>
</dl>
<h3 id="fastvideo.models.vaes.wanvae.ParallelTiledVAE.parallel_tiled_decode"><code>fastvideo.models.vaes.wanvae.ParallelTiledVAE.parallel_tiled_decode</code></h3>
<pre class="doc-signature"><code>parallel_tiled_decode(z: torch.FloatTensor) -&gt; torch.FloatTensor</code></pre>
<p>Parallel version of tiled_decode that distributes both temporal and spatial computation across GPUs</p>
<h3 id="fastvideo.models.vaes.wanvae.ParallelTiledVAE.spatial_tiled_decode"><code>fastvideo.models.vaes.wanvae.ParallelTiledVAE.spatial_tiled_decode</code></h3>
<pre class="doc-signature"><code>spatial_tiled_decode(z: torch.Tensor) -&gt; torch.Tensor</code></pre>
<p>Decode a batch of images using a tiled decoder.</p>
<h4>Parameters</h4>
<dl>
<dt><code>z: `torch.Tensor`</code></dt><dd><p>Input batch of latent vectors.</p></dd>
</dl>
<h4>Returns</h4>
<dl>
<dt><code>torch.Tensor</code></dt><dd><p><code>torch.Tensor</code>:
The decoded images.</p></dd>
</dl>
<h3 id="fastvideo.models.vaes.wanvae.ParallelTiledVAE.tiled_encode"><code>fastvideo.models.vaes.wanvae.ParallelTiledVAE.tiled_encode</code></h3>
<pre class="doc-signature"><code>tiled_encode(x: torch.Tensor) -&gt; torch.Tensor</code></pre>

<h3 id="fastvideo.models.vaes.wanvae.ParallelTiledVAE.tiled_decode"><code>fastvideo.models.vaes.wanvae.ParallelTiledVAE.tiled_decode</code></h3>
<pre class="doc-signature"><code>tiled_decode(z: torch.Tensor) -&gt; torch.Tensor</code></pre>

<h3 id="fastvideo.models.vaes.wanvae.ParallelTiledVAE.enable_tiling"><code>fastvideo.models.vaes.wanvae.ParallelTiledVAE.enable_tiling</code></h3>
<pre class="doc-signature"><code>enable_tiling(tile_sample_min_height: int | None = None, tile_sample_min_width: int | None = None, tile_sample_min_num_frames: int | None = None, tile_sample_stride_height: int | None = None, tile_sample_stride_width: int | None = None, tile_sample_stride_num_frames: int | None = None, blend_num_frames: int | None = None, use_tiling: bool | None = None, use_temporal_tiling: bool | None = None, use_parallel_tiling: bool | None = None) -&gt; None</code></pre>
<p>Enable tiled VAE decoding. When this option is enabled, the VAE will split the input tensor into tiles to
compute decoding and encoding in several steps. This is useful for saving a large amount of memory and to allow
processing larger images.</p>
<h4>Parameters</h4>
<dl>
<dt><code>tile_sample_min_height: `int`, *optional*</code></dt><dd><p>The minimum height required for a sample to be separated into tiles across the height dimension.</p></dd>
<dt><code>tile_sample_min_width: `int`, *optional*</code></dt><dd><p>The minimum width required for a sample to be separated into tiles across the width dimension.</p></dd>
<dt><code>tile_sample_min_num_frames: `int`, *optional*</code></dt><dd><p>The minimum number of frames required for a sample to be separated into tiles across the frame
dimension.</p></dd>
<dt><code>tile_sample_stride_height: `int`, *optional*</code></dt><dd><p>The minimum amount of overlap between two consecutive vertical tiles. This is to ensure that there are
no tiling artifacts produced across the height dimension.</p></dd>
<dt><code>tile_sample_stride_width: `int`, *optional*</code></dt><dd><p>The stride between two consecutive horizontal tiles. This is to ensure that there are no tiling
artifacts produced across the width dimension.</p></dd>
<dt><code>tile_sample_stride_num_frames: `int`, *optional*</code></dt><dd><p>The stride between two consecutive frame tiles. This is to ensure that there are no tiling artifacts
produced across the frame dimension.</p></dd>
</dl>
<h3 id="fastvideo.models.vaes.wanvae.ParallelTiledVAE.disable_tiling"><code>fastvideo.models.vaes.wanvae.ParallelTiledVAE.disable_tiling</code></h3>
<pre class="doc-signature"><code>disable_tiling() -&gt; None</code></pre>
<p>Disable tiled VAE decoding. If <code>enable_tiling</code> was previously enabled, this method will go back to computing
decoding in one step.</p>
<h2 id="fastvideo.models.vaes.wanvae.WanAttentionBlock"><code>fastvideo.models.vaes.wanvae.WanAttentionBlock</code></h2>
<pre class="doc-signature"><code>WanAttentionBlock(dim)</code></pre>
<p>Causal self-attention with a single head.</p>
<h3>Parameters</h3>
<dl>
<dt><code>dim: int</code></dt><dd><p>The number of channels in the input tensor.</p></dd>
</dl>

<h3 id="fastvideo.models.vaes.wanvae.WanAttentionBlock.forward"><code>fastvideo.models.vaes.wanvae.WanAttentionBlock.forward</code></h3>
<pre class="doc-signature"><code>forward(x)</code></pre>

<h2 id="fastvideo.models.vaes.wanvae.WanCausalConv3d"><code>fastvideo.models.vaes.wanvae.WanCausalConv3d</code></h2>
<pre class="doc-signature"><code>WanCausalConv3d(in_channels: int, out_channels: int, kernel_size: int | tuple&#91;int, int, int&#93;, stride: int | tuple&#91;int, int, int&#93; = 1, padding: int | tuple&#91;int, int, int&#93; = 0)</code></pre>
<p>A custom 3D causal convolution layer with feature caching support.</p>
<p>This layer extends the standard Conv3D layer by ensuring causality in the time dimension and handling feature
caching for efficient inference.</p>
<h3>Parameters</h3>
<dl>
<dt><code>in_channels: int</code></dt><dd><p>Number of channels in the input image</p></dd>
<dt><code>out_channels: int</code></dt><dd><p>Number of channels produced by the convolution</p></dd>
<dt><code>kernel_size: int or tuple</code></dt><dd><p>Size of the convolving kernel</p></dd>
<dt><code>stride: int or tuple</code></dt><dd><p>Stride of the convolution. Default: 1</p></dd>
<dt><code>padding: int or tuple</code></dt><dd><p>Zero-padding added to all three sides of the input. Default: 0</p></dd>
</dl>

<h3 id="fastvideo.models.vaes.wanvae.WanCausalConv3d.forward"><code>fastvideo.models.vaes.wanvae.WanCausalConv3d.forward</code></h3>
<pre class="doc-signature"><code>forward(x, cache_x = None)</code></pre>

<h2 id="fastvideo.models.vaes.wanvae.WanDecoder3d"><code>fastvideo.models.vaes.wanvae.WanDecoder3d</code></h2>
<pre class="doc-signature"><code>WanDecoder3d(dim = 128, z_dim = 4, dim_mult = (1, 2, 4, 4), num_res_blocks = 2, attn_scales = (), temperal_upsample = (False, True, True), dropout = 0.0, non_linearity: str = &#x27;silu&#x27;, out_channels: int = 3, is_residual: bool = False)</code></pre>
<p>A 3D decoder module.</p>
<h3>Parameters</h3>
<dl>
<dt><code>dim: int</code></dt><dd><p>The base number of channels in the first layer.</p></dd>
<dt><code>z_dim: int</code></dt><dd><p>The dimensionality of the latent space.</p></dd>
<dt><code>dim_mult: list of int</code></dt><dd><p>Multipliers for the number of channels in each block.</p></dd>
<dt><code>num_res_blocks: int</code></dt><dd><p>Number of residual blocks in each block.</p></dd>
<dt><code>attn_scales: list of float</code></dt><dd><p>Scales at which to apply attention mechanisms.</p></dd>
<dt><code>temperal_upsample: list of bool</code></dt><dd><p>Whether to upsample temporally in each block.</p></dd>
<dt><code>dropout: float</code></dt><dd><p>Dropout rate for the dropout layers.</p></dd>
<dt><code>non_linearity: str</code></dt><dd><p>Type of non-linearity to use.</p></dd>
</dl>

<h3 id="fastvideo.models.vaes.wanvae.WanDecoder3d.forward"><code>fastvideo.models.vaes.wanvae.WanDecoder3d.forward</code></h3>
<pre class="doc-signature"><code>forward(x)</code></pre>

<h2 id="fastvideo.models.vaes.wanvae.WanEncoder3d"><code>fastvideo.models.vaes.wanvae.WanEncoder3d</code></h2>
<pre class="doc-signature"><code>WanEncoder3d(in_channels: int = 3, dim = 128, z_dim = 4, dim_mult = (1, 2, 4, 4), num_res_blocks = 2, attn_scales = (), temperal_downsample = (True, True, False), dropout = 0.0, non_linearity: str = &#x27;silu&#x27;, is_residual: bool = False)</code></pre>
<p>A 3D encoder module.</p>
<h3>Parameters</h3>
<dl>
<dt><code>dim: int</code></dt><dd><p>The base number of channels in the first layer.</p></dd>
<dt><code>z_dim: int</code></dt><dd><p>The dimensionality of the latent space.</p></dd>
<dt><code>dim_mult: list of int</code></dt><dd><p>Multipliers for the number of channels in each block.</p></dd>
<dt><code>num_res_blocks: int</code></dt><dd><p>Number of residual blocks in each block.</p></dd>
<dt><code>attn_scales: list of float</code></dt><dd><p>Scales at which to apply attention mechanisms.</p></dd>
<dt><code>temperal_downsample: list of bool</code></dt><dd><p>Whether to downsample temporally in each block.</p></dd>
<dt><code>dropout: float</code></dt><dd><p>Dropout rate for the dropout layers.</p></dd>
<dt><code>non_linearity: str</code></dt><dd><p>Type of non-linearity to use.</p></dd>
</dl>

<h3 id="fastvideo.models.vaes.wanvae.WanEncoder3d.forward"><code>fastvideo.models.vaes.wanvae.WanEncoder3d.forward</code></h3>
<pre class="doc-signature"><code>forward(x)</code></pre>

<h2 id="fastvideo.models.vaes.wanvae.WanMidBlock"><code>fastvideo.models.vaes.wanvae.WanMidBlock</code></h2>
<pre class="doc-signature"><code>WanMidBlock(dim: int, dropout: float = 0.0, non_linearity: str = &#x27;silu&#x27;, num_layers: int = 1)</code></pre>
<p>Middle block for WanVAE encoder and decoder.</p>
<h3>Parameters</h3>
<dl>
<dt><code>dim: int</code></dt><dd><p>Number of input/output channels.</p></dd>
<dt><code>dropout: float</code></dt><dd><p>Dropout rate.</p></dd>
<dt><code>non_linearity: str</code></dt><dd><p>Type of non-linearity to use.</p></dd>
</dl>

<h3 id="fastvideo.models.vaes.wanvae.WanMidBlock.forward"><code>fastvideo.models.vaes.wanvae.WanMidBlock.forward</code></h3>
<pre class="doc-signature"><code>forward(x)</code></pre>

<h2 id="fastvideo.models.vaes.wanvae.WanRMS_norm"><code>fastvideo.models.vaes.wanvae.WanRMS_norm</code></h2>
<pre class="doc-signature"><code>WanRMS_norm(dim: int, channel_first: bool = True, images: bool = True, bias: bool = False)</code></pre>
<p>A custom RMS normalization layer.</p>
<h3>Parameters</h3>
<dl>
<dt><code>dim: int</code></dt><dd><p>The number of dimensions to normalize over.</p></dd>
<dt><code>channel_first: bool</code></dt><dd><p>Whether the input tensor has channels as the first dimension.
Default is True.</p></dd>
<dt><code>images: bool</code></dt><dd><p>Whether the input represents image data. Default is True.</p></dd>
<dt><code>bias: bool</code></dt><dd><p>Whether to include a learnable bias term. Default is False.</p></dd>
</dl>

<h3 id="fastvideo.models.vaes.wanvae.WanRMS_norm.forward"><code>fastvideo.models.vaes.wanvae.WanRMS_norm.forward</code></h3>
<pre class="doc-signature"><code>forward(x)</code></pre>

<h2 id="fastvideo.models.vaes.wanvae.WanResample"><code>fastvideo.models.vaes.wanvae.WanResample</code></h2>
<pre class="doc-signature"><code>WanResample(dim: int, mode: str, upsample_out_dim: int = None)</code></pre>
<p>A custom resampling module for 2D and 3D data.</p>
<h3>Parameters</h3>
<dl>
<dt><code>dim: int</code></dt><dd><p>The number of input/output channels.</p></dd>
<dt><code>mode: str</code></dt><dd><p>The resampling mode. Must be one of:
- 'none': No resampling (identity operation).
- 'upsample2d': 2D upsampling with nearest-exact interpolation and convolution.
- 'upsample3d': 3D upsampling with nearest-exact interpolation, convolution, and causal 3D convolution.
- 'downsample2d': 2D downsampling with zero-padding and convolution.
- 'downsample3d': 3D downsampling with zero-padding, convolution, and causal 3D convolution.</p></dd>
</dl>

<h3 id="fastvideo.models.vaes.wanvae.WanResample.forward"><code>fastvideo.models.vaes.wanvae.WanResample.forward</code></h3>
<pre class="doc-signature"><code>forward(x)</code></pre>

<h2 id="fastvideo.models.vaes.wanvae.WanResidualBlock"><code>fastvideo.models.vaes.wanvae.WanResidualBlock</code></h2>
<pre class="doc-signature"><code>WanResidualBlock(in_dim: int, out_dim: int, dropout: float = 0.0, non_linearity: str = &#x27;silu&#x27;)</code></pre>
<p>A custom residual block module.</p>
<h3>Parameters</h3>
<dl>
<dt><code>in_dim: int</code></dt><dd><p>Number of input channels.</p></dd>
<dt><code>out_dim: int</code></dt><dd><p>Number of output channels.</p></dd>
<dt><code>dropout: float</code></dt><dd><p>Dropout rate for the dropout layer. Default is 0.0.</p></dd>
<dt><code>non_linearity: str</code></dt><dd><p>Type of non-linearity to use. Default is "silu".</p></dd>
</dl>

<h3 id="fastvideo.models.vaes.wanvae.WanResidualBlock.forward"><code>fastvideo.models.vaes.wanvae.WanResidualBlock.forward</code></h3>
<pre class="doc-signature"><code>forward(x)</code></pre>

<h2 id="fastvideo.models.vaes.wanvae.WanResidualDownBlock"><code>fastvideo.models.vaes.wanvae.WanResidualDownBlock</code></h2>
<pre class="doc-signature"><code>WanResidualDownBlock(in_dim, out_dim, dropout, num_res_blocks, temperal_downsample = False, down_flag = False)</code></pre>


<h3 id="fastvideo.models.vaes.wanvae.WanResidualDownBlock.forward"><code>fastvideo.models.vaes.wanvae.WanResidualDownBlock.forward</code></h3>
<pre class="doc-signature"><code>forward(x)</code></pre>

<h2 id="fastvideo.models.vaes.wanvae.WanResidualUpBlock"><code>fastvideo.models.vaes.wanvae.WanResidualUpBlock</code></h2>
<pre class="doc-signature"><code>WanResidualUpBlock(in_dim: int, out_dim: int, num_res_blocks: int, dropout: float = 0.0, temperal_upsample: bool = False, up_flag: bool = False, non_linearity: str = &#x27;silu&#x27;)</code></pre>
<p>A block that handles upsampling for the WanVAE decoder.
Args:
    in_dim (int): Input dimension
    out_dim (int): Output dimension
    num_res_blocks (int): Number of residual blocks
    dropout (float): Dropout rate
    temperal_upsample (bool): Whether to upsample on temporal dimension
    up_flag (bool): Whether to upsample or not
    non_linearity (str): Type of non-linearity to use</p>

<h3 id="fastvideo.models.vaes.wanvae.WanResidualUpBlock.forward"><code>fastvideo.models.vaes.wanvae.WanResidualUpBlock.forward</code></h3>
<pre class="doc-signature"><code>forward(x)</code></pre>
<p>Forward pass through the upsampling block.
Args:
    x (torch.Tensor): Input tensor
    feat_cache (list, optional): Feature cache for causal convolutions
    feat_idx (list, optional): Feature index for cache management
Returns:
    torch.Tensor: Output tensor</p>
<h2 id="fastvideo.models.vaes.wanvae.WanUpBlock"><code>fastvideo.models.vaes.wanvae.WanUpBlock</code></h2>
<pre class="doc-signature"><code>WanUpBlock(in_dim: int, out_dim: int, num_res_blocks: int, dropout: float = 0.0, upsample_mode: str | None = None, non_linearity: str = &#x27;silu&#x27;)</code></pre>
<p>A block that handles upsampling for the WanVAE decoder.</p>
<h3>Parameters</h3>
<dl>
<dt><code>in_dim: int</code></dt><dd><p>Input dimension</p></dd>
<dt><code>out_dim: int</code></dt><dd><p>Output dimension</p></dd>
<dt><code>num_res_blocks: int</code></dt><dd><p>Number of residual blocks</p></dd>
<dt><code>dropout: float</code></dt><dd><p>Dropout rate</p></dd>
<dt><code>upsample_mode: str</code></dt><dd><p>Mode for upsampling ('upsample2d' or 'upsample3d')</p></dd>
<dt><code>non_linearity: str</code></dt><dd><p>Type of non-linearity to use</p></dd>
</dl>

<h3 id="fastvideo.models.vaes.wanvae.WanUpBlock.forward"><code>fastvideo.models.vaes.wanvae.WanUpBlock.forward</code></h3>
<pre class="doc-signature"><code>forward(x)</code></pre>
<p>Forward pass through the upsampling block.</p>
<h4>Parameters</h4>
<dl>
<dt><code>x: torch.Tensor</code></dt><dd><p>Input tensor</p></dd>
<dt><code>feat_cache: list</code></dt><dd><p>Feature cache for causal convolutions</p></dd>
<dt><code>feat_idx: list</code></dt><dd><p>Feature index for cache management</p></dd>
</dl>
<h4>Returns</h4>
<dl>
<dt><code></code></dt><dd><p>torch.Tensor: Output tensor</p></dd>
</dl>
<h2 id="fastvideo.models.vaes.wanvae.WanUpsample"><code>fastvideo.models.vaes.wanvae.WanUpsample</code></h2>
<pre class="doc-signature"><code>WanUpsample()</code></pre>
<p>Perform upsampling while ensuring the output tensor has the same data type as the input.</p>
<h3>Parameters</h3>
<dl>
<dt><code>x: torch.Tensor</code></dt><dd><p>Input tensor to be upsampled.</p></dd>
</dl>
<h3>Returns</h3>
<dl>
<dt><code></code></dt><dd><p>torch.Tensor: Upsampled tensor with the same data type as the input.</p></dd>
</dl>
<h3 id="fastvideo.models.vaes.wanvae.WanUpsample.forward"><code>fastvideo.models.vaes.wanvae.WanUpsample.forward</code></h3>
<pre class="doc-signature"><code>forward(x)</code></pre>

<h2 id="fastvideo.models.vaes.wanvae.WanVAEConfig"><code>fastvideo.models.vaes.wanvae.WanVAEConfig</code></h2>
<pre class="doc-signature"><code>WanVAEConfig(arch_config: WanVAEArchConfig = WanVAEArchConfig(), load_encoder: bool = True, load_decoder: bool = True, tile_sample_min_height: int = 256, tile_sample_min_width: int = 256, tile_sample_min_num_frames: int = 16, tile_sample_stride_height: int = 192, tile_sample_stride_width: int = 192, tile_sample_stride_num_frames: int = 12, blend_num_frames: int = 0, use_tiling: bool = False, use_temporal_tiling: bool = False, use_parallel_tiling: bool = False, use_temporal_scaling_frames: bool = True, use_feature_cache: bool = True, use_light_vae: bool = False, *, _resolved_attention_backend: AttentionBackendEnum | None = None)</code></pre>


<h2 id="fastvideo.models.vaes.wanvae.forward_context"><code>fastvideo.models.vaes.wanvae.forward_context</code></h2>
<pre class="doc-signature"><code>forward_context(first_frame_arg = False, feat_cache_arg = None, feat_idx_arg = None, first_chunk_arg = None, use_light_vae_arg = False)</code></pre>

<h2 id="fastvideo.models.vaes.wanvae.patchify"><code>fastvideo.models.vaes.wanvae.patchify</code></h2>
<pre class="doc-signature"><code>patchify(x, patch_size)</code></pre>

<h2 id="fastvideo.models.vaes.wanvae.unpatchify"><code>fastvideo.models.vaes.wanvae.unpatchify</code></h2>
<pre class="doc-signature"><code>unpatchify(x, patch_size)</code></pre>

</div>
