Hi,
Trying to run your code on cpu, I get:
Traceback (most recent call last):
  File "foo.py", line 71, in <module>
    y_true = kmodel(p_true,t.clone(),IF.clone())
  File "foo.py", line 36, in kmodel
    Cp[i,ton[i]:] = Cp[i,:Nt-ton[i]]
RuntimeError: unsupported operation: some elements of the input tensor and the written-to tensor refer to a single memory location. Please clone() the tensor before performing the operation.

That might be a problem