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.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.adjust_video_length
¶
adjust_video_length(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> int
Adjust video length based on VAE version.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch
|
ForwardBatch
|
The current batch information. |
required |
fastvideo_args
|
FastVideoArgs
|
The inference arguments. |
required |
Returns:
| Type | Description |
|---|---|
int
|
The batch with adjusted video length. |
Source code in fastvideo/pipelines/stages/latent_preparation.py
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
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 | |
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
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 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 501 502 503 504 | |
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.prepare_sta_param
¶
prepare_sta_param(batch: ForwardBatch, fastvideo_args: FastVideoArgs)
Prepare Sliding Tile Attention (STA) parameters and settings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch
|
ForwardBatch
|
The current batch information. |
required |
fastvideo_args
|
FastVideoArgs
|
The inference arguments. |
required |
Source code in fastvideo/pipelines/stages/denoising.py
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 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 | |
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.save_sta_search_results
¶
save_sta_search_results(batch: ForwardBatch)
Save the STA mask search results.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch
|
ForwardBatch
|
The current batch information. |
required |
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
1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 | |
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.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
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 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 | |
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
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 | |
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
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 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 | |
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
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 | |
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.adjust_video_length
¶
adjust_video_length(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> int
Adjust video length based on VAE version.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch
|
ForwardBatch
|
The current batch information. |
required |
fastvideo_args
|
FastVideoArgs
|
The inference arguments. |
required |
Returns:
| Type | Description |
|---|---|
int
|
The batch with adjusted video length. |
Source code in fastvideo/pipelines/stages/latent_preparation.py
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
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 153 154 155 156 157 158 159 160 161 162 163 164 165 | |
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 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 | |
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 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | |
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.StepvideoPromptEncodingStage
¶
Bases: PipelineStage
Stage for encoding prompts using the remote caption API.
This stage applies the magic string transformations and calls the remote caption service asynchronously to get: - primary prompt embeddings, - an attention mask, - and a clip embedding.
Source code in fastvideo/pipelines/stages/stepvideo_encoding.py
Functions¶
fastvideo.pipelines.stages.StepvideoPromptEncodingStage.verify_input
¶
verify_input(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
Verify stepvideo encoding stage inputs.
Source code in fastvideo/pipelines/stages/stepvideo_encoding.py
fastvideo.pipelines.stages.StepvideoPromptEncodingStage.verify_output
¶
verify_output(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
Verify stepvideo encoding stage outputs.
Source code in fastvideo/pipelines/stages/stepvideo_encoding.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
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 | |
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
640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 | |
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
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
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 | |
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
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 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 501 502 503 504 | |
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.prepare_sta_param
¶prepare_sta_param(batch: ForwardBatch, fastvideo_args: FastVideoArgs)
Prepare Sliding Tile Attention (STA) parameters and settings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch
|
ForwardBatch
|
The current batch information. |
required |
fastvideo_args
|
FastVideoArgs
|
The inference arguments. |
required |
Source code in fastvideo/pipelines/stages/denoising.py
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 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 | |
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.save_sta_search_results
¶save_sta_search_results(batch: ForwardBatch)
Save the STA mask search results.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch
|
ForwardBatch
|
The current batch information. |
required |
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
1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 | |
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.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
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 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 | |
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
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 | |
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
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 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 | |
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
640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 | |
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
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 | |
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.adjust_video_length
¶adjust_video_length(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> int
Adjust video length based on VAE version.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch
|
ForwardBatch
|
The current batch information. |
required |
fastvideo_args
|
FastVideoArgs
|
The inference arguments. |
required |
Returns:
| Type | Description |
|---|---|
int
|
The batch with adjusted video length. |
Source code in fastvideo/pipelines/stages/latent_preparation.py
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.adjust_video_length
¶adjust_video_length(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> int
Adjust video length based on VAE version.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch
|
ForwardBatch
|
The current batch information. |
required |
fastvideo_args
|
FastVideoArgs
|
The inference arguments. |
required |
Returns:
| Type | Description |
|---|---|
int
|
The batch with adjusted video length. |
Source code in fastvideo/pipelines/stages/latent_preparation.py
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
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 153 154 155 156 157 158 159 160 161 162 163 164 165 | |
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
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 | |
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 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | |
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 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 | |
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 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 | |
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 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | |
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.stepvideo_encoding
¶
Classes¶
fastvideo.pipelines.stages.stepvideo_encoding.StepvideoPromptEncodingStage
¶
Bases: PipelineStage
Stage for encoding prompts using the remote caption API.
This stage applies the magic string transformations and calls the remote caption service asynchronously to get: - primary prompt embeddings, - an attention mask, - and a clip embedding.
Source code in fastvideo/pipelines/stages/stepvideo_encoding.py
Functions¶
fastvideo.pipelines.stages.stepvideo_encoding.StepvideoPromptEncodingStage.verify_input
¶verify_input(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
Verify stepvideo encoding stage inputs.
Source code in fastvideo/pipelines/stages/stepvideo_encoding.py
fastvideo.pipelines.stages.stepvideo_encoding.StepvideoPromptEncodingStage.verify_output
¶verify_output(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> VerificationResult
Verify stepvideo encoding stage outputs.
Source code in fastvideo/pipelines/stages/stepvideo_encoding.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
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 | |
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.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.