Try to change your weight update code to:
with torch.no_grad():
    self.m -= self.m.grad * self.learning_rate
    self.b -= self.b.grad * self.learning_rate

We would like to mutate the values in-place without building a new computation graph, so you should use the torch.no_grad context manager.