Data Types

PauliString

PauliPropagation.PauliString — Type
PauliString(nqubits::Int, pauli::Symbol, qind::Integer, coeff=1.0)
PauliString(nqubits::Int, paulis::Vector{Symbol}, qinds::Vector{Integer}, coeff=1.0)

Constructor for a PauliString on nqubits qubits from a Symbol (:I, :X, :Y, :Z) or Vector{Symbol}. Provide the index or indices for those symbols as qind or qinds. The coefficient of the Pauli string in the Pauli sum defaults to 1.0.

source
PauliPropagation.PauliString — Type
PauliString(nqubits::Int, term::TermType, coeff::CoeffType)

PauliString is a struct that represents a Pauli string on nqubits qubits. Commonly term is an unsigned Integer. See the other PauliString constructors for higher-level usage.

source

PauliSum

PauliPropagation.PauliSum — Type
PauliSum(nqubits::Int, terms::Dict) <: AbstractPauliSum

PauliSum is a struct that represents a sum of Pauli strings acting on nqubits qubits. It is a wrapper around a dictionary Dict(Pauli string => coefficient}, where the Pauli strings are typically unsigned Integers for efficiency reasons.

source
PauliPropagation.PauliSum — Method
PauliSum(CoeffType, nq::Int)

Contructor for an empty PauliSum on nqubits qubits. The type of the coefficients can be provided.

source

VectorPauliSum

PauliPropagation.VectorPauliSum — Type
VectorPauliSum{TV,CV} <: AbstractPauliSum

VectorPauliSum is a mutable struct that represents a sum of Pauli strings acting on nqubits qubits. It is a wrapper around two vectors: one for the Pauli strings (as unsigned Integers for efficiency reasons), and one for the coefficients. Using it defaults to multi-threaded operations where possible.

source
PauliPropagation.VectorPauliSum — Method
VectorPauliSum(::Type{CT}, nqubits::Int)

Contructor for an empty VectorPauliSum on nqubits qubits. The type of the coefficients can be provided.

source

MultiPauliSum

PauliPropagation.MultiPauliSum — Type
MultiPauliSum(psum::AbstractPauliSum, n_zones=defaultnzones())
MultiPauliSum(pstr::PauliString, n_zones=defaultnzones())
MultiPauliSum(pstrs::Vector{PauliString}, n_zones=defaultnzones())
MultiPauliSum(nq::Integer, n_zones=defaultnzones())
MultiPauliSum(CoeffType, nq::Integer, n_zones=defaultnzones())

MultiPauliSum is a struct that represents a Pauli sum split over n_zones work zones, where every zone is a Pauli sum of the type that it was constructed from and is owned by a single thread. n_zones defaults to defaultnzones(). Operations within a zone are single-threaded, so all parallelism comes from the zones.

zoneof() assigns every Pauli string to one zone, so that all copies of a Pauli string end up in the same zone and merging never has to look beyond a zone. The Pauli strings that a gate creates for other zones are collected in an outbox and picked up by the owning zone in a second pass, rather than written into a zone that another thread owns. Every zone is thus read and written by one thread only, and no operation on a zone needs to be thread-safe.

propagate!() keeps a worker task on every thread for the whole circuit and hands it the same zones on every gate (see withworkers()), so a zone stays on the thread, and on the memory, where it started. With thread=false the zones are worked one after the other.

Splitting a PauliSum gives zones of PauliSums and splitting a VectorPauliSum gives zones of VectorPauliSums, and the type of the zones determines how they are propagated.

n_zones must be a power of two, which makes the zone assignment linear in the Pauli string and lets PauliRotation and the other gates that branch by a fixed bitmask take a faster path. See ZoneMap.

Examples

MultiPauliSum(4)                                # empty, on 4 qubits, over as many zones as threads
MultiPauliSum(PauliSum(PauliString(4, :X, 1)))  # split a Pauli sum
MultiPauliSum(VectorPauliSum(4), 8)             # empty, with VectorPauliSum zones, over 8 zones
source
PauliPropagation.MultiPauliPropagationCache — Type
MultiPauliPropagationCache(msum::MultiPauliSum)

Propagation cache for a MultiPauliSum. It carries the propagation cache of every zone, so that each zone propagates with the machinery of the Pauli sum type it carries, and one outbox per zone. An outbox is itself a MultiPauliSum in which a zone collects every Pauli string it creates for the zone that owns it, and which the owning zones pick up once all zones have finished applying the gate. This cache carries no auxiliary sum of its own, because every zone brings one.

source
PauliPropagation.PropagationBase.defaultnzones — Method
defaultnzones()

Get the number of zones to split over when none is given, which is one zone per thread if the number of threads is a power of two, and twice the next power of two otherwise.

The zones of a round are handed to the threads in contiguous chunks, so a zone count that the number of threads divides keeps every thread busy for the whole round, and splitting it any further only adds per-zone overhead. A number of threads that divides no power of two leaves some threads with one zone more than the others, and more zones make that imbalance a smaller share of the round: six threads keep 67% of their capacity busy over eight zones, but 89% over sixteen.

source

Conversions

PauliPropagation.convertcoefftype — Method
convertcoefftype(::Type{CT1}, vpsum::VectorPauliSum)

Convert the coefficient type of vpsum to CT1, returning a new VectorPauliSum.

Examples

vpsum = VectorPauliSum(PauliString(2, :X, 1, 1+0im))
convertcoefftype(Float64, vpsum)
source
PauliPropagation.convertcoefftype — Method
convertcoefftype(::Type{CT1}, pstr::PauliString)

Convert the coefficient type of pstr to CT1, returning a new PauliString.

Examples

convertcoefftype(Float64, PauliString(2, :X, 1, 1+0im))
source
PauliPropagation.convertcoefftype — Method
convertcoefftype(::Type{CT1}, psum::PauliSum)

Convert the coefficient type of psum to CT1, returning a new PauliSum.

Examples

psum = PauliSum(PauliString(2, :X, 1, 1+0im))
convertcoefftype(Float64, psum)
source

AbstractPauliSum

Base.:+ — Method
+(pstr::PauliString, psum::AbstractPauliSum)
+(psum::AbstractPauliSum, pstr::PauliString)

Addition of a PauliString to a PauliSum. Returns a PauliSum.

source
Base.:+ — Method
+(pstr1::PauliString, pstr2::PauliString)

Addition of two PauliStrings. Returns a PauliSum.

source
Base.:- — Method
-(pstr::PauliString, psum::AbstractPauliSum)
-(psum::AbstractPauliSum, pstr::PauliString)

Subtract a PauliString from a PauliSum or vice versa. Returns a PauliSum.

source
Base.:- — Method
-(pstr1::PauliString, pstr2::PauliString)

Subtract two PauliStrings. Returns a PauliSum.

source
PauliPropagation.PropagationBase.add! — Function
add!(psum::AbstractPauliSum, pauli::Symbol, qind::Integer, coeff=1.0)
add!(psum::AbstractPauliSum, paulis::Vector{Symbol}, qinds::Vector{Integer}, coeff=1.0)

Add a Pauli string to a AbstractPauliSum psum. Changes psum in-place. Provide the Pauli string as a Symbol (:I, :X, :Y, :Z) or Vector{Symbol}. Provide the index or indices for those symbols as qind or qinds. The coefficient of the Pauli string in the Pauli sum defaults to 1.0.

source
PauliPropagation.PropagationBase.add! — Method
add!(psum::AbstractPauliSum, pstr, coeff)

Add a Pauli string pstr with coefficient coeff to a AbstractPauliSum psum. This changes psum in-place. pstr needs to have the same type as paulitype(psum), and coeff needs to have the same type as coefftype(psum).

source
PauliPropagation.PropagationBase.add! — Method
add!(psum1::AbstractPauliSum, psum2::AbstractPauliSum)

Add two AbstractPauliSums psum1 and psum2. Changes psum1 in-place. psum1 and psum2 need to be defined on the same number of qubits and have the same coefficient type.

source
PauliPropagation.PropagationBase.add! — Method
add!(psum::AbstractPauliSum, pstr::PauliString)

Add a PauliString pstr to a PauliSum psum. Changes psum in-place. psum and pstr need to be defined on the same number of qubits and have the same coefficient type.

source
PauliPropagation.PropagationBase.getcoeff — Method
getcoeff(psum::AbstractPauliSum, pstr::Vector{Symbol}, qinds::Vector{Int})

Get the coefficient of a Pauli string in an AbstractPauliSum by providing the Pauli string pstr as a vector of Symbols acting on qubits qinds. This is consistent with how Pauli strings can be added to a PauliSum via add!(). Defaults to 0 if the Pauli string is not in the AbstractPauliSum.

source
PauliPropagation.PropagationBase.getcoeff — Method
getcoeff(psum::AbstractPauliSum, pstr::Integer)

Get the coefficient of a PauliString in a PauliSum. Defaults to 0 if the Pauli string is not in the PauliSum. Requires that the integer Pauli string in pstr is the same type as the integer Pauli strings in psum.

source
PauliPropagation.PropagationBase.getcoeff — Method
getcoeff(psum::AbstractPauliSum, pauli::Symbol, qind::Integer)

Get the coefficient of a Pauli string in an AbstractPauliSum by providing the Pauli string as a Symbol acting on qubit qind. This is consistent with how Pauli strings can be added to a PauliSum via add!(). Defaults to 0 if the Pauli string is not in the AbstractPauliSum.

source
PauliPropagation.PropagationBase.getcoeff — Method
getcoeff(psum::AbstractPauliSum, pstr::Vector{Symbol})

Get the coefficient of a Pauli string in a AbstractPauliSum by providing the Pauli string pstr as a vector of Symbols acting on all qubits. This is consistent with how Pauli strings can be added to a PauliSum via add!(). Defaults to 0 if the Pauli string is not in the AbstractPauliSum.

source
PauliPropagation.PropagationBase.set! — Function
set!(psum::AbstractPauliSum, pstr, coeff)

In-place setting the coefficient of a Pauli string in an AbstractPauliSum. The type of the Pauli string needs to be the typeof(pstr)==paulitype(psum) and typeof(coeff)==coefftype(psum).

source
PauliPropagation.paulis — Method
paulis(psum::AbstractPauliSum)

Returns an iterator over the integer pauli strings of an AbstractPauliSum. Call topaulistrings to receive entries as PauliStrings.

source
Base.push! — Method
push!(term_sum::AbstractTermSum, term, coeff)

Append term with coefficient coeff without checking whether term_sum already contains term. An array-based term sum then holds the term twice until it is merged, while a dict-based one merges immediately, because its terms are the keys.

source
PauliPropagation.PropagationBase.emptylike — Method
emptylike(term_sum::AbstractTermSum)

Create an empty term sum of the same type as term_sum, including its term type. This differs from similar(), which may keep the length of term_sum and leave its entries undefined. The default implementations assume the constructor TS(nsites, storage...) and can be overloaded for types that carry more than that.

source

NTupleInteger

PauliPropagation.PropagationBase.NTupleInteger — Type
NTupleInteger{N}

An unsigned integer of N 64-bit limbs, little-endian: limbs[1] holds the lowest bits. Every operation is unrolled over the limbs at compile time. It is the term type of a Pauli sum on more than 64 qubits, see getinttype. Values convert to and from the machine integers and BigInt, compare with them, and hash like the values of those types they equal. They do not convert to or compare with floating-point numbers. A single Pauli read with getpauli(pstr, index) comes back as a UInt64.

source