I’m running into this error too, but only when using CUDA. Here’s a minimal script to reproduce:
import torch
device = torch.device('cuda')
generator = torch.manual_seed(123)
x = torch.zeros(10, device=device)
x.uniform_(-1.0, 1.0, generator=generator)

Output:
$ python bug.py 
Traceback (most recent call last):
  File "bug.py", line 5, in <module>
    x.uniform_(-1.0, 1.0, generator=generator)
RuntimeError: Expected a 'N2at13CUDAGeneratorE' but found 'PN2at9GeneratorE'

Same thing happens if I use torch.Generator. By the way, is torch.Generator documented anywhere?