If you plot the floor function, you will see that the derivative is either zero or undefined. That’s a problem to optimize with gradient descent. 
Try replacing it with torch.floor(pred).detach() + pred - pred.detach().