hyworldvae ¶
Classes¶
fastvideo.models.vaes.hyworldvae.AutoencoderKLHYWorld ¶
Bases: Module, ParallelTiledVAE
A VAE model with KL loss for encoding videos into latents and decoding latent representations into videos. Revised from HunyuanVideo-1.5 with temporal caching support for HY-WorldPlay integration.
Source code in fastvideo/models/vaes/hyworldvae.py
Methods:¶
fastvideo.models.vaes.hyworldvae.AutoencoderKLHYWorld.clear_cache ¶
Initialize/clear the feature cache for chunk-based encoding/decoding.
This should be called before starting a new encode/decode sequence to ensure the cache is properly initialized.
Source code in fastvideo/models/vaes/hyworldvae.py
fastvideo.models.vaes.hyworldvae.AutoencoderKLHYWorld.forward ¶
forward(sample: Tensor, sample_posterior: bool = False, return_dict: bool = True, generator: Optional[Generator] = None) -> Tensor
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sample | `torch.Tensor` | Input sample. | required |
sample_posterior | `bool`, *optional*, defaults to `False` | Whether to sample from the posterior. | False |
return_dict | `bool`, *optional*, defaults to `True` | Whether or not to return a [ | True |
generator | `torch.Generator`, *optional* | Generator for sampling. | None |
Source code in fastvideo/models/vaes/hyworldvae.py
fastvideo.models.vaes.hyworldvae.HYWorldCausalConv3d ¶
HYWorldCausalConv3d(in_channels: int, out_channels: int, kernel_size: Union[int, Tuple[int, int, int]] = 3, stride: Union[int, Tuple[int, int, int]] = 1, padding: Union[int, Tuple[int, int, int]] = 0, dilation: Union[int, Tuple[int, int, int]] = 1, bias: bool = True, pad_mode: str = 'replicate')
Bases: Module
Causal Conv3d with optional cache support for temporal feature caching.
Source code in fastvideo/models/vaes/hyworldvae.py
Methods:¶
fastvideo.models.vaes.hyworldvae.HYWorldCausalConv3d.forward ¶
forward(hidden_states: Tensor, cache_x: Optional[Tensor] = None) -> Tensor
Forward pass with optional temporal caching.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hidden_states | Tensor | Input tensor of shape (B, C, T, H, W) | required |
cache_x | Optional[Tensor] | Optional cached frames from previous chunk, shape (B, C, CACHE_T, H, W) When provided, uses cached frames instead of padding for temporal dimension. | None |
Source code in fastvideo/models/vaes/hyworldvae.py
fastvideo.models.vaes.hyworldvae.HYWorldDecoder3D ¶
HYWorldDecoder3D(in_channels: int = 32, out_channels: int = 3, block_out_channels: Tuple[int, ...] = (1024, 1024, 512, 256, 128), layers_per_block: int = 2, spatial_compression_ratio: int = 16, temporal_compression_ratio: int = 4, upsample_match_channel: bool = True)
Bases: Module
Causal decoder for 3D video-like data used for HunyuanImage-1.5 Refiner with optional temporal caching.
Source code in fastvideo/models/vaes/hyworldvae.py
Methods:¶
fastvideo.models.vaes.hyworldvae.HYWorldDecoder3D.forward ¶
forward(hidden_states: Tensor, feat_cache: Optional[List[Optional[Tensor]]] = None, feat_idx: Optional[List[int]] = None, first_chunk: bool = False) -> Tensor
Forward pass with optional temporal caching.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hidden_states | Tensor | Input tensor of shape (B, C, T, H, W) | required |
feat_cache | Optional[List[Optional[Tensor]]] | List of cached features for each conv layer | None |
feat_idx | Optional[List[int]] | List containing current cache index [idx] | None |
first_chunk | bool | Whether this is the first chunk (for upsampling behavior) | False |
Source code in fastvideo/models/vaes/hyworldvae.py
fastvideo.models.vaes.hyworldvae.HYWorldDownBlock3D ¶
HYWorldDownBlock3D(in_channels: int, out_channels: int, num_layers: int = 1, downsample_out_channels: Optional[int] = None, add_temporal_downsample: int = True)
Bases: Module
Down block with resnet blocks and optional downsampling, with caching support.
Source code in fastvideo/models/vaes/hyworldvae.py
Methods:¶
fastvideo.models.vaes.hyworldvae.HYWorldDownBlock3D.forward ¶
forward(hidden_states: Tensor, feat_cache: Optional[List[Optional[Tensor]]] = None, feat_idx: Optional[List[int]] = None) -> Tensor
Forward pass with optional temporal caching.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hidden_states | Tensor | Input tensor of shape (B, C, T, H, W) | required |
feat_cache | Optional[List[Optional[Tensor]]] | List of cached features for each conv layer | None |
feat_idx | Optional[List[int]] | List containing current cache index [idx] | None |
Source code in fastvideo/models/vaes/hyworldvae.py
fastvideo.models.vaes.hyworldvae.HYWorldDownsample ¶
Bases: Module
Hierarchical downsampling with temporal/spatial support and optional caching.
Source code in fastvideo/models/vaes/hyworldvae.py
Methods:¶
fastvideo.models.vaes.hyworldvae.HYWorldDownsample.forward ¶
forward(x: Tensor, feat_cache: Optional[List[Optional[Tensor]]] = None, feat_idx: Optional[List[int]] = None)
Forward pass with optional temporal caching.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x | Tensor | Input tensor of shape (B, C, T, H, W) | required |
feat_cache | Optional[List[Optional[Tensor]]] | List of cached features for each conv layer | None |
feat_idx | Optional[List[int]] | List containing current cache index [idx] | None |
Source code in fastvideo/models/vaes/hyworldvae.py
fastvideo.models.vaes.hyworldvae.HYWorldEncoder3D ¶
HYWorldEncoder3D(in_channels: int = 3, out_channels: int = 64, block_out_channels: Tuple[int, ...] = (128, 256, 512, 1024, 1024), layers_per_block: int = 2, temporal_compression_ratio: int = 4, spatial_compression_ratio: int = 16, downsample_match_channel: bool = True)
Bases: Module
3D vae encoder for HunyuanImageRefiner with optional temporal caching.
Source code in fastvideo/models/vaes/hyworldvae.py
Methods:¶
fastvideo.models.vaes.hyworldvae.HYWorldEncoder3D.forward ¶
forward(hidden_states: Tensor, feat_cache: Optional[List[Optional[Tensor]]] = None, feat_idx: Optional[List[int]] = None) -> Tensor
Forward pass with optional temporal caching.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hidden_states | Tensor | Input tensor of shape (B, C, T, H, W) | required |
feat_cache | Optional[List[Optional[Tensor]]] | List of cached features for each conv layer | None |
feat_idx | Optional[List[int]] | List containing current cache index [idx] | None |
Source code in fastvideo/models/vaes/hyworldvae.py
fastvideo.models.vaes.hyworldvae.HYWorldMidBlock ¶
Bases: Module
Mid block with attention and resnet blocks, with optional caching support.
Source code in fastvideo/models/vaes/hyworldvae.py
Methods:¶
fastvideo.models.vaes.hyworldvae.HYWorldMidBlock.forward ¶
forward(hidden_states: Tensor, feat_cache: Optional[List[Optional[Tensor]]] = None, feat_idx: Optional[List[int]] = None) -> Tensor
Forward pass with optional temporal caching.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hidden_states | Tensor | Input tensor of shape (B, C, T, H, W) | required |
feat_cache | Optional[List[Optional[Tensor]]] | List of cached features for each conv layer | None |
feat_idx | Optional[List[int]] | List containing current cache index [idx] | None |
Source code in fastvideo/models/vaes/hyworldvae.py
fastvideo.models.vaes.hyworldvae.HYWorldResnetBlock ¶
HYWorldResnetBlock(in_channels: int, out_channels: Optional[int] = None, non_linearity: str = 'swish')
Bases: Module
Source code in fastvideo/models/vaes/hyworldvae.py
Methods:¶
fastvideo.models.vaes.hyworldvae.HYWorldResnetBlock.forward ¶
forward(hidden_states: Tensor, feat_cache: Optional[List[Optional[Tensor]]] = None, feat_idx: Optional[List[int]] = None) -> Tensor
Forward pass with optional temporal feature caching.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hidden_states | Tensor | Input tensor of shape (B, C, T, H, W) | required |
feat_cache | Optional[List[Optional[Tensor]]] | List of cached features for each conv layer | None |
feat_idx | Optional[List[int]] | List containing current cache index [idx] | None |
Source code in fastvideo/models/vaes/hyworldvae.py
fastvideo.models.vaes.hyworldvae.HYWorldUpBlock3D ¶
HYWorldUpBlock3D(in_channels: int, out_channels: int, num_layers: int = 1, upsample_out_channels: Optional[int] = None, add_temporal_upsample: bool = True)
Bases: Module
Up block with resnet blocks and optional upsampling, with caching support.
Source code in fastvideo/models/vaes/hyworldvae.py
Methods:¶
fastvideo.models.vaes.hyworldvae.HYWorldUpBlock3D.forward ¶
forward(hidden_states: Tensor, feat_cache: Optional[List[Optional[Tensor]]] = None, feat_idx: Optional[List[int]] = None, first_chunk: bool = False) -> Tensor
Forward pass with optional temporal caching.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hidden_states | Tensor | Input tensor of shape (B, C, T, H, W) | required |
feat_cache | Optional[List[Optional[Tensor]]] | List of cached features for each conv layer | None |
feat_idx | Optional[List[int]] | List containing current cache index [idx] | None |
first_chunk | bool | Whether this is the first chunk (for upsampling behavior) | False |
Source code in fastvideo/models/vaes/hyworldvae.py
fastvideo.models.vaes.hyworldvae.HYWorldUpsample ¶
Bases: Module
Hierarchical upsampling with temporal/spatial support and optional caching.
Source code in fastvideo/models/vaes/hyworldvae.py
Methods:¶
fastvideo.models.vaes.hyworldvae.HYWorldUpsample.forward ¶
forward(x: Tensor, feat_cache: Optional[List[Optional[Tensor]]] = None, feat_idx: Optional[List[int]] = None, first_chunk: bool = False)
Forward pass with optional temporal caching.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x | Tensor | Input tensor of shape (B, C, T, H, W) | required |
feat_cache | Optional[List[Optional[Tensor]]] | List of cached features for each conv layer | None |
feat_idx | Optional[List[int]] | List containing current cache index [idx] | None |
first_chunk | bool | Whether this is the first chunk (affects temporal upsample behavior) | False |