simulate.jl
Public functions
QuantumACES.ACESData
— TypeACESData
ACES noise characterisation experiment simulation results.
Fields
d::Design
: Experimental design.budget_set::Vector{Int}
: Measurement budgets.shots_set::Vector{Int}
: Measurement shots corresponding to the measurement budgets inbudget_set
.repetitions::Int
: Number of times to repeat the ACES estimation procedure.seeds::Vector{UInt64}
: Seeds for each of the repetitions.eigenvalues::Vector{Float64}
: Circuit eigenvalues.covariance::SparseMatrixCSC{Float64, Int32}
: Circuit eigenvalue estimator covariance matrix.est_eigenvalues_coll::Matrix{Vector{Float64}}
: Estimated circuit eigenvalues for each of the measurement budgets and repetitions.fgls_gate_eigenvalues_coll::Matrix{Vector{Float64}}
: FGLS estimated gate eigenvalues for each of the measurement budgets and repetitions.gls_gate_eigenvalues_coll::Matrix{Vector{Float64}}
: GLS estimated gate eigenvalues for each of the measurement budgets and repetitions, which uses the true circuit eigenvalue estimator covariance matrix.wls_gate_eigenvalues_coll::Matrix{Vector{Float64}}
: WLS estimated gate eigenvalues for each of the measurement budgets and repetitions.ols_gate_eigenvalues_coll::Matrix{Vector{Float64}}
: OLS estimated gate eigenvalues for each of the measurement budgets and repetitions.fgls_gate_probabilities_coll::Matrix{Dict{Gate, Vector{Float64}}}
: FGLS estimated gate probability distributions for each of the measurement budgets and repetitions.gls_gate_probabilities_coll::Matrix{Dict{Gate, Vector{Float64}}}
: GLS estimated gate probability distributions for each of the measurement budgets and repetitions.wls_gate_probabilities_coll::Matrix{Dict{Gate, Vector{Float64}}}
: WLS estimated gate probability distributions for each of the measurement budgets and repetitions.ols_gate_probabilities_coll::Matrix{Dict{Gate, Vector{Float64}}}
: OLS estimated gate probability distributions for each of the measurement budgets and repetitions.fgls_gate_norm_coll::Matrix{Float64}
: Normalised RMS error between the FGLS estimated gate eigenvalues and the true gate eigenvalues for each of the measurement budgets and repetitions.gls_gate_norm_coll::Matrix{Float64}
: Normalised RMS error between the GLS estimated gate eigenvalues and the true gate eigenvalues for each of the measurement budgets and repetitions.wls_gate_norm_coll::Matrix{Float64}
: Normalised RMS error between the WLS estimated gate eigenvalues and the true gate eigenvalues for each of the measurement budgets and repetitions.ols_gate_norm_coll::Matrix{Float64}
: Normalised RMS error between the OLS estimated gate eigenvalues and the true gate eigenvalues for each of the measurement budgets and repetitions.calculation_times::Matrix{Float64}
: Time taken to simulate sampling and estimate the gate eigenvalues with FGLS, GLS, WLS, and OLS for each repetition.overall_time::Float64
: Overall time taken to simulate ACES across all repetitions.
QuantumACES.simulate_aces
— Methodsimulate_aces(d::Design, budget_set::Vector{Int}; kwargs...)
Simulates ACES noise characterisation experiments for the experimental design d
across each of the measurement budgets in budget_set
.
WARNING: Seeding has the same features as in Stim. The behaviour of the same random seed will differ across different versions of Stim. Also, when measurement shots are sampled in batches, which occurs when max_samples
is exceeded, the results will differ from when all shots are sampled at once.
Arguments
d::Design
: Experimental design.budget_set::Vector{Int}
: Measurement budgets for which to simulate ACES.
Keyword arguments
repetitions::Int = 1
: Number of simulation repetitions.seed::Union{UInt64, Nothing} = nothing
: the seed to use for the random number generator.N_warn::Int = 3 * 10^4
: Number of circuit eigenvalues above which to warn the user about certain keyword argument choices.max_samples::Int = 10^10
: Maximum number of Stim samples collected in a single simulation.force_gc::Bool = false
: Whether to force garbage collection before and after each Stim simulation; this was added to prevent occasional segfaults but massively slows down the simulation, and currently does not appear to be necessary.diagnostics::Bool = true
: Whether to print diagnostics.detailed_diagnostics::Bool = false
: Whether to print detailed diagnostics.save_data::Bool = false
: Whether to save the data.save_interval::Int = 50
: Repetition interval at which to save the data.clear_design::Bool = false
: Whether to clear the saved design data after saving the full simulation data.
Private functions
QuantumACES.batch_shots
— Methodbatch_shots(shots::Int, measurements::Int, max_samples::Int)
Returns the shots divided into batches for sampling from Stim.
QuantumACES.estimate_eigenvalues
— Methodestimate_eigenvalues(d::Design, shots_set::Vector{Int}; kwargs...)
Returns simulated estimated circuit eigenvalues for the experimental design d
across each of the measurement shots counts specified in shots_set
.
Keyword arguments
seed::Union{UInt64, Nothing} = nothing
: Seed controlling the random seeds for Stim.epsilon::Float64 = 0.1
: Set estimated circuit eigenvalues below this threshold to this value, which sometimes occurs for experiments with small shot weights when the measurement budget is small.detailed_diagnostics::Bool = false
: Whether to print diagnostic information about the simulation.max_samples::Int = 10^10
: Maximum number of samples to take in a single Stim simulation.force_gc::Bool = false
: Whether to force garbage collection before and after each Stim simulation.
QuantumACES.estimate_gate_probabilities
— Methodestimate_gate_probabilities(d::Design, est_gate_eigenvalues::Vector{Float64})
Returns the gate Pauli error probabilities estimated from the estimated gate eigenvalues est_gate_eigenvalues
corresponding to the design d
. The estimated probability distributions are projected into the probability simplex.
QuantumACES.fgls_estimate_gate_eigenvalues
— Methodfgls_estimate_gate_eigenvalues(d::Design, est_eigenvalues::Vector{Float64}; kwargs...)
Returns the gate eigenvalues estimated from the estimated circuit eigenvalues est_eigenvalues
corresponding to the design d
with feasible generalised least squares.
Keyword arguments
epsilon::Float64 = 1e-10
: Threshold for convergence of the feasible generalised least squares algorithm.max_iterations::Int = 10
: Maximum number of iterations for the feasible generalised least squares algorithm.recalc_eigenvalues::Bool = true
: Iftrue
, the circuit eigenvalues are recalculated from the estimated gate eigenvalues at each iteration, which ensures that the estimated covariance matrix is positive-definite.constrain::Bool = true
: Iftrue
, the gate eigenvalues are constrained to be at most 1.diagnostics::Bool = false
: Whether to print diagnostic information about the feasible generalised least squares algorithm.
QuantumACES.get_stim_circuit_string
— Methodget_stim_circuit_string(circuit::Vector{Layer}, gate_probabilities::Dict{Gate, Vector{Float64}}, add_prep::Bool, add_meas::Bool)
Returns a Stim string representation of the circuit circuit
alongside error probabilities specified by gate_probabilities
, as well as noisy preparations if add_prep
is true
, and noisy measurements if add_meas
is true
.
Stim orders one-qubit Paulis as: X, Y, Z. We order one-qubit Paulis as: X, Z, Y. The indexing to transform between these orderings is: 1, 3, 2.
Stim orders two-qubit Paulis as: IX, IY, IZ, XI, XX, XY, XZ, YI, YX, YY, YZ, ZI, ZX, ZY, ZZ. We order two-qubit Paulis as: XI, IX, XX, ZI, YI, ZX, YX, IZ, XZ, IY, XY, ZZ, YZ, ZY, YY. The indexing to transform from the Stim ordering to ours is: 4, 1, 5, 12, 8, 13, 9, 3, 7, 2, 6, 15, 11, 14, 10. The indexing to transform from our ordering to the Stim ordering is: 2, 10, 8, 1, 3, 11, 9, 5, 7, 15, 13, 4, 6, 14, 12.
QuantumACES.gls_estimate_gate_eigenvalues
— Methodgls_estimate_gate_eigenvalues(d::Design, est_eigenvalues::Vector{Float64}, est_covariance::SparseMatrixCSC{Float64, Int32}; constrain::Bool = true)
Returns the gate eigenvalues estimated from the estimated circuit eigenvalues est_eigenvalues
corresponding to the design d
with generalised least squares, with estimated circuit eigenvalue covariance matrix est_covariance
. If constrain
is true
, the gate eigenvalues are constrained to be at most 1.
QuantumACES.ols_estimate_gate_eigenvalues
— Methodols_estimate_gate_eigenvalues(d::Design, est_eigenvalues::Vector{Float64}; constrain::Bool = true)
Returns the gate eigenvalues estimated from the estimated circuit eigenvalues est_eigenvalues
corresponding to the design d
with ordinary least squares. If constrain
is true
, the gate eigenvalues are constrained to be at most 1.
QuantumACES.stim_sample
— Methodstim_sample(stim_circuit_string::String, shots::Int; stim_seed::Union{UInt64, Nothing} = nothing, force_gc::Bool = false)
Returns bit-packaged measurement outcomes from simulating the circuit stim_circuit_string
over shots
measurement shots using the Python package Stim
. While the seed stim_seed
can be fixed, Stim
guarantees inconsistency when using the same seed on different versions.
QuantumACES.wls_estimate_gate_eigenvalues
— Methodwls_estimate_gate_eigenvalues(d::Design, est_eigenvalues::Vector{Float64}; constrain::Bool = true)
Returns the gate eigenvalues estimated from the estimated circuit eigenvalues est_eigenvalues
corresponding to the design d
with weighted least squares. If constrain
is true
, the gate eigenvalues are constrained to be at most 1.