callbacks
¶
Classes¶
fastvideo.train.callbacks.Callback
¶
Base callback with no-op hooks.
Subclasses override whichever hooks they need. The
training_config and method attributes are set by
CallbackDict after instantiation.
fastvideo.train.callbacks.CallbackDict
¶
Manages a collection of named callbacks.
Instantiates each callback from its _target_ config and
dispatches hook calls to all registered callbacks.
Source code in fastvideo/train/callbacks/callback.py
fastvideo.train.callbacks.EMACallback
¶
Bases: Callback
Manage EMA shadow weights for the student transformer.
All configuration lives in the YAML callbacks.ema section:
.. code-block:: yaml
callbacks:
ema:
decay: 0.9999
start_iter: 0
The callback creates an EMA_FSDP instance at train start,
updates it after each optimizer step, and exposes an
ema_context() context manager for temporarily swapping
EMA weights into the live model (used by validation).
Source code in fastvideo/train/callbacks/ema.py
Functions¶
fastvideo.train.callbacks.EMACallback.ema_context
¶
ema_context(transformer: Module) -> Generator[Module, None, None]
Temporarily swap EMA weights into transformer.
If EMA is not active, yields the transformer unchanged.
Source code in fastvideo/train/callbacks/ema.py
fastvideo.train.callbacks.GradNormClipCallback
¶
Bases: Callback
Clip gradient norms before the optimizer step.
max_grad_norm must be set explicitly in the callback
config (callbacks.grad_clip.max_grad_norm).
Source code in fastvideo/train/callbacks/grad_clip.py
fastvideo.train.callbacks.ValidationCallback
¶
ValidationCallback(*, pipeline_target: str, dataset_file: str, every_steps: int = 100, sampling_steps: list[int] | None = None, guidance_scale: float | None = None, num_frames: int | None = None, output_dir: str | None = None, sampling_timesteps: list[int] | None = None, **pipeline_kwargs: Any)
Bases: Callback
Generic validation callback driven entirely by YAML config.
Works with any pipeline that follows the
PipelineCls.from_pretrained(...) + pipeline.forward()
contract.
Source code in fastvideo/train/callbacks/validation.py
Modules¶
fastvideo.train.callbacks.callback
¶
Callback base class and CallbackDict manager.
Adapted from FastGen's callback pattern to FastVideo's types.
Classes¶
fastvideo.train.callbacks.callback.Callback
¶
Base callback with no-op hooks.
Subclasses override whichever hooks they need. The
training_config and method attributes are set by
CallbackDict after instantiation.
fastvideo.train.callbacks.callback.CallbackDict
¶
Manages a collection of named callbacks.
Instantiates each callback from its _target_ config and
dispatches hook calls to all registered callbacks.
Source code in fastvideo/train/callbacks/callback.py
Functions¶
fastvideo.train.callbacks.ema
¶
EMA (Exponential Moving Average) callback.
Owns the full EMA lifecycle: creation, per-step updates, weight
swapping for validation, and checkpoint state. All EMA config
lives under callbacks.ema in the YAML file.
Classes¶
fastvideo.train.callbacks.ema.EMACallback
¶
Bases: Callback
Manage EMA shadow weights for the student transformer.
All configuration lives in the YAML callbacks.ema section:
.. code-block:: yaml
callbacks:
ema:
decay: 0.9999
start_iter: 0
The callback creates an EMA_FSDP instance at train start,
updates it after each optimizer step, and exposes an
ema_context() context manager for temporarily swapping
EMA weights into the live model (used by validation).
Source code in fastvideo/train/callbacks/ema.py
Functions¶
fastvideo.train.callbacks.ema.EMACallback.ema_context
¶ema_context(transformer: Module) -> Generator[Module, None, None]
Temporarily swap EMA weights into transformer.
If EMA is not active, yields the transformer unchanged.
Source code in fastvideo/train/callbacks/ema.py
Functions¶
fastvideo.train.callbacks.grad_clip
¶
Gradient norm clipping callback.
Clips gradients on modules returned by
method.get_grad_clip_targets() before the optimizer step.
Optionally logs per-module grad norms to the tracker.
fastvideo.train.callbacks.validation
¶
Validation callback.
All configuration is read from the YAML callbacks.validation
section. The pipeline class is resolved from
pipeline_target.
Classes¶
fastvideo.train.callbacks.validation.ValidationCallback
¶
ValidationCallback(*, pipeline_target: str, dataset_file: str, every_steps: int = 100, sampling_steps: list[int] | None = None, guidance_scale: float | None = None, num_frames: int | None = None, output_dir: str | None = None, sampling_timesteps: list[int] | None = None, **pipeline_kwargs: Any)
Bases: Callback
Generic validation callback driven entirely by YAML config.
Works with any pipeline that follows the
PipelineCls.from_pretrained(...) + pipeline.forward()
contract.