train
¶
Modules¶
fastvideo.tests.train.callbacks
¶
Modules¶
fastvideo.tests.train.callbacks.test_callback
¶
CPU-only unit tests for :mod:fastvideo.train.callbacks.callback.
Covers the Callback base class no-op contract and the
CallbackDict instantiation / dispatch / state-dict logic.
The concrete callback subclasses (GradNormClipCallback,
EMACallback, ValidationCallback) have their own test files.
Classes¶
fastvideo.tests.train.callbacks.test_ema
¶
CPU-only unit tests for :mod:fastvideo.train.callbacks.ema.
Exercises the EMA lifecycle (lazy init, start_iter gating, decay
math, ema_context swap, state-dict round-trip) on a tiny CPU
nn.Linear. EMA_FSDP works without dist.init_process_group
because dist.is_initialized() returns False and _to_local_tensor
falls through to raw tensors for non-DTensor inputs.
Classes¶
fastvideo.tests.train.callbacks.test_grad_clip
¶
CPU-only unit tests for :mod:fastvideo.train.callbacks.grad_clip.
Exercises GradNormClipCallback.on_before_optimizer_step against
synthetic nn.Module targets with manually populated gradients.
Classes¶
fastvideo.tests.train.callbacks.test_validation
¶
CPU-only unit tests for :mod:fastvideo.train.callbacks.validation.
Covers the parts of ValidationCallback that don't need a real
pipeline or distributed init:
- constructor type coercions and defaults,
on_validation_begingating logic (every_steps + modulo),_find_ema_callbacklookup via_callback_dict,state_dict/load_state_dictrng round-trip.
The heavy _run_validation path needs a real diffusion pipeline plus
distributed init and is exercised by Phase ⅔ tests.
Classes¶
fastvideo.tests.train.methods
¶
Modules¶
fastvideo.tests.train.methods.test_wan_causal_dfsft
¶
Per-method GPU smoke test: WanCausalModel + DiffusionForcingSFTMethod.
Mirrors test_wan_finetune.py for the diffusion-forcing SFT
(DFSFT) algorithm on the causal Wan transformer. The harness is
intentionally identical so the two tests are easy to compare and so
future per-method tests can copy this template verbatim.
DFSFT samples inhomogeneous timesteps per chunk (chunk_size=3
in the fixture) and is the natural training counterpart of the
WanCausalModel plugin.
fastvideo.tests.train.methods.test_wan_finetune
¶
Per-method GPU smoke test: WanModel + FineTuneMethod.
Establishes the per-method test pattern for fastvideo/train:
- Instantiate the model + method via their public constructors
(no
Trainersetup, no FSDP wrapping). - Feed a synthetic
raw_batchdict throughmethod.single_train_step()+method.backward(). - Assert that the loss is finite and that the first transformer block received a finite, non-zero gradient.
The first block's gradient is the last one computed during backprop, so a healthy grad there implies the full forward + chain-rule path is intact. Keeping the assertion to a single block keeps the reference surface tiny — a later PR layers a device-keyed grad-norm regression on top of this same harness.
fastvideo.tests.train.models
¶
Modules¶
fastvideo.tests.train.models.test_load_hunyuan
¶
GPU loading + forward smoke test for HunyuanModel.
Loads the real HunyuanVideo checkpoint (~13B at bf16) via
HunyuanModel.__init__ and runs one transformer forward pass on
synthetic inputs. Hunyuan's transformer takes a slightly different
forward signature than Wan (no encoder_attention_mask, no
return_dict); this test mirrors the kwargs in
HunyuanModel._build_distill_input_kwargs.
fastvideo.tests.train.models.test_load_wan
¶
GPU loading + forward smoke test for WanModel.
Loads the real Wan2.1 1.3B checkpoint via WanModel.__init__ and
runs one transformer forward pass on synthetic inputs. Catches loader
or forward-signature regressions in
fastvideo.train.models.wan.WanModel and the underlying
WanTransformer3DModel.
fastvideo.tests.train.models.test_load_wan_causal
¶
GPU loading smoke test for WanCausalModel.
Verifies that WanCausalModel.__init__ resolves the
CausalWanTransformer3DModel class override and successfully loads
weights from the regular Wan2.1 1.3B checkpoint.
A real forward pass is intentionally omitted here: the causal
transformer requires per-frame timesteps, a block-causal attention
mask, and KV cache state that WanCausalModel.predict_noise_streaming
manages for production callers. PR 5 (per-method tests) exercises that
streaming forward path end-to-end.
fastvideo.tests.train.utils
¶
Modules¶
fastvideo.tests.train.utils.test_checkpoint
¶
CPU-only unit tests for :mod:fastvideo.train.utils.checkpoint.
Covers the pure-Python portions of the checkpoint manager: name
parsing, resume-path resolution, metadata round-trip, rolling-delete
cleanup, the _is_stateful predicate, and the maybe_save gating
logic. Code paths that touch DCP (dcp.save / dcp.load) and
CUDA RNG snapshots are intentionally not covered here — those need a
GPU runner and will be tested in later phases.
Classes¶
Functions¶
fastvideo.tests.train.utils.test_checkpoint.test_resolve_unknown_dir_raises
¶test_resolve_unknown_dir_raises(tmp_path: Path) -> None
A dir that is neither a checkpoint nor an output_dir-with-checkpoints.
Source code in fastvideo/tests/train/utils/test_checkpoint.py
fastvideo.tests.train.utils.test_config
¶
CPU-only unit tests for :func:load_run_config.
Classes¶
Functions¶
fastvideo.tests.train.utils.test_config.test_hsdp_shard_dim_defaults_to_num_gpus
¶test_hsdp_shard_dim_defaults_to_num_gpus(tmp_path: Path) -> None
When unset, hsdp_shard_dim and sp_size fall back to num_gpus.
Source code in fastvideo/tests/train/utils/test_config.py
fastvideo.tests.train.utils.test_config.test_overrides_create_intermediate_keys
¶test_overrides_create_intermediate_keys(tmp_path: Path) -> None
Overrides into a nested key absent from YAML should still apply.