Class session

Class Documentation

class session

A session of the Qristal SDK.

Public Functions

session()

Construct a new session object.

Some parameters are uninitialized, e.g., number of qubits (qns_). These parameters can be set manually (using corresponding setter methods) or via provided presets, e.g., init().

session(const std::string &name)

Construct a new session object with a specific name.

Parameters

name – Session name

session(const bool debug)

Construct a new session object with a specific debug flag.

Parameters

debug – Debug flag. Printing debug messages to console if true.

session(const bool debug, const bool msb)

Construct a new session object with a specific debug flag, using a specific ordering for out_counts and associated QML-relevant outputs.

Parameters
  • debug – Debug flag. Printing debug messages to console if true.

  • msb – MSB flag. If true, use MSB to determine ordering of out_counts vector, out_probs vector and out_prob_gradients table; else use LSB.

void set_infile(const std::string &infile)

Set the input QASM source file.

Parameters

infile – Full path to the source file

void set_infiles(const Table2d<std::string> &infiles)

Set the list input QASM source files.

Parameters

infiles – A list of paths to source files

const Table2d<std::string> &get_infiles() const

Get the list input QASM source files.

Returns

List input QASM source files

void set_instring(const std::string &instring)

Set the input QASM source string.

Parameters

instring – Input source string

void set_instrings(const Table2d<std::string> &instrings)

Set the list of input QASM source strings.

Parameters

instrings – Input source strings

const Table2d<std::string> &get_instrings() const

Get the input QASM source strings of the session.

Returns

List of source strings

void set_irtarget_m(const std::shared_ptr<xacc::CompositeInstruction> &irtarget_m)

Set the irtarget (xacc::CompositeInstruction) object.

Note

This xacc::CompositeInstruction can be manually constructed (i.e., building the IR tree using XACC). If the irtarget is provided instead of QASM strings or files, the QASM compilation step will be skipped.

Parameters

irtarget_m – Input IR object

void set_irtarget_ms(const std::vector<std::vector<std::shared_ptr<xacc::CompositeInstruction>>> &irtarget_ms)

Set the list of irtarget (xacc::CompositeInstruction) objects.

Parameters

irtarget_ms – List of input IR objects

const std::vector<std::vector<std::shared_ptr<xacc::CompositeInstruction>>> &get_irtarget_ms() const

Get the list of input IR objects.

Returns

List of input IR objects

void set_include_qb(const std::string &include_qb)

Set the path to the OpenQASM include file.

Parameters

include_qb – Path to the OpenQASM include file

void set_include_qbs(const Table2d<std::string> &include_qbs)

Set the list of paths to the OpenQASM include files.

Parameters

include_qbs – Paths to the OpenQASM include files

const Table2d<std::string> &get_include_qbs() const

Get the list of paths to the OpenQASM include files.

Returns

Paths to the OpenQASM include files

void set_parameter_vector(const std::vector<double> &vals_vec)

Set the parameter values for execution.

Parameters

vals_vec – New parameter vector for runtime substitution

void set_parameter_vectors(Table2d<std::vector<double>> vals_vecs)

Set the list of parameter values for execution.

Parameters

vals_vecs – New parameter vectors for runtime substitution

const Table2d<std::vector<double>> &get_parameter_vectors() const

Get the parameter values for runtime circuit execution.

Returns

A vector-of-vectors of parameter values

void set_calc_jacobian(bool calculate_gradients_m)

Determine whether jacobians will be calculated for parametrized circuits.

Parameters

calculate_gradients_m – Whether to calculate jacobians for parametrized circuits

void set_calc_jacobians(Table2d<bool> calculate_gradients_ms)

Determine whether jacobians will be calculated for specific parametrized circuits.

Parameters

calculate_gradients_ms – Whether to calculate jacobians for specific parametrized circuits

const Table2d<bool> &get_calc_jacobians() const

Get the jacobians calculation flags.

Returns

A 1-d array of jacobians calculation flags

void set_calc_out_counts(bool calculate_out_counts_m)

Determine whether non-compact output counts vector will be calculated.

Parameters

calculate_out_counts_m – Whether to calculate non-compact output counts vector.

void set_calc_out_countss(Table2d<bool> calculate_out_counts_ms)

Determine whether non-compact output counts vector will be calculated for specific circuits.

Parameters

calculate_out_counts_ms – Whether to calculate non-compact output counts vector for specific circuits.

const Table2d<bool> &get_calc_out_counts() const

Get the non-compact counts vector calculation flags.

Returns

A 1-d array of non-compact counts vector calculation flags

void set_remote_backend_database_path(const std::string &remote_backend_database)

Set the path to the remote backend database yaml file.

Parameters

remote_backend_database_path – Path to the remote backend database yaml file.

const std::string &get_remote_backend_database_path() const

Get the path to the remote backend database yaml file.

Returns

Path to the remote backend database yaml file.

void set_acc(const std::string &acc)

Set the backend accelerator.

Parameters

acc – Name of the accelerator

void set_accs(const Table2d<std::string> &accs)

Set the list of backend accelerators.

Parameters

accs – List of backend accelerator names

const Table2d<std::string> &get_accs() const

Get the list of backend accelerators.

Returns

List of backend accelerator names

void set_aer_sim_type(const std::string &sim_type)

Set the AER backend simulator type.

Parameters

sim_type – Simulator type

void set_aer_sim_types(const Table2d<std::string> &sim_types)

Set the AER backend simulator types.

Parameters

sim_types – Simulator type

const Table2d<std::string> &get_aer_sim_types() const

Get the AER backend simulator type.

Returns

Simulator type

void set_random(const size_t &in_random)

Set the depth of the auto-generated random circuit.

Parameters

in_random – Circuit depth

void set_randoms(const Table2d<size_t> &in_random)

Set the depths of the auto-generated random circuits.

Parameters

in_random – Circuit depth values

const Table2d<size_t> &get_randoms() const

Set the depths of the auto-generated random circuits.

Returns

Circuit depth values

void set_xasm(const bool &in_xasm)

Set the XASM input flag.

True if the input is in XASM dialect.

Parameters

in_xasm – XASM input flag

void set_xasms(const Table2d<bool> &in_xasm)

Set the XASM input flags.

Parameters

in_xasm – XASM input flags

const Table2d<bool> &get_xasms() const

Get the XASM input flag.

Returns

XASM input flags

void set_quil1(const bool &in_quil1)

Set the Quil input flag.

True if the input is in Quil (v1) dialect.

Parameters

in_quil1 – Quil input flag

void set_quil1s(const Table2d<bool> &in_quil1)

Set the Quil input flags.

Parameters

in_quil1 – Quil input flags

const Table2d<bool> &get_quil1s() const

Get the Quil input flags.

Returns

Quil input flags

void set_noplacement(const bool &in_noplacement)

Set the noplacement flag.

True to disable circuit placement.

Parameters

in_noplacement – noplacement flag

void set_noplacements(const Table2d<bool> &in_noplacement)

Set the noplacement flags.

Parameters

in_noplacement – noplacement flags

const Table2d<bool> &get_noplacements() const

Get the noplacement flag.

Returns

noplacement flags

void set_placement(const std::string &in_placement)

Set the circuit placement method.

Parameters

in_placement – Name of the circuit placement module

void set_placements(const Table2d<std::string> &in_placements)

Set the circuit placement methods.

Parameters

in_placements – Names of the circuit placement modules

const Table2d<std::string> &get_placements() const

Get the circuit placement methods.

Returns

Names of the circuit placement modules

void set_nooptimise(const bool &in_nooptimise)

Set the nooptimise flag.

True to disable circuit optimization

Parameters

in_nooptimise – nooptimise flag

void set_nooptimises(const Table2d<bool> &in_nooptimise)

Set the nooptimise flags.

Parameters

in_nooptimise – nooptimise flags

const Table2d<bool> &get_nooptimises() const

Get the nooptimise flags.

Returns

nooptimise flags

void set_circuit_opt(const Passes &in_passes)

Set the circuit optimization passes.

Parameters

in_opts – Sequence of optimization passes to apply

void set_circuit_opts(const Table2d<Passes> &in_passes)

Set the circuit optimization passes.

Parameters

in_opts – 2-D table of sequences of optimization passes to apply

const Table2d<Passes> &get_circuit_opts() const

Get the circuit optimization passes.

Returns

2-D table of sequences of optimization passes to apply

void set_execute_circuit(const bool &in_execute_circuit)

Set the execute_circuit flag.

True to disable circuit simulation, e.g., dry-run to inspect transpilation and resource estimation only.

Parameters

in_execute_circuit – execute_circuit flag

void set_execute_circuits(const Table2d<bool> &in_execute_circuit)

Set the execute_circuit flags.

Parameters

in_execute_circuit – execute_circuit flags

const Table2d<bool> &get_execute_circuits() const

Get the execute_circuit flags.

Returns

execute_circuit flags

void set_noise(const bool &in_noise)

Set the noise simulation flag.

True to enable noisy simulation.

Parameters

in_noise – Noise flag

void set_noises(const Table2d<bool> &in_noise)

Set the noise simulation flags.

Parameters

in_noise – Noise flags

const Table2d<bool> &get_noises() const

Get the noise simulation flags.

Returns

Noise flags

const std::shared_ptr<std::vector<std::complex<double>>> &get_state_vec_raw() const

Get the full state vector (works with QPP backend only!)

Returns

Full complex state vector as std::vector<std::complex<double>>

void get_state_vec(const bool &in_get_state_vec)

Set the flag to retrieve the state vector.

Parameters

in_get_state_vec – Flag to retrieve state vector (works with QPP backend only!)

void set_output_oqm_enabled(const bool &in_output_oqm_enabled)

Set the output transpilation and resource estimation flag.

True to enable output transpilation and resource estimation

Parameters

in_output_oqm_enabled – Config. value

void set_output_oqm_enableds(const Table2d<bool> &in_output_oqm_enabled)

Set the output oqm enableds object.

Parameters

in_output_oqm_enabled – Config. values

const Table2d<bool> &get_output_oqm_enableds() const

Get the output oqm enableds object.

Returns

Config. values

void set_notiming(const bool &in_notiming)

Set the notiming configuration flag.

Parameters

in_notiming – Config. value

void set_notimings(const Table2d<bool> &in_notiming)

Set the notiming configuration flags.

Parameters

in_notiming – Config. values

const Table2d<bool> &get_notimings() const

Get the notiming configuration flags.

Returns

Config. values

void set_qn(const size_t &in_qn)

Set the number of qubits.

Parameters

in_qn – Number of qubits

void set_qns(const Table2d<size_t> &in_qn)

Set the numbers of qubits.

Parameters

in_qn – Numbers of qubits

const Table2d<size_t> &get_qns() const

Get the numbers of qubits.

Returns

Number of qubits

void set_sn(const size_t &in_sn)

Set the number of measurement shots.

Parameters

in_sn – Number of shots

void set_sns(const Table2d<size_t> &in_sn)

Set the number of measurement shots.

Parameters

in_sn – Number of shots

const Table2d<size_t> &get_sns() const

Get the number of measurement shots.

Returns

Number of shots

void set_initial_bond_dimension(const size_t &in_initial_bond_dimension)

Set the initial bond dimension (tensor network simulators)

Note

This is only needed if using tensor network backend accelerators.

Parameters

in_initial_bond_dimension – Initial tensor network bond dimension value

void set_initial_bond_dimensions(const Table2d<size_t> &in_initial_bond_dimension)

Set the initial bond dimension (tensor network simulators)

Parameters

in_initial_bond_dimension – Initial tensor network bond dimension value

const Table2d<size_t> &get_initial_bond_dimensions() const

Get the initial bond dimension (tensor network simulators)

Returns

Initial tensor network bond dimension value

void set_initial_kraus_dimension(const size_t &in_initial_kraus_dimension)

Set the initial kraus dimension (emulator purification simulator)

Note

This is only needed if using the emulator purification backend accelerator.

Parameters

in_initial_kraus_dimension – Initial emulator purification kraus dimension value

void set_initial_kraus_dimensions(const Table2d<size_t> &in_initial_kraus_dimension)

Set the initial kraus dimension (emulator purification simulator)

Parameters

in_initial_kraus_dimension – Initial emulator purification kraus dimension value

const Table2d<size_t> &get_initial_kraus_dimensions() const

Get the initial kraus dimension (emulator purification simulator)

Returns

Initial emulator purification kraus dimension value

void set_max_bond_dimension(const size_t &in_max_bond_dimension)

Set the maximum bond dimension (tensor network simulators)

Note

This is only needed if using the tensor network backend accelerators.

Parameters

in_max_bond_dimension – Max tensor network bond dimension value

void set_max_bond_dimensions(const Table2d<size_t> &in_max_bond_dimension)

Set the maximum bond dimension (tensor network simulators)

Parameters

in_max_bond_dimension – Max tensor network bond dimension value

const Table2d<size_t> &get_max_bond_dimensions() const

Get the maximum bond dimension (tensor network simulators)

Returns

Max tensor network bond dimension value

void set_max_kraus_dimension(const size_t &in_max_kraus_dimension)

Set the maximum kraus dimension (emulator purification simulator)

Note

This is only needed if using the emulator purification backend accelerator.

Parameters

in_max_kraus_dimension – Max emulator purification kraus dimension value

void set_max_kraus_dimensions(const Table2d<size_t> &in_max_kraus_dimension)

Set the maximum kraus dimension (emulator purification simulator)

Parameters

in_max_kraus_dimension – Max emulator purification kraus dimension value

const Table2d<size_t> &get_max_kraus_dimensions() const

Get the maximum kraus dimension (emulator purification simulator)

Returns

Max emulator purification kraus dimension value

void set_svd_cutoff(const std::map<int, double> &in_svd_cutoff)

Set the SVD cutoff limit (tensor network simulators)

Note

This is only needed if using the tensor network backend accelerators.

Parameters

in_svd_cutoff – SVD cutoff value

void set_svd_cutoffs(const Table2d<std::map<int, double>> &in_svd_cutoff)

Set the SVD cutoff limit (tensor network simulators)

Parameters

in_svd_cutoff – SVD cutoff value

const Table2d<std::map<int, double>> &get_svd_cutoffs() const

Get the SVD cutoff limit (tensor network simulators)

Returns

SVD cutoff value

void set_rel_svd_cutoff(const std::map<int, double> &in_rel_svd_cutoff)

Set the relative SVD cutoff limit (tensor network simulators)

Note

This is only needed if using the tensor network backend accelerators.

Parameters

in_rel_svd_cutoff – SVD cutoff value

void set_rel_svd_cutoffs(const Table2d<std::map<int, double>> &in_rel_svd_cutoff)

Set the relative SVD cutoff limit (tensor network simulators)

Parameters

in_rel_svd_cutoff – SVD cutoff value

const Table2d<std::map<int, double>> &get_rel_svd_cutoffs() const

Get the relative SVD cutoff limit (tensor network simulators)

Returns

Relative SVD cutoff value

void set_measure_sample_method(const std::string &in_measure_sample_method)

Set the measurement sampling method. Options: “cutensornet” uses the single-shot cutensorNet contraction method of the entire tensor network state. Program terminates with error meassage if cutensorNet fails. “cutensornet_multishot” uses the multi-shot cutensorNet contraction method. “sequential” uses the cutensor sequential contraction method. “auto” (default) uses the cutensorNet contraction method and automatically swithes to the cutensor sequential contraction method if the cutensorNet method fails.

Note

This is only needed if using the emulator tensor network accelerator

Parameters

in_measure_sample_method – Measure sampling option value

void set_measure_sample_methods(const Table2d<std::string> &in_measure_sample_method)

Set the measurement sampling methods.

Parameters

in_measure_sample_method – Measure sampling option values

const Table2d<std::string> &get_measure_sample_methods() const

Get the measurement sampling method.

Returns

Measure sampling option values

void set_noise_model(NoiseModel &model)

Set the noise model.

Parameters

model – The noise model to use

void set_noise_models(const std::vector<std::vector<NoiseModel*>> &noise_models)

Set the noise models.

Parameters

models – The noise models to use

const std::vector<std::vector<NoiseModel*>> &get_noise_models() const

Get the noise models.

Returns

The noise models to use

void set_expected_amplitudes(const std::map<std::vector<bool>, std::complex<double>> &amp)

Set the expected amplitudes for Jensen–Shannon divergence calculation.

Parameters

amp – Amplitude values

void set_expected_amplitudess(const std::vector<std::vector<std::map<std::vector<bool>, std::complex<double>>>> &amp)

Set the expected amplitudes for Jensen–Shannon divergence calculation.

Parameters

amp – Amplitude values

const std::vector<std::vector<std::map<std::vector<bool>, std::complex<double>>>> &get_expected_amplitudes() const

Get the expected amplitudes for Jensen–Shannon divergence calculation.

Returns

Amplitude values

void set_debug(const bool &debug)

Set the debug flag (verbose logging)

Parameters

debug – Config. value

const bool &get_debug() const

Get the debug flag.

Returns

Config. value

const Table2d<std::map<std::vector<bool>, int>> &results() const

Get the output measurement counts as a map.

Returns

Measurement counts map

const Table2d<std::map<std::vector<bool>, int>> &results_native() const

Get the native output measurement counts as a map.

Beware: The native results are only stored separately, if a confusion or correction matrix was supplied to session, enabling automatic SPAM correction!

Returns

Native measurement counts map

const Table2d<std::vector<int>> &get_out_counts() const

Get the output measurement counts as a vector.

Returns

Measurement counts vector

const Table2d<std::vector<double>> &get_out_probs() const

Get the output probabilities.

Returns

Measurement probabilities vector

const Table2d<Table2d<double>> &get_out_prob_jacobians() const

Get the output probability gradients.

Returns

Table of probability jacobians w.r.t. runtime parameters

const Table2d<std::map<int, double>> &get_out_divergences() const

Get the output Jensen–Shannon divergence results.

Returns

Divergence results

const Table2d<std::string> &get_out_transpiled_circuits() const

Get the output transpiled circuits.

Returns

Output transpiled circuits

const Table2d<std::string> &get_out_qobjs() const

Get the output QObj Json strings.

Returns

QObj Json strings

const Table2d<std::string> &get_out_qbjsons() const

Get the output QB Json strings (hardware execution)

Returns

QB Json strings

const Table2d<std::map<int, int>> &get_out_single_qubit_gate_qtys() const

Get the output single-qubit gate counts.

Returns

Single-qubit gate counts

const Table2d<std::map<int, int>> &get_out_double_qubit_gate_qtys() const

Get the output two-qubit gate counts.

Returns

Two-qubit gate counts

const Table2d<std::map<int, double>> &get_out_total_init_maxgate_readout_times() const

Get the output total circuit execution time (hardware runtime estimation)

Returns

Estimated hardware runtime.

const Table2d<std::map<int, double>> &get_out_z_op_expects() const

Get the output expected value in the Z basis.

Returns

expected value in the Z basis

void set_SPAM_correction_matrix(const Eigen::MatrixXd &mat)

Set automatic SPAM correction by providing a suitable SPAM correction matrix.

Returns

&#8212;

const Eigen::MatrixXd &get_SPAM_correction_matrix() const

Get the stored SPAM correction matrix.

Returns

A const reference to Eigen::MatrixXd

void set_SPAM_confusion_matrix(const Eigen::MatrixXd &mat)

Set automatic SPAM correction by providing a suitable SPAM confusion matrix.

Returns

&#8212;

void set_noise_mitigation(const std::string &noise_mitigate)

Set the noise mitigation method.

Parameters

noise_mitigate – Noise mitigation method

void set_noise_mitigations(const Table2d<std::string> &noise_mitigates)

Set the noise mitigation methods.

Parameters

noise_mitigates – Noise mitigation methods

const Table2d<std::string> &get_noise_mitigations() const

Get the noise mitigation methods.

Returns

Noise mitigation methods

void set_seed(const size_t &in_seed)

Set the random seed value.

Parameters

in_seed – Seed value

void set_seeds(const Table2d<size_t> &in_seeds)

Set random seed values.

Parameters

in_seeds – Seed values

const Table2d<size_t> &get_seeds() const

Get random seed values.

Returns

Seed values

const std::string get_summary() const

Get the summary of all session configurations.

Returns

Session configuration summary

void setName(const Table2d<std::string> &name_)

Set the names of tasks.

Parameters

name_ – Task names

void setName(const std::string &name_)

Set the name of task.

Parameters

name_ – Task name

const Table2d<std::string> &getName() const

Get names of tasks.

Returns

Task names

void get_jensen_shannon(const size_t &ii, const size_t &jj)

Compute the Jensen-Shannon divergence result for the (ii, jj) result.

Parameters
  • ii – Row index

  • jj – Column index

void get_jensen_shannon()

Compute all the Jensen-Shannon divergence results.

void run(const size_t ii, const size_t jj)

Run a quantum task at the (ii, jj) index in the experiment table.

void validate_run()

Validate the run i.e. ensure all configurations are set in a valid manner.

void run()

Execute all quantum tasks.

void run_with_SPAM(size_t n_shots = 0)

Execute a standard SPAM benchmark, and use the measured confusion matrix to automatically correct SPAM errors in a consecutive run()

Arguments:

Parameters

n_shots – : The number of shots to be used for the SPAM benchmark. Defaults to 0, taking the same number of shots as set in sns_.

Returns

&#8212;

void set_parallel_run_config(const std::string &in_config)

Set the multi-qpu run configurations: e.g., the list of QPUs paricipate in this run

std::shared_ptr<async_job_handle> run_async(const std::size_t ii, const std::size_t jj, std::shared_ptr<xacc::Accelerator> acc)

Threadsafe execution of (ii, jj) task using the provided accelerator. Returns a job handle if the job is posted to a remote accelerator (e.g. AWS Braket). Otherwise, returns null if this function completes the run locally.

Executor &get_executor()

Get the QPU pool executor.

void init()

Shortcut for setting defaults 12 qubits, 1024 shots, noiseless

void aws_setup(uint wn)

AWS defaults.

Parameters

wn – Number of asynchronous workers

inline size_t bitstring_index(const std::vector<bool> &bitvec)

Returns the (base-10) integer vector index for the probabilities/ counts vector, corresponding to a bitstring for the quantum experiment at (ii, jj).

Parameters

bitvec – The bit-vector to be converted to the vector index

std::vector<bool> draw_shot(const size_t i, const size_t j)

Randomly draw (and remove) a single shot from the results map.

Private Types

enum class circuit_input_types

Valid input types:

Values:

enumerator INVALID
enumerator VALID_INSTRING_QPU
enumerator VALID_RANDOM
enumerator VALID_INFILE
enumerator VALID_IR
enumerator VALID_CUDAQ

Private Functions

int validate_sns_nonempty()
int validate_qns_nonempty()
int validate_instrings()
void validate_acc(const std::string &acc)
void validate_max_qubits_acc(size_t &num_qubits, std::string acc, std::string &aer_sim_type)
void validate_gate_noise(NoiseModel *&noise_model)
void validate_noise_mitigation(const std::string &noise_mitigate)
void validate_aer_sim_type(const std::string &sim_type)
void validate_measure_sample_options(const std::string &measure_sample_options)
int is_ii_consistent()
int is_jj_consistent()
circuit_input_types validate_infiles_instrings_randoms_irtarget_ms_nonempty(const size_t ii, const size_t jj)
std::string random_circuit(const int n_q, const int depth)
double get_jensen_shannon_divergence(const std::map<std::vector<bool>, int> &counts, const std::map<std::vector<bool>, std::complex<double>> &amplitudes)
std::string aer_circuit_transpiler(std::string &circuit)
void ensure_results_table_size(size_t ii, size_t jj)

Ensure that all result tables are resized/expanded to accommodate (ii, jj) experiment index.

run_i_j_config get_run_config(size_t ii, size_t jj)

Retrieve and validate run configurations for index pair (ii, jj) using the table index convention.

void process_run_result(const std::size_t ii, const std::size_t jj, const run_i_j_config &run_config, std::shared_ptr<xacc::CompositeInstruction> kernel_ir, std::shared_ptr<xacc::Accelerator> sim_qpu, const xacc::HeterogeneousMap &sim_qpu_configs, std::shared_ptr<xacc::AcceleratorBuffer> buffer_b, double runtime_ms, std::shared_ptr<qristal::backend> qb_transpiler)

Helper to populate result tables (e.g. counts, expectation values, resource estimations) post-execution.

std::shared_ptr<xacc::CompositeInstruction> compile_input(const std::string &in_source_string, int in_num_qubits, source_string_type in_source_type)

Util method to compile input source string into IR This method is thread-safe, thus can be used to compile multiple source strings in parallel.

std::string get_target_circuit_qasm_string(size_t ii, size_t jj, const run_i_j_config &run_config)

Retrieve the target circuit string for (i, j) task: This will involve loading file (if file mode is selected), generate random circuit string (if random mode is selected), etc.

std::shared_ptr<xacc::Accelerator> get_sim_qpu(bool execute_on_hardware, run_i_j_config &run_config)

Get the simulator based on run_i_j_config

void run_gradients(const size_t ii, const size_t jj)

Calculate the gradients for the parametrized quantum task at the (ii, jj) index in the experiment table.

void execute_on_simulator(std::shared_ptr<xacc::Accelerator> acc, std::shared_ptr<xacc::AcceleratorBuffer> buffer_b, std::vector<std::shared_ptr<xacc::CompositeInstruction>> &circuits, const run_i_j_config &run_config)

Execute the circuit on a simulator.

std::shared_ptr<async_job_handle> run_internal(const std::size_t ii, const std::size_t jj, std::shared_ptr<xacc::Accelerator> acc, std::mutex *optional_mutex = nullptr)

Internal (ii, jj) task execution. acc: if given (not null), this will be used for simulation. Otherwise, constructed from the run configuration for (ii, jj). optional_mutex: if not null, performed locking as appropriate to make this execution thread safe (e.g., accessing data members of this session instance).

template<typename CountMapT>
inline void populate_measure_counts_data(size_t ii, size_t jj, const CountMapT &measure_counts_map)

Populate QPU execution results for task (i, j) to the session data Templated measure_counts_map to support different type of map-like data.

Private Members

bool debug_ = false
bool out_counts_ordered_by_MSB_ = false
std::string remote_backend_database_path_
YAML::Node remote_backend_database_
Table2d<std::string> name_m
std::vector<std::vector<std::vector<int>>> number_m
Table2d<std::string> infiles_
Table2d<std::string> include_qbs_
Table2d<std::string> instrings_
std::vector<std::pair<std::string, std::function<void()>>> cudaq_kernels_
std::vector<std::vector<std::shared_ptr<xacc::CompositeInstruction>>> irtarget_ms_
Table2d<std::string> accs_
Table2d<std::string> aer_sim_types_
Table2d<size_t> randoms_
Table2d<std::string> placements_
Table2d<Passes> circuit_opts_

Circuit optimization passes to apply.

Table2d<bool> xasms_
Table2d<bool> quil1s_
Table2d<bool> noplacements_
Table2d<bool> nooptimises_
Table2d<bool> execute_circuits_
Table2d<bool> noises_
Table2d<bool> output_oqm_enableds_
Table2d<bool> notimings_
Table2d<bool> calc_out_counts_
Table2d<bool> calc_jacobians_
Table2d<size_t> qns_
Table2d<size_t> sns_
Table2d<size_t> seeds_
Table2d<std::vector<double>> parameter_vectors_
Table2d<size_t> max_bond_dimensions_
Table2d<size_t> initial_bond_dimensions_
Table2d<size_t> max_kraus_dimensions_
Table2d<size_t> initial_kraus_dimensions_
Table2d<std::map<int, double>> svd_cutoffs_
Table2d<std::map<int, double>> rel_svd_cutoffs_
Table2d<std::string> measure_sample_methods_
std::vector<std::vector<NoiseModel*>> noise_models_
Table2d<size_t> acc_uses_n_bits_
Table2d<std::map<std::vector<bool>, std::complex<double>>> expected_amplitudes_
Table2d<std::map<std::vector<bool>, int>> results_
Table2d<std::vector<double>> out_probs_
Table2d<std::vector<int>> out_counts_
Table2d<std::map<int, double>> out_divergences_
Table2d<std::string> out_transpiled_circuits_
Table2d<std::string> out_qobjs_
Table2d<std::string> out_qbjsons_
Table2d<Table2d<double>> out_prob_gradients_
Table2d<bool> acc_outputs_qbit0_left_
Table2d<std::map<int, int>> out_single_qubit_gate_qtys_
Table2d<std::map<int, int>> out_double_qubit_gate_qtys_
Table2d<std::map<int, double>> out_total_init_maxgate_readout_times_
Table2d<std::map<int, double>> out_z_op_expects_
std::shared_ptr<Executor> executor_
bool in_get_state_vec_
std::shared_ptr<std::vector<std::complex<double>>> state_vec_
bool perform_SPAM_correction_ = false
Eigen::MatrixXd SPAM_correction_mat_
Table2d<std::map<std::vector<bool>, int>> results_native_
Table2d<std::string> error_mitigations_
const int INVALID = -1
const int VALID = 0
const size_t RANDOMS_UPPERBOUND = 1000
const size_t SNS_LOWERBOUND = 1
const size_t SNS_UPPERBOUND = 1000000
const size_t QNS_LOWERBOUND = 1
const size_t QNS_UPPERBOUND = 10000
const size_t MAX_BOND_DIMENSION_LOWERBOUND = 1
const size_t MAX_BOND_DIMENSION_UPPERBOUND = 50000
const size_t INITIAL_BOND_DIMENSION_LOWERBOUND = 1
const size_t INITIAL_BOND_DIMENSION_UPPERBOUND = 50000
const size_t MAX_KRAUS_DIMENSION_LOWERBOUND = 1
const size_t MAX_KRAUS_DIMENSION_UPPERBOUND = 50000
const size_t INITIAL_KRAUS_DIMENSION_LOWERBOUND = 1
const size_t INITIAL_KRAUS_DIMENSION_UPPERBOUND = 50000
const std::unordered_set<std::string> VALID_SIMULATOR_ACCS = {"aer", "tnqvm", "qpp", "qsim", "sparse-sim", "cirq-qsim", "qb-mps", "qb-purification", "qb-mpdo"}
std::unordered_set<std::string> VALID_ACCS = VALID_SIMULATOR_ACCS
std::unordered_set<std::string> VALID_AER_SIM_TYPES = {"statevector", "density_matrix", "matrix_product_state"}
const std::unordered_map<std::string, size_t> MAX_QUBITS_ACCS = {std::make_pair("aer_density_matrix", 14), std::make_pair("aer_statevector", 28), std::make_pair("cirq-qsim", 28), std::make_pair("cudaq:custatevec_fp32", 28), std::make_pair("cudaq:custatevec_fp64", 28), std::make_pair("cudaq:dm", 14), std::make_pair("cudaq:qpp", 28), std::make_pair("qpp", 28), std::make_pair("qsim", 28)}
std::unordered_set<std::string> VALID_ERROR_MITIGATIONS = {"ro-error", "rich-extrap", "assignment-error-kernel"}
std::unordered_set<std::string> VALID_HARDWARE_PLACEMENTS = {"swap-shortest-path", "noise-aware"}
std::unordered_set<std::string> VALID_MEASURE_SAMPLING_OPTIONS = {"auto", "sequential", "cutensornet", "cutensornet_multishot"}

Private Static Functions

static std::string convertRawOpenQasmToQBKernel(const std::string &in_rawQasm)

Wrap raw OpenQASM string in a QB Kernel:

  • Move qreg to a kernel argument

  • Denote the kernel name as ‘qristal_circuit’