Quantum Computing Asked by BẢO BẠCH GIA on July 10, 2021
Recently, I have tried PennyLane and TensorFlow Quantum. These platforms are said to provide differentiable programming of quantum computers but I can’t understand it clearly though.
I have searched about differentiable programming and found out that it allows for gradient-based optimization of parameters in the program. Does differentiable programming of quantum computers supplied us with a faster way to do gradient descent such as parameter shift rules, natural gradient, …
Except for PennyLane and TensorFlow Quantum, Can we do differentiable programming of quantum computers on other platforms like Qiskit, Cirq, …
Yes, it is possible to do this with Qiskit and Cirq. For Qiskit, you can read up this tutorial page here.
There was an answer by Josh Izaac from Pennylane here awhile back about parameter shift rule and finite difference to do gradient on quantum circuit here: https://quantumcomputing.stackexchange.com/a/15445/9858
For any quantum software platform, you can do this. The gradient frame-work might not be built-in like Pennylane or Qiskit but you can write your own program to evaluate the gradient. If you already know how to evaluate your cost function then tweaking it a bit to evaluate the gradient is not too hard. So if you have the cost function $$C(theta) = langlepsi|U^dagger(theta) HU(theta)|psirangle $$ and if $U(theta)$ is generated from a gate that can be written as the exponential of Pauli operator, for instance $U(theta) = e^{-itheta/2 X} = R_X(theta)$, then to evaluate the derivative you can just evaluate the cost function with $theta$ shift by $+pi/2$ and $-pi/2$, then take the difference. So in the case you $R_X(theta)$ you have to perform the two operations/circuits:
Forward shift: $R_X(theta + pi/2) |psi rangle $
Backward shift: $R_X(theta - pi/2) |psi rangle$
Evaluate the cost for these two circuits, then take their difference to get the gradient. Note that here $|psirangle$ is just some initial state, you can take it to be $|0rangle$ if you want.
Correct answer by KAJ226 on July 10, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP