Note it isn’t the same. This implementation maintains the workers alive but also pre-fetches for the next epoch as the sampler is infinite. My understanding is that PyTorch’s persistent-workers feature won’t pre-fetch for the next epoch as the sampler would be empty.