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
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 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 | |
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.