Class session
Defined in File session.hpp
Nested Relationships
Nested Types
Class Documentation
-
class session
A session of the QB SDK quantum programming and execution framework.
Public Types
Public Functions
-
inline 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., qb12().
-
inline session(const std::string &name)
Construct a new session object with a specific name.
- Parameters
name – Session name
-
inline 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.
-
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 VectorString &infiles)
Set the list input QASM source files.
- Parameters
infiles – A list of paths to source files
-
const VectorString &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 VectorString &instrings)
Set the list of input QASM source strings.
- Parameters
instrings – Input source strings
-
const VectorString &get_instrings() const
Get the input QASM source strings of the session.
- Returns
List of source strings
Set the irtarget (
xacc::CompositeInstruction) object.Note
This
xacc::CompositeInstructioncan 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
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 VectorString &include_qbs)
Set the list of paths to the OpenQASM include files.
- Parameters
include_qbs – Paths to the OpenQASM include files
-
const VectorString &get_include_qbs() const
Get the list of paths to the OpenQASM include files.
- Returns
Paths to the OpenQASM include files
-
void set_qpu_config(const std::string &qpu_config)
Set the path to the qpu config JSON file.
- Parameters
qpu_config – Path to the qpu config JSON file
-
void set_qpu_configs(const VectorString &qpu_configs)
Set the list of paths to the qpu config JSON files.
- Parameters
qpu_configs – List of paths to the qpu config JSON files
-
const VectorString &get_qpu_configs() const
Get the list of paths to the qpu config JSON files.
- Returns
List of paths to the qpu config JSON files
-
void set_acc(const std::string &acc)
Set the backend accelerator.
- Parameters
acc – Name of the accelerator
-
void set_accs(const VectorString &accs)
Set the list of backend accelerators.
- Parameters
accs – List of backend accelerator names
-
const VectorString &get_accs() const
Get the list of backend accelerators.
- Returns
List of backend accelerator names
-
void set_aws_device_name(const std::string &device_name)
Set the AWS Braket device name, e.g., SV1, DM1, etc.
- Parameters
device_name – Name of AWS Braket device
-
void set_aws_device_names(const VectorString &device_names)
Set AWS Braket device names.
- Parameters
device_names – Names of AWS Braket devices
-
const VectorString &get_aws_device_names() const
Get AWS Braket device names.
- Returns
Names of AWS Braket devices
-
void set_aws_format(const std::string &format)
Set the format to submit circuits to AWS Braket
- Parameters
format – Format type (e.g., openqasm3)
-
void set_aws_formats(const VectorString &formats)
Set the format to submit circuits to AWS Braket
- Parameters
formats – List of format types (e.g., openqasm3)
-
const VectorString &get_aws_formats() const
Get format to submit circuits to AWS Braket.
- Returns
List of format types
-
void set_aws_s3(const std::string &bucket_name)
Set the AWS S3 bucket to store results.
- Parameters
bucket_name – Name of S3 bucket
-
void set_aws_s3s(const VectorString &bucket_names)
Set the AWS S3 bucket to store results.
- Parameters
bucket_names – Names of S3 bucket
-
const VectorString &get_aws_s3s() const
Get the AWS S3 bucket to store results.
- Returns
Names of S3 bucket
-
void set_aws_s3_path(const std::string &path)
Set the AWS S3 path.
- Parameters
path – AWS S3 path
-
void set_aws_s3_paths(const VectorString &paths)
Set the AWS S3 paths.
- Parameters
paths – AWS S3 paths
-
const VectorString &get_aws_s3_paths() const
Get the AWS S3 paths.
- Returns
AWS S3 paths
-
void set_aws_verbatim(const bool &verbatim)
Set the AWS verbatim mode.
- Parameters
verbatim – Verbatim mode
-
void set_aws_verbatims(const VectorBool &verbatims)
Set the AWS verbatim modes.
- Parameters
verbatims – Verbatim modes
-
const VectorBool &get_aws_verbatims() const
Get the AWS verbatim mode.
- Returns
Verbatim modes
-
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 VectorString &sim_types)
Set the AER backend simulator types.
- Parameters
sim_types – Simulator type
-
const VectorString &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 VectorN &in_random)
Set the depths of the auto-generated random circuits.
- Parameters
in_random – Circuit depth values
-
const VectorN &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 VectorBool &in_xasm)
Set the XASM input flags.
- Parameters
in_xasm – XASM input flags
-
const VectorBool &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 VectorBool &in_quil1)
Set the Quil input flags.
- Parameters
in_quil1 – Quil input flags
-
const VectorBool &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 VectorBool &in_noplacement)
Set the noplacement flags.
- Parameters
in_noplacement – noplacement flags
-
const VectorBool &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 VectorString &in_placements)
Set the circuit placement methods.
- Parameters
in_placements – Names of the circuit placement modules
-
const VectorString &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 VectorBool &in_nooptimise)
Set the nooptimise flags.
- Parameters
in_nooptimise – nooptimise flags
-
const VectorBool &get_nooptimises() const
Get the nooptimise flags.
- Returns
nooptimise flags
-
void set_nosim(const bool &in_nosim)
Set the nosim flag.
True to disable circuit simulation, e.g., dry-run to inspect transpilation and resource estimation only.
- Parameters
in_nosim – nosim flag
-
void set_nosims(const VectorBool &in_nosim)
Set the nosim flags.
- Parameters
in_nosim – nosim flags
-
const VectorBool &get_nosims() const
Get the nosim flags.
- Returns
nosim 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 VectorBool &in_noise)
Set the noise simulation flags.
- Parameters
in_noise – Noise flags
-
const VectorBool &get_noises() const
Get the noise simulation flags.
- Returns
Noise flags
-
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 VectorBool &in_output_oqm_enabled)
Set the output oqm enableds object.
- Parameters
in_output_oqm_enabled – Config. values
-
const VectorBool &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 VectorBool &in_notiming)
Set the notiming configuration flags.
- Parameters
in_notiming – Config. values
-
const VectorBool &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 VectorN &in_qn)
Set the numbers of qubits.
- Parameters
in_qn – Numbers of qubits
-
const VectorN &get_qns() const
Get the numbers of qubits.
- Returns
Number of qubits
-
void set_rn(const size_t &in_rn)
Set the number of repetitions.
- Parameters
in_rn – Number of repetitions
-
void set_rns(const VectorN &in_rn)
Set the numbers of repetitions.
- Parameters
in_rn – Numbers of repetitions
-
const VectorN &get_rns() const
Get the numbers of repetitions.
- Returns
Numbers of repetitions
-
void set_sn(const size_t &in_sn)
Set the number of measurement shots.
- Parameters
in_sn – Number of shots
-
void set_sns(const VectorN &in_sn)
Set the number of measurement shots.
- Parameters
in_sn – Number of shots
-
const VectorN &get_sns() const
Get the number of measurement shots.
- Returns
Number of shots
-
void set_theta(const ND &in_theta)
Set the angle variables (theta)
- Parameters
in_theta – Theta values
-
void set_thetas(const VectorMapND &in_theta)
Set the angle variables (theta)
- Parameters
in_theta – Theta values
-
const VectorMapND &get_thetas() const
Get the angle variables (theta)
- Returns
Theta values
-
const VectorBool &get_use_default_contrast_settings() const
Get the use_default_contrast_setting configuration flags.
- Returns
Config. values
-
void set_init_contrast_threshold(const double &in_init_contrast_threshold)
Set QB hardware contrast threshold above which initialisation is deemed successful.
- Parameters
in_init_contrast_threshold – Non-negative threshold value
-
void set_init_contrast_thresholds(const VectorMapND &in_init_contrast_thresholds)
Set QB hardware contrast threshold above which initialisation is deemed successful.
- Parameters
in_init_contrast_thresholds – Non-negative threshold values
-
const VectorMapND &get_init_contrast_thresholds() const
Get the contrast threshold for initialisation.
- Returns
Initialisation contrast thresholds
-
void set_qubit_contrast_threshold(const ND &in_qubit_contrast_threshold)
Set QB hardware contrast thresholds during final readout on a per-qubit basis.
- Parameters
in_qubit_contrast_threshold – Non-negative qubit readout threshold
-
void set_qubit_contrast_thresholds(const VectorMapND &in_qubit_contrast_thresholds)
Set QB hardware contrast thresholds during final readout on a per-qubit basis.
- Parameters
in_qubit_contrast_thresholds – Non-negative qubit readout threshold
-
const VectorMapND &get_qubit_contrast_thresholds() const
Get the qubit contrast thresholds for final readout.
- Returns
Contrast thresholds used for final readout
-
void set_max_bond_dimension(const size_t &in_max_bond_dimension)
Set the maximum bond dimension (MPS simulator)
Note
This is only needed if using the “tnqvm” backend accelerator.
- Parameters
in_max_bond_dimension – Max MPS bond dimension value
-
void set_max_bond_dimensions(const VectorN &in_max_bond_dimension)
Set the maximum bond dimension (MPS simulator)
- Parameters
in_max_bond_dimension – Max MPS bond dimension value
-
const VectorN &get_max_bond_dimensions() const
Get the maximum bond dimension (MPS simulator)
- Returns
Max MPS bond dimension value
-
void set_svd_cutoff(const ND &in_svd_cutoff)
Set the SVD cutoff limit (MPS simulator)
Note
This is only needed if using the “tnqvm” backend accelerator.
- Parameters
in_svd_cutoff – SVD cutoff value
-
void set_svd_cutoffs(const VectorMapND &in_svd_cutoff)
Set the SVD cutoff limit (MPS simulator)
- Parameters
in_svd_cutoff – SVD cutoff value
-
const VectorMapND &get_svd_cutoffs() const
Get the SVD cutoff limit (MPS simulator)
- Returns
SVD cutoff value
-
void set_noise_model(const std::string &noise_model)
Set the noise model name.
- Parameters
noise_model – Name of the noise model to use
-
void set_noise_models(const VectorString &noise_models)
Set the noise model name.
- Parameters
noise_models – Name of the noise model to use
-
const VectorString &get_noise_models() const
Get the noise model name.
- Returns
Name of the noise model to use
-
void set_output_amplitude(const NC &in_output_amplitude)
Set the amplitudes for Jensen–Shannon divergence calculation.
- Parameters
in_output_amplitude – Amplitude values
-
void set_output_amplitudes(const VectorMapNC &in_output_amplitude)
Set the amplitudes for Jensen–Shannon divergence calculation.
- Parameters
in_output_amplitude – Amplitude values
-
const VectorMapNC &get_output_amplitudes() const
Get the 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 VectorString &get_out_raws() const
Get the raw output bitstring results.
- Returns
Bitstring results
-
const VectorMapNN &get_out_counts() const
Get the output measurement counts.
- Returns
Measurement count map
-
const VectorMapND &get_out_divergences() const
Get the output Jensen–Shannon divergence results.
- Returns
Divergence results
-
const VectorString &get_out_transpiled_circuits() const
Get the output transpiled circuits.
- Returns
Output transpiled circuits
-
const VectorString &get_out_qobjs() const
Get the output QObj Json strings.
- Returns
QObj Json strings
-
const VectorString &get_out_qbjsons() const
Get the output QB Json strings (hardware execution)
- Returns
QB Json strings
-
const VectorMapNN &get_out_single_qubit_gate_qtys() const
Get the output single-qubit gate counts.
- Returns
Single-qubit gate counts
-
const VectorMapNN &get_out_double_qubit_gate_qtys() const
Get the output two-qubit gate counts.
- Returns
Two-qubit gate counts
-
const VectorMapND &get_out_total_init_maxgate_readout_times() const
Get the output total circuit execution time (hardware runtime estimation)
- Returns
Estimated hardware runtime.
-
const VectorMapND &get_out_z_op_expects() const
Get the output expected value in the Z basis.
- Returns
expected value in the Z basis
-
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 VectorString &noise_mitigates)
Set the noise mitigation methods.
- Parameters
noise_mitigates – Noise mitigation methods
-
const VectorString &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 VectorN &in_seeds)
Set random seed values.
- Parameters
in_seeds – Seed values
-
const VectorN &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 VectorString &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 VectorString &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 run()
Execute all quantum tasks.
-
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
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 qb12()
Shortcuts for setting defaults 12 qubits, 1024 shots, noiseless
-
void aws32dm1()
AWS Braket DM1, 32 async workers, 17 qubits, 256 shots, noiseless.
-
void aws32sv1()
AWS Braket SV1, 32 async workers, 34 qubits, 256 shots, noiseless.
-
void aws8tn1()
AWS Braket TN1, 8 async workers, 49 qubits, 256 shots, noiseless.
-
void set_contrasts(const double &init_ct, const double &q0_ct, const double &q1_ct)
For QB hardware: contrast threshold helper methods.
Contrast thresholds for QB hardware. Applies globally throughout a Qristal session.
- Parameters
init_ct – Input contrast threshold used for initialisation
q0_ct – Input contrast threshold used for final readout of qubit[0]
q1_ct – Input contrast threshold used for final readout of qubit[1]
-
void reset_contrasts()
Removes all contrast thresholds stored in a Qristal session.
-
inline session()