Skip to content

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
def test_resolve_unknown_dir_raises(tmp_path: Path) -> None:
    """A dir that is neither a checkpoint nor an output_dir-with-checkpoints."""
    bogus = tmp_path / "bogus"
    bogus.mkdir()
    with pytest.raises(ValueError, match="Could not resolve"):
        _resolve_resume_checkpoint(str(bogus), output_dir=str(tmp_path))

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
def 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."""
    data = _minimal_yaml()
    data["training"] = {"distributed": {"num_gpus": 4}}
    cfg = load_run_config(_write_yaml(tmp_path, data))
    assert cfg.training.distributed.hsdp_shard_dim == 4
    assert cfg.training.distributed.sp_size == 4
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.

Source code in fastvideo/tests/train/utils/test_config.py
def test_overrides_create_intermediate_keys(tmp_path: Path) -> None:
    """Overrides into a nested key absent from YAML should still apply."""
    data = _minimal_yaml()
    # No `training.checkpoint` block in the minimal YAML.
    path = _write_yaml(tmp_path, data)
    cfg = load_run_config(
        path,
        overrides=["--training.checkpoint.checkpoints_total_limit=5"],
    )
    assert cfg.training.checkpoint.checkpoints_total_limit == 5