Generation of measurement data
Set up
PastaQ.randombases
— Functionrandombases(N::Int, nshots::Int;
local_basis = ["X","Y","Z"],
ndistinctbases = nothing)
Generate nshots
measurement bases. By default, each local basis is randomly selected between ["X","Y","Z"]
, with "Z"
being the default basis where the quantum state is written. If ndistinctbases
is provided, the output consist of ndistinctbases
different measurement bases, each being repeated nshots÷ndistinctbases
times.
PastaQ.measurementgates
— Functionmeasurementgates(basis::Vector)
Given as input a measurement basis, returns the corresponding gate data structure. If the basis is "Z"
, no action is required. If not, a quantum gate corresponding to the given basis rotation is added to the list.
Example: basis = ["X","Z","Z","Y"]
-> gate_list = [("basisX", 1),("basisY", 4)]
PastaQ.randompreparations
— Functionrandompreparations(N::Int, nshots::Int;
local_input_state = ["X+","X-","Y+","Y-","Z+","Z-"],
ndistinctstates = nothing)
Generate nshots
input states to a quantum circuit. By default, each single-qubit state is randomly selected between the 6 eigenstates of the Pauli matrices, ["X+","X-","Y+","Y-","Z+","Z-"]
. If ndistinctstates
is provided, the output consist of numprep
different input states, each being repeated nshots÷ndistinctstates
times.
PastaQ.readouterror!
— Functionreadouterror!(measurement::Union{Vector, Matrix}, p1given0, p0given1)
Add readout error to a single projective measurement.
Arguments:
measurement
: bit string of projective measurement outcomep1given0
: readout error probability 0 -> 1p0given1
: readout error probability 1 -> 0
Data generation
PastaQ.getsamples!
— Functiongetsamples!(M::Union{MPS,MPO};
readout_errors = (p1given0 = nothing,
p0given1 = nothing))
Generate a single projective measurement in the MPS/MPO reference basis. If readout_errors
is non-trivial, readout errors with given probabilities are applied to the measurement outcome.
PastaQ.getsamples!(M::Union{MPS,MPO}, nshots::Int; kwargs...)
Perform nshots
projective measurements of a wavefunction |ψ⟩
or density operator ρ
in the MPS/MPO reference basis. Each measurement consists of a binary vector σ = (σ₁,σ₂,…)
, drawn from the probabilty distribution:
P(σ) = |⟨σ|ψ⟩|²
: ifM = ψ is MPS
P(σ) = ⟨σ|ρ|σ⟩
: ifM = ρ is MPO
PastaQ.getsamples
— Functiongetsamples(M::Union{MPS,MPO}, bases::Array)
Generate a dataset of measurements acccording to a set of input bases
. For a single measurement, Û
is the depth-1 local circuit rotating each qubit, the data-point σ = (σ₁,σ₂,…)
is drawn from the probability distribution:
P(σ) = |⟨σ|Û|ψ⟩|²
: ifM = ψ is MPS
P(σ) = <σ|Û ρ Û†|σ⟩
: ifM = ρ is MPO
getsamples(M::Union{MPS,MPO}, nshots::Int;
local_basis = ["X", "Y", "Z"],
ndistinctbases = nothing)
Perform nshots
projective measurements of a wavefunction |ψ⟩
or density operator ρ
. The measurement consists of a binary vector σ = (σ₁,σ₂,…)
, drawn from the probabilty distribution:
P(σ) = |⟨σ|Û|ψ⟩|²
: ifM = ψ is MPS
P(σ) = ⟨σ|Û ρ Û†|σ⟩
: ifM = ρ is MPO
For a single measurement, Û
is the depth-1 local circuit rotating each qubit, where the rotations are determined by randomly choosing from the bases specified by local_basis
keyword argument (i.e. if "X"
is chosen out of ["X", "Y", "Z"]
, the rotation is the eigenbasis of "X"
).
getsamples(N::Int64, gates::Vector{<:Tuple}, nshots::Int64;
noise = nothing,
process::Bool = false,
build_process::Bool = false,
local_basis::Array = ["X","Y","Z"],
local_input_state::Array = ["X+","X-","Y+","Y-","Z+","Z-"],
ndistinctbases = nothing,
ndistinctstates = nothing,
cutoff::Float64 = 1e-15,
maxdim::Int64 = 10000,
kwargs...)
Generate nshots
data-point for quantum state tomography or quantum process tomography for a quantum channel corresponding to a set of quantum gates
and a noise
model.
Arguments:
gates
: a set of quantum gatesnoise
: apply a noise model after each quantum gate in the circuitprocess
: if false, generate data for state tomography, where the state is defined by the gates applied to the state|0,0,...,⟩
. If true, generate data for process tomography.build_process
: if true, generate data by building the full unitary circuit or Choi matrix, and then sampling from that unitary circuit or Choi matrix (as opposed to running the circuit many times on different initial states). It is only used ifprocess = true
.local_input_state
: a set of input states (e.g.["X+","X-","Y+","Y-","Z+","Z-"]
) which are sampled randomly to generate input states.local_basis
: the local bases (e.g.["X","Y","Z"]
) which are sampled randomly to perform measurements in a random basis.