lora
¶
Training-side LoRA utilities for fastvideo.train model plugins.
Classes¶
fastvideo.train.utils.lora.LoraConfig
dataclass
¶
LoraConfig(enable: bool = False, rank: int | None = None, alpha: int | None = None, target_modules: list[str] | None = None)
Structured LoRA settings for one fastvideo.train model role.
Parsed from the nested models.<role>.lora YAML block::
lora:
enable: true # default false
rank: 16
alpha: 32 # defaults to rank when omitted
target_modules: [to_q, to_k, to_v, to_out]
enable is an explicit on/off switch so a config states its intent
plainly: the presence of rank alone never silently flips a run into
LoRA-only training. When enable is false a still-present rank is
ignored (with an INFO log), so a configured-but-off block is valid.
Functions¶
fastvideo.train.utils.lora.LoraConfig.coerce
classmethod
¶
coerce(obj: LoraConfig | dict[str, Any] | None) -> LoraConfig | None
Normalize a raw YAML mapping (or existing config) into a LoraConfig.
Returns None when no lora block was given, which callers treat
as "LoRA not configured" — identical in effect to enable: false.
Source code in fastvideo/train/utils/lora.py
Functions¶
fastvideo.train.utils.lora.enable_lora_training
¶
enable_lora_training(transformer: Module, *, lora_rank: int, lora_alpha: int | None = None, lora_target_modules: Sequence[str] | None = None) -> int
Replace supported linear layers with trainable LoRA wrappers.
Returns the number of layers converted to LoRA.