fastvideo ¶
Classes¶
fastvideo.PipelineConfig dataclass ¶
PipelineConfig(model_path: str = '', pipeline_config_path: str | None = None, embedded_cfg_scale: float = 6.0, flow_shift: float | None = None, flow_shift_sr: float | None = None, disable_autocast: bool = False, scheduler_step_in_fp32: bool = False, is_causal: bool = False, dit_config: DiTConfig = DiTConfig(), dit_precision: str = 'bf16', upsampler_config: UpsamplerConfig = UpsamplerConfig(), upsampler_precision: str = 'fp32', vae_config: VAEConfig = VAEConfig(), vae_precision: str = 'fp32', vae_decode_precision: str | None = None, vae_tiling: bool = True, vae_sp: bool = True, image_encoder_config: EncoderConfig = EncoderConfig(), image_encoder_precision: str = 'fp32', text_encoder_configs: tuple[EncoderConfig, ...] = (lambda: (EncoderConfig(),))(), text_encoder_precisions: tuple[str, ...] = (lambda: ('fp32',))(), preprocess_text_funcs: tuple[Callable[[str], str], ...] = (lambda: (preprocess_text,))(), postprocess_text_funcs: tuple[Callable[[BaseEncoderOutput], tensor], ...] = (lambda: (postprocess_text,))(), dmd_denoising_steps: list[int] | None = None, ti2v_task: bool = False, lucy_edit_task: bool = False, boundary_ratio: float | None = None)
Base configuration for all pipeline architectures.
Methods:¶
fastvideo.PipelineConfig.from_kwargs classmethod ¶
from_kwargs(kwargs: dict[str, Any], config_cli_prefix: str = '') -> PipelineConfig
Load PipelineConfig from kwargs Dictionary. kwargs: dictionary of kwargs config_cli_prefix: prefix of CLI arguments for this PipelineConfig instance
Source code in fastvideo/configs/pipelines/base.py
fastvideo.PipelineConfig.from_pretrained classmethod ¶
from_pretrained(model_path: str) -> PipelineConfig
use the pipeline class setting from model_path to match the pipeline config
Source code in fastvideo/configs/pipelines/base.py
fastvideo.SamplingParam dataclass ¶
SamplingParam(data_type: str = 'video', image_path: str | None = None, pil_image: Any | None = None, video_path: str | None = None, latents: Any | None = None, mouse_cond: Any | None = None, keyboard_cond: Any | None = None, grid_sizes: Any | None = None, pose: str | None = None, prompt_attention_mask: list = list(), negative_attention_mask: list = list(), camera_states: Any | None = None, camera_trajectory: str | None = None, action_list: list[str] | None = None, action_speed_list: list[float] | None = None, gt_latents: Any | None = None, conditioning_mask: Any | None = None, c2ws_plucker_emb: Any | None = None, action_path: str | None = None, refine_from: str | None = None, t_thresh: float = 0.5, spatial_refine_only: bool = False, num_cond_frames: int = 0, stage1_video: Any | None = None, prompt: str | list[str] | None = None, negative_prompt: str = 'Bright tones, overexposed, static, blurred details, subtitles, style, works, paintings, images, static, overall gray, worst quality, low quality, JPEG compression residue, ugly, incomplete, extra fingers, poorly drawn hands, poorly drawn faces, deformed, disfigured, misshapen limbs, fused fingers, still picture, messy background, three legs, many people in the background, walking backwards', max_sequence_length: int | None = None, prompt_path: str | None = None, output_path: str = 'outputs/', output_video_name: str | None = None, num_videos_per_prompt: int = 1, seed: int = 1024, num_frames: int = 125, height: int = 720, width: int = 1280, height_sr: int = 1072, width_sr: int = 1920, fps: int = 24, num_inference_steps: int = 50, num_inference_steps_sr: int = 50, guidance_scale: float = 1.0, batch_cfg: bool = False, guidance_scale_2: float | None = None, cfg_normalization: bool = False, cfg_truncation: float | None = 1.0, use_embedded_guidance: bool = False, true_cfg_scale: float = 1.0, guidance_rescale: float = 0.0, boundary_ratio: float | None = None, sigmas: list[float] | None = None, enable_teacache: bool = False, trajectory_type: str | None = None, movement_distance: float | None = None, camera_rotation: str | None = None, ltx2_cfg_scale_video: float = 1.0, ltx2_cfg_scale_audio: float = 1.0, ltx2_modality_scale_video: float = 1.0, ltx2_modality_scale_audio: float = 1.0, ltx2_rescale_scale: float = 0.0, ltx2_stg_scale_video: float = 0.0, ltx2_stg_scale_audio: float = 0.0, ltx2_stg_blocks_video: list[int] = (lambda: [29])(), ltx2_stg_blocks_audio: list[int] = (lambda: [29])(), ltx2_images: list[tuple[str, int, float]] | None = None, ltx2_image_crf: float = 33.0, ltx2_conditioning_latent_stage1: Any | None = None, ltx2_conditioning_latent_stage2: Any | None = None, ltx2_video_conditions: list[tuple[list[str], int, float]] | None = None, audio_start_in_s: float | None = None, audio_end_in_s: float | None = None, init_audio: Any = None, init_audio_strength: float | None = None, init_noise_level: float | None = None, inpaint_audio: Any = None, inpaint_mask: Any = None, continuation_state: ContinuationState | None = None, return_continuation_state: bool = False, save_video: bool = True, return_frames: bool = True, return_trajectory_latents: bool = False, return_trajectory_decoded: bool = False)
Sampling parameters for video generation.
Methods:¶
fastvideo.SamplingParam.add_cli_args staticmethod ¶
Add CLI arguments for SamplingParam fields
Source code in fastvideo/api/sampling_param.py
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 | |
fastvideo.VideoGenerator ¶
VideoGenerator(fastvideo_args: FastVideoArgs, executor_class: type[Executor], log_stats: bool, *, log_queue=None)
A unified class for generating videos using diffusion models.
This class provides a simple interface for video generation with rich customization options, similar to popular frameworks like HF Diffusers.
Initialize the video generator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fastvideo_args | FastVideoArgs | The inference arguments | required |
executor_class | type[Executor] | The executor class to use for inference | required |
log_stats | bool | Whether to log statistics | required |
log_queue | Optional multiprocessing.Queue to forward worker logs to | None |
Source code in fastvideo/entrypoints/video_generator.py
Methods:¶
fastvideo.VideoGenerator.default_health_check_request staticmethod ¶
Return the minimal typed request Dynamo uses for probes.
256x256, 8 frames, 1 inference step -- fast enough to be a viable liveness check, non-trivial enough to exercise the DiT -> VAE -> decode path. Consumers adapt this shape to their transport's health-check payload (see docs/design/server_contracts/dynamo.md).
Source code in fastvideo/entrypoints/video_generator.py
fastvideo.VideoGenerator.from_fastvideo_args classmethod ¶
from_fastvideo_args(fastvideo_args: FastVideoArgs, *, log_queue=None) -> VideoGenerator
Create a video generator with the specified arguments.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fastvideo_args | FastVideoArgs | The inference arguments | required |
log_queue | Optional multiprocessing.Queue to forward worker logs to | None |
Returns:
| Type | Description |
|---|---|
VideoGenerator | The created video generator |
Source code in fastvideo/entrypoints/video_generator.py
fastvideo.VideoGenerator.from_pretrained classmethod ¶
from_pretrained(model_path: str | GeneratorConfig | Mapping[str, Any] | None = None, **kwargs) -> VideoGenerator
Create a video generator from a pretrained model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_path | str | GeneratorConfig | Mapping[str, Any] | None | Path or identifier for the pretrained model | None |
pipeline_config | Pipeline config to use for inference | required | |
**kwargs | Additional arguments to customize model loading, set any FastVideoArgs or PipelineConfig attributes here. | {} |
Returns:
| Type | Description |
|---|---|
VideoGenerator | The created video generator |
Priority level: Default pipeline config < User's pipeline config < User's kwargs
Stable convenience kwargs remain supported here for common engine and offload settings. Advanced model- or pipeline-specific options should move to VideoGenerator.from_config(...).
Source code in fastvideo/entrypoints/video_generator.py
fastvideo.VideoGenerator.generate ¶
generate(request: GenerationRequest | Mapping[str, Any], *, log_queue=None) -> GenerationResult | list[GenerationResult]
Generate video or image outputs from a typed inference request.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request | GenerationRequest | Mapping[str, Any] | A | required |
log_queue | Optional multiprocessing.Queue to forward worker logs to during this request. | None |
Returns:
| Type | Description |
|---|---|
GenerationResult | list[GenerationResult] | A |
GenerationResult | list[GenerationResult] |
|
GenerationResult | list[GenerationResult] | prompts. |
Source code in fastvideo/entrypoints/video_generator.py
fastvideo.VideoGenerator.generate_async async ¶
Async generation that yields typed :class:VideoEvents.
Three consumers share this substrate:
- Streaming server (:mod:
fastvideo.entrypoints.streaming) — pipes :class:VideoPartialEventframes into fMP4. - Stateless OpenAI server — ignores progress events, forwards :class:
VideoFinalEventas the HTTP response body. - Dynamo native backend (
components/src/dynamo/fastvideo/) — wraps each event as anNvVideosResponsechunk.
The aggregated code path shipped here yields a single :class:VideoProgressEvent at start and one :class:VideoFinalEvent at end. Future work will thread per-step progress events through the pipeline's denoise loop so streaming consumers don't have to wait on a materialized final.
Source code in fastvideo/entrypoints/video_generator.py
fastvideo.VideoGenerator.generate_video ¶
generate_video(prompt: str | None = None, sampling_param: SamplingParam | None = None, mouse_cond: Tensor | None = None, keyboard_cond: Tensor | None = None, grid_sizes: tuple[int, int, int] | list[int] | Tensor | None = None, **kwargs) -> dict[str, Any] | list[dict[str, Any]]
Generate a video based on the given prompt.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prompt | str | None | The prompt to use for generation (optional if prompt_txt is provided) | None |
negative_prompt | The negative prompt to use (overrides the one in fastvideo_args) | required | |
output_path | Path to save the video (overrides the one in fastvideo_args) | required | |
prompt_path | Path to prompt file | required | |
save_video | Whether to save the video to disk | required | |
return_frames | Whether to include raw frames in the result dict | required | |
num_inference_steps | Number of denoising steps (overrides fastvideo_args) | required | |
guidance_scale | Classifier-free guidance scale (overrides fastvideo_args) | required | |
num_frames | Number of frames to generate (overrides fastvideo_args) | required | |
height | Height of generated video (overrides fastvideo_args) | required | |
width | Width of generated video (overrides fastvideo_args) | required | |
fps | Frames per second for saved video (overrides fastvideo_args) | required | |
seed | Random seed for generation (overrides fastvideo_args) | required | |
callback | Callback function called after each step | required | |
callback_steps | Number of steps between each callback | required |
Returns:
| Type | Description |
|---|---|
dict[str, Any] | list[dict[str, Any]] | A metadata dictionary for single-prompt generation, or a list of |
dict[str, Any] | list[dict[str, Any]] | metadata dictionaries for prompt-file batch generation. |
Source code in fastvideo/entrypoints/video_generator.py
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 | |
fastvideo.VideoGenerator.shutdown ¶
fastvideo.VideoGenerator.unmerge_lora_weights ¶
Use unmerged weights for inference to produce videos that align with validation videos generated during training.