Monte Carlo

Propagation

PauliPropagation.PropagationBase.applymergetruncateresample! — Method
applymergetruncateresample!(gate, prop_cache::AbstractPropagationCache, args...; max_size::Real, resampling_size::Integer=round(Int, max_size/2), resample_func=nothing, thread=true, kwargs...)

Like applymergetruncate!, but afterwards resamples prop_cache down to resampling_size terms (via resample!) whenever it exceeds max_size. This is the per-gate step function behind mcpropagate!. thread=false disables multithreading in every function on the VectorPauliSum backend that can multithread.

source
PauliPropagation.PropagationBase.mcpropagate — Function
mcpropagate(circuit, tsum::AbstractTermSum, thetas=nothing; max_size, resampling_size=round(Int, max_size/2), resample_func=nothing, thread=true, kwargs...)
mcpropagate(circuit, prop_cache::AbstractPropagationCache, thetas=nothing; max_size, resampling_size=round(Int, max_size/2), resample_func=nothing, thread=true, kwargs...)

Monte Carlo variant of propagate(). Once the number of terms exceeds max_size, the running term sum is resampling down (close) to resamplingsize. `resamplefuncselects the resampling strategy (seeresample!);kwargsare also passed toapplymergetruncate!(e.g.minabscoeff,max_weight) and to the resampling strategy (e.g.squared). For Pauli sums,heisenberg=trueadditionally selects the Heisenberg vs. Schrödinger picture (seepropagate).thread=falsedisables multithreading in every function on theVectorPauliSum` backend that can multithread.

source
PauliPropagation.PropagationBase.mcpropagate! — Function
mcpropagate!(circuit, psum::AbstractTermSum, thetas=nothing; thread=true, kwargs...)
mcpropagate!(circuit, prop_cache::AbstractPropagationCache, thetas=nothing; thread=true, kwargs...)

In-place version of mcpropagate. See mcpropagate for details.

source
PauliPropagation.PropagationBase.mcpropagate — Function
mcpropagate(circuit, pstr::PauliString, thetas=nothing; max_size, heisenberg=true, thread=true, kwargs...)

Monte Carlo propagation of a PauliString (see mcpropagate). pstr is converted into a VectorPauliSum, which is also the returned type.

source
PauliPropagation.PropagationBase.mcpropagate — Function
mcpropagate(circuit, psum::PauliSum, thetas=nothing; max_size, heisenberg=true, thread=true, kwargs...)

Monte Carlo propagation of a PauliSum (see mcpropagate). psum is converted into a VectorPauliSum and converted back on return, leaving psum unchanged.

source
PauliPropagation.PropagationBase.mcpropagate! — Function
mcpropagate!(circuit, prop_cache::AbstractPauliPropagationCache, thetas=nothing; heisenberg=true, thread=true, kwargs...)

Pauli-specific mcpropagate! method that additionally converts the circuit to the Heisenberg or Schrödinger picture (see propagate!) before delegating to the generic Monte Carlo propagation loop. thread=false disables multithreading in every function on the VectorPauliSum backend that can multithread.

source

Resampling

PauliPropagation.PropagationBase.multinomial_resample! — Method
multinomial_resample!(prop_cache::AbstractPropagationCache, target_size::Integer; squared=false, thread=true)

Draws target_size times with replacement, each term with probability proportional to its absolute coefficient (squared with squared=true), and keeps every drawn term with the weight of its draws. At most target_size terms survive, in their original order, so a sorted sum stays sorted. thread=false disables multithreading in every function on the VectorPauliSum backend that can multithread.

source
PauliPropagation.PropagationBase.resample! — Method
resample!(tsum::AbstractTermSum, target_size::Integer; thread=true, kwargs...)
resample!(prop_cache::AbstractPropagationCache, target_size::Integer; thread=true, kwargs...)

In-place version of resample. See resample for details.

source
PauliPropagation.PropagationBase.resample — Method
resample(tsum::AbstractTermSum, target_size::Integer; resample_func=nothing, squared=false, thread=true, kwargs...)

Resamples tsum down to about target_size terms, reweighting the survivors so that the result is an unbiased estimate of tsum. With squared=true, terms are sampled by their squared coefficients, and the result is no longer unbiased. resample_func defaults to semideterministic_systematic_resample!, or to multinomial_resample! when squared=true. thread=false disables multithreading in every function on the VectorPauliSum backend that can multithread.

source
PauliPropagation.PropagationBase.semideterministic_systematic_resample! — Method
semideterministic_systematic_resample!(prop_cache::AbstractPropagationCache, target_size::Integer; squared=false, thread=true)

Keeps every term whose absolute coefficient exceeds the sum of all absolute coefficients divided by target_size as it is, and fills the rest of target_size by systematic resampling of the other terms. squared=true is not supported. thread=false disables multithreading in every function on the VectorPauliSum backend that can multithread.

source
PauliPropagation.PropagationBase.systematic_resample! — Method
systematic_resample!(prop_cache::AbstractPropagationCache, target_size::Integer; squared=false, calibrate=true, rtol=0.01, atol=1, thread=true)

Low-variance resampling: an evenly spaced comb at a random offset is laid over the terms' weights, and every term it hits is kept once, with the weight of its teeth. The number of survivors is usually close to, and rarely more than, target_size. With calibrate=true, the comb spacing is narrowed until the expected number of survivors reaches (1 - rtol) * target_size - atol. thread=false disables multithreading in every function on the VectorPauliSum backend that can multithread.

source

Path Sampling

PauliPropagation.PropagationBase.mcsample — Function
mcsample(circuit, tsum::AbstractTermSum, params=nothing; squared=false, thread=true, kwargs...)
mcsample(circuit, prop_cache::AbstractPropagationCache, params=nothing; squared=false, thread=true, kwargs...)

Monte Carlo "path sampling" counterpart to propagate. Each term term in the term sum randomly samples a branch that a gate applies. For squared=false, that yields an unbiased sample of the propagated term sum, though the coefficients will likely grow exponentially. Average many independent calls (or pack many copies of the same term into one large tsum) to converge the result. Use squared=true to sample with probabilities proportional to squared coefficients instead of their absolute value (useful for e.g. 2-norm/OTOC-type estimators). For Pauli sums, heisenberg=true additionally selects the Heisenberg vs. Schrödinger picture (see propagate). thread=false disables multithreading in every function on the VectorPauliSum backend that can multithread, allowing efficient multi-threading on a higher level (e.g. Threads.@threads for _ in 1:10; propagate(...; thread=false); end).

source
PauliPropagation.PropagationBase.mcsample! — Function
mcsample!(circuit, tsum::AbstractTermSum, params=nothing; squared=false, thread=true, kwargs...)
mcsample!(circuit, prop_cache::AbstractPropagationCache, params=nothing; squared=false, thread=true, kwargs...)

In-place version of mcsample. See mcsample for details.

source
PauliPropagation.PropagationBase.mcsample — Function
mcsample(circuit, pstr::PauliString, params=nothing; squared=false, heisenberg=true, thread=true, kwargs...)

Monte Carlo path sampling of a PauliString (see mcsample). pstr is converted into a VectorPauliSum and converted back on return, since sampling leaves the number of terms unchanged.

source
PauliPropagation.PropagationBase.mcsample — Function
mcsample(circuit, psum::PauliSum, params=nothing; squared=false, heisenberg=true, thread=true, kwargs...)

Monte Carlo path sampling of a PauliSum (see mcsample). psum is converted into a VectorPauliSum and converted back on return, leaving psum unchanged.

source
PauliPropagation.PropagationBase.mcsample! — Function
mcsample!(circuit, tsum::AbstractPauliSum, params=nothing; heisenberg=true, thread=true, kwargs...)

Pauli-specific mcsample! method that additionally converts the circuit to the Heisenberg or Schrödinger picture (see propagate!) before delegating to the generic Monte Carlo sampling loop. thread=false disables multithreading in every function on the VectorPauliSum backend that can multithread.

source

Specializations

PauliPropagation.PropagationBase.mcapplytoall! — Method
mcapplytoall!(gate, psum::AbstractPauliSum, [param]; squared=false, thread=true, kwargs...)

1st-level function below mcsample! that stochastically applies one gate to every term in psum, in place. This is the Monte Carlo analogue of applytoall!: instead of branching a term into two, it randomly keeps one branch, reweighted to remain unbiased. Must be overloaded for each custom gate type. thread=false disables multithreading in every function on the VectorPauliSum backend that can multithread.

source