def test_ddp_spawn_fp16_compress_comm_hook(tmp_path):
    """Test for DDP Spawn FP16 compress hook."""
    model = BoringModel()
    strategy = DDPStrategy(ddp_comm_hook=default.fp16_compress_hook, start_method="spawn")
    trainer = Trainer(
        max_epochs=1,
        accelerator="gpu",
        devices=2,
        strategy=strategy,
        default_root_dir=tmp_path,
        sync_batchnorm=True,
        fast_dev_run=True,
        enable_progress_bar=False,
        enable_model_summary=False,
    )
    trainer.fit(model)
    assert trainer.state.finished, f"Training failed with {trainer.state}"
Test for DDP Spawn FP16 compress hook.
tests/tests_pytorch/strategies/test_ddp_integration_comm_hook.py