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.
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.
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.
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.
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.
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.
Resampling
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.
PauliPropagation.PropagationBase.resample — Method
resample(tsum::AbstractTermSum, target_size::Integer; resample_func=nothing, squared=false, thread=true, kwargs...)Resamples tsum down (close) to target_size terms. Renormalizes the survivors so that the sum stays an unbiased estimator of incoming sum. If squared=true, resampling is performed on the absolute square of the coefficients and is not an unbiased estimator of the incoming sum. thread=false disables multithreading in every function on the VectorPauliSum backend that can multithread.
PauliPropagation.PropagationBase.semideterministic_systematic_resample! — Method
semideterministic_systematic_resample!(prop_cache::AbstractPropagationCache, target_size::Integer; squared=false, thread=true)Terms whose weight exceeds the average per-slot weight total_weight / target_size are always kept; the remaining slots are filled by systematic comb resampling over what is left, folded into each term's own slot. squared=true is disallowed. thread=false disables multithreading in every function on the VectorPauliSum backend that can multithread.
PauliPropagation.PropagationBase.systematic_resample! — Method
systematic_resample!(prop_cache::AbstractPropagationCache, target_size::Integer; squared=false, calibrate=true, rtol=0.01, atol=0, thread=true)Low variance resampling technique that returns unique terms. The number of surviving terms is often close to, and generally at most, target_size. See calibrate/rtol/atol for tuning how closely the comb step is chosen to hit target_size unique survivors. thread=false disables multithreading in every function on the VectorPauliSum backend that can multithread.
PauliPropagation.PropagationBase.resample — Method
resample(psum::PauliSum, target_size::Integer; resample_func=nothing, squared=false, thread=true, kwargs...)Resampling of a PauliSum (see resample). psum is converted into a VectorPauliSum and converted back on return, leaving psum unchanged.
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).
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.
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.
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.
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.
VectorPauliSum Specialization
PauliPropagation.PropagationBase.mcapplytoall! — Method
mcapplytoall!(gate, psum::VectorPauliSum, [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.