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

asdict() → dict[source]
class c3.c3objs.Quantity(value, min_val=None, max_val=None, unit='undefined', 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

asdict()[source]

Return a config-compatible dictionary representation.

get_opt_value() → numpy.ndarray[source]

Get an optimizer friendly representation of the value.

get_value(val=None) → tensorflow.python.framework.ops.Tensor[source]

Return the value of this quantity as tensorflow.

Parameters

val (tf.float64) –

numpy() → numpy.ndarray[source]

Return the value of this quantity as numpy.

set_opt_value(val: float) → None[source]

Set value optimizer friendly.

Parameters

val (tf.float64) – Tensorflow number that will be mapped to a value between -1 and 1.

set_value(val) → None[source]

Set the value of this quantity as tensorflow. Value needs to be within specified min and max.

Parameter map

ParameterMap class

class c3.parametermap.ParameterMap(instructions: list = [], generator=None, model=None)[source]

Bases: object

Collects information about control and model parameters and provides different representations depending on use.

asdict() → dict[source]

Return a dictionary compatible with config files.

get_full_params() → Dict[str, c3.c3objs.Quantity][source]

Returns the full parameter vector, including model and control parameters.

get_opt_units() → List[str][source]

Returns a list of the units of the optimized quantities.

get_parameter(par_id: Tuple[str])c3.c3objs.Quantity[source]

Return one the current parameters.

Parameters

par_id (tuple) – Hierarchical identifier for parameter.

Returns

Return type

Quantity

get_parameters() → List[c3.c3objs.Quantity][source]

Return the current parameters.

Parameters

opt_map (list) – Hierarchical identifier for parameters.

Returns

Return type

list of Quantity

get_parameters_scaled() → numpy.ndarray[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.

Returns

Return type

list of Quantity

load_values(init_point)[source]

Load a previous parameter point to start the optimization from.

Parameters

init_point (str) – File location of the initial point

print_parameters() → None[source]

Print current parameters to stdout.

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_opt_map(opt_map) → None[source]

Set the opt_map, i.e. which parameters will be optimized.

set_parameters(values: list, opt_map=None) → 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.

set_parameters_scaled(values: tensorflow.python.ops.variables.Variable) → None[source]

Set the values in the original instruction class. This fuction should only be called by an optimizer. Are you an optimizer?

Parameters
  • values (list) – List of parameter values. Matrix valued parameters need to be flattened.

  • opt_map (list) – Corresponding identifiers for the parameter values.

str_parameters(opt_map: List[List[Tuple[str]]]) → 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

write_config(filepath: str) → None[source]

Write dictionary to a HJSON file.

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=None)[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
  • 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.

asdict() → dict[source]

Return a dictionary compatible with config files.

evaluate(seqs)[source]

Compute the population values for a given sequence of operations.

Parameters

seqs (str list) – A list of control pulses/gates to perform on the device.

Returns

A list of populations

Return type

list

get_gates()[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

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

propagation(signal: dict, gate)[source]

Solve the equation of motion (Lindblad or Schrödinger) for a given control signal and Hamiltonians.

Parameters
  • signal (dict) – Waveform of the control signal per drive line.

  • ts (tf.float64) – Vector of times.

  • gate (str) – Identifier for one of the gates.

Returns

Matrix representation of the gate.

Return type

unitary

quick_setup(filepath: str) → None[source]

Load a quick setup file and create all necessary components.

Parameters

filepath (str) – Location of the configuration file

set_created_by(config)[source]

Store the config file location used to created this experiment.

set_enable_store_unitaries(flag, logdir)[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

opt_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

opt_gates (Identifiers of the gates of interest. Can contain duplicates.) –

store_Udict(goal)[source]

Save unitary as text and pickle.

goal: tf.float64

Value of the goal function, if used.

write_config(filepath: str) → None[source]

Write dictionary to a HJSON file.

Main module

Base script to run the C3 code from a main config file.

Module contents