def test_distributed_sampler_without_global_seed(tmp_path):
    """Test that the samples are non-overlapping in DDP when shuffling is enabled and no global seed is set."""
    # This test must run without a global seed set (e.g. through `seed_everything`), to ensure that each process
    # starts with a different initial state.
    assert "PL_GLOBAL_SEED" not in os.environ
    train_dataloader = DataLoader(range(32), shuffle=True, batch_size=4)
    trainer = Trainer(
        default_root_dir=tmp_path,
        num_sanity_val_steps=False,
        logger=False,
        enable_progress_bar=False,
        accelerator="cpu",
        devices=2,
        strategy="ddp",
        max_epochs=1,
    )
    trainer.fit(TestModelUniqueDDPSampling(), train_dataloader)
Test that the samples are non-overlapping in DDP when shuffling is enabled and no global seed is set.
tests/tests_pytorch/trainer/test_dataloaders.py