Autograd on external library functions

I am currently following this tutorial here, but replacing the phase_damp operations with the qutip simulation using mesolve for research purpose, then use the output density matrix from qutip to calculate the probabilities on each wire using projective POVMs (like |0\rangle \langle 0|) following the last parameterization. Unfortunately, it seems like doing this will prevent the autograd from calculating the gradient, thus no update for the parameters. A work around I have been tinkering with is trying to directly feed the mesolve output to pennylane’s quantum circuits again, which seems somewhat infeasible due to certain restrictions?

Thank you for any help!

Hi @trungkien!

Yes, unfortunately you’ve pinpointed exactly what is happening – since QuTiP is not written using an autodifferentiation library, it ‘breaks’ the autodifferentiation.

Currently, as far as I can tell, the only solution to preserve differentiability would be to port the mesolve algorithm to be written using Autograd (or alternatively, JAX/Torch/TF). Is this something that would be feasible?


1 Like