Adjoint differentiation of simulated circuits
A classical reverse-pass method for computing circuit-parameter derivatives using access to simulated quantum states.
On this page
Definition, purpose and input assumptions
Adjoint differentiation exploits reversible unitary structure in a classical simulator. It propagates states and adjoint information to accumulate many derivatives without independently resimulating two shifted circuits for every parameter. The method assumes access to state arrays or equivalent simulator internals; it is not direct access available from quantum hardware measurements.
Mathematical mechanism
For U=U_m...U_1 and E=<psi_final|O|psi_final>, the derivative from gate j is 2Re<lambda_j|(partial_j U_j)|psi_(j-1)>, where |psi_(j-1)> is the state before that gate and |lambda_j>=U_(j+1) dagger...U_m dagger O|psi_final>. A reverse sweep reconstructs or updates these states. Memory and runtime depend on representation and whether operations are unitary.
Fully solved reference example
Let |psi>=R_Z(phi)R_Y(theta)|0> and O=Z. Since R_Z commutes with Z, E=cos(theta). Thus partial_theta E=-sin(theta) and partial_phi E=0. At theta=pi/3, these are-sqrt(3)/2 and 0 for every phi.
The zero phi derivative is not because R_Z has no physical effect: it changes X and Y expectations. It is zero because the chosen observable is insensitive to that relative phase. An adjoint implementation must reproduce this objective-specific derivative while retaining the phase in the simulated state.
Limitations and classical comparison
A statevector-based method still has exponential memory in qubit count. Nonunitary channels, measurement and conditional branches require adapted differentiation rules. Comparing its cost to hardware parameter shifts must acknowledge that the classical simulator possesses more internal information.
Scientific relationships
Adjoint differentiation is an alternative to parameter-shift gradients in statevector simulation. It is used in variational-circuit software and depends on the derivative semantics of each operation.
A two-qubit gradient with nonzero angle and phase derivatives
Prepare |ψ>=R_Z(φ) on q1 after CNOT q0→q1 after R_Y(θ) on q0, starting from |00>. Up to a global phase, the final state is cos(θ/2)|00>+e^{iφ}sin(θ/2)|11>. For O=XX+(3/10)Z0, the expectation is E=sin θ cos φ+(3/10)cos θ. Its derivatives are cos θ cos φ-(3/10)sin θ and -sin θ sin φ.
At θ=π/3, φ=π/4, the energy is √6/4+3/20. The two derivatives are √2/4-3√3/20 and -√6/4. Both parameters affect the objective, but their sensitivities are quite different. This example therefore checks more than a phase parameter that happens to commute with the measured observable.
Label the gates U1,U2,U3 in chronological order and the forward states ψj=Uj...U1|00>. Seed the reverse sweep with λ3=Oψ3. Propagate λ2=U3†λ3 and λ1=U2†λ2. The angle derivative is 2 Re<λ1|(-iY0/2)|ψ1>, and the phase derivative is 2 Re<λ3|(-iZ1/2)|ψ3>. These expressions use the state immediately after the differentiated gate because its derivative has been written as generator times that gate.
The costate is not a normalized physical state
In this example, XX anticommutes with Z0, so O²=(109/100)I. Consequently ||λ3||²=<ψ3|O²|ψ3>=109/100 for every normalized input. The adjoint costate has norm √109/10, not one. Normalizing it without retaining the scale would shrink every accumulated derivative and implement the wrong reverse calculation.
Backward propagation through unitary adjoints preserves that norm. The arrays are classical computational objects representing the sensitivity of the objective. They need not correspond to a state preparation, and storing or copying them does not invoke the physical no-cloning problem. Their usefulness comes precisely from information available inside a simulator that is not supplied by ordinary hardware measurement results.
For real parameters and a Hermitian parameter-independent O, the derivative combines the bra and ket contributions into twice a real part. A software implementation that differentiates only the ket and omits the conjugate term gives an incomplete result. If O itself depends on the parameter, the additional expectation <ψ|∂O|ψ> must also be included. For example, a fixed |0> with O(θ)=cos θ Z+sin θ X has derivative -sin θ even though its state derivative is zero.
What changes across a noisy channel
Apply amplitude damping of strength γ to q1 after the unitary circuit. The channel's dual maps XX to √(1-γ)XX and leaves Z0 unchanged. The resulting energy is Eγ=√(1-γ)sin θ cos φ+(3/10)cos θ. Its θ and φ derivatives follow by differentiating this expression, while its γ derivative is -sin θ cos φ/[2√(1-γ)] away from the endpoint.
This example can be differentiated by propagating the observable backward through the channel's dual map before using the unitary reverse sweep. That operation is not inversion of amplitude damping: information lost in the state channel has not been recovered. A general noisy simulation may require density matrices, trajectories, or a specialized differentiation method with different memory and statistical costs.
The apparent γ-derivative singularity as γ approaches one reflects the square-root parameterization of the remaining coherence. Reparameterizing γ=sin²β gives a smoother expression over an appropriate β interval. Differentiability assumptions should therefore concern the actual parameterized channel, rather than assuming every endpoint behaves like an interior unitary rotation.
Time, memory, and requested output
For a statevector simulator, a local gate application touches an array with 2^n amplitudes. A forward pass and a reverse pass can accumulate many gate derivatives with work proportional to the circuit length times that array cost, rather than independently simulating two circuits per parameter. This advantage still carries exponential statevector memory. Reconstructing earlier states with inverse gates can reduce stored checkpoints, while roundoff and nonunitary operations limit that strategy.
Applying O to seed the sweep also has a cost. A sparse sum of L Pauli strings can be handled through structured actions, whereas a dense arbitrary operator can require much more work. A weighted scalar combination of observables can share one seed; computing a full Jacobian of many separate outputs may require multiple sweeps or batching. The number of parameters alone does not specify the complete differentiation cost.
Repeated uses of one parameter contribute several gate-level terms that must be summed with any classical chain-rule factors. Exact inverse gates obey ∂U†=-U†(∂U)U†; a separately approximated inverse or a noisy operation needs its own model. These rules make the reverse calculation faithful to the actual program rather than to a simplified parameter list.
Sources
Verification scope
Recorded source check ·
Classical statevector differentiation, reversibility, and storage assumptions inspected.
Formal scientific or official reference-semantics anchor. No SDK execution, hardware run, universal performance claim, or independent external peer review asserted. Original finite examples and definitions are independent explanations.