The data is deterministic. Features and Labels are taken from a csv file. As for the use case, I’m working on seed averaging a bunch of models on different splits of the data and would like the training results to be reproducible. I first realized something might be amiss since nn.BCELoss() would trigger a CUDA error if I didn’t explicitly set the generator.
The snippet below is taken from a test performed on “mnist_train_small.csv” provided in Colab which gave differing results as well.
class DS(Dataset):
    def __init__(this, X=None, y=None, mode="train"):
        this.mode = mode
        this.X = X
        if mode == "train":
            this.y = y

    def __len__(this):
        return this.X.shape[0]

    def __getitem__(this, idx):
        if this.mode == "train":
            return torch.FloatTensor(this.X[idx]), torch.LongTensor(this.y[idx])
        else:
            return torch.FloatTensor(this.X[idx])

data = pd.read_csv("/content/sample_data/mnist_train_small.csv")

print(data.head(5)) # First 5 labels 5, 7, 9, 5, 2

X = data.iloc[:, 1:].copy().values
y = data.iloc[:, 0].copy().values

dl_setup = DS(X, y.reshape(-1,1))

tY = []
for i in range(5):
    tx, ty = dl_setup.__getitem__(i)
    tY.append(ty)

tY # 5, 7, 9, 5, 2

dl = DL(dl_setup, batch_size=16, shuffle=False)

xx, yy = next(iter(dl))

print(yy[:5]) #5, 7, 9, 5, 2

torch.manual_seed(0)
dl = DL(dl_setup, batch_size=16, shuffle=True)

xx, yy = next(iter(dl))

print(yy[:5]) #3, 7, 7, 8, 3

dl = DL(dl_setup, batch_size=16, shuffle=True, generator=torch.manual_seed(0))

xx, yy = next(iter(dl))

print(yy[:5]) #0, 3, 0, 7, 9