pipelines
¶
Diffusion pipelines for fastvideo.
This package contains diffusion pipelines for generating videos and images.
Classes¶
fastvideo.pipelines.ComposedPipelineBase
¶
ComposedPipelineBase(model_path: str, fastvideo_args: FastVideoArgs | TrainingArgs, required_config_modules: list[str] | None = None, loaded_modules: dict[str, Module] | None = None)
Bases: ABC
Base class for pipelines composed of multiple stages.
This class provides the framework for creating pipelines by composing multiple stages together. Each stage is responsible for a specific part of the diffusion process, and the pipeline orchestrates the execution of these stages.
Initialize the pipeline. After init, the pipeline should be ready to use. The pipeline should be stateless and not hold any batch state.
Source code in fastvideo/pipelines/composed_pipeline_base.py
Attributes¶
fastvideo.pipelines.ComposedPipelineBase.required_config_modules
property
¶
List of modules that are required by the pipeline. The names should match the diffusers directory and model_index.json file. These modules will be loaded using the PipelineComponentLoader and made available in the modules dictionary. Access these modules using the get_module method.
class ConcretePipeline(ComposedPipelineBase): _required_config_modules = ["vae", "text_encoder", "transformer", "scheduler", "tokenizer"]
@property
def required_config_modules(self):
return self._required_config_modules
fastvideo.pipelines.ComposedPipelineBase.stages
property
¶
stages: list[PipelineStage]
List of stages in the pipeline.
Functions¶
fastvideo.pipelines.ComposedPipelineBase.create_pipeline_stages
abstractmethod
¶
create_pipeline_stages(fastvideo_args: FastVideoArgs)
fastvideo.pipelines.ComposedPipelineBase.create_training_stages
¶
create_training_stages(training_args: TrainingArgs)
fastvideo.pipelines.ComposedPipelineBase.forward
¶
forward(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> ForwardBatch
Generate a video or image using the pipeline.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch
|
ForwardBatch
|
The batch to generate from. |
required |
fastvideo_args
|
FastVideoArgs
|
The inference arguments. |
required |
Returns: ForwardBatch: The batch with the generated video or image.
Source code in fastvideo/pipelines/composed_pipeline_base.py
fastvideo.pipelines.ComposedPipelineBase.from_pretrained
classmethod
¶
from_pretrained(model_path: str, device: str | None = None, torch_dtype: dtype | None = None, pipeline_config: str | PipelineConfig | None = None, args: Namespace | None = None, required_config_modules: list[str] | None = None, loaded_modules: dict[str, Module] | None = None, **kwargs) -> ComposedPipelineBase
Load a pipeline from a pretrained model. loaded_modules: Optional[Dict[str, torch.nn.Module]] = None, If provided, loaded_modules will be used instead of loading from config/pretrained weights.
Source code in fastvideo/pipelines/composed_pipeline_base.py
fastvideo.pipelines.ComposedPipelineBase.initialize_pipeline
¶
initialize_pipeline(fastvideo_args: FastVideoArgs)
fastvideo.pipelines.ComposedPipelineBase.load_modules
¶
load_modules(fastvideo_args: FastVideoArgs, loaded_modules: dict[str, Module] | None = None) -> dict[str, Any]
Load the modules from the config. loaded_modules: Optional[Dict[str, torch.nn.Module]] = None, If provided, loaded_modules will be used instead of loading from config/pretrained weights.
Source code in fastvideo/pipelines/composed_pipeline_base.py
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 | |
fastvideo.pipelines.ForwardBatch
dataclass
¶
ForwardBatch(data_type: str, generator: Generator | list[Generator] | None = None, image_path: str | None = None, image_embeds: list[Tensor] = list(), pil_image: Tensor | Image | None = None, preprocessed_image: Tensor | None = None, prompt: str | list[str] | None = None, negative_prompt: str | list[str] | None = None, prompt_path: str | None = None, output_path: str = 'outputs/', output_video_name: str | None = None, video_path: str | None = None, video_latent: Tensor | None = None, prompt_embeds: list[Tensor] = list(), negative_prompt_embeds: list[Tensor] | None = None, prompt_attention_mask: list[Tensor] | None = None, negative_attention_mask: list[Tensor] | None = None, clip_embedding_pos: list[Tensor] | None = None, clip_embedding_neg: list[Tensor] | None = None, max_sequence_length: int | None = None, prompt_template: dict[str, Any] | None = None, do_classifier_free_guidance: bool = False, batch_size: int | None = None, num_videos_per_prompt: int = 1, seed: int | None = None, seeds: list[int] | None = None, is_prompt_processed: bool = False, latents: Tensor | None = None, raw_latent_shape: Tensor | None = None, noise_pred: Tensor | None = None, image_latent: Tensor | None = None, height_latents: list[int] | int | None = None, width_latents: list[int] | int | None = None, num_frames: list[int] | int = 1, num_frames_round_down: bool = False, height: list[int] | int | None = None, width: list[int] | int | None = None, fps: list[int] | int | None = None, timesteps: Tensor | None = None, timestep: Tensor | float | int | None = None, step_index: int | None = None, boundary_ratio: float | None = None, num_inference_steps: int = 50, guidance_scale: float = 1.0, guidance_scale_2: float | None = None, guidance_rescale: float = 0.0, eta: float = 0.0, sigmas: list[float] | None = None, n_tokens: int | None = None, extra_step_kwargs: dict[str, Any] = dict(), modules: dict[str, Any] = dict(), output: Tensor | None = None, return_trajectory_latents: bool = False, return_trajectory_decoded: bool = False, trajectory_timesteps: list[Tensor] | None = None, trajectory_latents: Tensor | None = None, trajectory_decoded: list[Tensor] | None = None, extra: dict[str, Any] = dict(), save_video: bool = True, return_frames: bool = False, enable_teacache: bool = False, teacache_params: TeaCacheParams | WanTeaCacheParams | None = None, STA_param: list | None = None, is_cfg_negative: bool = False, mask_search_final_result_pos: list[list] | None = None, mask_search_final_result_neg: list[list] | None = None, VSA_sparsity: float = 0.0, logging_info: PipelineLoggingInfo = PipelineLoggingInfo())
Complete state passed through the pipeline execution.
This dataclass contains all information needed during the diffusion pipeline execution, allowing methods to update specific components without needing to manage numerous individual parameters.
Functions¶
fastvideo.pipelines.ForwardBatch.__post_init__
¶
Initialize dependent fields after dataclass initialization.
Source code in fastvideo/pipelines/pipeline_batch_info.py
fastvideo.pipelines.LoRAPipeline
¶
Bases: ComposedPipelineBase
Pipeline that supports injecting LoRA adapters into the diffusion transformer. TODO: support training.
Source code in fastvideo/pipelines/lora_pipeline.py
Functions¶
fastvideo.pipelines.LoRAPipeline.convert_to_lora_layers
¶
Unified method to convert the transformer to a LoRA transformer.
Source code in fastvideo/pipelines/lora_pipeline.py
fastvideo.pipelines.LoRAPipeline.set_lora_adapter
¶
Load a LoRA adapter into the pipeline and merge it into the transformer. Args: lora_nickname: The "nick name" of the adapter when referenced in the pipeline. lora_path: The path to the adapter, either a local path or a Hugging Face repo id.
Source code in fastvideo/pipelines/lora_pipeline.py
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 | |
fastvideo.pipelines.PipelineWithLoRA
¶
Bases: LoRAPipeline, ComposedPipelineBase
Type for a pipeline that has both ComposedPipelineBase and LoRAPipeline functionality.
Source code in fastvideo/pipelines/lora_pipeline.py
Functions¶
fastvideo.pipelines.build_pipeline
¶
build_pipeline(fastvideo_args: FastVideoArgs, pipeline_type: PipelineType | str = BASIC) -> PipelineWithLoRA
Only works with valid hf diffusers configs. (model_index.json) We want to build a pipeline based on the inference args mode_path: 1. download the model from the hub if it's not already downloaded 2. verify the model config and directory 3. based on the config, determine the pipeline class
Source code in fastvideo/pipelines/__init__.py
Modules¶
fastvideo.pipelines.basic
¶
Basic inference pipelines for fastvideo.
This package contains basic pipelines for video and image generation.
Modules¶
fastvideo.pipelines.basic.cosmos
¶
Modules¶
fastvideo.pipelines.basic.cosmos.cosmos_pipeline
¶Cosmos video diffusion pipeline implementation.
This module contains an implementation of the Cosmos video diffusion pipeline using the modular pipeline architecture.
fastvideo.pipelines.basic.cosmos.cosmos_pipeline.Cosmos2VideoToWorldPipeline
¶Cosmos2VideoToWorldPipeline(model_path: str, fastvideo_args: FastVideoArgs | TrainingArgs, required_config_modules: list[str] | None = None, loaded_modules: dict[str, Module] | None = None)
Bases: ComposedPipelineBase
Source code in fastvideo/pipelines/composed_pipeline_base.py
fastvideo.pipelines.basic.cosmos.cosmos_pipeline.Cosmos2VideoToWorldPipeline.create_pipeline_stages
¶create_pipeline_stages(fastvideo_args: FastVideoArgs)
Set up pipeline stages with proper dependency injection.
Source code in fastvideo/pipelines/basic/cosmos/cosmos_pipeline.py
fastvideo.pipelines.basic.hunyuan
¶
Modules¶
fastvideo.pipelines.basic.hunyuan.hunyuan_pipeline
¶Hunyuan video diffusion pipeline implementation.
This module contains an implementation of the Hunyuan video diffusion pipeline using the modular pipeline architecture.
fastvideo.pipelines.basic.hunyuan.hunyuan_pipeline.HunyuanVideoPipeline
¶HunyuanVideoPipeline(model_path: str, fastvideo_args: FastVideoArgs | TrainingArgs, required_config_modules: list[str] | None = None, loaded_modules: dict[str, Module] | None = None)
Bases: ComposedPipelineBase
Source code in fastvideo/pipelines/composed_pipeline_base.py
fastvideo.pipelines.basic.hunyuan.hunyuan_pipeline.HunyuanVideoPipeline.create_pipeline_stages
¶create_pipeline_stages(fastvideo_args: FastVideoArgs)
Set up pipeline stages with proper dependency injection.
Source code in fastvideo/pipelines/basic/hunyuan/hunyuan_pipeline.py
fastvideo.pipelines.basic.stepvideo
¶
Modules¶
fastvideo.pipelines.basic.stepvideo.stepvideo_pipeline
¶Hunyuan video diffusion pipeline implementation.
This module contains an implementation of the Hunyuan video diffusion pipeline using the modular pipeline architecture.
fastvideo.pipelines.basic.stepvideo.stepvideo_pipeline.StepVideoPipeline
¶
Bases: LoRAPipeline, ComposedPipelineBase
Source code in fastvideo/pipelines/lora_pipeline.py
fastvideo.pipelines.basic.stepvideo.stepvideo_pipeline.StepVideoPipeline.create_pipeline_stages
¶create_pipeline_stages(fastvideo_args: FastVideoArgs)
Set up pipeline stages with proper dependency injection.
Source code in fastvideo/pipelines/basic/stepvideo/stepvideo_pipeline.py
fastvideo.pipelines.basic.stepvideo.stepvideo_pipeline.StepVideoPipeline.initialize_pipeline
¶initialize_pipeline(fastvideo_args: FastVideoArgs)
Initialize the pipeline.
Source code in fastvideo/pipelines/basic/stepvideo/stepvideo_pipeline.py
fastvideo.pipelines.basic.stepvideo.stepvideo_pipeline.StepVideoPipeline.load_modules
¶load_modules(fastvideo_args: FastVideoArgs) -> dict[str, Any]
Load the modules from the config.
Source code in fastvideo/pipelines/basic/stepvideo/stepvideo_pipeline.py
fastvideo.pipelines.basic.wan
¶
Modules¶
fastvideo.pipelines.basic.wan.wan_causal_dmd_pipeline
¶Wan causal DMD pipeline implementation.
This module wires the causal DMD denoising stage into the modular pipeline.
fastvideo.pipelines.basic.wan.wan_causal_dmd_pipeline.WanCausalDMDPipeline
¶
Bases: LoRAPipeline, ComposedPipelineBase
Source code in fastvideo/pipelines/lora_pipeline.py
fastvideo.pipelines.basic.wan.wan_causal_dmd_pipeline.WanCausalDMDPipeline.create_pipeline_stages
¶create_pipeline_stages(fastvideo_args: FastVideoArgs) -> None
Set up pipeline stages with proper dependency injection.
Source code in fastvideo/pipelines/basic/wan/wan_causal_dmd_pipeline.py
fastvideo.pipelines.basic.wan.wan_dmd_pipeline
¶Wan video diffusion pipeline implementation.
This module contains an implementation of the Wan video diffusion pipeline using the modular pipeline architecture.
fastvideo.pipelines.basic.wan.wan_dmd_pipeline.WanDMDPipeline
¶
Bases: LoRAPipeline, ComposedPipelineBase
Wan video diffusion pipeline with LoRA support.
Source code in fastvideo/pipelines/lora_pipeline.py
fastvideo.pipelines.basic.wan.wan_dmd_pipeline.WanDMDPipeline.create_pipeline_stages
¶create_pipeline_stages(fastvideo_args: FastVideoArgs) -> None
Set up pipeline stages with proper dependency injection.
Source code in fastvideo/pipelines/basic/wan/wan_dmd_pipeline.py
fastvideo.pipelines.basic.wan.wan_i2v_dmd_pipeline
¶Wan video diffusion pipeline implementation.
This module contains an implementation of the Wan video diffusion pipeline using the modular pipeline architecture.
fastvideo.pipelines.basic.wan.wan_i2v_dmd_pipeline.WanImageToVideoDmdPipeline
¶
Bases: LoRAPipeline, ComposedPipelineBase
Source code in fastvideo/pipelines/lora_pipeline.py
fastvideo.pipelines.basic.wan.wan_i2v_dmd_pipeline.WanImageToVideoDmdPipeline.create_pipeline_stages
¶create_pipeline_stages(fastvideo_args: FastVideoArgs)
Set up pipeline stages with proper dependency injection.
Source code in fastvideo/pipelines/basic/wan/wan_i2v_dmd_pipeline.py
fastvideo.pipelines.basic.wan.wan_i2v_pipeline
¶Wan video diffusion pipeline implementation.
This module contains an implementation of the Wan video diffusion pipeline using the modular pipeline architecture.
fastvideo.pipelines.basic.wan.wan_i2v_pipeline.WanImageToVideoPipeline
¶
Bases: LoRAPipeline, ComposedPipelineBase
Source code in fastvideo/pipelines/lora_pipeline.py
fastvideo.pipelines.basic.wan.wan_i2v_pipeline.WanImageToVideoPipeline.create_pipeline_stages
¶create_pipeline_stages(fastvideo_args: FastVideoArgs)
Set up pipeline stages with proper dependency injection.
Source code in fastvideo/pipelines/basic/wan/wan_i2v_pipeline.py
fastvideo.pipelines.basic.wan.wan_pipeline
¶Wan video diffusion pipeline implementation.
This module contains an implementation of the Wan video diffusion pipeline using the modular pipeline architecture.
fastvideo.pipelines.basic.wan.wan_pipeline.WanPipeline
¶
Bases: LoRAPipeline, ComposedPipelineBase
Wan video diffusion pipeline with LoRA support.
Source code in fastvideo/pipelines/lora_pipeline.py
fastvideo.pipelines.basic.wan.wan_pipeline.WanPipeline.create_pipeline_stages
¶create_pipeline_stages(fastvideo_args: FastVideoArgs) -> None
Set up pipeline stages with proper dependency injection.
Source code in fastvideo/pipelines/basic/wan/wan_pipeline.py
fastvideo.pipelines.basic.wan.wan_v2v_pipeline
¶Wan video-to-video diffusion pipeline implementation.
This module contains an implementation of the Wan video-to-video diffusion pipeline using the modular pipeline architecture.
fastvideo.pipelines.basic.wan.wan_v2v_pipeline.WanVideoToVideoPipeline
¶
Bases: LoRAPipeline, ComposedPipelineBase
Source code in fastvideo/pipelines/lora_pipeline.py
fastvideo.pipelines.basic.wan.wan_v2v_pipeline.WanVideoToVideoPipeline.create_pipeline_stages
¶create_pipeline_stages(fastvideo_args: FastVideoArgs)
Set up pipeline stages with proper dependency injection.
Source code in fastvideo/pipelines/basic/wan/wan_v2v_pipeline.py
fastvideo.pipelines.composed_pipeline_base
¶
Base class for composed pipelines.
This module defines the base class for pipelines that are composed of multiple stages.
Classes¶
fastvideo.pipelines.composed_pipeline_base.ComposedPipelineBase
¶
ComposedPipelineBase(model_path: str, fastvideo_args: FastVideoArgs | TrainingArgs, required_config_modules: list[str] | None = None, loaded_modules: dict[str, Module] | None = None)
Bases: ABC
Base class for pipelines composed of multiple stages.
This class provides the framework for creating pipelines by composing multiple stages together. Each stage is responsible for a specific part of the diffusion process, and the pipeline orchestrates the execution of these stages.
Initialize the pipeline. After init, the pipeline should be ready to use. The pipeline should be stateless and not hold any batch state.
Source code in fastvideo/pipelines/composed_pipeline_base.py
Attributes¶
fastvideo.pipelines.composed_pipeline_base.ComposedPipelineBase.required_config_modules
property
¶List of modules that are required by the pipeline. The names should match the diffusers directory and model_index.json file. These modules will be loaded using the PipelineComponentLoader and made available in the modules dictionary. Access these modules using the get_module method.
class ConcretePipeline(ComposedPipelineBase): _required_config_modules = ["vae", "text_encoder", "transformer", "scheduler", "tokenizer"]
@property
def required_config_modules(self):
return self._required_config_modules
fastvideo.pipelines.composed_pipeline_base.ComposedPipelineBase.stages
property
¶stages: list[PipelineStage]
List of stages in the pipeline.
Functions¶
fastvideo.pipelines.composed_pipeline_base.ComposedPipelineBase.create_pipeline_stages
abstractmethod
¶create_pipeline_stages(fastvideo_args: FastVideoArgs)
fastvideo.pipelines.composed_pipeline_base.ComposedPipelineBase.create_training_stages
¶create_training_stages(training_args: TrainingArgs)
fastvideo.pipelines.composed_pipeline_base.ComposedPipelineBase.forward
¶forward(batch: ForwardBatch, fastvideo_args: FastVideoArgs) -> ForwardBatch
Generate a video or image using the pipeline.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch
|
ForwardBatch
|
The batch to generate from. |
required |
fastvideo_args
|
FastVideoArgs
|
The inference arguments. |
required |
Returns: ForwardBatch: The batch with the generated video or image.
Source code in fastvideo/pipelines/composed_pipeline_base.py
fastvideo.pipelines.composed_pipeline_base.ComposedPipelineBase.from_pretrained
classmethod
¶from_pretrained(model_path: str, device: str | None = None, torch_dtype: dtype | None = None, pipeline_config: str | PipelineConfig | None = None, args: Namespace | None = None, required_config_modules: list[str] | None = None, loaded_modules: dict[str, Module] | None = None, **kwargs) -> ComposedPipelineBase
Load a pipeline from a pretrained model. loaded_modules: Optional[Dict[str, torch.nn.Module]] = None, If provided, loaded_modules will be used instead of loading from config/pretrained weights.
Source code in fastvideo/pipelines/composed_pipeline_base.py
fastvideo.pipelines.composed_pipeline_base.ComposedPipelineBase.initialize_pipeline
¶initialize_pipeline(fastvideo_args: FastVideoArgs)
fastvideo.pipelines.composed_pipeline_base.ComposedPipelineBase.load_modules
¶load_modules(fastvideo_args: FastVideoArgs, loaded_modules: dict[str, Module] | None = None) -> dict[str, Any]
Load the modules from the config. loaded_modules: Optional[Dict[str, torch.nn.Module]] = None, If provided, loaded_modules will be used instead of loading from config/pretrained weights.
Source code in fastvideo/pipelines/composed_pipeline_base.py
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 | |
Functions¶
fastvideo.pipelines.lora_pipeline
¶
Classes¶
fastvideo.pipelines.lora_pipeline.LoRAPipeline
¶
Bases: ComposedPipelineBase
Pipeline that supports injecting LoRA adapters into the diffusion transformer. TODO: support training.
Source code in fastvideo/pipelines/lora_pipeline.py
Functions¶
fastvideo.pipelines.lora_pipeline.LoRAPipeline.convert_to_lora_layers
¶Unified method to convert the transformer to a LoRA transformer.
Source code in fastvideo/pipelines/lora_pipeline.py
fastvideo.pipelines.lora_pipeline.LoRAPipeline.set_lora_adapter
¶Load a LoRA adapter into the pipeline and merge it into the transformer. Args: lora_nickname: The "nick name" of the adapter when referenced in the pipeline. lora_path: The path to the adapter, either a local path or a Hugging Face repo id.
Source code in fastvideo/pipelines/lora_pipeline.py
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 | |
Functions¶
fastvideo.pipelines.pipeline_batch_info
¶
Data structures for functional pipeline processing.
This module defines the dataclasses used to pass state between pipeline components in a functional manner, reducing the need for explicit parameter passing.
Classes¶
fastvideo.pipelines.pipeline_batch_info.ForwardBatch
dataclass
¶
ForwardBatch(data_type: str, generator: Generator | list[Generator] | None = None, image_path: str | None = None, image_embeds: list[Tensor] = list(), pil_image: Tensor | Image | None = None, preprocessed_image: Tensor | None = None, prompt: str | list[str] | None = None, negative_prompt: str | list[str] | None = None, prompt_path: str | None = None, output_path: str = 'outputs/', output_video_name: str | None = None, video_path: str | None = None, video_latent: Tensor | None = None, prompt_embeds: list[Tensor] = list(), negative_prompt_embeds: list[Tensor] | None = None, prompt_attention_mask: list[Tensor] | None = None, negative_attention_mask: list[Tensor] | None = None, clip_embedding_pos: list[Tensor] | None = None, clip_embedding_neg: list[Tensor] | None = None, max_sequence_length: int | None = None, prompt_template: dict[str, Any] | None = None, do_classifier_free_guidance: bool = False, batch_size: int | None = None, num_videos_per_prompt: int = 1, seed: int | None = None, seeds: list[int] | None = None, is_prompt_processed: bool = False, latents: Tensor | None = None, raw_latent_shape: Tensor | None = None, noise_pred: Tensor | None = None, image_latent: Tensor | None = None, height_latents: list[int] | int | None = None, width_latents: list[int] | int | None = None, num_frames: list[int] | int = 1, num_frames_round_down: bool = False, height: list[int] | int | None = None, width: list[int] | int | None = None, fps: list[int] | int | None = None, timesteps: Tensor | None = None, timestep: Tensor | float | int | None = None, step_index: int | None = None, boundary_ratio: float | None = None, num_inference_steps: int = 50, guidance_scale: float = 1.0, guidance_scale_2: float | None = None, guidance_rescale: float = 0.0, eta: float = 0.0, sigmas: list[float] | None = None, n_tokens: int | None = None, extra_step_kwargs: dict[str, Any] = dict(), modules: dict[str, Any] = dict(), output: Tensor | None = None, return_trajectory_latents: bool = False, return_trajectory_decoded: bool = False, trajectory_timesteps: list[Tensor] | None = None, trajectory_latents: Tensor | None = None, trajectory_decoded: list[Tensor] | None = None, extra: dict[str, Any] = dict(), save_video: bool = True, return_frames: bool = False, enable_teacache: bool = False, teacache_params: TeaCacheParams | WanTeaCacheParams | None = None, STA_param: list | None = None, is_cfg_negative: bool = False, mask_search_final_result_pos: list[list] | None = None, mask_search_final_result_neg: list[list] | None = None, VSA_sparsity: float = 0.0, logging_info: PipelineLoggingInfo = PipelineLoggingInfo())
Complete state passed through the pipeline execution.
This dataclass contains all information needed during the diffusion pipeline execution, allowing methods to update specific components without needing to manage numerous individual parameters.
Functions¶
fastvideo.pipelines.pipeline_batch_info.ForwardBatch.__post_init__
¶Initialize dependent fields after dataclass initialization.
Source code in fastvideo/pipelines/pipeline_batch_info.py
fastvideo.pipelines.pipeline_batch_info.PipelineLoggingInfo
¶
Simple approach using OrderedDict to track stage metrics.
Source code in fastvideo/pipelines/pipeline_batch_info.py
Functions¶
fastvideo.pipelines.pipeline_batch_info.PipelineLoggingInfo.add_stage_execution_time
¶Add execution time for a stage.
Source code in fastvideo/pipelines/pipeline_batch_info.py
fastvideo.pipelines.pipeline_batch_info.PipelineLoggingInfo.add_stage_metric
¶Add any metric for a stage.
fastvideo.pipelines.pipeline_batch_info.PipelineLoggingInfo.get_execution_order
¶ fastvideo.pipelines.pipeline_batch_info.PipelineLoggingInfo.get_stage_info
¶
fastvideo.pipelines.pipeline_registry
¶
Classes¶
fastvideo.pipelines.pipeline_registry.PipelineType
¶
Enumeration for different pipeline types.
Inherits from str to allow string comparison for backward compatibility.
Functions¶
fastvideo.pipelines.pipeline_registry.PipelineType.choices
classmethod
¶ fastvideo.pipelines.pipeline_registry.PipelineType.from_string
classmethod
¶from_string(value: str) -> PipelineType
Convert string to PipelineType enum.
Source code in fastvideo/pipelines/pipeline_registry.py
Functions¶
fastvideo.pipelines.pipeline_registry.get_pipeline_registry
¶
get_pipeline_registry(pipeline_type: PipelineType | str | None = None) -> _PipelineRegistry
Get a pipeline registry for the specified mode, pipeline type, and workload type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pipeline_type
|
PipelineType | str | None
|
Pipeline type to load. If None and mode is provided, will be derived from mode. |
None
|
Returns:
| Type | Description |
|---|---|
_PipelineRegistry
|
A pipeline registry instance. |
Source code in fastvideo/pipelines/pipeline_registry.py
fastvideo.pipelines.pipeline_registry.import_pipeline_classes
cached
¶
import_pipeline_classes(pipeline_types: list[PipelineType] | PipelineType | None = None) -> dict[str, dict[str, dict[str, type[ComposedPipelineBase] | None]]]
Import pipeline classes based on the pipeline type and workload type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pipeline_types
|
list[PipelineType] | PipelineType | None
|
The pipeline types to load (basic, preprocess, training). If None, loads all types. |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, dict[str, dict[str, type[ComposedPipelineBase] | None]]]
|
A three-level nested dictionary: |
dict[str, dict[str, dict[str, type[ComposedPipelineBase] | None]]]
|
{pipeline_type: {architecture_name: {pipeline_name: pipeline_cls}}} |
dict[str, dict[str, dict[str, type[ComposedPipelineBase] | None]]]
|
e.g., {"basic": {"wan": {"WanPipeline": WanPipeline}}} |
Source code in fastvideo/pipelines/pipeline_registry.py
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 | |
fastvideo.pipelines.preprocess
¶
Modules¶
fastvideo.pipelines.preprocess.preprocess_pipeline_base
¶
Classes¶
fastvideo.pipelines.preprocess.preprocess_pipeline_base.BasePreprocessPipeline
¶BasePreprocessPipeline(model_path: str, fastvideo_args: FastVideoArgs | TrainingArgs, required_config_modules: list[str] | None = None, loaded_modules: dict[str, Module] | None = None)
Bases: ComposedPipelineBase
Base class for preprocessing pipelines that handles common functionality.
Source code in fastvideo/pipelines/composed_pipeline_base.py
fastvideo.pipelines.preprocess.preprocess_pipeline_base.BasePreprocessPipeline.create_pipeline_stages
¶create_pipeline_stages(fastvideo_args: FastVideoArgs)
Set up pipeline stages with proper dependency injection.
Source code in fastvideo/pipelines/preprocess/preprocess_pipeline_base.py
fastvideo.pipelines.preprocess.preprocess_pipeline_base.BasePreprocessPipeline.create_record
¶create_record(video_name: str, vae_latent: ndarray, text_embedding: ndarray, valid_data: dict[str, Any], idx: int, extra_features: dict[str, Any] | None = None) -> dict[str, Any]
Create a record for the Parquet dataset.
Source code in fastvideo/pipelines/preprocess/preprocess_pipeline_base.py
fastvideo.pipelines.preprocess.preprocess_pipeline_base.BasePreprocessPipeline.create_record_for_schema
¶create_record_for_schema(preprocess_batch: PreprocessBatch, schema: Schema, strict: bool = False) -> dict[str, Any]
Create a record for the Parquet dataset using a generic schema-based approach.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
preprocess_batch
|
PreprocessBatch
|
The batch containing the data to extract |
required |
schema
|
Schema
|
PyArrow schema defining the expected fields |
required |
strict
|
bool
|
If True, raises an exception when required fields are missing or unfilled |
False
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dictionary record matching the schema |
Raises:
| Type | Description |
|---|---|
ValueError
|
If strict=True and required fields are missing or unfilled |
Source code in fastvideo/pipelines/preprocess/preprocess_pipeline_base.py
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 | |
fastvideo.pipelines.preprocess.preprocess_pipeline_base.BasePreprocessPipeline.get_extra_features
¶Get additional features specific to the pipeline type. Override in subclasses.
fastvideo.pipelines.preprocess.preprocess_pipeline_base.BasePreprocessPipeline.get_pyarrow_schema
¶ fastvideo.pipelines.preprocess.preprocess_pipeline_base.BasePreprocessPipeline.get_schema_fields
¶Functions¶
fastvideo.pipelines.preprocess.preprocess_pipeline_i2v
¶
I2V Data Preprocessing pipeline implementation.
This module contains an implementation of the I2V Data Preprocessing pipeline using the modular pipeline architecture.
Classes¶
fastvideo.pipelines.preprocess.preprocess_pipeline_i2v.PreprocessPipeline_I2V
¶PreprocessPipeline_I2V(model_path: str, fastvideo_args: FastVideoArgs | TrainingArgs, required_config_modules: list[str] | None = None, loaded_modules: dict[str, Module] | None = None)
Bases: BasePreprocessPipeline
I2V preprocessing pipeline implementation.
Source code in fastvideo/pipelines/composed_pipeline_base.py
fastvideo.pipelines.preprocess.preprocess_pipeline_i2v.PreprocessPipeline_I2V.create_record
¶create_record(video_name: str, vae_latent: ndarray, text_embedding: ndarray, valid_data: dict[str, Any], idx: int, extra_features: dict[str, Any] | None = None) -> dict[str, Any]
Create a record for the Parquet dataset with CLIP features.
Source code in fastvideo/pipelines/preprocess/preprocess_pipeline_i2v.py
fastvideo.pipelines.preprocess.preprocess_pipeline_i2v.PreprocessPipeline_I2V.get_pyarrow_schema
¶Functions¶
fastvideo.pipelines.preprocess.preprocess_pipeline_ode_trajectory
¶
ODE Trajectory Data Preprocessing pipeline implementation.
This module contains an implementation of the ODE Trajectory Data Preprocessing pipeline using the modular pipeline architecture.
Sec 4.3 of CausVid paper: https://arxiv.org/pdf/2412.07772
Classes¶
fastvideo.pipelines.preprocess.preprocess_pipeline_ode_trajectory.PreprocessPipeline_ODE_Trajectory
¶PreprocessPipeline_ODE_Trajectory(model_path: str, fastvideo_args: FastVideoArgs | TrainingArgs, required_config_modules: list[str] | None = None, loaded_modules: dict[str, Module] | None = None)
Bases: BasePreprocessPipeline
ODE Trajectory preprocessing pipeline implementation.
Source code in fastvideo/pipelines/composed_pipeline_base.py
fastvideo.pipelines.preprocess.preprocess_pipeline_ode_trajectory.PreprocessPipeline_ODE_Trajectory.create_pipeline_stages
¶create_pipeline_stages(fastvideo_args: FastVideoArgs)
Set up pipeline stages with proper dependency injection.
Source code in fastvideo/pipelines/preprocess/preprocess_pipeline_ode_trajectory.py
fastvideo.pipelines.preprocess.preprocess_pipeline_ode_trajectory.PreprocessPipeline_ODE_Trajectory.get_pyarrow_schema
¶ fastvideo.pipelines.preprocess.preprocess_pipeline_ode_trajectory.PreprocessPipeline_ODE_Trajectory.preprocess_text_and_trajectory
¶preprocess_text_and_trajectory(fastvideo_args: FastVideoArgs, args)
Preprocess text-only data and generate trajectory information.
Source code in fastvideo/pipelines/preprocess/preprocess_pipeline_ode_trajectory.py
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 | |
Functions¶
fastvideo.pipelines.preprocess.preprocess_pipeline_t2v
¶
T2V Data Preprocessing pipeline implementation.
This module contains an implementation of the T2V Data Preprocessing pipeline using the modular pipeline architecture.
Classes¶
fastvideo.pipelines.preprocess.preprocess_pipeline_t2v.PreprocessPipeline_T2V
¶PreprocessPipeline_T2V(model_path: str, fastvideo_args: FastVideoArgs | TrainingArgs, required_config_modules: list[str] | None = None, loaded_modules: dict[str, Module] | None = None)
Bases: BasePreprocessPipeline
T2V preprocessing pipeline implementation.
Source code in fastvideo/pipelines/composed_pipeline_base.py
fastvideo.pipelines.preprocess.preprocess_pipeline_text
¶
Text-only Data Preprocessing pipeline implementation.
This module contains an implementation of the Text-only Data Preprocessing pipeline using the modular pipeline architecture, based on the ODE Trajectory preprocessing.
Classes¶
fastvideo.pipelines.preprocess.preprocess_pipeline_text.PreprocessPipeline_Text
¶PreprocessPipeline_Text(model_path: str, fastvideo_args: FastVideoArgs | TrainingArgs, required_config_modules: list[str] | None = None, loaded_modules: dict[str, Module] | None = None)
Bases: BasePreprocessPipeline
Text-only preprocessing pipeline implementation.
Source code in fastvideo/pipelines/composed_pipeline_base.py
fastvideo.pipelines.preprocess.preprocess_pipeline_text.PreprocessPipeline_Text.create_pipeline_stages
¶create_pipeline_stages(fastvideo_args: FastVideoArgs)
Set up pipeline stages with proper dependency injection.
Source code in fastvideo/pipelines/preprocess/preprocess_pipeline_text.py
fastvideo.pipelines.preprocess.preprocess_pipeline_text.PreprocessPipeline_Text.get_pyarrow_schema
¶ fastvideo.pipelines.preprocess.preprocess_pipeline_text.PreprocessPipeline_Text.preprocess_text_only
¶preprocess_text_only(fastvideo_args: FastVideoArgs, args)
Preprocess text-only data.
Source code in fastvideo/pipelines/preprocess/preprocess_pipeline_text.py
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 | |
Functions¶
fastvideo.pipelines.preprocess.preprocess_stages
¶
Classes¶
fastvideo.pipelines.preprocess.preprocess_stages.TextTransformStage
¶
Bases: PipelineStage
Process text data according to the cfg rate.
Source code in fastvideo/pipelines/preprocess/preprocess_stages.py
fastvideo.pipelines.preprocess.preprocess_stages.VideoTransformStage
¶VideoTransformStage(train_fps: int, num_frames: int, max_height: int, max_width: int, do_temporal_sample: bool)
Bases: PipelineStage
Crop a video in temporal dimension.
Source code in fastvideo/pipelines/preprocess/preprocess_stages.py
fastvideo.pipelines.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.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
Functions¶
fastvideo.pipelines.stages.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.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.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.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
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 | |
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
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 | |
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
566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 | |
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
1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 | |
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.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
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 | |
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
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 | |
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.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.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
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.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
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 | |
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
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 | |
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.
fastvideo.pipelines.stages.base.PipelineStage.device
property
¶Get the device for this stage.
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
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.
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
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
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 | |
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.CosmosDenoisingStage
¶
Bases: DenoisingStage
Denoising stage for Cosmos models using FlowMatchEulerDiscreteScheduler.
Source code in fastvideo/pipelines/stages/denoising.py
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
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
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 | |
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
566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 | |
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
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
1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 | |
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
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.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.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
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
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
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 | |
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
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
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
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 | |
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.
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
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 | |
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.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.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
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.
Source code in fastvideo/pipelines/stages/latent_preparation.py
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
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.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
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
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 | |
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.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
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.
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.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
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.
Source code in fastvideo/pipelines/stages/validators.py
fastvideo.pipelines.training
¶
Training pipelines for fastvideo.v1.
This package contains pipelines for training diffusion models.