posthoc_ema ¶
FSDP2-compatible post-hoc EMA used by the official MMAudio recipe.
Classes¶
fastvideo.train.callbacks.posthoc_ema.PostHocEMACallback ¶
PostHocEMACallback(*, sigma_rels: list[float] | tuple[float, ...] = (0.05, 0.1), update_every: int = 1, checkpoint_every: int = 5000, checkpoint_folder: str | None = None, start_iter: int = 0, default_output_sigma: float = 0.05, step_size_correction: bool = True)
Bases: Callback
Maintain and checkpoint multiple Karras EMA profiles on local shards.
The upstream nitrous-ema implementation deep-copies a complete model on rank zero. That is appropriate for MMAudio's DDP trainer but not for a FastVideo FSDP2/HSDP transformer. This callback applies the same update and synthesis equations independently to every local FSDP shard. Together the rank-local snapshots represent the same full EMA model without gathering it on every optimizer step.
Source code in fastvideo/train/callbacks/posthoc_ema.py
Functions:¶
fastvideo.train.callbacks.posthoc_ema.sigma_rel_to_gamma ¶
Algorithm 2 from Karras et al., matching nitrous-ema.
Source code in fastvideo/train/callbacks/posthoc_ema.py
fastvideo.train.callbacks.posthoc_ema.solve_posthoc_weights ¶
solve_posthoc_weights(timesteps: Tensor, gammas: Tensor, target_timestep: int, target_gamma: float) -> Tensor
Algorithm 3 from Karras et al., matching nitrous-ema.