latent_preparation
¶
Latent preparation stage for diffusion pipelines.
Classes¶
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
Functions¶
fastvideo.pipelines.stages.latent_preparation.CosmosLatentPreparationStage.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.CosmosLatentPreparationStage.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.CosmosLatentPreparationStage.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.LatentPreparationStage
¶
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
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.