Skip to content

wanvae

Classes

fastvideo.models.vaes.wanvae.AutoencoderKLWan

AutoencoderKLWan(config: WanVAEConfig)

Bases: Module, ParallelTiledVAE

A VAE model with KL loss for encoding videos into latents and decoding latent representations into videos. Introduced in [Wan 2.1].

Source code in fastvideo/models/vaes/wanvae.py
def __init__(
    self,
    config: WanVAEConfig,
) -> None:
    nn.Module.__init__(self)
    ParallelTiledVAE.__init__(self, config)

    self.z_dim = config.z_dim
    self.temperal_downsample = list(config.temperal_downsample)
    self.temperal_upsample = list(config.temperal_downsample)[::-1]

    decoder_base_dim = config.base_dim if config.decoder_base_dim is None else config.decoder_base_dim

    self.latents_mean = list(config.latents_mean)
    self.latents_std = list(config.latents_std)
    self.shift_factor = config.shift_factor

    if config.load_encoder:
        self.encoder = WanEncoder3d(
            in_channels=config.in_channels,
            dim=config.base_dim, 
            z_dim=self.z_dim * 2,
            dim_mult=config.dim_mult, 
            num_res_blocks=config.num_res_blocks,
            attn_scales=config.attn_scales,
            temperal_downsample=self.temperal_downsample,
            dropout=config.dropout,
            is_residual=config.is_residual,
        )
    self.quant_conv = WanCausalConv3d(self.z_dim * 2, self.z_dim * 2, 1)
    self.post_quant_conv = WanCausalConv3d(self.z_dim, self.z_dim, 1)

    if config.load_decoder:
        self.decoder = WanDecoder3d(
            dim=decoder_base_dim, 
            z_dim=self.z_dim,
            dim_mult=config.dim_mult, 
            num_res_blocks=config.num_res_blocks,
            attn_scales=config.attn_scales,
            temperal_upsample=self.temperal_upsample, 
            dropout=config.dropout,
            out_channels=config.out_channels,
            is_residual=config.is_residual,
        )

    self.use_feature_cache = config.use_feature_cache

Methods:

fastvideo.models.vaes.wanvae.AutoencoderKLWan.forward
forward(sample: Tensor, sample_posterior: bool = False, generator: Generator | None = None) -> Tensor

Parameters:

Name Type Description Default
sample `torch.Tensor`

Input sample.

required
return_dict `bool`, *optional*, defaults to `True`

Whether or not to return a [DecoderOutput] instead of a plain tuple.

required
Source code in fastvideo/models/vaes/wanvae.py
def forward(
    self,
    sample: torch.Tensor,
    sample_posterior: bool = False,
    generator: torch.Generator | None = None,
) -> torch.Tensor:
    """
    Args:
        sample (`torch.Tensor`): Input sample.
        return_dict (`bool`, *optional*, defaults to `True`):
            Whether or not to return a [`DecoderOutput`] instead of a plain tuple.
    """
    x = sample
    posterior = self.encode(x).latent_dist
    z = posterior.sample(generator=generator) if sample_posterior else posterior.mode()
    dec = self.decode(z)
    return dec
fastvideo.models.vaes.wanvae.AutoencoderKLWan.optimize_memory_format
optimize_memory_format() -> None

Optional CUDA-only weight layout optimization used by MG3 LightVAE.

Source code in fastvideo/models/vaes/wanvae.py
def optimize_memory_format(self) -> None:
    """Optional CUDA-only weight layout optimization used by MG3 LightVAE."""

    def _convert(module: nn.Module) -> None:
        for child in module.children():
            if isinstance(child, nn.Conv3d):
                child.weight.data = child.weight.data.to(
                    memory_format=torch.channels_last_3d
                )
            else:
                _convert(child)

    _convert(self)
fastvideo.models.vaes.wanvae.AutoencoderKLWan.streaming_decode
streaming_decode(z: Tensor, cache: list[Tensor | None], is_first_chunk: bool = False) -> tuple[Tensor, list[Tensor | None]]

Parameters:

Name Type Description Default
z `torch.Tensor`

Latent tensor of shape [B, C, T, H, W].

required
cache `list[torch.Tensor | None]`

The VAE cache.

required
is_first_chunk `bool`

Whether this is the first chunk in the sequence.

False

Returns:

Type Description
tuple[Tensor, list[Tensor | None]]

A tuple of (decoded_frames, updated_cache).

Source code in fastvideo/models/vaes/wanvae.py
def streaming_decode(
    self,
    z: torch.Tensor,
    cache: list[torch.Tensor | None],
    is_first_chunk: bool = False,
) -> tuple[torch.Tensor, list[torch.Tensor | None]]:
    """
    Args:
        z (`torch.Tensor`): Latent tensor of shape [B, C, T, H, W].
        cache (`list[torch.Tensor | None]`): The VAE cache.
        is_first_chunk (`bool`): Whether this is the first chunk in the sequence.

    Returns:
        A tuple of (decoded_frames, updated_cache).
    """
    iter_ = z.shape[2]
    x = self.post_quant_conv(z)

    with forward_context(feat_cache_arg=cache, feat_idx_arg=0,
                         use_light_vae_arg=self.config.use_light_vae):
        outputs = []
        for i in range(iter_):
            feat_idx.set(0)
            first_chunk.set(is_first_chunk and i == 0)
            decoded_chunk = self.decoder(x[:, :, i:i + 1, :, :])
            outputs.append(decoded_chunk)
        out = torch.cat(outputs, dim=2)

    if self.config.patch_size is not None:
        out = unpatchify(out, patch_size=self.config.patch_size)

    out = out.float()
    out = torch.clamp(out, min=-1.0, max=1.0)

    return out, cache

fastvideo.models.vaes.wanvae.WanAttentionBlock

WanAttentionBlock(dim)

Bases: Module

Causal self-attention with a single head.

Parameters:

Name Type Description Default
dim int

The number of channels in the input tensor.

required
Source code in fastvideo/models/vaes/wanvae.py
def __init__(self, dim) -> None:
    super().__init__()
    self.dim = dim

    # layers
    self.norm = WanRMS_norm(dim)
    self.to_qkv = nn.Conv2d(dim, dim * 3, 1)
    self.proj = nn.Conv2d(dim, dim, 1)

fastvideo.models.vaes.wanvae.WanCausalConv3d

WanCausalConv3d(in_channels: int, out_channels: int, kernel_size: int | tuple[int, int, int], stride: int | tuple[int, int, int] = 1, padding: int | tuple[int, int, int] = 0)

Bases: Conv3d

A custom 3D causal convolution layer with feature caching support.

This layer extends the standard Conv3D layer by ensuring causality in the time dimension and handling feature caching for efficient inference.

Parameters:

Name Type Description Default
in_channels int

Number of channels in the input image

required
out_channels int

Number of channels produced by the convolution

required
kernel_size int or tuple

Size of the convolving kernel

required
stride int or tuple

Stride of the convolution. Default: 1

1
padding int or tuple

Zero-padding added to all three sides of the input. Default: 0

0
Source code in fastvideo/models/vaes/wanvae.py
def __init__(
    self,
    in_channels: int,
    out_channels: int,
    kernel_size: int | tuple[int, int, int],
    stride: int | tuple[int, int, int] = 1,
    padding: int | tuple[int, int, int] = 0,
) -> None:
    super().__init__(
        in_channels=in_channels,
        out_channels=out_channels,
        kernel_size=kernel_size,
        stride=stride,
        padding=padding,
    )
    self.padding: tuple[int, int, int]
    # Set up causal padding
    self._padding: tuple[int, ...] = (self.padding[2], self.padding[2],
                                      self.padding[1], self.padding[1],
                                      2 * self.padding[0], 0)
    self.padding = (0, 0, 0)

fastvideo.models.vaes.wanvae.WanDecoder3d

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 = 'silu', out_channels: int = 3, is_residual: bool = False)

Bases: Module

A 3D decoder module.

Parameters:

Name Type Description Default
dim int

The base number of channels in the first layer.

128
z_dim int

The dimensionality of the latent space.

4
dim_mult list of int

Multipliers for the number of channels in each block.

(1, 2, 4, 4)
num_res_blocks int

Number of residual blocks in each block.

2
attn_scales list of float

Scales at which to apply attention mechanisms.

()
temperal_upsample list of bool

Whether to upsample temporally in each block.

(False, True, True)
dropout float

Dropout rate for the dropout layers.

0.0
non_linearity str

Type of non-linearity to use.

'silu'
Source code in fastvideo/models/vaes/wanvae.py
def __init__(
    self,
    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 = "silu",
    out_channels: int = 3,
    is_residual: bool = False,
):
    super().__init__()
    self.dim = dim
    self.z_dim = z_dim
    dim_mult = list(dim_mult)
    self.dim_mult = dim_mult
    self.num_res_blocks = num_res_blocks
    self.attn_scales = list(attn_scales)
    self.temperal_upsample = list(temperal_upsample)

    self.nonlinearity = get_act_fn(non_linearity)

    # dimensions
    dims = [dim * u for u in [dim_mult[-1]] + dim_mult[::-1]]

    # init block
    self.conv_in = WanCausalConv3d(z_dim, dims[0], 3, padding=1)

    # middle blocks
    self.mid_block = WanMidBlock(dims[0],
                                 dropout,
                                 non_linearity,
                                 num_layers=1)

    # upsample blocks
    self.up_blocks = nn.ModuleList([])
    for i, (in_dim,
            out_dim) in enumerate(zip(dims[:-1], dims[1:], strict=True)):
        # residual (+attention) blocks
        if i > 0 and not is_residual:
            # wan vae 2.1
            in_dim = in_dim // 2

        # determine if we need upsampling
        up_flag = i != len(dim_mult) - 1
        # determine upsampling mode, if not upsampling, set to None
        upsample_mode = None
        if up_flag and temperal_upsample[i]:
            upsample_mode = "upsample3d"
        elif up_flag:
            upsample_mode = "upsample2d"

        # Create and add the upsampling block
        if is_residual:
            up_block = WanResidualUpBlock(
                in_dim=in_dim,
                out_dim=out_dim,
                num_res_blocks=num_res_blocks,
                dropout=dropout,
                temperal_upsample=temperal_upsample[i] if up_flag else False,
                up_flag=up_flag,
                non_linearity=non_linearity,
            )
        else:
            up_block = WanUpBlock(
                in_dim=in_dim,
                out_dim=out_dim,
                num_res_blocks=num_res_blocks,
                dropout=dropout,
                upsample_mode=upsample_mode,
                non_linearity=non_linearity,
            )
        self.up_blocks.append(up_block)

    # output blocks
    self.norm_out = WanRMS_norm(out_dim, images=False)
    self.conv_out = WanCausalConv3d(out_dim, out_channels, 3, padding=1)

    self.gradient_checkpointing = False

fastvideo.models.vaes.wanvae.WanEncoder3d

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 = 'silu', is_residual: bool = False)

Bases: Module

A 3D encoder module.

Parameters:

Name Type Description Default
dim int

The base number of channels in the first layer.

128
z_dim int

The dimensionality of the latent space.

4
dim_mult list of int

Multipliers for the number of channels in each block.

(1, 2, 4, 4)
num_res_blocks int

Number of residual blocks in each block.

2
attn_scales list of float

Scales at which to apply attention mechanisms.

()
temperal_downsample list of bool

Whether to downsample temporally in each block.

(True, True, False)
dropout float

Dropout rate for the dropout layers.

0.0
non_linearity str

Type of non-linearity to use.

'silu'
Source code in fastvideo/models/vaes/wanvae.py
def __init__(
    self,
    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 = "silu",
    is_residual: bool = False,  # wan 2.2 vae use a residual downblock
):
    super().__init__()
    self.dim = dim
    self.z_dim = z_dim
    dim_mult = list(dim_mult)
    self.dim_mult = dim_mult
    self.num_res_blocks = num_res_blocks
    self.attn_scales = list(attn_scales)
    self.temperal_downsample = list(temperal_downsample)
    self.nonlinearity = get_act_fn(non_linearity)

    # dimensions
    dims = [dim * u for u in [1] + dim_mult]
    scale = 1.0

    # init block
    self.conv_in = WanCausalConv3d(in_channels, dims[0], 3, padding=1)

    # downsample blocks
    self.down_blocks = nn.ModuleList([])
    for i, (in_dim,
            out_dim) in enumerate(zip(dims[:-1], dims[1:], strict=True)):
        # residual (+attention) blocks
        if is_residual:
            self.down_blocks.append(
                WanResidualDownBlock(
                    in_dim,
                    out_dim,
                    dropout,
                    num_res_blocks,
                    temperal_downsample=temperal_downsample[i] if i != len(dim_mult) - 1 else False,
                    down_flag=i != len(dim_mult) - 1,
                )
            )
        else:
            for _ in range(num_res_blocks):
                self.down_blocks.append(WanResidualBlock(in_dim, out_dim, dropout))
                if scale in attn_scales:
                    self.down_blocks.append(WanAttentionBlock(out_dim))
                in_dim = out_dim

            # downsample block
            if i != len(dim_mult) - 1:
                mode = "downsample3d" if temperal_downsample[i] else "downsample2d"
                self.down_blocks.append(WanResample(out_dim, mode=mode))
                scale /= 2.0

    # middle blocks
    self.mid_block = WanMidBlock(out_dim,
                                 dropout,
                                 non_linearity,
                                 num_layers=1)

    # output blocks
    self.norm_out = WanRMS_norm(out_dim, images=False)
    self.conv_out = WanCausalConv3d(out_dim, z_dim, 3, padding=1)

    self.gradient_checkpointing = False

fastvideo.models.vaes.wanvae.WanMidBlock

WanMidBlock(dim: int, dropout: float = 0.0, non_linearity: str = 'silu', num_layers: int = 1)

Bases: Module

Middle block for WanVAE encoder and decoder.

Parameters:

Name Type Description Default
dim int

Number of input/output channels.

required
dropout float

Dropout rate.

0.0
non_linearity str

Type of non-linearity to use.

'silu'
Source code in fastvideo/models/vaes/wanvae.py
def __init__(self,
             dim: int,
             dropout: float = 0.0,
             non_linearity: str = "silu",
             num_layers: int = 1):
    super().__init__()
    self.dim = dim

    # Create the components
    resnets = [WanResidualBlock(dim, dim, dropout, non_linearity)]
    attentions = []
    for _ in range(num_layers):
        attentions.append(WanAttentionBlock(dim))
        resnets.append(WanResidualBlock(dim, dim, dropout, non_linearity))
    self.attentions = nn.ModuleList(attentions)
    self.resnets = nn.ModuleList(resnets)

    self.gradient_checkpointing = False

fastvideo.models.vaes.wanvae.WanRMS_norm

WanRMS_norm(dim: int, channel_first: bool = True, images: bool = True, bias: bool = False)

Bases: Module

A custom RMS normalization layer.

Parameters:

Name Type Description Default
dim int

The number of dimensions to normalize over.

required
channel_first bool

Whether the input tensor has channels as the first dimension. Default is True.

True
images bool

Whether the input represents image data. Default is True.

True
bias bool

Whether to include a learnable bias term. Default is False.

False
Source code in fastvideo/models/vaes/wanvae.py
def __init__(self,
             dim: int,
             channel_first: bool = True,
             images: bool = True,
             bias: bool = False) -> None:
    super().__init__()
    broadcastable_dims = (1, 1, 1) if not images else (1, 1)
    shape = (dim, *broadcastable_dims) if channel_first else (dim, )

    self.channel_first = channel_first
    self.scale = dim**0.5
    self.gamma = nn.Parameter(torch.ones(shape))
    self.bias = nn.Parameter(torch.zeros(shape)) if bias else 0.0

fastvideo.models.vaes.wanvae.WanResample

WanResample(dim: int, mode: str, upsample_out_dim: int = None)

Bases: Module

A custom resampling module for 2D and 3D data.

Parameters:

Name Type Description Default
dim int

The number of input/output channels.

required
mode str

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.

required
Source code in fastvideo/models/vaes/wanvae.py
def __init__(self, dim: int, mode: str, upsample_out_dim: int = None) -> None:
    super().__init__()
    self.dim = dim
    self.mode = mode

    # default to dim //2
    if upsample_out_dim is None:
        upsample_out_dim = dim // 2

    # layers
    if mode == "upsample2d":
        self.resample = nn.Sequential(
            WanUpsample(scale_factor=(2.0, 2.0), mode="nearest-exact"),
            nn.Conv2d(dim, upsample_out_dim, 3, padding=1),
        )
    elif mode == "upsample3d":
        self.resample = nn.Sequential(
            WanUpsample(scale_factor=(2.0, 2.0), mode="nearest-exact"),
            nn.Conv2d(dim, upsample_out_dim, 3, padding=1),
        )
        self.time_conv = WanCausalConv3d(dim,
                                         dim * 2, (3, 1, 1),
                                         padding=(1, 0, 0))

    elif mode == "downsample2d":
        self.resample = nn.Sequential(nn.ZeroPad2d((0, 1, 0, 1)),
                                      nn.Conv2d(dim, dim, 3, stride=(2, 2)))
    elif mode == "downsample3d":
        self.resample = nn.Sequential(nn.ZeroPad2d((0, 1, 0, 1)),
                                      nn.Conv2d(dim, dim, 3, stride=(2, 2)))
        self.time_conv = WanCausalConv3d(dim,
                                         dim, (3, 1, 1),
                                         stride=(2, 1, 1),
                                         padding=(0, 0, 0))

    else:
        self.resample = nn.Identity()

fastvideo.models.vaes.wanvae.WanResidualBlock

WanResidualBlock(in_dim: int, out_dim: int, dropout: float = 0.0, non_linearity: str = 'silu')

Bases: Module

A custom residual block module.

Parameters:

Name Type Description Default
in_dim int

Number of input channels.

required
out_dim int

Number of output channels.

required
dropout float

Dropout rate for the dropout layer. Default is 0.0.

0.0
non_linearity str

Type of non-linearity to use. Default is "silu".

'silu'
Source code in fastvideo/models/vaes/wanvae.py
def __init__(
    self,
    in_dim: int,
    out_dim: int,
    dropout: float = 0.0,
    non_linearity: str = "silu",
) -> None:
    super().__init__()
    self.in_dim = in_dim
    self.out_dim = out_dim
    self.nonlinearity = get_act_fn(non_linearity)

    # layers
    self.norm1 = WanRMS_norm(in_dim, images=False)
    self.conv1 = WanCausalConv3d(in_dim, out_dim, 3, padding=1)
    self.norm2 = WanRMS_norm(out_dim, images=False)
    self.dropout = nn.Dropout(dropout)
    self.conv2 = WanCausalConv3d(out_dim, out_dim, 3, padding=1)
    self.conv_shortcut = WanCausalConv3d(
        in_dim, out_dim, 1) if in_dim != out_dim else nn.Identity()

fastvideo.models.vaes.wanvae.WanResidualUpBlock

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 = 'silu')

Bases: Module

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

Source code in fastvideo/models/vaes/wanvae.py
def __init__(
    self,
    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 = "silu",
):
    super().__init__()
    self.in_dim = in_dim
    self.out_dim = out_dim

    if up_flag:
        self.avg_shortcut = DupUp3D(
            in_dim,
            out_dim,
            factor_t=2 if temperal_upsample else 1,
            factor_s=2,
        )
    else:
        self.avg_shortcut = None

    # create residual blocks
    resnets = []
    current_dim = in_dim
    for _ in range(num_res_blocks + 1):
        resnets.append(WanResidualBlock(current_dim, out_dim, dropout, non_linearity))
        current_dim = out_dim

    self.resnets = nn.ModuleList(resnets)

    # Add upsampling layer if needed
    if up_flag:
        upsample_mode = "upsample3d" if temperal_upsample else "upsample2d"
        self.upsampler = WanResample(out_dim, mode=upsample_mode, upsample_out_dim=out_dim)
    else:
        self.upsampler = None

    self.gradient_checkpointing = False

Methods:

fastvideo.models.vaes.wanvae.WanResidualUpBlock.forward
forward(x)

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

Source code in fastvideo/models/vaes/wanvae.py
def forward(self, x):
    """
    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
    """
    if self.avg_shortcut is not None:
        x_copy = x.clone()

    for resnet in self.resnets:
        x = resnet(x)

    if self.upsampler is not None:
        x = self.upsampler(x)

    if self.avg_shortcut is not None:
        x = x + self.avg_shortcut(x_copy)

    return x

fastvideo.models.vaes.wanvae.WanUpBlock

WanUpBlock(in_dim: int, out_dim: int, num_res_blocks: int, dropout: float = 0.0, upsample_mode: str | None = None, non_linearity: str = 'silu')

Bases: Module

A block that handles upsampling for the WanVAE decoder.

Parameters:

Name Type Description Default
in_dim int

Input dimension

required
out_dim int

Output dimension

required
num_res_blocks int

Number of residual blocks

required
dropout float

Dropout rate

0.0
upsample_mode str

Mode for upsampling ('upsample2d' or 'upsample3d')

None
non_linearity str

Type of non-linearity to use

'silu'
Source code in fastvideo/models/vaes/wanvae.py
def __init__(
    self,
    in_dim: int,
    out_dim: int,
    num_res_blocks: int,
    dropout: float = 0.0,
    upsample_mode: str | None = None,
    non_linearity: str = "silu",
):
    super().__init__()
    self.in_dim = in_dim
    self.out_dim = out_dim

    # Create layers list
    resnets = []
    # Add residual blocks and attention if needed
    current_dim = in_dim
    for _ in range(num_res_blocks + 1):
        resnets.append(
            WanResidualBlock(current_dim, out_dim, dropout, non_linearity))
        current_dim = out_dim

    self.resnets = nn.ModuleList(resnets)

    # Add upsampling layer if needed
    self.upsamplers = None
    if upsample_mode is not None:
        self.upsamplers = nn.ModuleList(
            [WanResample(out_dim, mode=upsample_mode)])

    self.gradient_checkpointing = False

Methods:

fastvideo.models.vaes.wanvae.WanUpBlock.forward
forward(x)

Forward pass through the upsampling block.

Parameters:

Name Type Description Default
x Tensor

Input tensor

required
feat_cache list

Feature cache for causal convolutions

required
feat_idx list

Feature index for cache management

required

Returns:

Type Description

torch.Tensor: Output tensor

Source code in fastvideo/models/vaes/wanvae.py
def forward(self, x):
    """
    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
    """
    for resnet in self.resnets:
        x = resnet(x)

    if self.upsamplers is not None:
        x = self.upsamplers[0](x)
    return x

fastvideo.models.vaes.wanvae.WanUpsample

Bases: Upsample

Perform upsampling while ensuring the output tensor has the same data type as the input.

Parameters:

Name Type Description Default
x Tensor

Input tensor to be upsampled.

required

Returns:

Type Description

torch.Tensor: Upsampled tensor with the same data type as the input.

Functions: