base ¶
Classes¶
fastvideo.train.models.base.CausalModelBase ¶
CausalModelBase(*, trainable: bool = True, lora: LoraConfig | dict[str, Any] | None = None, attention_backend: AttentionBackendEnum | str | None = None)
Bases: ModelBase
Extension for causal / streaming model plugins.
Cache state is internal to the model instance and keyed by cache_tag (no role handle needed).
Source code in fastvideo/train/models/base.py
Methods:¶
fastvideo.train.models.base.CausalModelBase.clear_caches abstractmethod ¶
clear_caches(*, cache_tag: str = 'pos') -> None
fastvideo.train.models.base.CausalModelBase.predict_noise_streaming abstractmethod ¶
predict_noise_streaming(noisy_latents: Tensor, timestep: Tensor, batch: TrainingBatch, *, conditional: bool, cache_tag: str = 'pos', store_kv: bool = False, cur_start_frame: int = 0, cfg_uncond: dict[str, Any] | None = None, attn_kind: Literal['dense', 'vsa'] = 'dense') -> Tensor | None
Streaming predict-noise that may update internal caches.
Source code in fastvideo/train/models/base.py
fastvideo.train.models.base.CausalModelBase.predict_x0_streaming ¶
predict_x0_streaming(noisy_latents: Tensor, timestep: Tensor, batch: TrainingBatch, *, conditional: bool, cache_tag: str = 'pos', store_kv: bool = False, cur_start_frame: int = 0, cfg_uncond: dict[str, Any] | None = None, attn_kind: Literal['dense', 'vsa'] = 'dense') -> Tensor | None
Predict x0 streaming via predict_noise_streaming + conversion.
Source code in fastvideo/train/models/base.py
fastvideo.train.models.base.ModelBase ¶
ModelBase(*, trainable: bool = True, lora: LoraConfig | dict[str, Any] | None = None, attention_backend: AttentionBackendEnum | str | None = None)
Bases: ABC
Per-role model instance.
Every role (student, teacher, critic, …) gets its own ModelBase instance. Each instance owns its own transformer and noise_scheduler. Heavyweight resources (VAE, dataloader, RNG seeds) are loaded lazily via :meth:init_preprocessors, which the method calls only on the student.
Source code in fastvideo/train/models/base.py
Attributes¶
fastvideo.train.models.base.ModelBase.attention_backend_name property ¶
attention_backend_name: str | None
Explicit per-role backend name, or None for global/default.
fastvideo.train.models.base.ModelBase.device property ¶
The local CUDA device for this rank.
fastvideo.train.models.base.ModelBase.num_train_timesteps property ¶
num_train_timesteps: int
Return the scheduler's training timestep horizon.
Methods:¶
fastvideo.train.models.base.ModelBase.add_noise abstractmethod ¶
fastvideo.train.models.base.ModelBase.backward abstractmethod ¶
fastvideo.train.models.base.ModelBase.decode_latents ¶
Decode [B, T, C, H, W] latents to [B, C, T, H, W] media.
RL reward methods call this hook instead of reaching into model-specific VAE normalization details.
Source code in fastvideo/train/models/base.py
fastvideo.train.models.base.ModelBase.init_preprocessors ¶
Load VAE, build dataloader, seed RNGs.
Called only on the student by the method's __init__. Default is a no-op so teacher/critic instances skip this.
Source code in fastvideo/train/models/base.py
fastvideo.train.models.base.ModelBase.on_train_start ¶
fastvideo.train.models.base.ModelBase.predict_noise abstractmethod ¶
predict_noise(noisy_latents: Tensor, timestep: Tensor, batch: TrainingBatch, *, conditional: bool, cfg_uncond: dict[str, Any] | None = None, attn_kind: Literal['dense', 'vsa'] = 'dense') -> Tensor
Predict noise/flow for the given noisy latents.
Source code in fastvideo/train/models/base.py
fastvideo.train.models.base.ModelBase.predict_x0 ¶
predict_x0(noisy_latents: Tensor, timestep: Tensor, batch: TrainingBatch, *, conditional: bool, cfg_uncond: dict[str, Any] | None = None, attn_kind: Literal['dense', 'vsa'] = 'dense') -> Tensor
Predict x0 via predict_noise + conversion.
Source code in fastvideo/train/models/base.py
fastvideo.train.models.base.ModelBase.prepare_batch abstractmethod ¶
prepare_batch(raw_batch: dict[str, Any], *, generator: Generator, latents_source: Literal['data', 'zeros'] = 'data') -> TrainingBatch
Convert a dataloader batch into forward primitives.