API Documentation¶
C3objs¶
Basic custom objects.
- class c3.c3objs.C3obj(name, desc='', comment='', params=None)[source]¶
Bases:
object
Represents an abstract object with parameters. To be inherited from.
- Parameters
name (str) – short name that will be used as identifier
desc (str) – longer description of the component
comment (str) – additional information about the component
params (dict) – Parameters in this dict can be accessed and optimized
- class c3.c3objs.Quantity(value, unit='undefined', min_val=None, max_val=None, symbol='\\alpha')[source]¶
Bases:
object
Represents any physical quantity used in the model or the pulse specification. For arithmetic operations just the numeric value is used. The value itself is stored in an optimizer friendly way as a float between -1 and 1. The conversion is given by
scale (value + 1) / 2 + offset
- Parameters
value (np.array(np.float64) or np.float64) – value of the quantity
min_val (np.array(np.float64) or np.float64) – minimum this quantity is allowed to take
max_val (np.array(np.float64) or np.float64) – maximum this quantity is allowed to take
unit (str) – physical unit
symbol (str) – latex representation
- get_other_value(val) Tensor [source]¶
Return an arbitrary value of the same scale as this quantity as tensorflow.
- Parameters
val (tf.float64) –
dtype (tf.dtypes) –
- get_value() Tensor [source]¶
Return the value of this quantity as tensorflow.
- Parameters
val (tf.float64) –
dtype (tf.dtypes) –
Experiment module¶
Experiment class that models and simulates the whole experiment.
It combines the information about the model of the quantum device, the control stack and the operations that can be done on the device.
Given this information an experiment run is simulated, returning either processes, states or populations.
- class c3.experiment.Experiment(pmap: Optional[ParameterMap] = None, prop_method=None, sim_res=100000000000.0)[source]¶
Bases:
object
It models all of the behaviour of the physical experiment, serving as a host for the individual parts making up the experiment.
- Parameters
pmap (ParameterMap) –
including model: Model
The underlying physical device.
- generator: Generator
The infrastructure for generating and sending control signals to the device.
- gateset: GateSet
A gate level description of the operations implemented by control pulses.
- compute_final_state(solver='rk4', step_function='schrodinger')[source]¶
Solve the Lindblad master equation by integrating the differential equation of the density matrix
- Returns
Final state after time evolution.
- Return type
List
- compute_propagators()[source]¶
Compute the unitary representation of operations. If no operations are specified in self.opt_gates the complete gateset is computed.
- Returns
A dictionary of gate names and their unitary representation.
- Return type
dict
- compute_states(solver='rk4', step_function='schrodinger')[source]¶
Use a state solver to compute the trajectory of the system.
- Returns
List of states of the system from simulation.
- Return type
List[tf.tensor]
- evaluate_legacy(sequences, psi_init: Optional[Tensor] = None)[source]¶
Compute the population values for a given sequence of operations.
- Parameters
sequences (str list) – A list of control pulses/gates to perform on the device.
psi_init (tf.Tensor) – A tensor containing the initial statevector
- Returns
A list of populations
- Return type
list
- evaluate_qasm(sequences, psi_init: Optional[Tensor] = None)[source]¶
Compute the population values for a given sequence (in QASM format) of operations.
- Parameters
sequences (dict list) – A list of control pulses/gates to perform on the device in QASM format.
psi_init (tf.Tensor) – A tensor containing the initial statevector
- Returns
A list of populations
- Return type
list
- get_perfect_gates(gate_keys: Optional[list] = None) Dict[str, ndarray] [source]¶
Return a perfect gateset for the gate_keys.
- Parameters
gate_keys (list) – (Optional) List of gates to evaluate.
- Returns
A dictionary of gate names and np.array representation of the corresponding unitary
- Return type
Dict[str, np.array]
- Raises
Exception – Raise general exception for undefined gate
- load_quick_setup(filepath: str) None [source]¶
Load a quick setup file.
- Parameters
filepath (str) – Location of the configuration file
- lookup_gate(name, qubits, params=None) constant [source]¶
Returns a fixed operation or a parametric virtual Z gate. To be extended to general parametric gates.
- populations(state, lindbladian)[source]¶
Compute populations from a state or density vector.
- Parameters
state (tf.Tensor) – State or densitiy vector.
lindbladian (boolean) – Specify if conversion to density matrix is needed.
- Returns
Vector of populations.
- Return type
tf.Tensor
- process(populations, labels=None)[source]¶
Apply a readout procedure to a population vector. Very specialized at the moment.
- Parameters
populations (list) – List of populations from evaluating.
labels (list) – List of state labels specifying a subspace.
- Returns
A list of processed populations.
- Return type
list
- quick_setup(cfg, base_dir: Optional[str] = None) None [source]¶
Load a quick setup cfg and create all necessary components.
- Parameters
cfg (Dict) – Configuration options
- read_config(filepath: str) None [source]¶
Load a file and parse it to create a Model object.
- Parameters
filepath (str) – Location of the configuration file
- set_enable_store_unitaries(flag, logdir, exist_ok=False)[source]¶
Saving of unitary propagators.
- Parameters
flag (boolean) – Enable or disable saving.
logdir (str) – File path location for the resulting unitaries.
- set_opt_gates(gates)[source]¶
Specify a selection of gates to be computed.
- Parameters
gates (Identifiers of the gates of interest. Can contain duplicates.) –
- set_opt_gates_seq(seqs)[source]¶
Specify a selection of gates to be computed.
- Parameters
seqs (Identifiers of the sequences of interest. Can contain duplicates.) –
- set_prop_method(prop_method=None) None [source]¶
Configure the selected propagation method by either linking the function handle or looking it up in the library.
Model module¶
The model class, containing information on the system and its modelling.
- class c3.model.Model(subsystems=None, couplings=None, tasks=None, max_excitations=0)[source]¶
Bases:
object
What the theorist thinks about from the system.
Class to store information about our system/problem/device. Different models can represent the same system.
- Parameters
subsystems (list) – List of individual, non-interacting physical components like qubits or resonators
couplings (list) – List of interaction operators between subsystems, like couplings or drives.
tasks (list) – Badly named list of processing steps like line distortions and read out modeling
max_excitations (int) – Allow only up to max_excitations in the system
- Hs_of_t(signal, interpolate_res=2)[source]¶
Generate a list of Hamiltonians for each time step of interpolated signal for Runge-Kutta Methods.
- Parameters
signal (_type_) – Input signal
interpolate_res (int, optional) – Interpolation resolution according to RK method. Defaults to 2.
L_dag_L (tf.tensor, optional) – List of {L^dagger L} where L represents the collapse operators. Defaults to None. This is only used for stochastic case.
- Returns
List of Hamiltonians (or effective Hamiltonians for stochastic case) for each time step.
- Return type
dict
- fromdict(cfg: dict) None [source]¶
Load a file and parse it to create a Model object.
- Parameters
cfg (dict) – configuration file
- get_Frame_Rotation(t_final: float64, freqs: dict, framechanges: dict)[source]¶
Compute the frame rotation needed to align Lab frame and rotating Eigenframes of the qubits.
- Parameters
t_final (tf.float64) – Gate length
freqs (list) – Frequencies of the local oscillators.
framechanges (list) – List of framechanges. A phase shift applied to the control signal to compensate relative phases of drive oscillator and qubit.
- Returns
A (diagonal) propagator that adjust phases
- Return type
tf.Tensor
- get_Hamiltonian(signal=None)[source]¶
Get a hamiltonian with an optional signal. This will return an hamiltonian over time. Can be used e.g. for tuning the frequency of a transmon, where the control hamiltonian is not easily accessible. If max.excitation is non-zero the resulting Hamiltonian is cut accordingly
- get_dephasing_channel(t_final, amps)[source]¶
Compute the matrix of the dephasing channel to be applied on the operation.
- Parameters
t_final (tf.float64) – Duration of the operation.
amps (dict of tf.float64) – Dictionary of average amplitude on each drive line.
- Returns
Matrix representation of the dephasing channel.
- Return type
tf.tensor
- get_init_state() Tensor [source]¶
Get an initial state. If a task to compute a thermal state is set, return that.
- read_config(filepath: str) None [source]¶
Load a file and parse it to create a Model object.
- Parameters
filepath (str) – Location of the configuration file
- reorder_frame(e: constant, v: constant, ordered: bool) Tuple[constant, constant, constant] [source]¶
Reorders the new basis states according to their overlap with bare qubit states.
- set_FR(use_FR)[source]¶
Setter for the frame rotation option for adjusting the individual rotating frames of qubits when using gate sequences
- set_dressed(dressed)[source]¶
Go to a dressed frame where static couplings have been eliminated.
- Parameters
dressed (boolean) –
- set_lindbladian(lindbladian: bool) None [source]¶
Set whether to include open system dynamics.
- Parameters
lindbladian (boolean) –
- set_max_excitations(max_excitations) None [source]¶
Set the maximum number of excitations in the system used for propagation.
- update_dressed(ordered=True)[source]¶
Compute the Hamiltonians in the dressed basis by diagonalizing the drift and applying the resulting transformation to the control Hamiltonians.
- class c3.model.Model_basis_change(subsystems=None, couplings=None, tasks=None, max_excitations=0, U_transform=None)[source]¶
Bases:
Model
Model with an additional unitary basis change.
- Parameters
U_transform (tf.constant(dtype=tf.complex128)) – Unitary matrix describing the basis change of the system
Parameter map¶
ParameterMap class
- class c3.parametermap.ParameterMap(instructions: List[Instruction] = [], generator=None, model=None)[source]¶
Bases:
object
Collects information about control and model parameters and provides different representations depending on use.
- check_limits(opt_map)[source]¶
Check if all elements of equal ids have the same limits. This has to be checked against if setting values optimizer friendly.
- Parameters
opt_map –
- get_full_params() Dict[str, Quantity] [source]¶
Returns the full parameter vector, including model and control parameters.
- get_key_from_scaled_index(idx, opt_map=None) str [source]¶
Get the key of the value at position ìdx of the scaled_parameters output :param idx: :param opt_map:
- get_parameter(par_id: Tuple[str, ...]) Quantity [source]¶
Return one the current parameters.
- Parameters
par_id (tuple) – Hierarchical identifier for parameter.
- Return type
- get_parameter_dict(opt_map=None) Dict[str, Quantity] [source]¶
Return the current parameters in a dictionary including keys. :param opt_map:
- Return type
Dictionary with Quantities
- get_parameters(opt_map=None) List[Quantity] [source]¶
Return the current parameters.
- Parameters
opt_map (list) – Hierarchical identifier for parameters.
- Return type
list of Quantity
- get_parameters_scaled(opt_map=None) Tensor [source]¶
Return the current parameters. This fuction should only be called by an optimizer. Are you an optimizer?
- Parameters
opt_map (tuple) – Hierarchical identifier for parameters.
- Return type
list of Quantity
- load_values(init_point, extend_bounds=False)[source]¶
Load a previous parameter point to start the optimization from.
- Parameters
init_point (str) – File location of the initial point
extend_bounds (bool) – Whether or not to allow the loaded parameters’ bounds to be extended if they exceed those specified.
- read_config(filepath: str) None [source]¶
Load a file and parse it to create a ParameterMap object.
- Parameters
filepath (str) – Location of the configuration file
- set_parameters(values: Union[List, ndarray], opt_map=None, extend_bounds=False) None [source]¶
Set the values in the original instruction class.
- Parameters
values (list) – List of parameter values. Can be nested, if a parameter is matrix valued.
opt_map (list) – Corresponding identifiers for the parameter values.
extend_bounds (bool) – If true bounds of quantity objects will be extended.
- store_values(path: str, optim_status=None) None [source]¶
Write current parameter values to file. Stores the numeric values, as well as the names in form of the opt_map and physical units. If an optim_status is given that will be used.
- Parameters
path (str) – Location of the resulting logfile.
optim_status (dict) – Dictionary containing current parameters and goal function value.
- str_parameters(opt_map: Optional[Union[List[List[Tuple[str]]], List[List[str]]]] = None, human=False) str [source]¶
Return a multi-line human-readable string of the optmization parameter names and current values.
- Parameters
opt_map (list) – Optionally use only the specified parameters.
- Returns
Parameters and their values
- Return type
str
Main module¶
Base script to run the C3 code from a main config file.
- c3.main.run_cfg(cfg, opt_config_filename, debug=False)[source]¶
Execute an optimization problem described in the cfg file.
- Parameters
cfg (Dict[str, Union[str, int, float]]) – Configuration file containing optimization options and information needed to completely setup the system and optimization problem.
debug (bool, optional) – Skip running the actual optimization, by default False
Module contents¶
Subpackages¶
- Generator package
- Submodules
- Devices module
- Generator module
- Module contents
- Libraries package
- Algorithms module
- Chip module
- Constants module
- Envelopes module
- Estimators module
- Fidelities module
- Hamiltonians module
- Sampling module
- Tasks module
- Module contents
- adaptive_scan
- algo_reg_deco
- cma_pre_lbfgs
- cmaes
- gcmaes
- grid2D
- lbfgs
- lbfgs_grad_free
- oneplusone
- single_eval
- sweep
- tf_adadelta
- tf_adam
- tf_rmsprop
- tf_sgd
- CShuntFluxQubit
- CShuntFluxQubitCos
- Coupling
- Coupling_Drive
- Drive
- Fluxonium
- LineComponent
- PhysicalComponent
- Qubit
- Resonator
- SNAIL
- Transmon
- TransmonExpanded
- dev_reg_deco
- cosine
- cosine_flattop
- delta_pulse
- drag_der
- drag_sigma
- env_reg_deco
- flattop
- flattop_cut
- flattop_cut_center
- flattop_risefall
- flattop_risefall_1ns
- flattop_variant
- fourier_cos
- fourier_sin
- gaussian_der
- gaussian_der_nonorm
- gaussian_nonorm
- gaussian_sigma
- no_drive
- pwc
- pwc_shape
- pwc_shape_plateau
- pwc_symmetric
- rect
- slepian_fourier
- trapezoid
- dv_g_LL_prime
- estimator_reg_deco
- g_LL_prime
- g_LL_prime_combined
- mean_dist
- mean_exp_stds_dist
- mean_sim_stds_dist
- median_dist
- neg_loglkh_binom
- neg_loglkh_binom_norm
- neg_loglkh_gauss
- neg_loglkh_gauss_norm
- neg_loglkh_gauss_norm_sum
- neg_loglkh_multinom
- neg_loglkh_multinom_norm
- rms_dist
- rms_exp_stds_dist
- rms_sim_stds_dist
- std_of_diffs
- RB
- average_infid
- average_infid_seq
- average_infid_set
- calculate_state_overlap
- epc_analytical
- fid_reg_deco
- leakage_RB
- lindbladian_RB_left
- lindbladian_RB_right
- lindbladian_average_infid
- lindbladian_average_infid_set
- lindbladian_epc_analytical
- lindbladian_population
- lindbladian_unitary_infid
- lindbladian_unitary_infid_set
- open_system_deco
- orbit_infid
- population
- populations
- set_deco
- state_deco
- state_transfer_from_states
- state_transfer_infid
- state_transfer_infid_set
- unitary_deco
- unitary_infid
- unitary_infid_set
- duffing
- hamiltonian_reg_deco
- int_XX
- int_YY
- resonator
- third_order
- x_drive
- y_drive
- z_drive
- all
- even
- even_fid
- from_end
- from_start
- high_std
- random_sample
- sampling_reg_deco
- ConfusionMatrix
- InitialiseGround
- MeasurementRescale
- Task
- task_deco
- Optimizers
- Signal package
- Utilities package
- Qutip utilities module
- Tensorflow utilities module
- Log Reader utilities module
- Miscellaneous utilities module
- Module contents
- T1_sequence
- basis
- expand_dims
- get_basis_matrices
- hilbert_space_kron
- insert_mat_kron
- inverseC
- kron_ids
- np_kron_n
- pad_matrix
- pauli_basis
- perfect_cliffords
- perfect_parametric_gate
- perfect_single_q_parametric_gate
- projector
- ramsey_echo_sequence
- ramsey_sequence
- rotation
- single_length_RB
- two_qubit_gate_tomography
- xy_basis
- Id_like
- anticommutator
- commutator
- get_tf_log_level
- interpolate_signal
- set_tf_log_level
- super_to_choi
- tf_abs
- tf_abs_squared
- tf_ave
- tf_average_fidelity
- tf_choi_to_chi
- tf_complexify
- tf_convolve
- tf_convolve_legacy
- tf_diff
- tf_dm_to_vec
- tf_dmdm_fid
- tf_dmket_fid
- tf_ketket_fid
- tf_kron
- tf_limit_gpu_memory
- tf_list_avail_devices
- tf_log10
- tf_log_level_info
- tf_matmul_left
- tf_matmul_n
- tf_matmul_right
- tf_measure_operator
- tf_project_to_comp
- tf_setup
- tf_spost
- tf_spre
- tf_state_to_dm
- tf_super
- tf_super_to_fid
- tf_superoper_average_fidelity
- tf_superoper_unitary_overlap
- tf_unitary_overlap
- tf_vec_to_dm
- show_table
- ask_yn
- deprecated
- eng_num
- flatten
- log_setup
- num3str
- replace_symlink
- Qiskit modules for C3
- C3 Backend module
- C3 Provider module
- C3 Job module
- C3 Exceptions module
- C3 Gates module
- C3 Backend Utilities module
- Module contents