def test_simple_profiler_distributed_files(tmp_path):
    """Ensure the proper files are saved in distributed."""
    profiler = SimpleProfiler(dirpath=tmp_path, filename="profiler")
    model = BoringModel()
    trainer = Trainer(
        default_root_dir=tmp_path,
        fast_dev_run=2,
        strategy="ddp_spawn",
        accelerator="cpu",
        devices=2,
        profiler=profiler,
        logger=False,
    )
    trainer.fit(model)
    trainer.validate(model)
    trainer.test(model)

    actual = set(os.listdir(profiler.dirpath))
    expected = {f"{stage}-profiler-{rank}.txt" for stage in ("fit", "validate", "test") for rank in (0, 1)}
    assert actual == expected

    for f in profiler.dirpath.iterdir():
        assert f.read_text("utf-8")
Ensure the proper files are saved in distributed.
tests/tests_pytorch/profilers/test_profiler.py