stages
¶
Pipeline stages for diffusion models.
This package contains the various stages that can be composed to create complete diffusion pipelines.
Classes¶
fastvideo.pipelines.stages.CausalDMDDenosingStage
¶
Bases: DenoisingStage
Denoising stage for causal diffusion.
Source code in fastvideo/pipelines/stages/causal_denoising.py
Functions¶
fastvideo.pipelines.stages.CausalDMDDenosingStage.verify_input
¶
verify_input(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
Verify denoising stage inputs.
Source code in fastvideo/pipelines/stages/causal_denoising.py
fastvideo.pipelines.stages.CausalDenoisingStage
¶
Bases: CausalDMDDenosingStage
Causal block-by-block denoising with standard multi-step flow matching (scheduler.step), not DMD few-step.
Each block is fully denoised through all scheduler timesteps before moving to the next block. After each block is denoised, the KV cache is updated with clean context so subsequent blocks can attend to prior clean frames.
Source code in fastvideo/pipelines/stages/causal_denoising.py
fastvideo.pipelines.stages.ConditioningStage
¶
Bases: PipelineStage
Stage for applying conditioning to the diffusion process.
This stage handles the application of conditioning, such as classifier-free guidance, to the diffusion process.
Functions¶
fastvideo.pipelines.stages.ConditioningStage.forward
¶
forward(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> ForwardBatch
Apply conditioning to the diffusion process.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch
|
ForwardBatch
|
The current batch information. |
required |
fastvideo_args
|
FastVideoArgs
|
The inference arguments. |
required |
Returns:
| Type | Description |
|---|---|
ForwardBatch
|
The batch with applied conditioning. |
Source code in fastvideo/pipelines/stages/conditioning.py
fastvideo.pipelines.stages.ConditioningStage.verify_input
¶
verify_input(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
Verify conditioning stage inputs.
Source code in fastvideo/pipelines/stages/conditioning.py
fastvideo.pipelines.stages.ConditioningStage.verify_output
¶
verify_output(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
Verify conditioning stage outputs.
Source code in fastvideo/pipelines/stages/conditioning.py
fastvideo.pipelines.stages.Cosmos25AutoDenoisingStage
¶
Bases: PipelineStage
Route Cosmos 2.5 denoising to T2W vs V2W/I2W.
Source code in fastvideo/pipelines/stages/denoising.py
fastvideo.pipelines.stages.Cosmos25AutoLatentPreparationStage
¶
Bases: PipelineStage
Route Cosmos 2.5 latent prep to T2W vs V2W/I2W.
Source code in fastvideo/pipelines/stages/latent_preparation.py
fastvideo.pipelines.stages.Cosmos25DenoisingStage
¶
Bases: CosmosDenoisingStage
Denoising stage for Cosmos 2.5 DiT (expects 1D/2D timestep, not 5D).
Source code in fastvideo/pipelines/stages/denoising.py
fastvideo.pipelines.stages.Cosmos25LatentPreparationStage
¶
Bases: CosmosLatentPreparationStage
Latent preparation for Cosmos 2.5 DiT input conventions.
Source code in fastvideo/pipelines/stages/latent_preparation.py
Functions¶
fastvideo.pipelines.stages.Cosmos25LatentPreparationStage.verify_input
¶
verify_input(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
Verify Cosmos latent preparation stage inputs.
Source code in fastvideo/pipelines/stages/latent_preparation.py
fastvideo.pipelines.stages.Cosmos25LatentPreparationStage.verify_output
¶
verify_output(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
Verify latent preparation stage outputs.
Source code in fastvideo/pipelines/stages/latent_preparation.py
fastvideo.pipelines.stages.Cosmos25T2WDenoisingStage
¶
Bases: Cosmos25DenoisingStage
Cosmos 2.5 Text2World denoising stage.
Source code in fastvideo/pipelines/stages/denoising.py
fastvideo.pipelines.stages.Cosmos25T2WLatentPreparationStage
¶
Bases: PipelineStage
Cosmos 2.5 Text2World latent preparation.
Source code in fastvideo/pipelines/stages/latent_preparation.py
fastvideo.pipelines.stages.Cosmos25TextEncodingStage
¶
Bases: PipelineStage
Cosmos 2.5 text encoding stage.
Cosmos 2.5 uses Reason1 (Qwen2.5-VL) and relies on the encoder's
compute_text_embeddings_online().
Source code in fastvideo/pipelines/stages/text_encoding.py
fastvideo.pipelines.stages.Cosmos25TimestepPreparationStage
¶
Bases: TimestepPreparationStage
Cosmos 2.5 timestep preparation with scheduler-specific kwargs.
Source code in fastvideo/pipelines/stages/timestep_preparation.py
fastvideo.pipelines.stages.Cosmos25V2WDenoisingStage
¶
Bases: Cosmos25DenoisingStage
Cosmos 2.5 Video2World denoising stage.
Source code in fastvideo/pipelines/stages/denoising.py
fastvideo.pipelines.stages.Cosmos25V2WLatentPreparationStage
¶
Bases: Cosmos25LatentPreparationStage
Cosmos 2.5 V2W/I2W latent preparation stage (conditioning-aware).
Source code in fastvideo/pipelines/stages/latent_preparation.py
fastvideo.pipelines.stages.CosmosDenoisingStage
¶
Bases: DenoisingStage
Denoising stage for Cosmos models using FlowMatchEulerDiscreteScheduler.
Source code in fastvideo/pipelines/stages/denoising.py
Functions¶
fastvideo.pipelines.stages.CosmosDenoisingStage.verify_input
¶
verify_input(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
Verify Cosmos denoising stage inputs.
Source code in fastvideo/pipelines/stages/denoising.py
fastvideo.pipelines.stages.CosmosDenoisingStage.verify_output
¶
verify_output(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
Verify Cosmos denoising stage outputs.
Source code in fastvideo/pipelines/stages/denoising.py
fastvideo.pipelines.stages.CosmosLatentPreparationStage
¶
Bases: PipelineStage
Cosmos-specific latent preparation stage that properly handles the tensor shapes and conditioning masks required by the Cosmos transformer.
This stage replicates the logic from diffusers' Cosmos2VideoToWorldPipeline.prepare_latents()
Source code in fastvideo/pipelines/stages/latent_preparation.py
fastvideo.pipelines.stages.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
Functions¶
fastvideo.pipelines.stages.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.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
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 | |
fastvideo.pipelines.stages.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.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.DecodingStage.verify_output
¶
verify_output(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
Verify decoding stage outputs.
Source code in fastvideo/pipelines/stages/decoding.py
fastvideo.pipelines.stages.DenoisingStage
¶
Bases: PipelineStage
Stage for running the denoising loop in diffusion pipelines.
This stage handles the iterative denoising process that transforms the initial noise into the final output.
Source code in fastvideo/pipelines/stages/denoising.py
Functions¶
fastvideo.pipelines.stages.DenoisingStage.forward
¶
forward(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> ForwardBatch
Run the denoising loop.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch
|
ForwardBatch
|
The current batch information. |
required |
fastvideo_args
|
FastVideoArgs
|
The inference arguments. |
required |
Returns:
| Type | Description |
|---|---|
ForwardBatch
|
The batch with denoised latents. |
Source code in fastvideo/pipelines/stages/denoising.py
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 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 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 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 | |
fastvideo.pipelines.stages.DenoisingStage.prepare_extra_func_kwargs
¶
Prepare extra kwargs for the scheduler step / denoise step.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
func
|
The function to prepare kwargs for. |
required | |
kwargs
|
The kwargs to prepare. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
The prepared kwargs. |
Source code in fastvideo/pipelines/stages/denoising.py
fastvideo.pipelines.stages.DenoisingStage.progress_bar
¶
Create a progress bar for the denoising process.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
iterable
|
Iterable | None
|
The iterable to iterate over. |
None
|
total
|
int | None
|
The total number of items. |
None
|
Returns:
| Type | Description |
|---|---|
tqdm
|
A tqdm progress bar. |
Source code in fastvideo/pipelines/stages/denoising.py
fastvideo.pipelines.stages.DenoisingStage.rescale_noise_cfg
¶
Rescale noise prediction according to guidance_rescale.
Based on findings of "Common Diffusion Noise Schedules and Sample Steps are Flawed" (https://arxiv.org/pdf/2305.08891.pdf), Section 3.4.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
noise_cfg
|
The noise prediction with guidance. |
required | |
noise_pred_text
|
The text-conditioned noise prediction. |
required | |
guidance_rescale
|
The guidance rescale factor. |
0.0
|
Returns:
| Type | Description |
|---|---|
Tensor
|
The rescaled noise prediction. |
Source code in fastvideo/pipelines/stages/denoising.py
fastvideo.pipelines.stages.DenoisingStage.verify_input
¶
verify_input(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
Verify denoising stage inputs.
Source code in fastvideo/pipelines/stages/denoising.py
fastvideo.pipelines.stages.DenoisingStage.verify_output
¶
verify_output(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
Verify denoising stage outputs.
Source code in fastvideo/pipelines/stages/denoising.py
fastvideo.pipelines.stages.DmdDenoisingStage
¶
Bases: DenoisingStage
Denoising stage for DMD.
Source code in fastvideo/pipelines/stages/denoising.py
Functions¶
fastvideo.pipelines.stages.DmdDenoisingStage.forward
¶
forward(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> ForwardBatch
Run the denoising loop.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch
|
ForwardBatch
|
The current batch information. |
required |
fastvideo_args
|
FastVideoArgs
|
The inference arguments. |
required |
Returns:
| Type | Description |
|---|---|
ForwardBatch
|
The batch with denoised latents. |
Source code in fastvideo/pipelines/stages/denoising.py
1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 | |
fastvideo.pipelines.stages.EncodingStage
¶
Bases: PipelineStage
Stage for encoding pixel space representations into latent space.
This stage handles the encoding of pixel-space video/images into latent representations for further processing in the diffusion pipeline.
Source code in fastvideo/pipelines/stages/encoding.py
Functions¶
fastvideo.pipelines.stages.EncodingStage.forward
¶
forward(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> ForwardBatch
Encode pixel space representations into latent space.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch
|
ForwardBatch
|
The current batch information. |
required |
fastvideo_args
|
FastVideoArgs
|
The inference arguments. |
required |
Returns:
| Type | Description |
|---|---|
ForwardBatch
|
The batch with encoded latents. |
Source code in fastvideo/pipelines/stages/encoding.py
fastvideo.pipelines.stages.EncodingStage.verify_input
¶
verify_input(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
Verify encoding stage inputs.
Source code in fastvideo/pipelines/stages/encoding.py
fastvideo.pipelines.stages.EncodingStage.verify_output
¶
verify_output(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
Verify encoding stage outputs.
Source code in fastvideo/pipelines/stages/encoding.py
fastvideo.pipelines.stages.GameCraftDenoisingStage
¶
Bases: DenoisingStage
Denoising stage for HunyuanGameCraft with camera/action conditioning.
This stage handles: - Camera state encoding via CameraNet (Plücker coordinates) - Concatenation of latents with gt_latents and mask (33 channels) - Flow matching denoising with camera conditioning - Support for autoregressive generation with history frames
Source code in fastvideo/pipelines/stages/gamecraft_denoising.py
Functions¶
fastvideo.pipelines.stages.GameCraftDenoisingStage.forward
¶
forward(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> ForwardBatch
Run the denoising loop with camera/action conditioning.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch
|
ForwardBatch
|
The current batch information. Must contain: - latents: Noise latents [B, 16, T, H, W] - camera_states: Plücker coordinates [B, T_video, 6, H_video, W_video] - gt_latents (optional): Ground truth latents for conditioning [B, 16, T, H, W] - conditioning_mask (optional): Mask for conditioning [B, 1, T, H, W] |
required |
fastvideo_args
|
FastVideoArgs
|
The inference arguments. |
required |
Returns:
| Type | Description |
|---|---|
ForwardBatch
|
The batch with denoised latents. |
Source code in fastvideo/pipelines/stages/gamecraft_denoising.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 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 | |
fastvideo.pipelines.stages.GameCraftDenoisingStage.verify_input
¶
verify_input(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
Verify that required inputs are present.
Source code in fastvideo/pipelines/stages/gamecraft_denoising.py
fastvideo.pipelines.stages.GameCraftDenoisingStage.verify_output
¶
verify_output(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
Verify that outputs are properly set.
Source code in fastvideo/pipelines/stages/gamecraft_denoising.py
fastvideo.pipelines.stages.GameCraftImageVAEEncodingStage
¶
Bases: PipelineStage
Stage for encoding a reference image into gt_latents and conditioning_mask for HunyuanGameCraft image-to-video generation.
Official GameCraft I2V flow: 1. VAE-encode the reference image -> [B, 16, 1, H_lat, W_lat] 2. Scale by VAE scaling_factor (0.476986) 3. Repeat to all temporal frames 4. Zero out non-conditioned frames (first frame only for short videos, first half for longer autoregressive generation) 5. Build a binary mask (1 = conditioned, 0 = generate) 6. Store gt_latents and conditioning_mask on the batch for the denoising stage
If no image is provided (T2V mode), this stage is a no-op; the denoising stage already falls back to zero gt_latents and zero mask.
Source code in fastvideo/pipelines/stages/gamecraft_image_encoding.py
Functions¶
fastvideo.pipelines.stages.GameCraftImageVAEEncodingStage.forward
¶
forward(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> ForwardBatch
Encode reference image for I2V, or skip for T2V.
Source code in fastvideo/pipelines/stages/gamecraft_image_encoding.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | |
fastvideo.pipelines.stages.HYWorldDenoisingStage
¶
Bases: DenoisingStage
Denoising stage for HYWorld-style chunk-based video generation.
This stage implements bi_rollout denoising with: - Chunk-based processing (generates video in chunks, e.g., 4 frames at a time) - Context frame selection based on camera view alignment - 3D-aware generation using view matrices and camera intrinsics - Support for action conditioning - Dual timestep handling (context frames use different timestep than current frames) - Context frame selection based on camera view alignment
Source code in fastvideo/pipelines/stages/hyworld_denoising.py
Functions¶
fastvideo.pipelines.stages.HYWorldDenoisingStage.forward
¶
forward(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> ForwardBatch
Run the chunk-based denoising loop with context frame selection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch
|
ForwardBatch
|
The current batch information. Must contain: - viewmats: torch.Tensor | None - Camera view matrices (B, T, 4, 4) - Ks: torch.Tensor | None - Camera intrinsics (B, T, 3, 3) - action: torch.Tensor | None - Action conditioning (B, T) - chunk_latent_frames: int - Number of frames per chunk (default: 16 for bidirectional model) These can be passed via batch.extra dict or as direct attributes. |
required |
fastvideo_args
|
FastVideoArgs
|
The inference arguments. |
required |
Returns:
| Type | Description |
|---|---|
ForwardBatch
|
The batch with denoised latents. |
Source code in fastvideo/pipelines/stages/hyworld_denoising.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 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 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 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 | |
fastvideo.pipelines.stages.HYWorldDenoisingStage.verify_input
¶
verify_input(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
Verify HYWorld denoising stage inputs.
Source code in fastvideo/pipelines/stages/hyworld_denoising.py
fastvideo.pipelines.stages.HYWorldDenoisingStage.verify_output
¶
verify_output(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
Verify HYWorld denoising stage outputs.
Source code in fastvideo/pipelines/stages/hyworld_denoising.py
fastvideo.pipelines.stages.HYWorldImageEncodingStage
¶
Bases: ImageEncodingStage
Stage for encoding image prompts into embeddings for HYWorld models.
Uses SigLIP (or other vision encoder) to encode reference images for I2V tasks. Also encodes reference image with VAE for conditional latent.
Source code in fastvideo/pipelines/stages/image_encoding.py
Functions¶
fastvideo.pipelines.stages.HYWorldImageEncodingStage.forward
¶
forward(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> ForwardBatch
Encode the prompt into image encoder hidden states and VAE latents.
For I2V
- encodes the reference image using SigLIP → image_embeds
- encodes the reference image using VAE → image_latent (expanded to full temporal dim)
For T2V: creates zero embeddings
The image_latent is expanded to match the full temporal dimension of the video latent, following the original HunyuanVideo-1.5 implementation where: - First frame contains the encoded reference image - All other frames are zeros - Mask channel is 1 for first frame, 0 for rest
Source code in fastvideo/pipelines/stages/image_encoding.py
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 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 | |
fastvideo.pipelines.stages.HYWorldImageEncodingStage.verify_input
¶
verify_input(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
fastvideo.pipelines.stages.Hy15ImageEncodingStage
¶
Bases: ImageEncodingStage
Stage for encoding image prompts into embeddings for HunyuanVideo1.5 models.
Source code in fastvideo/pipelines/stages/image_encoding.py
Functions¶
fastvideo.pipelines.stages.Hy15ImageEncodingStage.forward
¶
forward(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> ForwardBatch
Encode the prompt into image encoder hidden states.
Source code in fastvideo/pipelines/stages/image_encoding.py
fastvideo.pipelines.stages.Hy15ImageEncodingStage.verify_input
¶
verify_input(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
fastvideo.pipelines.stages.ImageEncodingStage
¶
Bases: PipelineStage
Stage for encoding image prompts into embeddings for diffusion models.
This stage handles the encoding of image prompts into the embedding space expected by the diffusion model.
Initialize the prompt encoding stage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
enable_logging
|
Whether to enable logging for this stage. |
required | |
is_secondary
|
Whether this is a secondary image encoder. |
required |
Source code in fastvideo/pipelines/stages/image_encoding.py
Functions¶
fastvideo.pipelines.stages.ImageEncodingStage.forward
¶
forward(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> ForwardBatch
Encode the prompt into image encoder hidden states.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch
|
ForwardBatch
|
The current batch information. |
required |
fastvideo_args
|
FastVideoArgs
|
The inference arguments. |
required |
Returns:
| Type | Description |
|---|---|
ForwardBatch
|
The batch with encoded prompt embeddings. |
Source code in fastvideo/pipelines/stages/image_encoding.py
fastvideo.pipelines.stages.ImageEncodingStage.verify_input
¶
verify_input(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
Verify image encoding stage inputs.
Source code in fastvideo/pipelines/stages/image_encoding.py
fastvideo.pipelines.stages.ImageEncodingStage.verify_output
¶
verify_output(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
Verify image encoding stage outputs.
Source code in fastvideo/pipelines/stages/image_encoding.py
fastvideo.pipelines.stages.ImageVAEEncodingStage
¶
Bases: PipelineStage
Stage for encoding image pixel representations into latent space.
This stage handles the encoding of image pixel representations into the final input format (e.g., latents) for image-to-video generation.
Source code in fastvideo/pipelines/stages/image_encoding.py
Functions¶
fastvideo.pipelines.stages.ImageVAEEncodingStage.forward
¶
forward(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> ForwardBatch
Encode pixel representations into latent space.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch
|
ForwardBatch
|
The current batch information. |
required |
fastvideo_args
|
FastVideoArgs
|
The inference arguments. |
required |
Returns:
| Type | Description |
|---|---|
ForwardBatch
|
The batch with encoded outputs. |
Source code in fastvideo/pipelines/stages/image_encoding.py
392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 | |
fastvideo.pipelines.stages.ImageVAEEncodingStage.verify_input
¶
verify_input(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
Verify encoding stage inputs.
Source code in fastvideo/pipelines/stages/image_encoding.py
fastvideo.pipelines.stages.ImageVAEEncodingStage.verify_output
¶
verify_output(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
Verify encoding stage outputs.
Source code in fastvideo/pipelines/stages/image_encoding.py
fastvideo.pipelines.stages.InputValidationStage
¶
Bases: PipelineStage
Stage for validating and preparing inputs for diffusion pipelines.
This stage validates that all required inputs are present and properly formatted before proceeding with the diffusion process.
Functions¶
fastvideo.pipelines.stages.InputValidationStage.forward
¶
forward(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> ForwardBatch
Validate and prepare inputs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch
|
ForwardBatch
|
The current batch information. |
required |
fastvideo_args
|
FastVideoArgs
|
The inference arguments. |
required |
Returns:
| Type | Description |
|---|---|
ForwardBatch
|
The validated batch information. |
Source code in fastvideo/pipelines/stages/input_validation.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 | |
fastvideo.pipelines.stages.InputValidationStage.verify_input
¶
verify_input(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
Verify input validation stage inputs.
Source code in fastvideo/pipelines/stages/input_validation.py
fastvideo.pipelines.stages.InputValidationStage.verify_output
¶
verify_output(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
Verify input validation stage outputs.
Source code in fastvideo/pipelines/stages/input_validation.py
fastvideo.pipelines.stages.LTX2AudioDecodingStage
¶
Bases: PipelineStage
Decode LTX-2 audio latents into a waveform.
Source code in fastvideo/pipelines/stages/ltx2_audio_decoding.py
fastvideo.pipelines.stages.LTX2DenoisingStage
¶
Bases: PipelineStage
Run the LTX-2 denoising loop over the sigma schedule.
Source code in fastvideo/pipelines/stages/ltx2_denoising.py
fastvideo.pipelines.stages.LTX2LatentPreparationStage
¶
Bases: PipelineStage
Prepare initial LTX-2 latents without relying on a diffusers scheduler.
Source code in fastvideo/pipelines/stages/ltx2_latent_preparation.py
fastvideo.pipelines.stages.LTX2TextEncodingStage
¶
Bases: TextEncodingStage
LTX2 text encoding stage with sequence parallelism support.
When SP is enabled (sp_world_size > 1), only rank 0 runs the text encoder and broadcasts embeddings to other ranks. This avoids I/O contention from all ranks loading the Gemma model simultaneously, which can cause text encoding to take 100+ seconds instead of ~5 seconds.
Source code in fastvideo/pipelines/stages/text_encoding.py
fastvideo.pipelines.stages.LatentPreparationStage
¶
LatentPreparationStage(scheduler, transformer, use_btchw_layout: bool = False)
Bases: PipelineStage
Stage for preparing initial latent variables for the diffusion process.
This stage handles the preparation of the initial latent variables that will be denoised during the diffusion process.
Source code in fastvideo/pipelines/stages/latent_preparation.py
Functions¶
fastvideo.pipelines.stages.LatentPreparationStage.forward
¶
forward(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> ForwardBatch
Prepare initial latent variables for the diffusion process.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch
|
ForwardBatch
|
The current batch information. |
required |
fastvideo_args
|
FastVideoArgs
|
The inference arguments. |
required |
Returns:
| Type | Description |
|---|---|
ForwardBatch
|
The batch with prepared latent variables. |
Source code in fastvideo/pipelines/stages/latent_preparation.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | |
fastvideo.pipelines.stages.LatentPreparationStage.verify_input
¶
verify_input(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
Verify latent preparation stage inputs.
Source code in fastvideo/pipelines/stages/latent_preparation.py
fastvideo.pipelines.stages.LatentPreparationStage.verify_output
¶
verify_output(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
Verify latent preparation stage outputs.
Source code in fastvideo/pipelines/stages/latent_preparation.py
fastvideo.pipelines.stages.LongCatKVCacheInitStage
¶
Bases: PipelineStage
Pre-compute KV cache for conditioning frames.
After this stage: - batch.kv_cache_dict contains {block_idx: (k, v)} - batch.cond_latents contains the conditioning latents - batch.latents contains ONLY noise latents
Source code in fastvideo/pipelines/stages/longcat_kv_cache_init.py
Functions¶
fastvideo.pipelines.stages.LongCatKVCacheInitStage.forward
¶
forward(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> ForwardBatch
Initialize KV cache from conditioning latents.
Source code in fastvideo/pipelines/stages/longcat_kv_cache_init.py
fastvideo.pipelines.stages.LongCatVCDenoisingStage
¶
Bases: LongCatDenoisingStage
LongCat denoising with Video Continuation and KV cache support.
Key differences from I2V denoising: - Supports KV cache (reuses cached K/V from conditioning frames) - Handles larger num_cond_latents - Concatenates conditioning latents back after denoising
When use_kv_cache=True: - batch.latents contains ONLY noise frames (cond removed by KV cache init) - batch.kv_cache_dict contains cached K/V - batch.cond_latents contains conditioning latents for post-concat
When use_kv_cache=False: - batch.latents contains ALL frames (cond + noise) - Timestep masking: timestep[:, :num_cond_latents] = 0 - Selective denoising: only update noise frames
Source code in fastvideo/pipelines/stages/denoising.py
Functions¶
fastvideo.pipelines.stages.LongCatVCDenoisingStage.forward
¶
forward(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> ForwardBatch
Run denoising loop with VC conditioning and optional KV cache.
Source code in fastvideo/pipelines/stages/longcat_vc_denoising.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | |
fastvideo.pipelines.stages.LongCatVideoVAEEncodingStage
¶
Bases: PipelineStage
Encode video frames to latent space for VC conditioning.
This stage: 1. Loads video frames from path or uses provided frames 2. Takes the last num_cond_frames from the video 3. Preprocesses and stacks frames 4. Encodes via VAE to latent space 5. Applies LongCat-specific normalization 6. Calculates num_cond_latents
Source code in fastvideo/pipelines/stages/longcat_video_vae_encoding.py
Functions¶
fastvideo.pipelines.stages.LongCatVideoVAEEncodingStage.forward
¶
forward(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> ForwardBatch
Encode video frames to latent for VC conditioning.
Source code in fastvideo/pipelines/stages/longcat_video_vae_encoding.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | |
fastvideo.pipelines.stages.LongCatVideoVAEEncodingStage.normalize_latents
¶
Apply LongCat-specific latent normalization.
Formula: (latents - mean) / std
Source code in fastvideo/pipelines/stages/longcat_video_vae_encoding.py
fastvideo.pipelines.stages.LongCatVideoVAEEncodingStage.retrieve_latents
¶
retrieve_latents(encoder_output: Any, generator: Generator | None) -> Tensor
Sample from VAE posterior.
Source code in fastvideo/pipelines/stages/longcat_video_vae_encoding.py
fastvideo.pipelines.stages.PipelineStage
¶
Bases: ABC
Abstract base class for all pipeline stages.
A pipeline stage represents a discrete step in the diffusion process that can be composed with other stages to create a complete pipeline. Each stage is responsible for a specific part of the process, such as prompt encoding, latent preparation, etc.
Attributes¶
fastvideo.pipelines.stages.PipelineStage.device
property
¶
Get the device for this stage.
Functions¶
fastvideo.pipelines.stages.PipelineStage.__call__
¶
__call__(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> ForwardBatch
Execute the stage's processing on the batch with optional verification and logging. Should not be overridden by subclasses.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch
|
ForwardBatch
|
The current batch information. |
required |
fastvideo_args
|
FastVideoArgs
|
The inference arguments. |
required |
Returns:
| Type | Description |
|---|---|
ForwardBatch
|
The updated batch information after this stage's processing. |
Source code in fastvideo/pipelines/stages/base.py
fastvideo.pipelines.stages.PipelineStage.forward
abstractmethod
¶
forward(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> ForwardBatch
Forward pass of the stage's processing.
This method should be implemented by subclasses to provide the forward processing logic for the stage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch
|
ForwardBatch
|
The current batch information. |
required |
fastvideo_args
|
FastVideoArgs
|
The inference arguments. |
required |
Returns:
| Type | Description |
|---|---|
ForwardBatch
|
The updated batch information after this stage's processing. |
Source code in fastvideo/pipelines/stages/base.py
fastvideo.pipelines.stages.PipelineStage.set_logging
¶
set_logging(enable: bool)
Enable or disable logging for this stage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
enable
|
bool
|
Whether to enable logging. |
required |
fastvideo.pipelines.stages.PipelineStage.verify_input
¶
verify_input(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
Verify the input for the stage.
Example
from fastvideo.pipelines.stages.validators import V, VerificationResult
def verify_input(self, batch, fastvideo_args): result = VerificationResult() result.add_check("height", batch.height, V.positive_int_divisible(8)) result.add_check("width", batch.width, V.positive_int_divisible(8)) result.add_check("image_latent", batch.image_latent, V.is_tensor) return result
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch
|
ForwardBatch
|
The current batch information. |
required |
fastvideo_args
|
FastVideoArgs
|
The inference arguments. |
required |
Returns:
| Type | Description |
|---|---|
VerificationResult
|
A VerificationResult containing the verification status. |
Source code in fastvideo/pipelines/stages/base.py
fastvideo.pipelines.stages.PipelineStage.verify_output
¶
verify_output(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
Verify the output for the stage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch
|
ForwardBatch
|
The current batch information. |
required |
fastvideo_args
|
FastVideoArgs
|
The inference arguments. |
required |
Returns:
| Type | Description |
|---|---|
VerificationResult
|
A VerificationResult containing the verification status. |
Source code in fastvideo/pipelines/stages/base.py
fastvideo.pipelines.stages.RefImageEncodingStage
¶
Bases: ImageEncodingStage
Stage for encoding reference image prompts into embeddings for Wan2.1 Control models.
This stage extends ImageEncodingStage with specialized preprocessing for reference images.
Source code in fastvideo/pipelines/stages/image_encoding.py
Functions¶
fastvideo.pipelines.stages.RefImageEncodingStage.forward
¶
forward(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> ForwardBatch
Encode the prompt into image encoder hidden states.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch
|
ForwardBatch
|
The current batch information. |
required |
fastvideo_args
|
FastVideoArgs
|
The inference arguments. |
required |
Returns:
| Type | Description |
|---|---|
ForwardBatch
|
The batch with encoded prompt embeddings. |
Source code in fastvideo/pipelines/stages/image_encoding.py
fastvideo.pipelines.stages.SRDenoisingStage
¶
Bases: PipelineStage
Stage for running the denoising loop in SR diffusion pipelines. Used by Hunyuan15 SR pipeline.
This stage handles the iterative denoising process that transforms the initial noise into the final output.
Source code in fastvideo/pipelines/stages/sr_denoising.py
Functions¶
fastvideo.pipelines.stages.SRDenoisingStage.forward
¶
forward(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> ForwardBatch
Run the denoising loop.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch
|
ForwardBatch
|
The current batch information. |
required |
fastvideo_args
|
FastVideoArgs
|
The inference arguments. |
required |
Returns:
| Type | Description |
|---|---|
ForwardBatch
|
The batch with denoised latents. |
Source code in fastvideo/pipelines/stages/sr_denoising.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 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 | |
fastvideo.pipelines.stages.SRDenoisingStage.prepare_extra_func_kwargs
¶
Prepare extra kwargs for the scheduler step / denoise step.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
func
|
The function to prepare kwargs for. |
required | |
kwargs
|
The kwargs to prepare. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
The prepared kwargs. |
Source code in fastvideo/pipelines/stages/sr_denoising.py
fastvideo.pipelines.stages.SRDenoisingStage.progress_bar
¶
Create a progress bar for the denoising process.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
iterable
|
Iterable | None
|
The iterable to iterate over. |
None
|
total
|
int | None
|
The total number of items. |
None
|
Returns:
| Type | Description |
|---|---|
tqdm
|
A tqdm progress bar. |
Source code in fastvideo/pipelines/stages/sr_denoising.py
fastvideo.pipelines.stages.SRDenoisingStage.verify_input
¶
verify_input(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
Verify denoising stage inputs.
Source code in fastvideo/pipelines/stages/sr_denoising.py
fastvideo.pipelines.stages.SRDenoisingStage.verify_output
¶
verify_output(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
Verify denoising stage outputs.
Source code in fastvideo/pipelines/stages/sr_denoising.py
fastvideo.pipelines.stages.TextEncodingStage
¶
Bases: PipelineStage
Stage for encoding text prompts into embeddings for diffusion models.
This stage handles the encoding of text prompts into the embedding space expected by the diffusion model.
Initialize the prompt encoding stage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
enable_logging
|
Whether to enable logging for this stage. |
required | |
is_secondary
|
Whether this is a secondary text encoder. |
required |
Source code in fastvideo/pipelines/stages/text_encoding.py
Functions¶
fastvideo.pipelines.stages.TextEncodingStage.encode_text
¶
encode_text(text: str | list[str], fastvideo_args: FastVideoArgs, encoder_index: int | list[int] | None = None, return_attention_mask: bool = False, return_type: str = 'list', device: device | str | None = None, dtype: dtype | None = None, max_length: int | None = None, truncation: bool | None = None, padding: bool | str | None = None)
Encode plain text using selected text encoder(s) and return embeddings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str | list[str]
|
A single string or a list of strings to encode. |
required |
fastvideo_args
|
FastVideoArgs
|
The inference arguments providing pipeline config, including tokenizer and encoder settings, preprocess and postprocess functions. |
required |
encoder_index
|
int | list[int] | None
|
Encoder selector by index. Accepts an int or list of ints. |
None
|
return_attention_mask
|
bool
|
If True, also return attention masks for each selected encoder. |
False
|
return_type
|
str
|
"list" (default) returns a list aligned with selection; "dict" returns a dict keyed by encoder index as a string; "stack" stacks along a new first dimension (requires matching shapes). |
'list'
|
device
|
device | str | None
|
Optional device override for inputs; defaults to local torch device. |
None
|
dtype
|
dtype | None
|
Optional dtype to cast returned embeddings to. |
None
|
max_length
|
int | None
|
Optional per-call tokenizer override. |
None
|
truncation
|
bool | None
|
Optional per-call tokenizer override. |
None
|
padding
|
bool | str | None
|
Optional per-call tokenizer override. |
None
|
Returns:
| Type | Description |
|---|---|
|
Depending on return_type and return_attention_mask: |
|
|
|
|
|
|
Source code in fastvideo/pipelines/stages/text_encoding.py
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 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 | |
fastvideo.pipelines.stages.TextEncodingStage.forward
¶
forward(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> ForwardBatch
Encode the prompt into text encoder hidden states.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch
|
ForwardBatch
|
The current batch information. |
required |
fastvideo_args
|
FastVideoArgs
|
The inference arguments. |
required |
Returns:
| Type | Description |
|---|---|
ForwardBatch
|
The batch with encoded prompt embeddings. |
Source code in fastvideo/pipelines/stages/text_encoding.py
fastvideo.pipelines.stages.TextEncodingStage.verify_input
¶
verify_input(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
Verify text encoding stage inputs.
Source code in fastvideo/pipelines/stages/text_encoding.py
fastvideo.pipelines.stages.TextEncodingStage.verify_output
¶
verify_output(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
Verify text encoding stage outputs.
Source code in fastvideo/pipelines/stages/text_encoding.py
fastvideo.pipelines.stages.TimestepPreparationStage
¶
Bases: PipelineStage
Stage for preparing timesteps for the diffusion process.
This stage handles the preparation of the timestep sequence that will be used during the diffusion process.
Source code in fastvideo/pipelines/stages/timestep_preparation.py
Functions¶
fastvideo.pipelines.stages.TimestepPreparationStage.forward
¶
forward(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> ForwardBatch
Prepare timesteps for the diffusion process.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch
|
ForwardBatch
|
The current batch information. |
required |
fastvideo_args
|
FastVideoArgs
|
The inference arguments. |
required |
Returns:
| Type | Description |
|---|---|
ForwardBatch
|
The batch with prepared timesteps. |
Source code in fastvideo/pipelines/stages/timestep_preparation.py
fastvideo.pipelines.stages.TimestepPreparationStage.verify_input
¶
verify_input(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
Verify timestep preparation stage inputs.
Source code in fastvideo/pipelines/stages/timestep_preparation.py
fastvideo.pipelines.stages.TimestepPreparationStage.verify_output
¶
verify_output(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
Verify timestep preparation stage outputs.
Source code in fastvideo/pipelines/stages/timestep_preparation.py
fastvideo.pipelines.stages.VideoVAEEncodingStage
¶
Bases: ImageVAEEncodingStage
Stage for encoding video pixel representations into latent space.
This stage handles the encoding of video pixel representations for video-to-video generation and control. Inherits from ImageVAEEncodingStage to reuse common functionality.
Source code in fastvideo/pipelines/stages/image_encoding.py
Functions¶
fastvideo.pipelines.stages.VideoVAEEncodingStage.forward
¶
forward(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> ForwardBatch
Encode video pixel representations into latent space.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch
|
ForwardBatch
|
The current batch information. |
required |
fastvideo_args
|
FastVideoArgs
|
The inference arguments. |
required |
Returns:
| Type | Description |
|---|---|
ForwardBatch
|
The batch with encoded outputs. |
Source code in fastvideo/pipelines/stages/image_encoding.py
565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 | |
fastvideo.pipelines.stages.VideoVAEEncodingStage.verify_input
¶
verify_input(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
Verify video encoding stage inputs.
Source code in fastvideo/pipelines/stages/image_encoding.py
fastvideo.pipelines.stages.VideoVAEEncodingStage.verify_output
¶
verify_output(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
Verify video encoding stage outputs.
Source code in fastvideo/pipelines/stages/image_encoding.py
Modules¶
fastvideo.pipelines.stages.base
¶
Base classes for pipeline stages.
This module defines the abstract base classes for pipeline stages that can be composed to create complete diffusion pipelines.
Classes¶
fastvideo.pipelines.stages.base.PipelineStage
¶
Bases: ABC
Abstract base class for all pipeline stages.
A pipeline stage represents a discrete step in the diffusion process that can be composed with other stages to create a complete pipeline. Each stage is responsible for a specific part of the process, such as prompt encoding, latent preparation, etc.
Attributes¶
fastvideo.pipelines.stages.base.PipelineStage.device
property
¶Get the device for this stage.
Functions¶
fastvideo.pipelines.stages.base.PipelineStage.__call__
¶__call__(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> ForwardBatch
Execute the stage's processing on the batch with optional verification and logging. Should not be overridden by subclasses.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch
|
ForwardBatch
|
The current batch information. |
required |
fastvideo_args
|
FastVideoArgs
|
The inference arguments. |
required |
Returns:
| Type | Description |
|---|---|
ForwardBatch
|
The updated batch information after this stage's processing. |
Source code in fastvideo/pipelines/stages/base.py
fastvideo.pipelines.stages.base.PipelineStage.forward
abstractmethod
¶forward(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> ForwardBatch
Forward pass of the stage's processing.
This method should be implemented by subclasses to provide the forward processing logic for the stage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch
|
ForwardBatch
|
The current batch information. |
required |
fastvideo_args
|
FastVideoArgs
|
The inference arguments. |
required |
Returns:
| Type | Description |
|---|---|
ForwardBatch
|
The updated batch information after this stage's processing. |
Source code in fastvideo/pipelines/stages/base.py
fastvideo.pipelines.stages.base.PipelineStage.set_logging
¶set_logging(enable: bool)
Enable or disable logging for this stage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
enable
|
bool
|
Whether to enable logging. |
required |
fastvideo.pipelines.stages.base.PipelineStage.verify_input
¶verify_input(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
Verify the input for the stage.
Example
from fastvideo.pipelines.stages.validators import V, VerificationResult
def verify_input(self, batch, fastvideo_args): result = VerificationResult() result.add_check("height", batch.height, V.positive_int_divisible(8)) result.add_check("width", batch.width, V.positive_int_divisible(8)) result.add_check("image_latent", batch.image_latent, V.is_tensor) return result
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch
|
ForwardBatch
|
The current batch information. |
required |
fastvideo_args
|
FastVideoArgs
|
The inference arguments. |
required |
Returns:
| Type | Description |
|---|---|
VerificationResult
|
A VerificationResult containing the verification status. |
Source code in fastvideo/pipelines/stages/base.py
fastvideo.pipelines.stages.base.PipelineStage.verify_output
¶verify_output(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
Verify the output for the stage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch
|
ForwardBatch
|
The current batch information. |
required |
fastvideo_args
|
FastVideoArgs
|
The inference arguments. |
required |
Returns:
| Type | Description |
|---|---|
VerificationResult
|
A VerificationResult containing the verification status. |
Source code in fastvideo/pipelines/stages/base.py
fastvideo.pipelines.stages.base.StageVerificationError
¶
Bases: Exception
Exception raised when stage verification fails.
Functions¶
fastvideo.pipelines.stages.causal_denoising
¶
Classes¶
fastvideo.pipelines.stages.causal_denoising.CausalDMDDenosingStage
¶
Bases: DenoisingStage
Denoising stage for causal diffusion.
Source code in fastvideo/pipelines/stages/causal_denoising.py
Functions¶
fastvideo.pipelines.stages.causal_denoising.CausalDMDDenosingStage.verify_input
¶verify_input(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
Verify denoising stage inputs.
Source code in fastvideo/pipelines/stages/causal_denoising.py
fastvideo.pipelines.stages.causal_denoising.CausalDenoisingStage
¶
Bases: CausalDMDDenosingStage
Causal block-by-block denoising with standard multi-step flow matching (scheduler.step), not DMD few-step.
Each block is fully denoised through all scheduler timesteps before moving to the next block. After each block is denoised, the KV cache is updated with clean context so subsequent blocks can attend to prior clean frames.
Source code in fastvideo/pipelines/stages/causal_denoising.py
Functions¶
fastvideo.pipelines.stages.conditioning
¶
Conditioning stage for diffusion pipelines.
Classes¶
fastvideo.pipelines.stages.conditioning.ConditioningStage
¶
Bases: PipelineStage
Stage for applying conditioning to the diffusion process.
This stage handles the application of conditioning, such as classifier-free guidance, to the diffusion process.
Functions¶
fastvideo.pipelines.stages.conditioning.ConditioningStage.forward
¶forward(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> ForwardBatch
Apply conditioning to the diffusion process.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch
|
ForwardBatch
|
The current batch information. |
required |
fastvideo_args
|
FastVideoArgs
|
The inference arguments. |
required |
Returns:
| Type | Description |
|---|---|
ForwardBatch
|
The batch with applied conditioning. |
Source code in fastvideo/pipelines/stages/conditioning.py
fastvideo.pipelines.stages.conditioning.ConditioningStage.verify_input
¶verify_input(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
Verify conditioning stage inputs.
Source code in fastvideo/pipelines/stages/conditioning.py
fastvideo.pipelines.stages.conditioning.ConditioningStage.verify_output
¶verify_output(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
Verify conditioning stage outputs.
Source code in fastvideo/pipelines/stages/conditioning.py
Functions¶
fastvideo.pipelines.stages.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
Functions¶
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
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 | |
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.
Source code in fastvideo/pipelines/stages/decoding.py
Functions¶
fastvideo.pipelines.stages.denoising
¶
Denoising stage for diffusion pipelines.
Classes¶
fastvideo.pipelines.stages.denoising.Cosmos25AutoDenoisingStage
¶
Bases: PipelineStage
Route Cosmos 2.5 denoising to T2W vs V2W/I2W.
Source code in fastvideo/pipelines/stages/denoising.py
fastvideo.pipelines.stages.denoising.Cosmos25DenoisingStage
¶
Bases: CosmosDenoisingStage
Denoising stage for Cosmos 2.5 DiT (expects 1D/2D timestep, not 5D).
Source code in fastvideo/pipelines/stages/denoising.py
fastvideo.pipelines.stages.denoising.Cosmos25T2WDenoisingStage
¶
Bases: Cosmos25DenoisingStage
Cosmos 2.5 Text2World denoising stage.
Source code in fastvideo/pipelines/stages/denoising.py
fastvideo.pipelines.stages.denoising.Cosmos25V2WDenoisingStage
¶
Bases: Cosmos25DenoisingStage
Cosmos 2.5 Video2World denoising stage.
Source code in fastvideo/pipelines/stages/denoising.py
fastvideo.pipelines.stages.denoising.CosmosDenoisingStage
¶
Bases: DenoisingStage
Denoising stage for Cosmos models using FlowMatchEulerDiscreteScheduler.
Source code in fastvideo/pipelines/stages/denoising.py
Functions¶
fastvideo.pipelines.stages.denoising.CosmosDenoisingStage.verify_input
¶verify_input(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
Verify Cosmos denoising stage inputs.
Source code in fastvideo/pipelines/stages/denoising.py
fastvideo.pipelines.stages.denoising.CosmosDenoisingStage.verify_output
¶verify_output(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
Verify Cosmos denoising stage outputs.
Source code in fastvideo/pipelines/stages/denoising.py
fastvideo.pipelines.stages.denoising.DenoisingStage
¶
Bases: PipelineStage
Stage for running the denoising loop in diffusion pipelines.
This stage handles the iterative denoising process that transforms the initial noise into the final output.
Source code in fastvideo/pipelines/stages/denoising.py
Functions¶
fastvideo.pipelines.stages.denoising.DenoisingStage.forward
¶forward(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> ForwardBatch
Run the denoising loop.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch
|
ForwardBatch
|
The current batch information. |
required |
fastvideo_args
|
FastVideoArgs
|
The inference arguments. |
required |
Returns:
| Type | Description |
|---|---|
ForwardBatch
|
The batch with denoised latents. |
Source code in fastvideo/pipelines/stages/denoising.py
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 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 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 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 | |
fastvideo.pipelines.stages.denoising.DenoisingStage.prepare_extra_func_kwargs
¶Prepare extra kwargs for the scheduler step / denoise step.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
func
|
The function to prepare kwargs for. |
required | |
kwargs
|
The kwargs to prepare. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
The prepared kwargs. |
Source code in fastvideo/pipelines/stages/denoising.py
fastvideo.pipelines.stages.denoising.DenoisingStage.progress_bar
¶Create a progress bar for the denoising process.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
iterable
|
Iterable | None
|
The iterable to iterate over. |
None
|
total
|
int | None
|
The total number of items. |
None
|
Returns:
| Type | Description |
|---|---|
tqdm
|
A tqdm progress bar. |
Source code in fastvideo/pipelines/stages/denoising.py
fastvideo.pipelines.stages.denoising.DenoisingStage.rescale_noise_cfg
¶Rescale noise prediction according to guidance_rescale.
Based on findings of "Common Diffusion Noise Schedules and Sample Steps are Flawed" (https://arxiv.org/pdf/2305.08891.pdf), Section 3.4.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
noise_cfg
|
The noise prediction with guidance. |
required | |
noise_pred_text
|
The text-conditioned noise prediction. |
required | |
guidance_rescale
|
The guidance rescale factor. |
0.0
|
Returns:
| Type | Description |
|---|---|
Tensor
|
The rescaled noise prediction. |
Source code in fastvideo/pipelines/stages/denoising.py
fastvideo.pipelines.stages.denoising.DenoisingStage.verify_input
¶verify_input(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
Verify denoising stage inputs.
Source code in fastvideo/pipelines/stages/denoising.py
fastvideo.pipelines.stages.denoising.DenoisingStage.verify_output
¶verify_output(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
Verify denoising stage outputs.
Source code in fastvideo/pipelines/stages/denoising.py
fastvideo.pipelines.stages.denoising.DmdDenoisingStage
¶
Bases: DenoisingStage
Denoising stage for DMD.
Source code in fastvideo/pipelines/stages/denoising.py
Functions¶
fastvideo.pipelines.stages.denoising.DmdDenoisingStage.forward
¶forward(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> ForwardBatch
Run the denoising loop.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch
|
ForwardBatch
|
The current batch information. |
required |
fastvideo_args
|
FastVideoArgs
|
The inference arguments. |
required |
Returns:
| Type | Description |
|---|---|
ForwardBatch
|
The batch with denoised latents. |
Source code in fastvideo/pipelines/stages/denoising.py
1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 | |
Functions¶
fastvideo.pipelines.stages.encoding
¶
Encoding stage for diffusion pipelines.
Classes¶
fastvideo.pipelines.stages.encoding.EncodingStage
¶
Bases: PipelineStage
Stage for encoding pixel space representations into latent space.
This stage handles the encoding of pixel-space video/images into latent representations for further processing in the diffusion pipeline.
Source code in fastvideo/pipelines/stages/encoding.py
Functions¶
fastvideo.pipelines.stages.encoding.EncodingStage.forward
¶forward(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> ForwardBatch
Encode pixel space representations into latent space.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch
|
ForwardBatch
|
The current batch information. |
required |
fastvideo_args
|
FastVideoArgs
|
The inference arguments. |
required |
Returns:
| Type | Description |
|---|---|
ForwardBatch
|
The batch with encoded latents. |
Source code in fastvideo/pipelines/stages/encoding.py
fastvideo.pipelines.stages.encoding.EncodingStage.verify_input
¶verify_input(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
Verify encoding stage inputs.
Source code in fastvideo/pipelines/stages/encoding.py
fastvideo.pipelines.stages.encoding.EncodingStage.verify_output
¶verify_output(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
Verify encoding stage outputs.
Source code in fastvideo/pipelines/stages/encoding.py
Functions¶
fastvideo.pipelines.stages.gamecraft_denoising
¶
GameCraft denoising stage for camera/action-conditioned video generation.
This stage implements the denoising loop for HunyuanGameCraft, which generates game-like videos with camera and action conditioning via: 1. CameraNet - Encodes Plücker coordinates into features added to image embeddings 2. Concatenated input - 33 channels (16 latent + 16 gt_latent + 1 mask) 3. Mask-based conditioning for autoregressive generation
Classes¶
fastvideo.pipelines.stages.gamecraft_denoising.GameCraftDenoisingStage
¶
Bases: DenoisingStage
Denoising stage for HunyuanGameCraft with camera/action conditioning.
This stage handles: - Camera state encoding via CameraNet (Plücker coordinates) - Concatenation of latents with gt_latents and mask (33 channels) - Flow matching denoising with camera conditioning - Support for autoregressive generation with history frames
Source code in fastvideo/pipelines/stages/gamecraft_denoising.py
Functions¶
fastvideo.pipelines.stages.gamecraft_denoising.GameCraftDenoisingStage.forward
¶forward(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> ForwardBatch
Run the denoising loop with camera/action conditioning.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch
|
ForwardBatch
|
The current batch information. Must contain: - latents: Noise latents [B, 16, T, H, W] - camera_states: Plücker coordinates [B, T_video, 6, H_video, W_video] - gt_latents (optional): Ground truth latents for conditioning [B, 16, T, H, W] - conditioning_mask (optional): Mask for conditioning [B, 1, T, H, W] |
required |
fastvideo_args
|
FastVideoArgs
|
The inference arguments. |
required |
Returns:
| Type | Description |
|---|---|
ForwardBatch
|
The batch with denoised latents. |
Source code in fastvideo/pipelines/stages/gamecraft_denoising.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 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 | |
fastvideo.pipelines.stages.gamecraft_denoising.GameCraftDenoisingStage.verify_input
¶verify_input(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
Verify that required inputs are present.
Source code in fastvideo/pipelines/stages/gamecraft_denoising.py
fastvideo.pipelines.stages.gamecraft_denoising.GameCraftDenoisingStage.verify_output
¶verify_output(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
Verify that outputs are properly set.
Source code in fastvideo/pipelines/stages/gamecraft_denoising.py
Functions¶
fastvideo.pipelines.stages.gamecraft_image_encoding
¶
GameCraft image-to-video encoding stage.
Encodes a reference image into gt_latents and conditioning_mask for HunyuanGameCraft I2V generation. For T2V this stage is a no-op.
Classes¶
fastvideo.pipelines.stages.gamecraft_image_encoding.GameCraftImageVAEEncodingStage
¶
Bases: PipelineStage
Stage for encoding a reference image into gt_latents and conditioning_mask for HunyuanGameCraft image-to-video generation.
Official GameCraft I2V flow: 1. VAE-encode the reference image -> [B, 16, 1, H_lat, W_lat] 2. Scale by VAE scaling_factor (0.476986) 3. Repeat to all temporal frames 4. Zero out non-conditioned frames (first frame only for short videos, first half for longer autoregressive generation) 5. Build a binary mask (1 = conditioned, 0 = generate) 6. Store gt_latents and conditioning_mask on the batch for the denoising stage
If no image is provided (T2V mode), this stage is a no-op; the denoising stage already falls back to zero gt_latents and zero mask.
Source code in fastvideo/pipelines/stages/gamecraft_image_encoding.py
Functions¶
fastvideo.pipelines.stages.gamecraft_image_encoding.GameCraftImageVAEEncodingStage.forward
¶forward(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> ForwardBatch
Encode reference image for I2V, or skip for T2V.
Source code in fastvideo/pipelines/stages/gamecraft_image_encoding.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | |
Functions¶
fastvideo.pipelines.stages.hyworld_denoising
¶
HYWorld denoising stage for chunk-based video generation with context frame selection.
This stage implements the bi_rollout denoising logic from HYWorld, which processes video generation in chunks with camera-aware context frame selection for temporal consistency.
Classes¶
fastvideo.pipelines.stages.hyworld_denoising.HYWorldDenoisingStage
¶
Bases: DenoisingStage
Denoising stage for HYWorld-style chunk-based video generation.
This stage implements bi_rollout denoising with: - Chunk-based processing (generates video in chunks, e.g., 4 frames at a time) - Context frame selection based on camera view alignment - 3D-aware generation using view matrices and camera intrinsics - Support for action conditioning - Dual timestep handling (context frames use different timestep than current frames) - Context frame selection based on camera view alignment
Source code in fastvideo/pipelines/stages/hyworld_denoising.py
Functions¶
fastvideo.pipelines.stages.hyworld_denoising.HYWorldDenoisingStage.forward
¶forward(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> ForwardBatch
Run the chunk-based denoising loop with context frame selection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch
|
ForwardBatch
|
The current batch information. Must contain: - viewmats: torch.Tensor | None - Camera view matrices (B, T, 4, 4) - Ks: torch.Tensor | None - Camera intrinsics (B, T, 3, 3) - action: torch.Tensor | None - Action conditioning (B, T) - chunk_latent_frames: int - Number of frames per chunk (default: 16 for bidirectional model) These can be passed via batch.extra dict or as direct attributes. |
required |
fastvideo_args
|
FastVideoArgs
|
The inference arguments. |
required |
Returns:
| Type | Description |
|---|---|
ForwardBatch
|
The batch with denoised latents. |
Source code in fastvideo/pipelines/stages/hyworld_denoising.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 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 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 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 | |
fastvideo.pipelines.stages.hyworld_denoising.HYWorldDenoisingStage.verify_input
¶verify_input(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
Verify HYWorld denoising stage inputs.
Source code in fastvideo/pipelines/stages/hyworld_denoising.py
fastvideo.pipelines.stages.hyworld_denoising.HYWorldDenoisingStage.verify_output
¶verify_output(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
Verify HYWorld denoising stage outputs.
Source code in fastvideo/pipelines/stages/hyworld_denoising.py
Functions¶
fastvideo.pipelines.stages.image_encoding
¶
Image and video encoding stages for diffusion pipelines.
This module contains implementations of encoding stages for diffusion pipelines: - ImageEncodingStage: Encodes images using image encoders (e.g., CLIP) - RefImageEncodingStage: Encodes reference image for Wan2.1 control pipeline - ImageVAEEncodingStage: Encodes images to latent space using VAE for I2V generation - VideoVAEEncodingStage: Encodes videos to latent space using VAE for V2V and control tasks
Classes¶
fastvideo.pipelines.stages.image_encoding.HYWorldImageEncodingStage
¶
Bases: ImageEncodingStage
Stage for encoding image prompts into embeddings for HYWorld models.
Uses SigLIP (or other vision encoder) to encode reference images for I2V tasks. Also encodes reference image with VAE for conditional latent.
Source code in fastvideo/pipelines/stages/image_encoding.py
Functions¶
fastvideo.pipelines.stages.image_encoding.HYWorldImageEncodingStage.forward
¶forward(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> ForwardBatch
Encode the prompt into image encoder hidden states and VAE latents.
For I2V
- encodes the reference image using SigLIP → image_embeds
- encodes the reference image using VAE → image_latent (expanded to full temporal dim)
For T2V: creates zero embeddings
The image_latent is expanded to match the full temporal dimension of the video latent, following the original HunyuanVideo-1.5 implementation where: - First frame contains the encoded reference image - All other frames are zeros - Mask channel is 1 for first frame, 0 for rest
Source code in fastvideo/pipelines/stages/image_encoding.py
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 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 | |
fastvideo.pipelines.stages.image_encoding.HYWorldImageEncodingStage.verify_input
¶verify_input(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
fastvideo.pipelines.stages.image_encoding.Hy15ImageEncodingStage
¶
Bases: ImageEncodingStage
Stage for encoding image prompts into embeddings for HunyuanVideo1.5 models.
Source code in fastvideo/pipelines/stages/image_encoding.py
Functions¶
fastvideo.pipelines.stages.image_encoding.Hy15ImageEncodingStage.forward
¶forward(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> ForwardBatch
Encode the prompt into image encoder hidden states.
Source code in fastvideo/pipelines/stages/image_encoding.py
fastvideo.pipelines.stages.image_encoding.Hy15ImageEncodingStage.verify_input
¶verify_input(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
fastvideo.pipelines.stages.image_encoding.ImageEncodingStage
¶
Bases: PipelineStage
Stage for encoding image prompts into embeddings for diffusion models.
This stage handles the encoding of image prompts into the embedding space expected by the diffusion model.
Initialize the prompt encoding stage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
enable_logging
|
Whether to enable logging for this stage. |
required | |
is_secondary
|
Whether this is a secondary image encoder. |
required |
Source code in fastvideo/pipelines/stages/image_encoding.py
Functions¶
fastvideo.pipelines.stages.image_encoding.ImageEncodingStage.forward
¶forward(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> ForwardBatch
Encode the prompt into image encoder hidden states.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch
|
ForwardBatch
|
The current batch information. |
required |
fastvideo_args
|
FastVideoArgs
|
The inference arguments. |
required |
Returns:
| Type | Description |
|---|---|
ForwardBatch
|
The batch with encoded prompt embeddings. |
Source code in fastvideo/pipelines/stages/image_encoding.py
fastvideo.pipelines.stages.image_encoding.ImageEncodingStage.verify_input
¶verify_input(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
Verify image encoding stage inputs.
Source code in fastvideo/pipelines/stages/image_encoding.py
fastvideo.pipelines.stages.image_encoding.ImageEncodingStage.verify_output
¶verify_output(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
Verify image encoding stage outputs.
Source code in fastvideo/pipelines/stages/image_encoding.py
fastvideo.pipelines.stages.image_encoding.ImageVAEEncodingStage
¶
Bases: PipelineStage
Stage for encoding image pixel representations into latent space.
This stage handles the encoding of image pixel representations into the final input format (e.g., latents) for image-to-video generation.
Source code in fastvideo/pipelines/stages/image_encoding.py
Functions¶
fastvideo.pipelines.stages.image_encoding.ImageVAEEncodingStage.forward
¶forward(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> ForwardBatch
Encode pixel representations into latent space.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch
|
ForwardBatch
|
The current batch information. |
required |
fastvideo_args
|
FastVideoArgs
|
The inference arguments. |
required |
Returns:
| Type | Description |
|---|---|
ForwardBatch
|
The batch with encoded outputs. |
Source code in fastvideo/pipelines/stages/image_encoding.py
392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 | |
fastvideo.pipelines.stages.image_encoding.ImageVAEEncodingStage.verify_input
¶verify_input(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
Verify encoding stage inputs.
Source code in fastvideo/pipelines/stages/image_encoding.py
fastvideo.pipelines.stages.image_encoding.ImageVAEEncodingStage.verify_output
¶verify_output(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
Verify encoding stage outputs.
Source code in fastvideo/pipelines/stages/image_encoding.py
fastvideo.pipelines.stages.image_encoding.RefImageEncodingStage
¶
Bases: ImageEncodingStage
Stage for encoding reference image prompts into embeddings for Wan2.1 Control models.
This stage extends ImageEncodingStage with specialized preprocessing for reference images.
Source code in fastvideo/pipelines/stages/image_encoding.py
Functions¶
fastvideo.pipelines.stages.image_encoding.RefImageEncodingStage.forward
¶forward(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> ForwardBatch
Encode the prompt into image encoder hidden states.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch
|
ForwardBatch
|
The current batch information. |
required |
fastvideo_args
|
FastVideoArgs
|
The inference arguments. |
required |
Returns:
| Type | Description |
|---|---|
ForwardBatch
|
The batch with encoded prompt embeddings. |
Source code in fastvideo/pipelines/stages/image_encoding.py
fastvideo.pipelines.stages.image_encoding.VideoVAEEncodingStage
¶
Bases: ImageVAEEncodingStage
Stage for encoding video pixel representations into latent space.
This stage handles the encoding of video pixel representations for video-to-video generation and control. Inherits from ImageVAEEncodingStage to reuse common functionality.
Source code in fastvideo/pipelines/stages/image_encoding.py
Functions¶
fastvideo.pipelines.stages.image_encoding.VideoVAEEncodingStage.forward
¶forward(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> ForwardBatch
Encode video pixel representations into latent space.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch
|
ForwardBatch
|
The current batch information. |
required |
fastvideo_args
|
FastVideoArgs
|
The inference arguments. |
required |
Returns:
| Type | Description |
|---|---|
ForwardBatch
|
The batch with encoded outputs. |
Source code in fastvideo/pipelines/stages/image_encoding.py
565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 | |
fastvideo.pipelines.stages.image_encoding.VideoVAEEncodingStage.verify_input
¶verify_input(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
Verify video encoding stage inputs.
Source code in fastvideo/pipelines/stages/image_encoding.py
fastvideo.pipelines.stages.image_encoding.VideoVAEEncodingStage.verify_output
¶verify_output(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
Verify video encoding stage outputs.
Source code in fastvideo/pipelines/stages/image_encoding.py
Functions¶
fastvideo.pipelines.stages.input_validation
¶
Input validation stage for diffusion pipelines.
Classes¶
fastvideo.pipelines.stages.input_validation.InputValidationStage
¶
Bases: PipelineStage
Stage for validating and preparing inputs for diffusion pipelines.
This stage validates that all required inputs are present and properly formatted before proceeding with the diffusion process.
Functions¶
fastvideo.pipelines.stages.input_validation.InputValidationStage.forward
¶forward(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> ForwardBatch
Validate and prepare inputs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch
|
ForwardBatch
|
The current batch information. |
required |
fastvideo_args
|
FastVideoArgs
|
The inference arguments. |
required |
Returns:
| Type | Description |
|---|---|
ForwardBatch
|
The validated batch information. |
Source code in fastvideo/pipelines/stages/input_validation.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 | |
fastvideo.pipelines.stages.input_validation.InputValidationStage.verify_input
¶verify_input(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
Verify input validation stage inputs.
Source code in fastvideo/pipelines/stages/input_validation.py
fastvideo.pipelines.stages.input_validation.InputValidationStage.verify_output
¶verify_output(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
Verify input validation stage outputs.
Source code in fastvideo/pipelines/stages/input_validation.py
Functions¶
fastvideo.pipelines.stages.latent_preparation
¶
Latent preparation stage for diffusion pipelines.
Classes¶
fastvideo.pipelines.stages.latent_preparation.Cosmos25AutoLatentPreparationStage
¶
Bases: PipelineStage
Route Cosmos 2.5 latent prep to T2W vs V2W/I2W.
Source code in fastvideo/pipelines/stages/latent_preparation.py
fastvideo.pipelines.stages.latent_preparation.Cosmos25LatentPreparationStage
¶
Bases: CosmosLatentPreparationStage
Latent preparation for Cosmos 2.5 DiT input conventions.
Source code in fastvideo/pipelines/stages/latent_preparation.py
Functions¶
fastvideo.pipelines.stages.latent_preparation.Cosmos25LatentPreparationStage.verify_input
¶verify_input(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
Verify Cosmos latent preparation stage inputs.
Source code in fastvideo/pipelines/stages/latent_preparation.py
fastvideo.pipelines.stages.latent_preparation.Cosmos25LatentPreparationStage.verify_output
¶verify_output(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
Verify latent preparation stage outputs.
Source code in fastvideo/pipelines/stages/latent_preparation.py
fastvideo.pipelines.stages.latent_preparation.Cosmos25T2WLatentPreparationStage
¶
Bases: PipelineStage
Cosmos 2.5 Text2World latent preparation.
Source code in fastvideo/pipelines/stages/latent_preparation.py
fastvideo.pipelines.stages.latent_preparation.Cosmos25V2WLatentPreparationStage
¶
Bases: Cosmos25LatentPreparationStage
Cosmos 2.5 V2W/I2W latent preparation stage (conditioning-aware).
Source code in fastvideo/pipelines/stages/latent_preparation.py
fastvideo.pipelines.stages.latent_preparation.CosmosLatentPreparationStage
¶
Bases: PipelineStage
Cosmos-specific latent preparation stage that properly handles the tensor shapes and conditioning masks required by the Cosmos transformer.
This stage replicates the logic from diffusers' Cosmos2VideoToWorldPipeline.prepare_latents()
Source code in fastvideo/pipelines/stages/latent_preparation.py
fastvideo.pipelines.stages.latent_preparation.LatentPreparationStage
¶
LatentPreparationStage(scheduler, transformer, use_btchw_layout: bool = False)
Bases: PipelineStage
Stage for preparing initial latent variables for the diffusion process.
This stage handles the preparation of the initial latent variables that will be denoised during the diffusion process.
Source code in fastvideo/pipelines/stages/latent_preparation.py
Functions¶
fastvideo.pipelines.stages.latent_preparation.LatentPreparationStage.forward
¶forward(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> ForwardBatch
Prepare initial latent variables for the diffusion process.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch
|
ForwardBatch
|
The current batch information. |
required |
fastvideo_args
|
FastVideoArgs
|
The inference arguments. |
required |
Returns:
| Type | Description |
|---|---|
ForwardBatch
|
The batch with prepared latent variables. |
Source code in fastvideo/pipelines/stages/latent_preparation.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | |
fastvideo.pipelines.stages.latent_preparation.LatentPreparationStage.verify_input
¶verify_input(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
Verify latent preparation stage inputs.
Source code in fastvideo/pipelines/stages/latent_preparation.py
fastvideo.pipelines.stages.latent_preparation.LatentPreparationStage.verify_output
¶verify_output(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
Verify latent preparation stage outputs.
Source code in fastvideo/pipelines/stages/latent_preparation.py
Functions¶
fastvideo.pipelines.stages.longcat_denoising
¶
LongCat-specific denoising stage implementing CFG-zero optimized guidance.
Classes¶
fastvideo.pipelines.stages.longcat_denoising.LongCatDenoisingStage
¶
Bases: DenoisingStage
LongCat denoising stage with CFG-zero optimized guidance scale.
Implements: 1. Optimized CFG scale from CFG-zero paper 2. Negation of noise prediction before scheduler step (flow matching convention) 3. Batched CFG computation (unlike standard FastVideo separate passes)
Source code in fastvideo/pipelines/stages/denoising.py
Functions¶
fastvideo.pipelines.stages.longcat_denoising.LongCatDenoisingStage.forward
¶forward(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> ForwardBatch
Run LongCat denoising loop with optimized CFG.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch
|
ForwardBatch
|
The current batch information. |
required |
fastvideo_args
|
FastVideoArgs
|
The inference arguments. |
required |
Returns:
| Type | Description |
|---|---|
ForwardBatch
|
The batch with denoised latents. |
Source code in fastvideo/pipelines/stages/longcat_denoising.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | |
fastvideo.pipelines.stages.longcat_denoising.LongCatDenoisingStage.optimized_scale
¶Calculate optimized scale from CFG-zero paper.
st_star = (v_cond^T * v_uncond) / ||v_uncond||^2
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
positive_flat
|
Conditional prediction, flattened [B, -1] |
required | |
negative_flat
|
Unconditional prediction, flattened [B, -1] |
required |
Returns:
| Name | Type | Description |
|---|---|---|
st_star |
Tensor
|
Optimized scale [B, 1] |
Source code in fastvideo/pipelines/stages/longcat_denoising.py
Functions¶
fastvideo.pipelines.stages.longcat_i2v_denoising
¶
LongCat I2V Denoising Stage with conditioning support.
This stage implements Tier 3 I2V denoising: 1. Per-frame timestep masking (timestep[:, :num_cond_latents] = 0) 2. Passes num_cond_latents to transformer (for RoPE skipping) 3. Selective denoising (only updates non-conditioned frames) 4. CFG-zero optimized guidance
Classes¶
fastvideo.pipelines.stages.longcat_i2v_denoising.LongCatI2VDenoisingStage
¶
Bases: LongCatDenoisingStage
LongCat denoising with I2V conditioning support.
Key modifications from base LongCat denoising: 1. Sets timestep=0 for conditioning frames 2. Passes num_cond_latents to transformer 3. Only applies scheduler step to non-conditioned frames
Source code in fastvideo/pipelines/stages/denoising.py
Functions¶
fastvideo.pipelines.stages.longcat_i2v_denoising.LongCatI2VDenoisingStage.forward
¶forward(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> ForwardBatch
Run denoising loop with I2V conditioning.
Source code in fastvideo/pipelines/stages/longcat_i2v_denoising.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 | |
Functions¶
fastvideo.pipelines.stages.longcat_i2v_latent_preparation
¶
LongCat I2V Latent Preparation Stage.
This stage prepares latents with image conditioning for the first frame.
Classes¶
fastvideo.pipelines.stages.longcat_i2v_latent_preparation.LongCatI2VLatentPreparationStage
¶
LongCatI2VLatentPreparationStage(scheduler, transformer, use_btchw_layout: bool = False)
Bases: LatentPreparationStage
Prepare latents with image conditioning for first frame.
This stage: 1. Generates random noise for all frames 2. Replaces first latent frame with encoded image latent 3. Marks conditioning information in batch
Source code in fastvideo/pipelines/stages/latent_preparation.py
Functions¶
fastvideo.pipelines.stages.longcat_i2v_latent_preparation.LongCatI2VLatentPreparationStage.forward
¶forward(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> ForwardBatch
Prepare latents with I2V conditioning.
Source code in fastvideo/pipelines/stages/longcat_i2v_latent_preparation.py
Functions¶
fastvideo.pipelines.stages.longcat_image_vae_encoding
¶
LongCat Image VAE Encoding Stage for I2V generation.
This stage handles encoding a single input image to latent space with LongCat-specific normalization for I2V conditioning.
Classes¶
fastvideo.pipelines.stages.longcat_image_vae_encoding.LongCatImageVAEEncodingStage
¶
Bases: PipelineStage
Encode input image to latent space for I2V conditioning.
This stage: 1. Preprocesses image to match target dimensions 2. Encodes via VAE to latent space 3. Applies LongCat-specific normalization 4. Stores latent and calculates num_cond_latents
Source code in fastvideo/pipelines/stages/longcat_image_vae_encoding.py
Functions¶
fastvideo.pipelines.stages.longcat_image_vae_encoding.LongCatImageVAEEncodingStage.forward
¶forward(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> ForwardBatch
Encode image to latent for I2V conditioning.
Source code in fastvideo/pipelines/stages/longcat_image_vae_encoding.py
fastvideo.pipelines.stages.longcat_image_vae_encoding.LongCatImageVAEEncodingStage.normalize_latents
¶Apply LongCat-specific latent normalization.
Formula: (latents - mean) / std
This matches the original LongCat implementation and is DIFFERENT from standard VAE scaling (which uses scaling_factor).
Source code in fastvideo/pipelines/stages/longcat_image_vae_encoding.py
fastvideo.pipelines.stages.longcat_image_vae_encoding.LongCatImageVAEEncodingStage.retrieve_latents
¶retrieve_latents(encoder_output: object, generator: Generator | None) -> Tensor
Sample from VAE posterior.
Source code in fastvideo/pipelines/stages/longcat_image_vae_encoding.py
Functions¶
fastvideo.pipelines.stages.longcat_kv_cache_init
¶
LongCat KV Cache Initialization Stage for Video Continuation (VC).
This stage pre-computes K/V cache for conditioning frames.
Classes¶
fastvideo.pipelines.stages.longcat_kv_cache_init.LongCatKVCacheInitStage
¶
Bases: PipelineStage
Pre-compute KV cache for conditioning frames.
After this stage: - batch.kv_cache_dict contains {block_idx: (k, v)} - batch.cond_latents contains the conditioning latents - batch.latents contains ONLY noise latents
Source code in fastvideo/pipelines/stages/longcat_kv_cache_init.py
Functions¶
fastvideo.pipelines.stages.longcat_kv_cache_init.LongCatKVCacheInitStage.forward
¶forward(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> ForwardBatch
Initialize KV cache from conditioning latents.
Source code in fastvideo/pipelines/stages/longcat_kv_cache_init.py
Functions¶
fastvideo.pipelines.stages.longcat_refine_init
¶
LongCat refinement initialization stage.
This stage prepares the latent variables for LongCat's 480p->720p refinement by: 1. Loading the stage1 (480p) video 2. Upsampling it to 720p resolution 3. Encoding it with VAE 4. Mixing with noise according to t_thresh
Classes¶
fastvideo.pipelines.stages.longcat_refine_init.LongCatRefineInitStage
¶
Bases: PipelineStage
Stage for initializing LongCat refinement from a stage1 (480p) video.
This replicates the logic from LongCatVideoPipeline.generate_refine(): - Load stage1_video frames - Upsample spatially and temporally - VAE encode and normalize - Mix with noise according to t_thresh
Source code in fastvideo/pipelines/stages/longcat_refine_init.py
Functions¶
fastvideo.pipelines.stages.longcat_refine_init.LongCatRefineInitStage.forward
¶forward(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> ForwardBatch
Initialize latents for refinement.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch
|
ForwardBatch
|
The current batch information. |
required |
fastvideo_args
|
FastVideoArgs
|
The inference arguments. |
required |
Returns:
| Type | Description |
|---|---|
ForwardBatch
|
The batch with initialized latents for refinement. |
Source code in fastvideo/pipelines/stages/longcat_refine_init.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 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 | |
Functions¶
fastvideo.pipelines.stages.longcat_refine_timestep
¶
LongCat refinement timestep preparation stage.
This stage prepares special timesteps for LongCat refinement that start from t_thresh.
Classes¶
fastvideo.pipelines.stages.longcat_refine_timestep.LongCatRefineTimestepStage
¶
Bases: PipelineStage
Stage for preparing timesteps specific to LongCat refinement.
For refinement, we need to start from t_thresh instead of t=1.0, so we: 1. Generate normal timesteps for num_inference_steps 2. Filter to only keep timesteps < t_thresh * 1000 3. Prepend t_thresh * 1000 as the first timestep
Source code in fastvideo/pipelines/stages/longcat_refine_timestep.py
Functions¶
fastvideo.pipelines.stages.longcat_refine_timestep.LongCatRefineTimestepStage.forward
¶forward(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> ForwardBatch
Prepare refinement-specific timesteps.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch
|
ForwardBatch
|
The current batch information. |
required |
fastvideo_args
|
FastVideoArgs
|
The inference arguments. |
required |
Returns:
| Type | Description |
|---|---|
ForwardBatch
|
The batch with refinement timesteps. |
Source code in fastvideo/pipelines/stages/longcat_refine_timestep.py
Functions¶
fastvideo.pipelines.stages.longcat_vc_denoising
¶
LongCat VC Denoising Stage with KV cache support.
This stage extends the I2V denoising stage to support: 1. KV cache for conditioning frames 2. Video continuation with multiple conditioning frames
Classes¶
fastvideo.pipelines.stages.longcat_vc_denoising.LongCatVCDenoisingStage
¶
Bases: LongCatDenoisingStage
LongCat denoising with Video Continuation and KV cache support.
Key differences from I2V denoising: - Supports KV cache (reuses cached K/V from conditioning frames) - Handles larger num_cond_latents - Concatenates conditioning latents back after denoising
When use_kv_cache=True: - batch.latents contains ONLY noise frames (cond removed by KV cache init) - batch.kv_cache_dict contains cached K/V - batch.cond_latents contains conditioning latents for post-concat
When use_kv_cache=False: - batch.latents contains ALL frames (cond + noise) - Timestep masking: timestep[:, :num_cond_latents] = 0 - Selective denoising: only update noise frames
Source code in fastvideo/pipelines/stages/denoising.py
Functions¶
fastvideo.pipelines.stages.longcat_vc_denoising.LongCatVCDenoisingStage.forward
¶forward(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> ForwardBatch
Run denoising loop with VC conditioning and optional KV cache.
Source code in fastvideo/pipelines/stages/longcat_vc_denoising.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | |
Functions¶
fastvideo.pipelines.stages.longcat_video_vae_encoding
¶
LongCat Video VAE Encoding Stage for Video Continuation (VC) generation.
This stage handles encoding multiple video frames to latent space with LongCat-specific normalization for VC conditioning.
Classes¶
fastvideo.pipelines.stages.longcat_video_vae_encoding.LongCatVideoVAEEncodingStage
¶
Bases: PipelineStage
Encode video frames to latent space for VC conditioning.
This stage: 1. Loads video frames from path or uses provided frames 2. Takes the last num_cond_frames from the video 3. Preprocesses and stacks frames 4. Encodes via VAE to latent space 5. Applies LongCat-specific normalization 6. Calculates num_cond_latents
Source code in fastvideo/pipelines/stages/longcat_video_vae_encoding.py
Functions¶
fastvideo.pipelines.stages.longcat_video_vae_encoding.LongCatVideoVAEEncodingStage.forward
¶forward(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> ForwardBatch
Encode video frames to latent for VC conditioning.
Source code in fastvideo/pipelines/stages/longcat_video_vae_encoding.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | |
fastvideo.pipelines.stages.longcat_video_vae_encoding.LongCatVideoVAEEncodingStage.normalize_latents
¶Apply LongCat-specific latent normalization.
Formula: (latents - mean) / std
Source code in fastvideo/pipelines/stages/longcat_video_vae_encoding.py
fastvideo.pipelines.stages.longcat_video_vae_encoding.LongCatVideoVAEEncodingStage.retrieve_latents
¶retrieve_latents(encoder_output: Any, generator: Generator | None) -> Tensor
Sample from VAE posterior.
Source code in fastvideo/pipelines/stages/longcat_video_vae_encoding.py
Functions¶
fastvideo.pipelines.stages.ltx2_audio_decoding
¶
Audio decoding stage for LTX-2 pipelines.
Classes¶
fastvideo.pipelines.stages.ltx2_audio_decoding.LTX2AudioDecodingStage
¶
Bases: PipelineStage
Decode LTX-2 audio latents into a waveform.
Source code in fastvideo/pipelines/stages/ltx2_audio_decoding.py
Functions¶
fastvideo.pipelines.stages.ltx2_denoising
¶
LTX-2 denoising stage using the native sigma schedule.
Classes¶
fastvideo.pipelines.stages.ltx2_denoising.LTX2DenoisingStage
¶
Bases: PipelineStage
Run the LTX-2 denoising loop over the sigma schedule.
Source code in fastvideo/pipelines/stages/ltx2_denoising.py
Functions¶
fastvideo.pipelines.stages.ltx2_latent_preparation
¶
Latent preparation stage for LTX-2 pipelines.
Classes¶
fastvideo.pipelines.stages.ltx2_latent_preparation.LTX2LatentPreparationStage
¶
Bases: PipelineStage
Prepare initial LTX-2 latents without relying on a diffusers scheduler.
Source code in fastvideo/pipelines/stages/ltx2_latent_preparation.py
Functions¶
fastvideo.pipelines.stages.ltx2_text_encoding
¶
LTX2-specific text encoding stage with sequence parallelism broadcast support.
When running with sequence parallelism (SP), the Gemma text encoder is only executed on rank 0, and the embeddings are broadcast to all other ranks. This avoids I/O contention from all ranks loading the Gemma model simultaneously.
Classes¶
fastvideo.pipelines.stages.ltx2_text_encoding.LTX2TextEncodingStage
¶
Bases: TextEncodingStage
LTX2 text encoding stage with sequence parallelism support.
When SP is enabled (sp_world_size > 1), only rank 0 runs the text encoder and broadcasts embeddings to other ranks. This avoids I/O contention from all ranks loading the Gemma model simultaneously, which can cause text encoding to take 100+ seconds instead of ~5 seconds.
Source code in fastvideo/pipelines/stages/text_encoding.py
Functions¶
fastvideo.pipelines.stages.matrixgame_denoising
¶
Classes¶
fastvideo.pipelines.stages.matrixgame_denoising.BlockProcessingContext
dataclass
¶
BlockProcessingContext(batch: ForwardBatch, block_idx: int, start_index: int, kv_cache1: list[dict[Any, Any]], kv_cache2: list[dict[Any, Any]] | None, kv_cache_mouse: list[dict[Any, Any]] | None, kv_cache_keyboard: list[dict[Any, Any]] | None, crossattn_cache: list[dict[Any, Any]], timesteps: Tensor, block_sizes: list[int], noise_pool: list[Tensor] | None, fastvideo_args: FastVideoArgs, target_dtype: dtype, autocast_enabled: bool, boundary_timestep: float | None, high_noise_timesteps: Tensor | None, context_noise: float, image_kwargs: dict[str, Any], pos_cond_kwargs: dict[str, Any])
Dataclass contains for block processing.
Functions¶
fastvideo.pipelines.stages.sd35_conditioning
¶
Classes¶
fastvideo.pipelines.stages.sd35_conditioning.SD35DenoisingStage
¶
Bases: PipelineStage
Denoising loop for SD3.5 (2D transformer + FlowMatch scheduler).
Source code in fastvideo/pipelines/stages/sd35_conditioning.py
Functions¶
fastvideo.pipelines.stages.sr_denoising
¶
Denoising stage for diffusion pipelines.
Classes¶
fastvideo.pipelines.stages.sr_denoising.SRDenoisingStage
¶
Bases: PipelineStage
Stage for running the denoising loop in SR diffusion pipelines. Used by Hunyuan15 SR pipeline.
This stage handles the iterative denoising process that transforms the initial noise into the final output.
Source code in fastvideo/pipelines/stages/sr_denoising.py
Functions¶
fastvideo.pipelines.stages.sr_denoising.SRDenoisingStage.forward
¶forward(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> ForwardBatch
Run the denoising loop.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch
|
ForwardBatch
|
The current batch information. |
required |
fastvideo_args
|
FastVideoArgs
|
The inference arguments. |
required |
Returns:
| Type | Description |
|---|---|
ForwardBatch
|
The batch with denoised latents. |
Source code in fastvideo/pipelines/stages/sr_denoising.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 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 | |
fastvideo.pipelines.stages.sr_denoising.SRDenoisingStage.prepare_extra_func_kwargs
¶Prepare extra kwargs for the scheduler step / denoise step.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
func
|
The function to prepare kwargs for. |
required | |
kwargs
|
The kwargs to prepare. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
The prepared kwargs. |
Source code in fastvideo/pipelines/stages/sr_denoising.py
fastvideo.pipelines.stages.sr_denoising.SRDenoisingStage.progress_bar
¶Create a progress bar for the denoising process.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
iterable
|
Iterable | None
|
The iterable to iterate over. |
None
|
total
|
int | None
|
The total number of items. |
None
|
Returns:
| Type | Description |
|---|---|
tqdm
|
A tqdm progress bar. |
Source code in fastvideo/pipelines/stages/sr_denoising.py
fastvideo.pipelines.stages.sr_denoising.SRDenoisingStage.verify_input
¶verify_input(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
Verify denoising stage inputs.
Source code in fastvideo/pipelines/stages/sr_denoising.py
fastvideo.pipelines.stages.sr_denoising.SRDenoisingStage.verify_output
¶verify_output(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
Verify denoising stage outputs.
Source code in fastvideo/pipelines/stages/sr_denoising.py
Functions¶
fastvideo.pipelines.stages.text_encoding
¶
Prompt encoding stages for diffusion pipelines.
This module contains implementations of prompt encoding stages for diffusion pipelines.
Classes¶
fastvideo.pipelines.stages.text_encoding.Cosmos25TextEncodingStage
¶
Bases: PipelineStage
Cosmos 2.5 text encoding stage.
Cosmos 2.5 uses Reason1 (Qwen2.5-VL) and relies on the encoder's
compute_text_embeddings_online().
Source code in fastvideo/pipelines/stages/text_encoding.py
fastvideo.pipelines.stages.text_encoding.TextEncodingStage
¶
Bases: PipelineStage
Stage for encoding text prompts into embeddings for diffusion models.
This stage handles the encoding of text prompts into the embedding space expected by the diffusion model.
Initialize the prompt encoding stage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
enable_logging
|
Whether to enable logging for this stage. |
required | |
is_secondary
|
Whether this is a secondary text encoder. |
required |
Source code in fastvideo/pipelines/stages/text_encoding.py
Functions¶
fastvideo.pipelines.stages.text_encoding.TextEncodingStage.encode_text
¶encode_text(text: str | list[str], fastvideo_args: FastVideoArgs, encoder_index: int | list[int] | None = None, return_attention_mask: bool = False, return_type: str = 'list', device: device | str | None = None, dtype: dtype | None = None, max_length: int | None = None, truncation: bool | None = None, padding: bool | str | None = None)
Encode plain text using selected text encoder(s) and return embeddings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str | list[str]
|
A single string or a list of strings to encode. |
required |
fastvideo_args
|
FastVideoArgs
|
The inference arguments providing pipeline config, including tokenizer and encoder settings, preprocess and postprocess functions. |
required |
encoder_index
|
int | list[int] | None
|
Encoder selector by index. Accepts an int or list of ints. |
None
|
return_attention_mask
|
bool
|
If True, also return attention masks for each selected encoder. |
False
|
return_type
|
str
|
"list" (default) returns a list aligned with selection; "dict" returns a dict keyed by encoder index as a string; "stack" stacks along a new first dimension (requires matching shapes). |
'list'
|
device
|
device | str | None
|
Optional device override for inputs; defaults to local torch device. |
None
|
dtype
|
dtype | None
|
Optional dtype to cast returned embeddings to. |
None
|
max_length
|
int | None
|
Optional per-call tokenizer override. |
None
|
truncation
|
bool | None
|
Optional per-call tokenizer override. |
None
|
padding
|
bool | str | None
|
Optional per-call tokenizer override. |
None
|
Returns:
| Type | Description |
|---|---|
|
Depending on return_type and return_attention_mask: |
|
|
|
|
|
|
Source code in fastvideo/pipelines/stages/text_encoding.py
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 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 | |
fastvideo.pipelines.stages.text_encoding.TextEncodingStage.forward
¶forward(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> ForwardBatch
Encode the prompt into text encoder hidden states.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch
|
ForwardBatch
|
The current batch information. |
required |
fastvideo_args
|
FastVideoArgs
|
The inference arguments. |
required |
Returns:
| Type | Description |
|---|---|
ForwardBatch
|
The batch with encoded prompt embeddings. |
Source code in fastvideo/pipelines/stages/text_encoding.py
fastvideo.pipelines.stages.text_encoding.TextEncodingStage.verify_input
¶verify_input(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
Verify text encoding stage inputs.
Source code in fastvideo/pipelines/stages/text_encoding.py
fastvideo.pipelines.stages.text_encoding.TextEncodingStage.verify_output
¶verify_output(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
Verify text encoding stage outputs.
Source code in fastvideo/pipelines/stages/text_encoding.py
Functions¶
fastvideo.pipelines.stages.timestep_preparation
¶
Timestep preparation stages for diffusion pipelines.
This module contains implementations of timestep preparation stages for diffusion pipelines.
Classes¶
fastvideo.pipelines.stages.timestep_preparation.Cosmos25TimestepPreparationStage
¶
Bases: TimestepPreparationStage
Cosmos 2.5 timestep preparation with scheduler-specific kwargs.
Source code in fastvideo/pipelines/stages/timestep_preparation.py
fastvideo.pipelines.stages.timestep_preparation.SD35TimestepPreparationStage
¶
Bases: TimestepPreparationStage
SD3/SD3.5 timestep preparation with optional dynamic shifting (mu).
When the scheduler supports use_dynamic_shifting, this stage computes a
resolution-dependent mu value and passes it to set_timesteps().
Source code in fastvideo/pipelines/stages/timestep_preparation.py
fastvideo.pipelines.stages.timestep_preparation.TimestepPreparationStage
¶
Bases: PipelineStage
Stage for preparing timesteps for the diffusion process.
This stage handles the preparation of the timestep sequence that will be used during the diffusion process.
Source code in fastvideo/pipelines/stages/timestep_preparation.py
Functions¶
fastvideo.pipelines.stages.timestep_preparation.TimestepPreparationStage.forward
¶forward(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> ForwardBatch
Prepare timesteps for the diffusion process.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch
|
ForwardBatch
|
The current batch information. |
required |
fastvideo_args
|
FastVideoArgs
|
The inference arguments. |
required |
Returns:
| Type | Description |
|---|---|
ForwardBatch
|
The batch with prepared timesteps. |
Source code in fastvideo/pipelines/stages/timestep_preparation.py
fastvideo.pipelines.stages.timestep_preparation.TimestepPreparationStage.verify_input
¶verify_input(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
Verify timestep preparation stage inputs.
Source code in fastvideo/pipelines/stages/timestep_preparation.py
fastvideo.pipelines.stages.timestep_preparation.TimestepPreparationStage.verify_output
¶verify_output(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
Verify timestep preparation stage outputs.
Source code in fastvideo/pipelines/stages/timestep_preparation.py
Functions¶
fastvideo.pipelines.stages.utils
¶
Utility functions for pipeline stages.
Functions¶
fastvideo.pipelines.stages.utils.retrieve_timesteps
¶
retrieve_timesteps(scheduler: Any, num_inference_steps: int | None = None, device: str | device | None = None, timesteps: list[int] | None = None, sigmas: list[float] | None = None, **kwargs: Any) -> tuple[Any, int]
Calls the scheduler's set_timesteps method and retrieves timesteps from the scheduler after the call. Handles
custom timesteps. Any kwargs will be supplied to scheduler.set_timesteps.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scheduler
|
`SchedulerMixin`
|
The scheduler to get timesteps from. |
required |
num_inference_steps
|
`int`
|
The number of diffusion steps used when generating samples with a pre-trained model. If used, |
None
|
device
|
`str` or `torch.device`, *optional*
|
The device to which the timesteps should be moved to. If |
None
|
timesteps
|
`List[int]`, *optional*
|
Custom timesteps used to override the timestep spacing strategy of the scheduler. If |
None
|
sigmas
|
`List[float]`, *optional*
|
Custom sigmas used to override the timestep spacing strategy of the scheduler. If |
None
|
Returns:
| Type | Description |
|---|---|
Any
|
|
int
|
second element is the number of inference steps. |
Source code in fastvideo/pipelines/stages/utils.py
fastvideo.pipelines.stages.validators
¶
Common validators for pipeline stage verification.
This module provides reusable validation functions that can be used across all pipeline stages for input/output verification.
Classes¶
fastvideo.pipelines.stages.validators.StageValidators
¶
Common validators for pipeline stages.
Functions¶
fastvideo.pipelines.stages.validators.StageValidators.bool_value
staticmethod
¶ fastvideo.pipelines.stages.validators.StageValidators.divisible
staticmethod
¶Return a validator that checks if value is divisible by divisor.
Source code in fastvideo/pipelines/stages/validators.py
fastvideo.pipelines.stages.validators.StageValidators.divisible_by
staticmethod
¶ fastvideo.pipelines.stages.validators.StageValidators.generator_or_list_generators
staticmethod
¶Check if value is a Generator or list of Generators.
Source code in fastvideo/pipelines/stages/validators.py
fastvideo.pipelines.stages.validators.StageValidators.is_list
staticmethod
¶ fastvideo.pipelines.stages.validators.StageValidators.is_tensor
staticmethod
¶Check if value is a torch tensor and doesn't contain NaN values.
fastvideo.pipelines.stages.validators.StageValidators.is_tuple
staticmethod
¶ fastvideo.pipelines.stages.validators.StageValidators.list_length
staticmethod
¶ fastvideo.pipelines.stages.validators.StageValidators.list_min_length
staticmethod
¶ fastvideo.pipelines.stages.validators.StageValidators.list_not_empty
staticmethod
¶ fastvideo.pipelines.stages.validators.StageValidators.list_of_tensors
staticmethod
¶Check if value is a non-empty list where all items are tensors without NaN values.
Source code in fastvideo/pipelines/stages/validators.py
fastvideo.pipelines.stages.validators.StageValidators.list_of_tensors_dims
staticmethod
¶Return a validator that checks if value is a list of tensors with specific dimensions and no NaN values.
Source code in fastvideo/pipelines/stages/validators.py
fastvideo.pipelines.stages.validators.StageValidators.list_of_tensors_min_dims
staticmethod
¶Return a validator that checks if value is a list of tensors with at least min_dims dimensions and no NaN values.
Source code in fastvideo/pipelines/stages/validators.py
fastvideo.pipelines.stages.validators.StageValidators.list_of_tensors_with_dims
staticmethod
¶Check if value is a non-empty list where all items are tensors with specific dimensions and no NaN values.
Source code in fastvideo/pipelines/stages/validators.py
fastvideo.pipelines.stages.validators.StageValidators.list_of_tensors_with_min_dims
staticmethod
¶Check if value is a non-empty list where all items are tensors with at least min_dims dimensions and no NaN values.
Source code in fastvideo/pipelines/stages/validators.py
fastvideo.pipelines.stages.validators.StageValidators.min_dims
staticmethod
¶Return a validator that checks if tensor has at least min_dims dimensions and no NaN values.
Source code in fastvideo/pipelines/stages/validators.py
fastvideo.pipelines.stages.validators.StageValidators.non_negative_float
staticmethod
¶ fastvideo.pipelines.stages.validators.StageValidators.non_negative_int
staticmethod
¶ fastvideo.pipelines.stages.validators.StageValidators.none_or_list
staticmethod
¶ fastvideo.pipelines.stages.validators.StageValidators.none_or_positive_int
staticmethod
¶ fastvideo.pipelines.stages.validators.StageValidators.none_or_tensor
staticmethod
¶Check if value is None or a tensor without NaN values.
Source code in fastvideo/pipelines/stages/validators.py
fastvideo.pipelines.stages.validators.StageValidators.none_or_tensor_with_dims
staticmethod
¶Return a validator that checks if value is None or a tensor with specific dimensions and no NaN values.
Source code in fastvideo/pipelines/stages/validators.py
fastvideo.pipelines.stages.validators.StageValidators.not_none
staticmethod
¶ fastvideo.pipelines.stages.validators.StageValidators.positive_float
staticmethod
¶ fastvideo.pipelines.stages.validators.StageValidators.positive_int
staticmethod
¶ fastvideo.pipelines.stages.validators.StageValidators.positive_int_divisible
staticmethod
¶Return a validator that checks if value is a positive integer divisible by divisor.
Source code in fastvideo/pipelines/stages/validators.py
fastvideo.pipelines.stages.validators.StageValidators.string_not_empty
staticmethod
¶ fastvideo.pipelines.stages.validators.StageValidators.string_or_list_strings
staticmethod
¶Check if value is a string or list of strings.
Source code in fastvideo/pipelines/stages/validators.py
fastvideo.pipelines.stages.validators.StageValidators.tensor_min_dims
staticmethod
¶Check if value is a tensor with at least min_dims dimensions and no NaN values.
Source code in fastvideo/pipelines/stages/validators.py
fastvideo.pipelines.stages.validators.StageValidators.tensor_shape_matches
staticmethod
¶Check if tensor shape matches expected shape (None for any size) and no NaN values.
Source code in fastvideo/pipelines/stages/validators.py
fastvideo.pipelines.stages.validators.StageValidators.tensor_with_dims
staticmethod
¶Check if value is a tensor with specific dimensions and no NaN values.
Source code in fastvideo/pipelines/stages/validators.py
fastvideo.pipelines.stages.validators.StageValidators.with_dims
staticmethod
¶Return a validator that checks if tensor has specific dimensions and no NaN values.
Source code in fastvideo/pipelines/stages/validators.py
fastvideo.pipelines.stages.validators.ValidationFailure
¶
ValidationFailure(validator_name: str, actual_value: Any, expected: str | None = None, error_msg: str | None = None)
Details about a specific validation failure.
Source code in fastvideo/pipelines/stages/validators.py
fastvideo.pipelines.stages.validators.VerificationResult
¶
Wrapper class for stage verification results.
Source code in fastvideo/pipelines/stages/validators.py
Functions¶
fastvideo.pipelines.stages.validators.VerificationResult.add_check
¶add_check(field_name: str, value: Any, validators: Callable[[Any], bool] | list[Callable[[Any], bool]]) -> VerificationResult
Add a validation check for a field.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
field_name
|
str
|
Name of the field being checked |
required |
value
|
Any
|
The actual value to validate |
required |
validators
|
Callable[[Any], bool] | list[Callable[[Any], bool]]
|
Single validation function or list of validation functions. Each function will be called with the value as its first argument. |
required |
Returns:
| Type | Description |
|---|---|
VerificationResult
|
Self for method chaining |
Examples:
Single validator¶
result.add_check("tensor", my_tensor, V.is_tensor)
Multiple validators (all must pass)¶
result.add_check("latents", batch.latents, [V.is_tensor, V.with_dims(5)])
Using partial functions for parameters¶
result.add_check("height", batch.height, [V.not_none, V.divisible(8)])
Source code in fastvideo/pipelines/stages/validators.py
fastvideo.pipelines.stages.validators.VerificationResult.get_detailed_failures
¶get_detailed_failures() -> dict[str, list[ValidationFailure]]
fastvideo.pipelines.stages.validators.VerificationResult.get_failed_fields
¶ fastvideo.pipelines.stages.validators.VerificationResult.get_failure_summary
¶get_failure_summary() -> str
Get a comprehensive summary of all validation failures.