Hi,
This won’t work as the computed gradients won’t be the ones corresponding to what you computed in numba.
If you can, you should reimplement your loss function with pytorch operations to have automatic differentiation of it.
Otherwise, you will need to write a new autograd.Function as discussed here 20 to specify what the backward should be.