base ¶
Base classes for pipeline stages.
This module defines the abstract base classes for pipeline stages that can be composed to create complete diffusion pipelines.
Classes¶
fastvideo.pipelines.stages.base.PipelineStage ¶
Bases: ABC
Abstract base class for all pipeline stages.
A pipeline stage represents a discrete step in the diffusion process that can be composed with other stages to create a complete pipeline. Each stage is responsible for a specific part of the process, such as prompt encoding, latent preparation, etc.
Attributes¶
fastvideo.pipelines.stages.base.PipelineStage.device property ¶
Get the device for this stage.
Methods:¶
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.