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.
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.
PauliPropagation.PropagationBase.coefftype — Method
coefftype(pstr::PauliString)Get the coefficient type of a PauliString.
PauliPropagation.PropagationBase.numcoefftype — Method
numcoefftype(pstr::PauliString)Get the type of the numerical coefficient of a PauliString. Will return the type of the output of numcoefftype(coefftype(pstr)).
PauliPropagation.nqubits — Method
nqubits(pstr::PauliString)Get the number of qubits that the PauliString is defined on.
PauliPropagation.paulitype — Method
paulitype(pstr::PauliString)Get the Pauli integer type of a PauliString.
PauliSum
PauliPropagation.PauliSum — Type
PauliSum(nqubits::Int, terms::Dict) <: AbstractPauliSumPauliSum 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.
PauliPropagation.PauliSum — Method
PauliSum(nqubits::Integer)Contructor for an empty PauliSum on nqubits qubits. Element type defaults for Float64.
PauliPropagation.PauliSum — Method
PauliSum(CoeffType, nq::Int)Contructor for an empty PauliSum on nqubits qubits. The type of the coefficients can be provided.
PauliPropagation.nqubits — Method
nqubits(psum::PauliSum)Get the number of qubits that the PauliSum is defined on.
VectorPauliSum
PauliPropagation.VectorPauliSum — Type
VectorPauliSum{TV,CV} <: AbstractPauliSumVectorPauliSum 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.
PauliPropagation.VectorPauliSum — Method
VectorPauliSum(nqubits::Int)Constructor for an empty VectorPauliSum on nqubits qubits. Element type defaults for Float64.
PauliPropagation.VectorPauliSum — Method
VectorPauliSum(::Type{CT}, nqubits::Int)Contructor for an empty VectorPauliSum on nqubits qubits. The type of the coefficients can be provided.
PauliPropagation.nqubits — Method
nqubits(vpsum::VectorPauliSum)Get the number of qubits that the VectorPauliSum is defined on.
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 zonesPauliPropagation.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.
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.
PauliPropagation.PropagationBase.nzones — Method
nzones(msum::AbstractTermSum)
nzones(zone_map::ZoneMap)Get the number of work zones that msum is split over, or that zone_map assigns to.
PauliPropagation.PropagationBase.zoneof — Method
zoneof(msum, term)
zoneof(zone_map::ZoneMap, term)Get the index of the zone that owns term.
PauliPropagation.PropagationBase.zones — Method
zones(msum::AbstractTermSum)Get the term sums that msum is split over, which is the storage that a multi sum carries.
PauliPropagation.PropagationBase.zonesizes — Method
zonesizes(msum::AbstractTermSum)Get the number of terms in each zone of msum.
Conversions
PauliPropagation.PauliSum — Method
PauliSum(pstr::PauliString)Constructor for a PauliSum on nqubits qubits from a PauliString.
PauliPropagation.PauliSum — Method
PauliSum(pstrs::Vector{PauliString})Constructor for a PauliSum on nqubits qubits from a PauliString.
PauliPropagation.PauliSum — Method
PauliSum(vpsum::VectorPauliSum)Convert a VectorPauliSum to a PauliSum. Does not change vpsum.
PauliPropagation.PauliSum — Method
PauliSum(nq::Integer, pstr::PauliString)Constructor for a PauliSum on nqubits qubits from a PauliString.
PauliPropagation.VectorPauliSum — Method
VectorPauliSum(nq::Integer, pstr::PauliString)Constructor for a VectorPauliSum on nqubits qubits from a PauliString.
PauliPropagation.VectorPauliSum — Method
VectorPauliSum(pstr::PauliString)Constructor for a VectorPauliSum from a PauliString.
PauliPropagation.VectorPauliSum — Method
VectorPauliSum(psum::PauliSum)Convert a PauliSum to a VectorPauliSum.
PauliPropagation.VectorPauliSum — Method
VectorPauliSum(pstrs::Vector{PauliString})Constructor for a VectorPauliSum from a vector of PauliStrings.
PauliPropagation._checknumberofqubits — Method
Checks whether the number of qubits nqubits is the same between in some collection.
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)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))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)AbstractPauliSum
PauliPropagation.AbstractPauliSum — Type
AbstractPauliSum <: AbstractTermSumAbstract type for objects represented sums of Paulis with coefficients.
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.
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).
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.
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.
PauliPropagation.PropagationBase.coefficients — Function
coefficients(psum::AbstractPauliSum)Returns an iterator over the coefficients of a PauliSum. Call topaulistrings to receive entries as PauliStrings.
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.
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.
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.
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.
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).
PauliPropagation.paulis — Method
paulis(psum::AbstractPauliSum)Returns an iterator over the integer pauli strings of an AbstractPauliSum. Call topaulistrings to receive entries as PauliStrings.
PauliPropagation.paulitype — Method
paulitype(psum::AbstractPauliSum)Get the Pauli integer type of a AbstractPauliSum object.
PauliPropagation.topaulistrings — Method
topaulistrings(psum::AbstractPauliSum)Returns the Pauli strings in a, AbstractPauliSum and their coefficients as a list of PauliString.
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.
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.
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.
PauliPropagation.PropagationBase.anylimbs — Method
anylimbs(f, x::NTupleInteger)Whether f(limb) is nonzero for any 64-bit limb of x, with f taking and returning a UInt64.