xnn.common.distributed.shard_indices#
- xnn.common.distributed.shard_indices(n)[source]#
The dataset indices this rank scores: every
WORLD_SIZE-th one.A strided shard,
range(RANK, n, WORLD_SIZE), so that ranks hold disjoint subsets whose union is exactly the dataset. Unliketorch.utils.data.DistributedSamplernothing is padded or repeated, so metrics gathered across ranks equal the single-process ones; the price is that shards may differ in length by one, which evaluation does not mind (training does, which is why the trainer keeps the sampler). Usable directly as aDataLoadersampler.