Can you try maybe
alpha = alpha.to(device)

I think the ‘to’ function is not in-place…this is what I get when I run in my termnal…
>>> a = torch.tensor([1., 2., 3.])
>>> a.to('cuda:0')
tensor([1., 2., 3.], device='cuda:0')
>>> a
tensor([1., 2., 3.])
>>> a = a.to('cuda:0')
>>> a
tensor([1., 2., 3.], device='cuda:0')
>>> 

But it is different when I use a layer (Module)…
>>> linear = nn.Linear(2, 2)
>>> linear.weight.data
tensor([[ 0.3646,  0.5939],
        [-0.2984,  0.4559]])
>>> linear.to('cuda:0')
Linear(in_features=2, out_features=2, bias=True)
>>> linear.weight.data
tensor([[ 0.3646,  0.5939],
        [-0.2984,  0.4559]], device='cuda:0')
>>> 


So, yeah, a bit confusing, which is why I have always treated the ‘to’ function as NOT in-place and always used
model = model.to('cuda:0')