decoding
¶
Decoding stage for diffusion pipelines.
Classes¶
fastvideo.pipelines.stages.decoding.DecodingStage
¶
Bases: PipelineStage
Stage for decoding latent representations into pixel space.
This stage handles the decoding of latent representations into the final output format (e.g., pixel values).
Source code in fastvideo/pipelines/stages/decoding.py
Methods:¶
fastvideo.pipelines.stages.decoding.DecodingStage.decode
¶
decode(latents: Tensor, fastvideo_args: FastVideoArgs) -> Tensor
Decode latent representations into pixel space using VAE.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
latents
|
Tensor
|
Input latent tensor with shape (batch, channels, frames, height_latents, width_latents) |
required |
fastvideo_args
|
FastVideoArgs
|
Configuration containing: - disable_autocast: Whether to disable automatic mixed precision (default: False) - pipeline_config.vae_precision: VAE computation precision ("fp32", "fp16", "bf16") - pipeline_config.vae_tiling: Whether to enable VAE tiling for memory efficiency |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Decoded video tensor with shape (batch, channels, frames, height, width), |
Tensor
|
normalized to [0, 1] range and moved to CPU as float32 |
Source code in fastvideo/pipelines/stages/decoding.py
fastvideo.pipelines.stages.decoding.DecodingStage.forward
¶
forward(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> ForwardBatch
Decode latent representations into pixel space.
This method processes the batch through the VAE decoder, converting latent representations to pixel-space video/images. It also optionally decodes trajectory latents for visualization purposes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch
|
ForwardBatch
|
The current batch containing: - latents: Tensor to decode (batch, channels, frames, height_latents, width_latents) - return_trajectory_decoded (optional): Flag to decode trajectory latents - trajectory_latents (optional): Latents at different timesteps - trajectory_timesteps (optional): Corresponding timesteps |
required |
fastvideo_args
|
FastVideoArgs
|
Configuration containing: - output_type: "latent" to skip decoding, otherwise decode to pixels - vae_cpu_offload: Whether to offload VAE to CPU after decoding - model_loaded: Track VAE loading state - model_paths: Path to VAE model if loading needed |
required |
Returns:
| Type | Description |
|---|---|
ForwardBatch
|
Modified batch with: - output: Decoded frames (batch, channels, frames, height, width) as CPU float32 - trajectory_decoded (if requested): List of decoded frames per timestep |
Source code in fastvideo/pipelines/stages/decoding.py
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 | |
fastvideo.pipelines.stages.decoding.DecodingStage.streaming_decode
¶
streaming_decode(latents: Tensor, fastvideo_args: FastVideoArgs, cache: list[Tensor | None] | None = None, is_first_chunk: bool = False) -> tuple[Tensor, list[Tensor | None]]
Decode latent representations into pixel space using VAE with streaming cache.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
latents
|
Tensor
|
Input latent tensor with shape (batch, channels, frames, height_latents, width_latents) |
required |
fastvideo_args
|
FastVideoArgs
|
Configuration object. |
required |
cache
|
list[Tensor | None] | None
|
VAE cache from previous call, or None to initialize a new cache. |
None
|
is_first_chunk
|
bool
|
Whether this is the first chunk. |
False
|
Returns:
| Type | Description |
|---|---|
tuple[Tensor, list[Tensor | None]]
|
A tuple of (decoded_frames, updated_cache). |
Source code in fastvideo/pipelines/stages/decoding.py
fastvideo.pipelines.stages.decoding.DecodingStage.verify_input
¶
verify_input(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
Verify decoding stage inputs.
Source code in fastvideo/pipelines/stages/decoding.py
fastvideo.pipelines.stages.decoding.DecodingStage.verify_output
¶
verify_output(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
Verify decoding stage outputs.