Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2.7 KiB
2.7 KiB
fastvideo/models/ — Model Implementations
Generated: 2026-05-02
DiT / VAE / encoder / scheduler / upsampler / audio model classes. Pre-commit excludes this directory — yapf/ruff/mypy do not run on commits here. Match neighboring file style manually.
Layout
models/
├── dits/
│ ├── <model>.py # Single-file DiT (wanvideo, ltx2, hunyuanvideo, cosmos, ...)
│ ├── hyworld/ # Multi-file DiT family
│ ├── lingbotworld/ # ditto
│ └── matrixgame2/ # ditto
├── vaes/ # AutoencoderKL variants per model family
├── encoders/ # T5, CLIP, Llama, Qwen2.5, Gemma, SigLIP, Reason1, audio conditioner
├── schedulers/ # FlowMatch / EulerDiscrete / DPM custom schedulers
├── upsamplers/ # Hunyuan15 super-resolution
├── audio/ # Audio-VAE/decoder modules (LTX-2 audio, Stable Audio)
├── camera/ # Camera-conditioning modules (Gen3C)
└── loader/ # component_loader.py, fsdp_load.py, weight_utils.py
loader/component_loader.py is the central entry point that the pipeline uses
to instantiate model components from a HF directory. New components plug in
through register_* calls or by extending the ComponentLoader mappings.
Adding a Model Component (DiT / VAE / Encoder)
- Read
fastvideo/layers/AGENTS.mdfirst — it defines which tensor-parallel linear / attention layer to use. Do not freelance. - Define the arch in
models/<role>/<model>.py. Mirror the official reference's constructor args; do not "improve" the layer choices. - Add the matching arch config in
configs/models/<role>/<model>.py. - Expose
param_names_mappingon the config — it is the source of truth for the converter underscripts/checkpoint_conversion/. - Use
init_logger(__name__), not stdlib logging.
State-Dict Discipline
- The native component's
state_dict()defines target keys + shapes. - Conversion scripts (
scripts/checkpoint_conversion/) bend to the model, not the other way around. - Fused QKV / packed MLP layouts must be documented in the config or the model module — converters need to split/fuse accordingly.
Anti-Patterns
- Importing
transformers/diffusersmodel classes at runtime inside the forward path — these belong in the loader, not the architecture file. - Adding training-only state (EMA buffers, optimizer state) to the inference state-dict surface.
- Calling
torch.distributeddirectly. Go throughfastvideo.distributed. - Treating this directory as lint-clean. It isn't (see pre-commit excludes).