Gradients

PauliPropagation.rewindgradient! — Method
rewindgradient!(circuit, psum::AbstractPauliSum, params, overlapfunc; kwargs...)
rewindgradient!(circuit, prop_cache::AbstractPauliPropagationCache, params, overlapfunc; kwargs...)

In-place version of rewindgradient, which leaves the propagated operator in psum or prop_cache.

source
PauliPropagation.rewindgradient — Method
rewindgradient(circuit, psum::AbstractPauliSum, params, overlapfunc; thread=true, kwargs...)

Compute overlapfunc(propagate(circuit, psum, params; kwargs...)) together with its gradient with respect to params, in one paired forward and backward sweep costing O(length(circuit)) gate applications. The only parametrized gates can be PauliRotations. All other gates must not be parametrized or frozen via freeze(gate, param) before inputting to rewindgradient. Noise channels are not supported, frozen or not, because the backward sweep cannot undo them. overlapfunc must be linear in the coefficients of the Pauli sum it is handed, e.g. any of overlapwithzero, overlapwithplus, overlapwithcomputational, overlapwithmaxmixed, or overlapwithpaulisum. Both sweeps run with the gate implementations of the type of psum, so a MultiPauliSum runs them zone by zone. kwargs are passed on to applymergetruncate! in the forward sweep and the operator side of the backward sweep. Returns (expec, grad).

This design is adapted from the publication ``Backpropagating Pauli Propagation'' by Lin et al. (arXiv:2607.15184).

source