QuantumFlow: Gradients of parameterized gates, and gradient descent optimizers
Calculate the gradients of a function of expectation for a parameterized quantum circuit, using the middle-out algorithm.
ket0 – An initial state.
circ – A circuit that acts on the initial state.
hermitian – A Hermitian Operation for which the expectation is evaluated
dfunc – Derivative of func. Defaults to identity.
The gradient with respect to the circuits parameters.
Calculate the gradients of state fidelity for a parameterized quantum circuit, using the middle-out algorithm.
ket0 – An initial state.
ket1 – A target state. We calculate the fidelity between this state and
circuit. (the resultant of the) –
circ – A circuit that acts on ket0.
The gradients of state fidelity with respect to the circuits parameters.
Calculate the gradients of state angle for a parameterized quantum circuit, using the middle-out algorithm.
ket0 – An initial state.
ket1 – A target state. We calculate the fidelity between this state and the resultant of the circuit.
circ – A circuit that acts on ket0.
The gradients of the inter-state angle with respect to the circuits parameters.
Calculate the gradients of state angle for a parameterized quantum circuit, using the parameter-shift rule.
Returns the gate shift-constant, and two circuits, circ0, circ1. Gradients are proportional to the difference in expectation between the two circuits.
r, circ0, circ1 = qf.parameter_shift_circuits(circ, n)
fid0 = qf.state_fidelity(circ0.run(ket0), ket1)
fid1 = qf.state_fidelity(circ1.run(ket0), ket1)
grad = r*(fid1-fid0)
circ – A quantum circuit with parameterized gates
index – The index of the target gate in the quantum circuit
r – The gate shift constant circ0: Circuit with parameter shift on target gate. circ1: Circuit with negative parameter shift on target gate.