Kevin_Shen:

If we push the for-loop into the __getitem__ function, does that mean it’s 1 worker doing the loop?


Yes, but also in the default setup, where you are using a single index, a single worker will create the batch, so there shouldn’t be a difference I assume (each worker creates its own batch).



 Kevin_Shen:

I was wondering if it is possible to assign a row index of the preallocated tensor to each worker and have them copy the data into that index of the tensor in __getitem__ ?


Multiple workers do not create the same batch, but each worker will build its own batch.
There is a feature request letting multiple workers work on the same batch, but I don’t think it’s ready yet.