FastVideo Documentation
repository·main·Indexed 26 days ago
https://github.com/hao-ai-lab/fastvideoFastVideo is a unified post-training and real-time inference framework for accelerated video generation, supporting bidirectional and autoregressive models. Version 0.2.0 includes the Dreamverse application, featuring a backend for video segment generation and a Next.js frontend. The framework supports CUDA 12.6 and 13.0, provides Docker deployment options, and includes a PromptEnhancer for guided continuation and autonomous expansion of video clips.
What's inside FastVideo
- FastVideo is a unified inference and post-training framework designed for accelerated video generation using diffusion models. It provides an end-to-end pipeline covering data preprocessing, model training, fine-tuning, distillation, and inference. The framework is modular and extensible, supporting both training-free and post-training optimizations.
Overview of the FastVideo Modular Training Framework
mainThefastvideo/train/directory contains the new modular training infrastructure for FastVideo. Unlike the legacyfastvideo/training/system which used monolithic per-model pipeline scripts, the new framework is composable. It allows developers to combine model plugins with specific training method classes using hierarchical YAML configurations.Overview of FastVideo features
mainFastVideo is a unified post-training and real-time inference framework for accelerated video generation. Key capabilities include:
- Post-training Support: Full and LoRA finetuning for video DiTs, data preprocessing, DMD2 stepwise distillation, Sparse attention (VSA), and Causal distillation via Self-Forcing.
- Inference Optimizations: Sequence Parallelism for distributed inference and multiple attention backends.
- Hardware Support: Optimized for H100, A100, and 4090 across Linux, Windows, and MacOS.
- Realtime Generation: Includes Dreamverse, a platform for realtime video generation and "vibe directing" that can be deployed locally, via Docker, or on serverless Modal.
Understand FastVideo Server Integration Contracts
mainFastVideo provides a typed public API (
fastvideo.api) designed to be consumed by different server-class integrations. These integrations share a single execution substrate to maintain consistency. The three primary integration patterns are:- Stateless OpenAI: Uses HTTP POST
/v1/videos. It mapsVideoGenerationsRequesttoGenerationRequestmerged ontoServeConfig.default_request. It is stateless, with an optionalContinuationStateround-trip. - Streaming WebSocket: Uses WebSocket JSON and binary fMP4. It processes a
GenerationRequestper segment and uses a server-heldSessionStorewith snapshot-on-demand. - Dynamo native backend: Uses Dynamo RPC. It maps
NvCreateVideoRequestvia an adapter toGenerationRequest. State is currently aggregated, with plans for disaggregation viaContinuationState.
All integrations consume the same underlying
fastvideo.apisurface.- Stateless OpenAI: Uses HTTP POST
Data requirements for FastVideo finetuning
mainFastVideo uses precomputed embeddings and latents to reduce GPU memory usage by eliminating the need to load the text encoder and VAE during training. The required components depend on the model type:
Text-to-Video (T2V) Finetuning
- Text embeddings: Precomputed embeddings (e.g., T5 or LLaMA) stored as numpy arrays in Parquet files.
- Video latents: VAE-encoded representations of the training videos.
Image-to-Video (I2V) Finetuning
In addition to the T2V requirements, certain architectures (like Wan2.1 and Wan2.2 A14B) require:
- First frame latent: VAE-encoded representation of the first frame used for conditioning.
- CLIP features: Image embeddings from a CLIP vision encoder for the conditioning frame.
Understand Dreamverse Architecture and Runtime
mainDreamverse consists of two primary components:
- Frontend: A Next.js application located at
apps/dreamverse/web/that manages UI state, websocket connections, and user interaction flows. - Server: A Python FastAPI runtime located at
apps/dreamverse/dreamverse/that manages generation state, prompt rewriting, safety, GPU execution, and websocket session semantics.
Communication occurs via HTTP and a single websocket on the
/wsendpoint. The server is the authoritative source of truth for generation state and prompt memory, while the frontend manages local UI state and proposes prompt changes.- Frontend: A Next.js application located at
Use the Core FastVideo API for media generation
mainFastVideo provides a high-level interface for loading media generation pipelines and controlling the generation process through three primary components:
fastvideo.VideoGenerator: The main entry point used to load a pipeline and perform high-level media generation.fastvideo.PipelineConfig: A configuration object used to describe the specific components (models, schedulers, etc.) required by a pipeline.fastvideo.SamplingParam: A configuration object used to define sampling parameters at generation time (e.g., guidance scale, steps).
Supported FastVideo Attention Kernels
mainFastVideo provides several optimized attention kernels for video generation:
- Video Sparse Attention (VSA): A sparse attention mechanism that selects top-k blocks.
- Sliding Tile Attention (STA): Kernel support is located in the
fastvideo-kernelpackage. Note that the full FastVideo STA pipeline workflow is archived in thesta_do_not_deletedirectory. - Attn-QAT Training: Provides Runtime-JIT Triton forward and backward kernels designed for role-local quantization-aware training.
Understand the Dreamverse Architecture and Responsibility Split
mainDreamverse is designed as a local-first application where the browser communicates with a local control plane rather than directly with cloud providers. The architecture is split into three primary layers:
1. Frontend (
apps/dreamverse/web)- Responsibilities: UI state, local interaction state, selecting compute modes, displaying cost/health/status, and local forms for provider configuration. It sends prompt and rewrite requests to the local controller.
- Constraints: Must not own provider credentials, provider API calls, or runtime lifecycle.
2. Controller (
apps/dreamverse/controller)- Responsibilities: Local-only storage of provider credentials, compute mode selection, provisioning/monitoring runtimes, and reverse proxying HTTP/Websocket traffic from the frontend to the active runtime.
- Constraints: Must not own prompt rewrite logic, seed prompt memory, or generation queue behavior.
3. Runtime (
apps/dreamverse/dreamverseorruntime/)- Responsibilities: Authoritative owner of
/wssession state, prompt rewrite execution, prompt safety, seed prompt memory, and generation orchestration. - Constraints: Must remain provider-agnostic and follow a stable contract.
Understand the FastVideo training file structure
mainThe training infrastructure is organized into several key directories within
fastvideo/train/:entrypoint/: Containstrain.py, the CLI entrypoint used withtorchrun.trainer.py: The main orchestrator for the training loop.models/: Contains model definitions (e.g.,wan/for Wan 2.1 T2V and Wan causal models).methods/: Contains training algorithms such asdistribution_matching/(DMD2, Self-Forcing) andfine_tuning/(SFT, DFSFT).callbacks/: Contains pluggable hooks likegrad_clip.py,ema.py, andvalidation.py.utils/: Contains core utilities for configuration parsing, model/method building, optimization, checkpointing, and data loading.
Understand the training directory layout
mainThe
examples/train/directory is organized as follows:configs/: Contains single-step training configurations categorized by method and model.scenario/: Contains multi-step end-to-end training pipelines.run.sh: The launcher script for single-node training.run_slurm.sh: The launcher script for multi-node Slurm training.
Collect environment information for debugging
mainTo gather diagnostic information about your current environment (useful when filing GitHub issues), run the
collect_env.pyscript from the repository root.python collect_env.py