Generation of measurement data

Set up

PastaQ.randombasesFunction
randombases(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.

source
PastaQ.measurementgatesFunction
measurementgates(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)]

source
PastaQ.randompreparationsFunction
randompreparations(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.

source
PastaQ.readouterror!Function
readouterror!(measurement::Union{Vector, Matrix}, p1given0, p0given1)

Add readout error to a single projective measurement.

Arguments:

  • measurement: bit string of projective measurement outcome
  • p1given0: readout error probability 0 -> 1
  • p0given1: readout error probability 1 -> 0
source

Data generation

PastaQ.getsamples!Function
getsamples!(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.

source
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(σ) = |⟨σ|ψ⟩|² : if M = ψ is MPS
  • P(σ) = ⟨σ|ρ|σ⟩ : if M = ρ is MPO
source
PastaQ.getsamplesFunction
getsamples(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(σ) = |⟨σ|Û|ψ⟩|² : if M = ψ is MPS
  • P(σ) = <σ|Û ρ Û†|σ⟩ : if M = ρ is MPO
source
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(σ) = |⟨σ|Û|ψ⟩|² : if M = ψ is MPS
  • P(σ) = ⟨σ|Û ρ Û†|σ⟩ : if M = ρ 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").

source
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 gates
  • noise: apply a noise model after each quantum gate in the circuit
  • process: 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 if process = 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.
source