Stable Video Diffusion¶
Stable Video Diffusion is an image-to-video latent diffusion model that synthesizes a short video from a single input image. RBLN Optimum provides accelerated Stable Video Diffusion pipelines on RBLN NPUs.
Supported NPU
Diffusers pipelines run on ATOM™ only. Rebel100™ does not support them yet.
Supported Pipelines¶
RBLN Optimum supports the following Stable Video Diffusion pipelines:
| Pipeline | Class | Description |
|---|---|---|
| Image-to-Video | RBLNStableVideoDiffusionPipeline | Generate a video sequence from an input image. |
Important: Batch Size Configuration for Guidance Scale¶
Batch Size and Guidance Scale
When running Stable Video Diffusion with max_guidance_scale > 1.0 (default: 3.0), classifier-free guidance doubles the UNet's effective batch size during inference.
Because RBLN NPUs rely on static graph compilation, the UNet batch size configured at compile time must match the runtime batch size. Otherwise, the compiled graph cannot execute and inference fails.
Default Behavior¶
If you do not set the UNet batch size explicitly, RBLN Optimum does the following:
- Assumes you'll use the default
max_guidance_scale(3.0) - Automatically sets the UNet batch size to 2× the pipeline batch size
If you plan to use the default max guidance scale (which is > 1.0), this automatic configuration works correctly. However, if you plan to use a different guidance scale or want more control, explicitly configure the UNet's batch size.
Example: Explicitly Setting the UNet Batch Size¶
Example: Using max_guidance_scale = 1.0¶
If you plan to use a max guidance scale of exactly 1.0 (which does not use classifier-free guidance), explicitly set the UNet batch size to match your inference batch size:
Usage Example¶
API Reference¶
RBLNStableVideoDiffusionPipeline ¶
Bases: RBLNDiffusionMixin, StableVideoDiffusionPipeline
RBLN-accelerated implementation of Stable Video Diffusion pipeline for image-to-video generation.
This pipeline compiles Stable Video Diffusion models to run efficiently on RBLN NPUs, enabling high-performance inference for generating videos from images with optimized memory usage and throughput.
from_pretrained(model_id, *, export=None, model_save_dir=None, rbln_config=None, lora_ids=None, lora_weights_names=None, lora_scales=None, **kwargs) classmethod ¶
Load a pretrained diffusion pipeline from a model checkpoint, with optional compilation for RBLN NPUs.
It supports various diffusion pipelines including Stable Diffusion, Kandinsky, ControlNet, and other diffusers-based models.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_id | `str` | The model ID or path to the pretrained model to load. Can be either:
| required |
export | bool | None | If True, takes a PyTorch model from | None |
model_save_dir | str | PathLike[str] | None | Directory to save the compiled model artifacts. Only used when | None |
rbln_config | dict[str, Any] | RBLNModelConfig | None | Configuration options for RBLN compilation. Can include settings for specific submodules such as | None |
lora_ids | str | list[str] | None | LoRA adapter ID(s) to load and apply before compilation. LoRA weights are fused into the model weights during compilation. Only used when | None |
lora_weights_names | str | list[str] | None | Names of specific LoRA weight files to load, corresponding to lora_ids. Only used when | None |
lora_scales | float | list[float] | None | Scaling factor(s) to apply to the LoRA adapter(s). Only used when | None |
kwargs | Any | Additional arguments to pass to the underlying diffusion pipeline constructor or the RBLN compilation process. These may include parameters specific to individual submodules or the particular diffusion pipeline being used. | {} |
Returns:
| Type | Description |
|---|---|
Self | A compiled or loaded diffusion pipeline that can be used for inference on RBLN NPU. The returned object is an instance of the class that called this method, inheriting from RBLNDiffusionMixin. |
RBLNStableVideoDiffusionPipelineConfig ¶
Bases: RBLNModelConfig
__init__(image_encoder=None, unet=None, vae=None, *, batch_size=None, height=None, width=None, num_frames=None, decode_chunk_size=None, guidance_scale=None, **kwargs) ¶
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image_encoder | RBLNCLIPVisionModelWithProjectionConfig | None | Configuration for the image encoder component. Initialized as RBLNCLIPVisionModelWithProjectionConfig if not provided. | None |
unet | RBLNUNetSpatioTemporalConditionModelConfig | None | Configuration for the UNet model component. Initialized as RBLNUNetSpatioTemporalConditionModelConfig if not provided. | None |
vae | RBLNAutoencoderKLTemporalDecoderConfig | None | Configuration for the VAE model component. Initialized as RBLNAutoencoderKLTemporalDecoderConfig if not provided. | None |
batch_size | int | None | Batch size for inference, applied to all submodules. | None |
height | int | None | Height of the generated images. | None |
width | int | None | Width of the generated images. | None |
num_frames | int | None | The number of frames in the generated video. | None |
decode_chunk_size | int | None | The number of frames to decode at once during VAE decoding. Useful for managing memory usage during video generation. | None |
guidance_scale | float | None | Scale for classifier-free guidance. | None |
kwargs | Any | Additional arguments passed to the parent RBLNModelConfig. | {} |
Raises:
| Type | Description |
|---|---|
ValueError | If both image_size and height/width are provided. |
Note
When guidance_scale > 1.0, the UNet batch size is automatically doubled to accommodate classifier-free guidance.
from_pretrained(path, rbln_config=None, return_unused_kwargs=False, **kwargs) classmethod ¶
Load a RBLNModelConfig from a path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path | str | Path to the RBLNModelConfig file or directory containing the config file. | required |
rbln_config | dict[str, Any] | None | Additional configuration to override. | None |
return_unused_kwargs | bool | Whether to return unused kwargs. | False |
kwargs | Any | Additional keyword arguments to override configuration values. Keys starting with 'rbln_' will have the prefix removed and be used to update the configuration. | {} |
Returns:
| Name | Type | Description |
|---|---|---|
RBLNModelConfig | Self | tuple[Self, dict[str, Any]] | The loaded configuration instance. |
Note
This method loads the configuration from the specified path and applies any provided overrides. If the loaded configuration class doesn't match the expected class, a warning will be logged.
Examples:
initialize_submodule_config(submodule_config=None, force_kwargs=False, **kwargs) ¶
Build the config of a submodule from the parent's runtime options and kwargs.
Returns the submodule config instance when its class is known (an instance was passed, or cls_name was given), otherwise the merged kwargs dict for the model class to resolve later.
get_load_overrides() ¶
Extract the options that must cross the load boundary, for passing to from_pretrained.
Returns the explicitly-set runtime options (device, device_map, create_runtimes, activate_profiler, timeout) and the subclass-specific non-save attributes (load-behavior flags such as _load_visual_runtime, which are never serialized so they can only travel with the caller), recursively including submodules. Compile-time attributes are not included: when loading a compiled model they come from the artifact's rbln_config.json, and this dict is merged on top of it.
Returns:
| Type | Description |
|---|---|
dict[str, Any] | Dictionary of load overrides, keyed like the |