I tried the tpye_as method, it does not change the tensor’s device.
a = torch.randint(0,5,(2,2),device='cuda:0')
b = torch.randn(2,2,device='cuda:1')
a = a.type_as(b)
a.device 
-> device(type='cuda', index=0)
b.device
-> device(type='cuda', index=1)