As far as I know, if both the input data and the model parameters must always be the same type in order to be compatible.
It’s a bit of a gotcha, but type(data) would always return torch.Tensor  . You would need to use data.type() to really see what’s going on, i.e., to show whether it’s torch.cuda.FloatTensor or torch.FloatTensor etc.
Could you maybe try again checking your input data types before they go into the model?
EDIT:
I don’t know if x.requires_grad_().to(device) is sufficient. Maybe try
x.requires_grad_()
x = x.to(device)