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
¶
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
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 | |
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.