Libraries package

Libraries contain a collection of functions that all share a signature to be used interchangably. One entry of a library is selected in the corresponding config file.

Algorithms module

Constants module

All physical constants used in other code.

Envelopes module

Library of envelope functions.

All functions assume the input of a time vector.

c3.libraries.envelopes.drag(t, params)[source]

Second order gaussian with fixed time/sigma ratio.

c3.libraries.envelopes.drag_der(t, params)[source]

Derivative of second order gaussian.

c3.libraries.envelopes.drag_sigma(t, params)[source]

Second order gaussian.

c3.libraries.envelopes.flattop(t, params)[source]

Flattop gaussian with fixed width of 1ns.

c3.libraries.envelopes.flattop_risefall(t, params)[source]

Flattop gaussian with width of length risefall, modelled by error functions.

Parameters

params (dict) –

t_upfloat

Center of the ramp up.

t_downfloat

Center of the ramp down.

risefallfloat

Length of the ramps.

c3.libraries.envelopes.flattop_variant(t, params)[source]

Flattop variant.

c3.libraries.envelopes.fourier_cos(t, params)[source]

Fourier basis of the pulse constant pulse (cos).

Parameters

params (dict) –

ampslist

Weights of the fourier components

freqslist

Frequencies of the fourier components

c3.libraries.envelopes.fourier_sin(t, params)[source]

Fourier basis of the pulse constant pulse (sin).

Parameters

params (dict) –

ampslist

Weights of the fourier components

freqslist

Frequencies of the fourier components

c3.libraries.envelopes.gaussian(t, params)[source]

Normalized gaussian with fixed time/sigma ratio.

Parameters

params (dict) –

t_finalfloat

Total length of the Gaussian.

c3.libraries.envelopes.gaussian_der(t, params)[source]

Derivative of the normalized gaussian (ifself not normalized).

c3.libraries.envelopes.gaussian_der_nonorm(t, params)[source]

Derivative of the normalized gaussian (ifself not normalized).

c3.libraries.envelopes.gaussian_nonorm(t, params)[source]

Non-normalized gaussian. Maximum value is 1, area is given by length.

Parameters

params (dict) –

t_finalfloat

Total length of the Gaussian.

sigma: float

Width of the Gaussian.

c3.libraries.envelopes.gaussian_sigma(t, params)[source]

Normalized gaussian. Total area is 1, maximum is determined accordingly.

Parameters

params (dict) –

t_finalfloat

Total length of the Gaussian.

sigma: float

Width of the Gaussian.

c3.libraries.envelopes.no_drive(t, params)[source]

Do nothing.

c3.libraries.envelopes.pwc(t, params)[source]

Piecewise constant pulse.

c3.libraries.envelopes.rect(t, params)[source]

Rectangular pulse. Returns 1 at every time step.

Estimators module

Collection of estimator functions, to compare two sets of (noisy) data.

c3.libraries.estimators.dv_g_LL_prime(gs, dv_gs, weights)[source]
c3.libraries.estimators.estimator_reg_deco(func)[source]

Decorator for making registry of functions

c3.libraries.estimators.g_LL_prime(exp_values, sim_values, exp_stds, shots)[source]
c3.libraries.estimators.g_LL_prime_combined(gs, weights)[source]
c3.libraries.estimators.mean_dist(exp_values, sim_values, exp_stds, shots)[source]

Return the root mean squared of the differences.

c3.libraries.estimators.mean_exp_stds_dist(exp_values, sim_values, exp_stds, shots)[source]

Return the mean of the distance in number of exp_stds away.

c3.libraries.estimators.mean_sim_stds_dist(exp_values, sim_values, exp_stds, shots)[source]

Return the mean of the distance in number of exp_stds away.

c3.libraries.estimators.median_dist(exp_values, sim_values, exp_stds, shots)[source]

Return the median of the differences.

c3.libraries.estimators.neg_loglkh_binom(exp_values, sim_values, exp_stds, shots)[source]

Average likelihood of the experimental values with binomial distribution.

Return the likelihood of the experimental values given the simulated values, and given a binomial distribution function.

c3.libraries.estimators.neg_loglkh_binom_norm(exp_values, sim_values, exp_stds, shots)[source]

Average likelihood of the exp values with normalised binomial distribution.

Return the likelihood of the experimental values given the simulated values, and given a binomial distribution function that is normalised to give probability 1 at the top of the distribution.

c3.libraries.estimators.neg_loglkh_gauss(exp_values, sim_values, exp_stds, shots)[source]

Likelihood of the experimental values.

The distribution is assumed to be binomial (approximated by a gaussian).

c3.libraries.estimators.neg_loglkh_gauss_norm(exp_values, sim_values, exp_stds, shots)[source]

Likelihood of the experimental values.

The distribution is assumed to be binomial (approximated by a gaussian) that is normalised to give probability 1 at the top of the distribution.

c3.libraries.estimators.neg_loglkh_gauss_norm_sum(exp_values, sim_values, exp_stds, shots)[source]

Likelihood of the experimental values.

The distribution is assumed to be binomial (approximated by a gaussian) that is normalised to give probability 1 at the top of the distribution.

c3.libraries.estimators.neg_loglkh_multinom(exp_values, sim_values, exp_stds, shots)[source]

Average likelihood of the experimental values with multinomial distribution.

Return the likelihood of the experimental values given the simulated values, and given a multinomial distribution function.

c3.libraries.estimators.neg_loglkh_multinom_norm(exp_values, sim_values, exp_stds, shots)[source]

Average likelihood of the experimental values with multinomial distribution.

Return the likelihood of the experimental values given the simulated values, and given a multinomial distribution function that is normalised to give probability 1 at the top of the distribution.

c3.libraries.estimators.rms_dist(exp_values, sim_values, exp_stds, shots)[source]

Return the root mean squared of the differences.

c3.libraries.estimators.rms_exp_stds_dist(exp_values, sim_values, exp_stds, shots)[source]

Return the root mean squared of the differences measured in exp_stds.

c3.libraries.estimators.rms_sim_stds_dist(exp_values, sim_values, exp_stds, shots)[source]

Return the root mean squared of the differences measured in exp_stds.

c3.libraries.estimators.std_of_diffs(exp_values, sim_values, exp_stds, shots)[source]

Return the std of the distances.

Fidelities module

Library of fidelity functions.

c3.libraries.fidelities.RB(U_dict, min_length: int = 5, max_length: int = 500, num_lengths: int = 20, num_seqs: int = 30, logspace=False, lindbladian=False, padding='')[source]
c3.libraries.fidelities.average_infid(U_dict: dict, gate: str, index, dims, proj=True)[source]

Average fidelity uses the Pauli basis to compare. Thus, perfect gates are always 2x2 (per qubit) and the actual unitary needs to be projected down.

Parameters
  • U_dict (dict) – Contains unitary representations of the gates, identified by a key.

  • index (int) – Index of the qubit(s) in the Hilbert space to be evaluated

  • dims (list) – List of dimensions of qubits

  • proj (boolean) – Project to computational subspace

c3.libraries.fidelities.average_infid_set(U_dict: dict, index, dims, eval, proj=True)[source]

Mean average fidelity over all gates in U_dict.

Parameters
  • U_dict (dict) – Contains unitary representations of the gates, identified by a key.

  • index (int) – Index of the qubit(s) in the Hilbert space to be evaluated

  • dims (list) – List of dimensions of qubits

  • proj (boolean) – Project to computational subspace

Returns

Mean average fidelity

Return type

tf.float64

c3.libraries.fidelities.epc_analytical(U_dict: dict, index, dims, proj: bool)[source]
c3.libraries.fidelities.fid_reg_deco(func)[source]

Decorator for making registry of functions

c3.libraries.fidelities.iswap_comp_sub(U_dict: dict, index, dims, eval, proj=True)[source]
c3.libraries.fidelities.iswap_leakage(U_dict: dict, index, dims, eval, proj=True)[source]
c3.libraries.fidelities.iswap_transfer(U_dict: dict, index, dims, eval, proj=True)[source]
c3.libraries.fidelities.leakage_RB(U_dict, min_length: int = 5, max_length: int = 500, num_lengths: int = 20, num_seqs: int = 30, logspace=False, lindbladian=False)[source]
c3.libraries.fidelities.lindbladian_RB_left(U_dict: dict, gate: str, index, dims, proj: bool = False)[source]
c3.libraries.fidelities.lindbladian_RB_right(U_dict: dict, gate: str, index, dims, proj: bool)[source]
c3.libraries.fidelities.lindbladian_average_infid(U_dict: dict, gate: str, index, dims, proj=True)[source]

Average fidelity uses the Pauli basis to compare. Thus, perfect gates are always 2x2 (per qubit) and the actual unitary needs to be projected down.

Parameters
  • U_dict (dict) – Contains unitary representations of the gates, identified by a key.

  • index (int) – Index of the qubit(s) in the Hilbert space to be evaluated

  • dims (list) – List of dimensions of qubits

  • proj (boolean) – Project to computational subspace

c3.libraries.fidelities.lindbladian_average_infid_set(U_dict: dict, index, dims, eval, proj=True)[source]

Mean average fidelity over all gates in U_dict.

Parameters
  • U_dict (dict) – Contains unitary representations of the gates, identified by a key.

  • index (int) – Index of the qubit(s) in the Hilbert space to be evaluated

  • dims (list) – List of dimensions of qubits

  • proj (boolean) – Project to computational subspace

Returns

Mean average fidelity

Return type

tf.float64

c3.libraries.fidelities.lindbladian_epc_analytical(U_dict: dict, proj: bool)[source]
c3.libraries.fidelities.lindbladian_population(U_dict: dict, lvl: int, gate: str)[source]
c3.libraries.fidelities.lindbladian_unitary_infid(U_dict: dict, gate: str, index, dims, proj: bool)[source]

Variant of the unitary fidelity for the Lindbladian propagator.

Parameters
  • U_dict (dict) – Contains unitary representations of the gates, identified by a key.

  • index (int) – Index of the qubit(s) in the Hilbert space to be evaluated

  • gate (str) – One of the keys of U_dict, selects the gate to be evaluated

  • dims (list) – List of dimensions of qubits

  • proj (boolean) – Project to computational subspace

Returns

Overlap fidelity for the Lindblad propagator.

Return type

tf.float

c3.libraries.fidelities.lindbladian_unitary_infid_set(U_dict: dict, index, dims, eval, proj=True)[source]

Variant of the mean unitary fidelity for the Lindbladian propagator.

Parameters
  • U_dict (dict) – Contains unitary representations of the gates, identified by a key.

  • index (int) – Index of the qubit(s) in the Hilbert space to be evaluated

  • dims (list) – List of dimensions of qubits

  • proj (boolean) – Project to computational subspace

Returns

Mean overlap fidelity for the Lindblad propagator for all gates in U_dict.

Return type

tf.float

c3.libraries.fidelities.orbit_infid(U_dict, RB_number: int = 30, RB_length: int = 20, lindbladian=False, shots: int = None, seqs=None, noise=None)[source]
c3.libraries.fidelities.population(U_dict: dict, lvl: int, gate: str)[source]
c3.libraries.fidelities.populations(state, lindbladian)[source]
c3.libraries.fidelities.state_transfer_infid(U_dict: dict, gate: str, index, dims, psi_0, proj: bool)[source]

Single gate state transfer infidelity.

Parameters
  • U_dict (dict) – Contains unitary representations of the gates, identified by a key.

  • index (int) – Index of the qubit(s) in the Hilbert space to be evaluated

  • gate (str) – One of the keys of U_dict, selects the gate to be evaluated

  • dims (list) – List of dimensions of qubits

  • psi_0 (tf.Tensor) – Initial state of the device

  • proj (boolean) – Project to computational subspace

Returns

State infidelity for the selected gate

Return type

tf.float

c3.libraries.fidelities.state_transfer_infid_set(U_dict: dict, index, dims, psi_0, proj=True)[source]

Mean state transfer infidelity.

Parameters
  • U_dict (dict) – Contains unitary representations of the gates, identified by a key.

  • index (int) – Index of the qubit(s) in the Hilbert space to be evaluated

  • dims (list) – List of dimensions of qubits

  • psi_0 (tf.Tensor) – Initial state of the device

  • proj (boolean) – Project to computational subspace

Returns

State infidelity, averaged over the gates in U_dict

Return type

tf.float

c3.libraries.fidelities.unitary_infid(U_dict: dict, gate: str, index, dims, proj: bool)[source]

Unitary overlap between ideal and actually performed gate.

Parameters
  • U_dict (dict) – Contains unitary representations of the gates, identified by a key.

  • index (int) – Index of the qubit(s) in the Hilbert space to be evaluated

  • gate (str) – One of the keys of U_dict, selects the gate to be evaluated

  • dims (list) – List of dimensions of qubits

  • proj (boolean) – Project to computational subspace

Returns

Unitary fidelity.

Return type

tf.float

c3.libraries.fidelities.unitary_infid_set(U_dict: dict, index, dims, eval, proj=True)[source]

Mean unitary overlap between ideal and actually performed gate for the gates in U_dict.

Parameters
  • U_dict (dict) – Contains unitary representations of the gates, identified by a key.

  • index (int) – Index of the qubit(s) in the Hilbert space to be evaluated

  • dims (list) – List of dimensions of qubits

  • proj (boolean) – Project to computational subspace

Returns

Unitary fidelity.

Return type

tf.float

Hamiltonians module

Library of Hamiltonian functions.

c3.libraries.hamiltonians.duffing(a)[source]

Anharmonic part of the duffing oscillator.

Parameters

a (Tensor) – Annihilator.

Returns

Number operator.

Return type

Tensor

c3.libraries.hamiltonians.int_XX(anhs)[source]

Dipole type coupling.

Parameters

anhs (Tensor list) – Annihilators.

Returns

coupling

Return type

Tensor

c3.libraries.hamiltonians.int_YY(anhs)[source]

Dipole type coupling.

Parameters

anhs (Tensor list) – Annihilators.

Returns

coupling

Return type

Tensor

c3.libraries.hamiltonians.resonator(a)[source]

Harmonic oscillator hamiltonian given the annihilation operator.

Parameters

a (Tensor) – Annihilator.

Returns

Number operator.

Return type

Tensor

c3.libraries.hamiltonians.x_drive(a)[source]

Semiclassical drive.

Parameters

a (Tensor) – Annihilator.

Returns

Number operator.

Return type

Tensor

c3.libraries.hamiltonians.y_drive(a)[source]

Semiclassical drive.

Parameters

a (Tensor) – Annihilator.

Returns

Number operator.

Return type

Tensor

c3.libraries.hamiltonians.z_drive(a)[source]

Semiclassical drive.

Parameters

a (Tensor) – Annihilator.

Returns

Number operator.

Return type

Tensor

Sampling module

Functions to select samples from a dataset by various criteria.

c3.libraries.sampling.all(learn_from, batch_size)[source]

Return all points.

Parameters
  • learn_from (list) – List of data points

  • batch_size (int) – Number of points to select

Returns

All indeces.

Return type

list

c3.libraries.sampling.even(learn_from, batch_size)[source]

Select evenly distanced samples across the set.

Parameters
  • learn_from (list) – List of data points

  • batch_size (int) – Number of points to select

Returns

Selected indices.

Return type

list

c3.libraries.sampling.even_fid(learn_from, batch_size)[source]

Select evenly among reached fidelities.

Parameters
  • learn_from (list) – List of data points.

  • batch_size (int) – Number of points to select.

Returns

Selected indices.

Return type

list

c3.libraries.sampling.from_end(learn_from, batch_size)[source]

Select from the end.

Parameters
  • learn_from (list) – List of data points

  • batch_size (int) – Number of points to select

Returns

Selected indices.

Return type

list

c3.libraries.sampling.from_start(learn_from, batch_size)[source]

Select from the beginning.

Parameters
  • learn_from (list) – List of data points

  • batch_size (int) – Number of points to select

Returns

Selected indices.

Return type

list

c3.libraries.sampling.high_std(learn_from, batch_size)[source]

Select points that have a high ratio of standard deviation to mean. Sampling from ORBIT data, points with a high std have the most coherent error, thus might be suitable for model learning. This has yet to be confirmed beyond anecdotal observation.

Parameters
  • learn_from (list) – List of data points.

  • batch_size (int) – Number of points to select.

Returns

Selected indices.

Return type

list

c3.libraries.sampling.random_sample(learn_from, batch_size)[source]

Select randomly.

Parameters
  • learn_from (list) – List of data points.

  • batch_size (int) – Number of points to select.

Returns

Selected indices.

Return type

list

c3.libraries.sampling.sampling_reg_deco(func)[source]

Decorator for making registry of functions

Module contents