pygsti.processors.processorspec.QubitProcessorSpec

Contents

pygsti.processors.processorspec.QubitProcessorSpec#

class QubitProcessorSpec(num_qubits, gate_names, nonstd_gate_unitaries=None, availability=None, geometry=None, qubit_labels=None, nonstd_gate_symplecticreps=None, prep_names=('rho0',), povm_names=('Mdefault',), instrument_names=(), nonstd_preps=None, nonstd_povms=None, nonstd_instruments=None, aux_info=None)#

Bases: QuditProcessorSpec

The device specification for a one or more qudit quantum computer.

Parameters:
  • num_qubits (int) – The number of qubits in the device.

  • gate_names (list of strings) –

    The names of gates in the device. This may include standard gate names known by pyGSTi (see below) or names which appear in the nonstd_gate_unitaries argument. The set of standard gate names includes, but is not limited to:

    • ’Gi’ : the 1Q idle operation

    • ’Gx’,’Gy’,’Gz’ : 1-qubit pi/2 rotations

    • ’Gxpi’,’Gypi’,’Gzpi’ : 1-qubit pi rotations

    • ’Gh’ : Hadamard

    • ’Gp’ : phase or S-gate (i.e., ((1,0),(0,i)))

    • ’Gcphase’,’Gcnot’,’Gswap’ : standard 2-qubit gates

    Alternative names can be used for all or any of these gates, but then they must be explicitly defined in the nonstd_gate_unitaries dictionary. Including any standard names in nonstd_gate_unitaries overrides the default (builtin) unitary with the one supplied.

  • nonstd_gate_unitaries (dictionary of numpy arrays) – A dictionary with keys that are gate names (strings) and values that are numpy arrays specifying quantum gates in terms of unitary matrices. This is an additional “lookup” database of unitaries - to add a gate to this QubitProcessorSpec its names still needs to appear in the gate_names list. This dictionary’s values specify additional (target) native gates that can be implemented in the device as unitaries acting on ordinary pure-state-vectors, in the standard computationl basis. These unitaries need not, and often should not, be unitaries acting on all of the qubits. E.g., a CNOT gate is specified by a key that is the desired name for CNOT, and a value that is the standard 4 x 4 complex matrix for CNOT. All gate names must start with ‘G’. As an advanced behavior, a unitary-matrix-returning function which takes a single argument - a tuple of label arguments - may be given instead of a single matrix to create an operation factory which allows continuously-parameterized gates. This function must also return an empty/dummy unitary when None is given as it’s argument.

  • availability (dict, optional) – A dictionary whose keys are some subset of the keys (which are gate names) nonstd_gate_unitaries and the strings (which are gate names) in gate_names and whose values are lists of qubit-label-tuples. Each qubit-label-tuple must have length equal to the number of qubits the corresponding gate acts upon, and causes that gate to be available to act on the specified qubits. Instead of a list of tuples, values of availability may take the special values “all-permutations” and “all-combinations”, which as their names imply, equate to all possible permutations and combinations of the appropriate number of qubit labels (deterined by the gate’s dimension). If a gate name is not present in availability, the default is “all-permutations”. So, the availability of a gate only needs to be specified when it cannot act in every valid way on the qubits (e.g., the device does not have all-to-all connectivity).

  • geometry ({"line","ring","grid","torus"} or QubitGraph, optional) – The type of connectivity among the qubits, specifying a graph used to define neighbor relationships. Alternatively, a QubitGraph object with qubit_labels as the node labels may be passed directly. This argument is only used as a convenient way of specifying gate availability (edge connections are used for gates whose availability is unspecified by availability or whose value there is “all-edges”).

  • qubit_labels (list or tuple, optional) – The labels (integers or strings) of the qubits. If None, then the integers starting with zero are used.

  • nonstd_gate_symplecticreps (dict, optional) – A dictionary similar to nonstd_gate_unitaries that supplies, instead of a unitary matrix, the symplectic representation of a Clifford operations, given as a 2-tuple of numpy arrays. #TODO: Better explanation of this specifier.

  • prep_names (list or tuple of str, optional (default ('rho0',))) – List of strings corresponding to the names of the native state preparation operations supported by this processor specification. State preparation names must start with ‘rho’.

  • povm_names (list or tuple of str, optional (default ('Mdefault',))) – List of strings corresponding to the names of the native POVMs supported by this processor specification. POVM names must start with ‘M’.

  • instrument_names (list or tuple of str, optional (default ())) – List of strings corresponding to the names of the quantum instruments supported by this processor specification. Instrument names must start with ‘I’.

  • nonstd_preps (dict, optional (default None)) –

    Dictionary mapping preparation names (as specified in prep_names) to corresponding state preparations. The values of this dictionary can be the following specifiers:

    • numpy ndarray: numpy vector corresponding to the dense representation of the pure

      state corresponding to this state preparation, written in the standard/computational basis.

    • string specifiers: For string state preparation specifiers there are two prefixes supported

      which determine the parsing applied for conversion to a corresponding state preparation.: The first prefix is ‘rho_’. When this prefix is used, any digits proceeding in the string are interpreted as the bitstring labeling a standard basis state. E.g. ‘rho_01’ corresponds to the state |01>. The second prefix is ‘rho’ (w/o the underscore). When this prefix is used the following digits are interpreted as an integer. This integer is then converted into a bitstring labeling the corresponding standard basis state (with the conversion using right-LSB convention).

  • nonstd_povms (dict, optional (default None)) –

    Dictionary mapping POVM names (as specified in povm_names) to corresponding POVMs. The values of this dictionary can be the following specifiers:

    • string specifiers: Presently two special string specifiers are supported, ‘Mdefault’ and ‘Mz’,

      both of which map to POVMs for computational-basis readout with the appropriate dimensions.

    • dictionary: A dictionary whose keys are effect labels, and whose values are specifiers used to construct

      corresponding effects. Effect specifiers can themselves take two forms: - list of numpy arrays: List of numpy arrays corresponding to the component pure states whose corresponding projectors (density matrix vectors) are summed to produce this POVM effect. When there is only a single such pure state then one can alternatively use that numpy array directly as the value (without wrapping in a list) for convenience. E.g. to construct a two-qubit, two-outcome, POVM corresponding to parity readout wherein each POVM effect corresponds to a rank-2 projector onto the even or odd computational subspace the complete POVM specifier would be: {‘even’: [np.array([1,0,0,0], np.array([0,0,0,1])], ‘odd’: [np.array([0,1,0,0], np.array([0,0,1,0])]} -list of string specifiers: Alternatively one can specify a list of effect specifiers using special string notation. String specifiers can take three formats: 1. They can be strings which directly correspond to the desired output bit/ditstring in the standard basis.

      E.g. “0000” or “1001”.

      1. Strings prefixed by either ‘E_’ or ‘E’ (w/o an underscore). In the first case any digits proceeding the

        E_” are interpreted as a bitstring. If prefixed by “E” (w/o an underscore) the proceeding digits are interpreted as an integer and converted into a base d number using right-LSB convention. E.g. ‘E_0000’ corresponds to the state |0000>, and E15 corresponds to |1111> (assuming this was acting on 4-qubits).

  • nonstd_instruments (dict, optional (default None)) –

    Dictionary mapping instrument names (as specified in instrument_names) to corresponding instruments. The values of this dictionary can be the following specifiers:

    • string specifiers: Presently only one special string specifier is supported, ‘Iz’. This corresponds to a quantum

      instrument for computational-basis readout.

    • dictionary: A dictionary whose keys are instrument effect labels, and whose values are specifiers used to construct the

      corresponding instrument effects. Instrument effect specifiers can take the following form: - numpy array: A numpy array corresponding to the dense representation of the instrument effect. - lists of 2-tuples: Each tuple in this list of 2-tuples is such that the first element corresponds to a POVM effect specifier (see nonstd_povms for supported options), and the second element is a state preparation specifier (see nonstd_preps for supported options). These specifiers are used to construct appropriate effect and preparation representations which are then have their outer product taken. This is done for each 2-tuple, and the outer products are then summed to get the overall instrument effect. In the case where there is only a single 2-tuple for an instrument effect this tuple can be used directly as the dictionary value (w/o being wrapped in a list) for convenience.

  • aux_info (dict, optional) – Any additional information that should be attached to this processor spec.

Methods

__init__(num_qubits, gate_names[, ...])

add_mongodb_write_ops(write_ops, mongodb[, ...])

Accumulate write and update operations for writing this object to a MongoDB database.

available_gatelabels(gate_name, sslbls)

List all the gate labels that are available for gate_name on at least a subset of sslbls.

available_gatenames(sslbls)

List all the gate names that are available within a set of state space labels.

compute_2Q_connectivity()

Constructs a graph encoding the connectivity between qubits via 2-qubit gates.

compute_clifford_2Q_connectivity()

Constructs a graph encoding the connectivity between qubits via 2-qubit Clifford gates.

compute_clifford_ops_on_qubits()

Constructs a dictionary mapping tuples of state space labels to the clifford operations available on them.

compute_clifford_symplectic_reps([...])

Constructs a dictionary of the symplectic representations for all the Clifford gates in this processor spec.

compute_multiqubit_inversion_relations()

Computes the inverses of multi-qubit (>1 qubit) gates.

compute_one_qubit_gate_relations()

Computes the basic pair-wise relationships relationships between the gates.

compute_ops_on_qubits()

Constructs a dictionary mapping tuples of state space labels to the operations available on them.

compute_ops_on_qudits()

Constructs a dictionary mapping tuples of state space labels to the operations available on them.

dump(f[, format])

Serializes and writes this object to a given output stream.

dumps([format])

Serializes this object and returns it as a string.

force_recompute_gate_relationships()

Invalidates LRU caches for all compute_* methods of this object, forcing them to recompute their values.

from_mongodb(mongodb, doc_id, **kwargs)

Create and initialize an object from a MongoDB instance.

from_mongodb_doc(mongodb, collection_name, ...)

Create and initialize an object from a MongoDB instance and pre-loaded primary document.

from_nice_serialization(state)

Create and initialize an object from a "nice" serialization.

gate_num_qubits(gate_name)

The number of qubits that a given gate acts upon.

gate_num_qudits(gate_name)

The number of qudits that a given gate acts upon.

instrument_specifier(name)

The specifier for a given instrument name.

is_available(gate_label)

Check whether a gate at a given location is available.

load(f[, format])

Load an object of this type, or a subclass of this type, from an input stream.

loads(s[, format])

Load an object of this type, or a subclass of this type, from a string.

map_qubit_labels(mapper)

Creates a new QubitProcessorSpec whose qubit labels are updated according to the mapping function mapper.

map_qudit_labels(mapper)

Creates a new QuditProcessorSpec whose qudit labels are updated according to the mapping function mapper.

povm_specifier(name)

The specifier for a given POVM name.

prep_specifier(name)

The specifier for a given state preparation name.

read(path[, format])

Read an object of this type, or a subclass of this type, from a file.

remove_from_mongodb(mongodb, doc_id[, ...])

Remove the documents corresponding to an instance of this class from a MongoDB database.

remove_me_from_mongodb(mongodb[, session, ...])

rename_gate_inplace(existing_gate_name, ...)

Renames a gate within this processor specification.

resolved_availability(gate_name[, ...])

The availability of a given gate, resolved as either a tuple of sslbl-tuples or a function.

subset([gate_names_to_include, ...])

Construct a smaller processor specification by keeping only a select set of gates from this processor spec.

to_nice_serialization()

Serialize this object in a way that adheres to "niceness" rules of common text file formats.

write(path, **format_kwargs)

Writes this object to a file.

write_to_mongodb(mongodb[, session, ...])

Write this object to a MongoDB database.

Attributes

collection_name

global_idle_gate_name

The (first) gate name that corresponds to a global idle operation.

global_idle_layer_label

Similar to global_idle_gate_name but include the appropriate sslbls (either None or all the qudits)

idle_gate_names

The gate names that correspond to idle operations.

num_qubits

The number of qudits.

num_qudits

The number of qudits.

primitive_op_labels

All the primitive operation labels derived from the gate names and availabilities

qubit_graph

The qubit graph (geometry).

qubit_labels

The qubit labels.

add_mongodb_write_ops(write_ops, mongodb, overwrite_existing=False, **kwargs)#

Accumulate write and update operations for writing this object to a MongoDB database.

Similar to write_to_mongodb() but collects write operations instead of actually executing any write operations on the database. This function may be preferred to write_to_mongodb() when this object is being written as a part of a larger entity and executing write operations is saved until the end.

As in write_to_mongodb(), self.collection_name is the collection name and _id is either: 1) the ID used by a previous write or initial read-in, if one exists, OR 2) a new random bson.objectid.ObjectId

Parameters:
  • write_ops (WriteOpsByCollection) – An object that keeps track of pymongo write operations on a per-collection basis. This object accumulates write operations to be performed at some point in the future.

  • mongodb (pymongo.database.Database) – The MongoDB instance to write data to.

  • overwrite_existing (bool, optional) – Whether existing documents should be overwritten. The default of False causes a ValueError to be raised if a document with the given _id already exists and is different from what is being written.

  • **kwargs (dict) – Additional keyword arguments potentially used by subclass implementations. Any arguments allowed by a subclass’s _add_auxiliary_write_ops_and_update_doc method is allowed here.

Returns:

The identifier (_id value) of the main document that was written.

Return type:

bson.objectid.ObjectId

available_gatelabels(gate_name, sslbls)#

List all the gate labels that are available for gate_name on at least a subset of sslbls.

Parameters:
  • gate_name (str) – The gate name.

  • sslbls (tuple) – The state space labels to find availability within.

Returns:

The available gate labels (all with name gate_name).

Return type:

tuple of Labels

available_gatenames(sslbls)#

List all the gate names that are available within a set of state space labels.

This function finds all the gate names that are available for at least a subset of sslbls.

Parameters:

sslbls (tuple) – The state space labels to find availability within.

Returns:

A tuple of gate names (strings).

Return type:

tuple of strings

compute_2Q_connectivity()#

Constructs a graph encoding the connectivity between qubits via 2-qubit gates.

Returns:

A graph with nodes equal to the qubit labels and edges present whenever there is a 2-qubit gate between the vertex qubits.

Return type:

QubitGraph

compute_clifford_2Q_connectivity()#

Constructs a graph encoding the connectivity between qubits via 2-qubit Clifford gates.

Returns:

A graph with nodes equal to the qubit labels and edges present whenever there is a 2-qubit Clifford gate between the vertex qubits.

Return type:

QubitGraph

compute_clifford_ops_on_qubits()#

Constructs a dictionary mapping tuples of state space labels to the clifford operations available on them.

Returns:

A dictionary with keys that are state space label tuples and values that are lists of gate labels, giving the available Clifford gates on those target labels.

Return type:

dict

compute_clifford_symplectic_reps(gatename_filter=None)#

Constructs a dictionary of the symplectic representations for all the Clifford gates in this processor spec.

Parameters:

gatename_filter (iterable, optional) – A list, tuple, or set of gate names whose symplectic representations should be returned (if they exist).

Returns:

keys are gate names, values are (symplectic_matrix, phase_vector) tuples.

Return type:

dict

compute_multiqubit_inversion_relations()#

Computes the inverses of multi-qubit (>1 qubit) gates.

Finds whether any of the multi-qubit gates in this device also have their inverse in the model. That is, if the unitaries for the multi-qubit gate with name name1 followed by the multi-qubit gate (of the same dimension) with name name2 multiple (up to phase) to the identity, then gate_inverse[name1] = name2 and gate_inverse[name2] = name1

1-qubit gates are not computed by this method, as they are be computed by the method compute_one_qubit_gate_relations().

Returns:

gate_inverse – Keys and values are gate names, mapping a gate name to its inverse gate (if one exists).

Return type:

dict

compute_one_qubit_gate_relations()#

Computes the basic pair-wise relationships relationships between the gates.

1. It multiplies all possible combinations of two 1-qubit gates together, from the full model available to in this device. If the two gates multiple to another 1-qubit gate from this set of gates this is recorded in the dictionary self.oneQgate_relations. If the 1-qubit gate with name name1 followed by the 1-qubit gate with name name2 multiple (up to phase) to the gate with name3, then self.oneQgate_relations[name1,`name2`] = name3.

2. If the inverse of any 1-qubit gate is contained in the model, this is recorded in the dictionary self.gate_inverse.

Returns:

  • gate_relations (dict) – Keys are (gatename1, gatename2) and values are either the gate name of the product of the two gates or None, signifying the identity.

  • gate_inverses (dict) – Keys and values are gate names, mapping a gate name to its inverse gate (if one exists).

compute_ops_on_qubits()#

Constructs a dictionary mapping tuples of state space labels to the operations available on them.

Returns:

A dictionary with keys that are state space label tuples and values that are lists of gate labels, giving the available gates on those target labels.

Return type:

dict

compute_ops_on_qudits()#

Constructs a dictionary mapping tuples of state space labels to the operations available on them.

Returns:

A dictionary with keys that are state space label tuples and values that are lists of gate labels, giving the available gates on those target labels.

Return type:

dict

dump(f, format='json', **format_kwargs)#

Serializes and writes this object to a given output stream.

Parameters:
  • f (file-like) – A writable output stream.

  • format ({'json', 'repr'}) – The format to write.

  • format_kwargs (dict, optional) – Additional arguments specific to the format being used. For example, the JSON format accepts indent as an argument because json.dump does.

Return type:

None

dumps(format='json', **format_kwargs)#

Serializes this object and returns it as a string.

Parameters:
  • format ({'json', 'repr'}) – The format to write.

  • format_kwargs (dict, optional) – Additional arguments specific to the format being used. For example, the JSON format accepts indent as an argument because json.dump does.

Return type:

str

force_recompute_gate_relationships()#

Invalidates LRU caches for all compute_* methods of this object, forcing them to recompute their values.

The compute_* methods of this processor spec compute various relationships and properties of its gates. These routines can be computationally intensive, and so their values are cached for performance. If the gates of a processor spec changes and its compute_* methods are used, force_recompute_gate_relationships should be called.

classmethod from_mongodb(mongodb, doc_id, **kwargs)#

Create and initialize an object from a MongoDB instance.

Parameters:
  • mongodb (pymongo.database.Database) – The MongoDB instance to load from.

  • doc_id (bson.objecctid.ObjectId or dict) – The object ID or filter used to find a single object ID within the database. This document is loaded from the collection given by the collection_name attribute of this class.

  • **kwargs (dict) – Additional keyword arguments potentially used by subclass implementations. Any arguments allowed by a subclass’s _create_obj_from_doc_and_mongodb method is allowed here.

Return type:

object

classmethod from_mongodb_doc(mongodb, collection_name, doc, **kwargs)#

Create and initialize an object from a MongoDB instance and pre-loaded primary document.

Parameters:
  • mongodb (pymongo.database.Database) – The MongoDB instance to load from.

  • collection_name (str) – The collection name within mongodb that doc was loaded from. This is needed for the sole purpose of setting the created (returned) object’s database “coordinates”.

  • doc (dict) – The already-retrieved main document for the object being loaded. This takes the place of giving an identifier for this object.

  • **kwargs (dict) – Additional keyword arguments potentially used by subclass implementations. Any arguments allowed by a subclass’s _create_obj_from_doc_and_mongodb method is allowed here.

Return type:

object

classmethod from_nice_serialization(state)#

Create and initialize an object from a “nice” serialization.

A “nice” serialization here means one created by a prior call to to_nice_serialization using this class or a subclass of it. Nice serializations adhere to additional rules (e.g. that dictionary keys must be strings) that make them amenable to common file formats (e.g. JSON).

The state argument is typically a dictionary containing ‘module’ and ‘state’ keys specifying the type of object that should be created. This type must be this class or a subclass of it.

Parameters:

state (object) – An object, usually a dictionary, representing the object to de-serialize.

Return type:

object

gate_num_qubits(gate_name)#

The number of qubits that a given gate acts upon.

Parameters:

gate_name (str) – The name of the gate.

Return type:

int

gate_num_qudits(gate_name)#

The number of qudits that a given gate acts upon.

Parameters:

gate_name (str) – The name of the gate.

Return type:

int

instrument_specifier(name)#

The specifier for a given instrument name.

The returned value specifies an instrument in one of several ways. It can either be a string identifying a standard instrument (like “Iz”), or a dictionary with values that are lists/tuples of 2-tuples describing each instrument member as the sum of rank-1 process matrices. Each 2-tuple element can be a string describing a standard state or a complex array describing an arbitrary pure state.

Parameters:

name (str) – The name of the state preparation to access.

Return type:

str or dict

is_available(gate_label)#

Check whether a gate at a given location is available.

Parameters:

gate_label (Label) – The gate name and target labels to check availability of.

Return type:

bool

classmethod load(f, format='json')#

Load an object of this type, or a subclass of this type, from an input stream.

Parameters:
  • f (file-like) – An open input stream to read from.

  • format ({'json'}) – The format of the input stream data.

Return type:

NicelySerializable

classmethod loads(s, format='json')#

Load an object of this type, or a subclass of this type, from a string.

Parameters:
  • s (str) – The serialized object.

  • format ({'json'}) – The format of the string data.

Return type:

NicelySerializable

map_qubit_labels(mapper)#

Creates a new QubitProcessorSpec whose qubit labels are updated according to the mapping function mapper.

Parameters:

mapper (dict or function) – A dictionary whose keys are the existing self.qubit_labels values and whose value are the new labels, or a function which takes a single (existing qubit-label) argument and returns a new qubit label.

Return type:

QubitProcessorSpec

map_qudit_labels(mapper)#

Creates a new QuditProcessorSpec whose qudit labels are updated according to the mapping function mapper.

Parameters:

mapper (dict or function) – A dictionary whose keys are the existing self.qudit_labels values and whose value are the new labels, or a function which takes a single (existing qudit-label) argument and returns a new qudit label.

Return type:

QuditProcessorSpec

povm_specifier(name)#

The specifier for a given POVM name.

The returned value specifies a POVM in one of several ways. It can either be a string identifying a standard POVM (like “Mz”), or a dictionary with values describing the pure states that each element of the POVM projects onto. Each value can be either a string describing a standard state or a complex array.

Parameters:

name (str) – The name of the POVM to access.

Return type:

str or numpy.ndarray

prep_specifier(name)#

The specifier for a given state preparation name.

The returned value specifies a state in one of several ways. It can either be a string identifying a standard state preparation (like “rho0”), or a complex array describing a pure state.

Parameters:

name (str) – The name of the state preparation to access.

Return type:

str or numpy.ndarray

classmethod read(path, format=None)#

Read an object of this type, or a subclass of this type, from a file.

Parameters:
  • path (str or Path or file-like) – The filename to open or an already open input stream.

  • format ({'json', None}) – The format of the file. If None this is determined automatically by the filename extension of a given path.

Return type:

NicelySerializable

classmethod remove_from_mongodb(mongodb, doc_id, collection_name=None, session=None, recursive='default')#

Remove the documents corresponding to an instance of this class from a MongoDB database.

Parameters:
  • mongodb (pymongo.database.Database) – The MongoDB instance to remove documents from.

  • doc_id (bson.objectid.ObjectId) – The identifier of the root document stored in the database.

  • collection_name (str, optional) – the MongoDB collection within mongodb where the main document resides. If None, then <this_class>.collection_name is used (which is usually what you want).

  • session (pymongo.client_session.ClientSession, optional) – MongoDB session object to use when interacting with the MongoDB database. This can be used to implement transactions among other things.

  • recursive (RecursiveRemovalSpecification, optional) – An object that filters the type of documents that are removed. Used when working with inter-related experiment designs, data, and results objects to only remove the types of documents you know aren’t being shared with other documents.

Return type:

None

rename_gate_inplace(existing_gate_name, new_gate_name)#

Renames a gate within this processor specification.

Parameters:
  • existing_gate_name (str) – The existing gate name you want to change.

  • new_gate_name (str) – The new gate name.

Return type:

None

resolved_availability(gate_name, tuple_or_function='auto')#

The availability of a given gate, resolved as either a tuple of sslbl-tuples or a function.

This function does more than just access the availability attribute, as this may hold special values like “all-edges”. It takes the value of self.availability[gate_name] and resolves and converts it into the desired format: either a tuple of state-space labels or a function with a single state-space-labels-tuple argument.

Parameters:
  • gate_name (str) – The gate name to get the availability of.

  • tuple_or_function ({'tuple', 'function', 'auto'}) – The type of object to return. ‘tuple’ means a tuple of state space label tuples, e.g. ((0,1), (1,2)). ‘function’ means a function that takes a single state space label tuple argument and returns True or False to indicate whether the gate is available on the given target labels. If ‘auto’ is given, then either a tuple or function is returned - whichever is more computationally convenient.

Return type:

tuple or function

subset(gate_names_to_include='all', qubit_labels_to_keep='all')#

Construct a smaller processor specification by keeping only a select set of gates from this processor spec.

Parameters:

gate_names_to_include (list or tuple or set) – The gate names that should be included in the returned processor spec.

Return type:

QubitProcessorSpec

to_nice_serialization()#

Serialize this object in a way that adheres to “niceness” rules of common text file formats.

Returns:

Usually a dictionary representing the serialized object, but may also be another native Python type, e.g. a string or list.

Return type:

object

write(path, **format_kwargs)#

Writes this object to a file.

Parameters:
  • path (str or Path) – The name of the file that is written.

  • format_kwargs (dict, optional) – Additional arguments specific to the format being used. For example, the JSON format accepts indent as an argument because json.dump does.

Return type:

None

write_to_mongodb(mongodb, session=None, overwrite_existing=False, **kwargs)#

Write this object to a MongoDB database.

The collection name used is self.collection_name, and the _id is either: 1) the ID used by a previous write or initial read-in, if one exists, OR 2) a new random bson.objectid.ObjectId

Parameters:
  • mongodb (pymongo.database.Database) – The MongoDB instance to write data to.

  • session (pymongo.client_session.ClientSession, optional) – MongoDB session object to use when interacting with the MongoDB database. This can be used to implement transactions among other things.

  • overwrite_existing (bool, optional) – Whether existing documents should be overwritten. The default of False causes a ValueError to be raised if a document with the given _id already exists and is different from what is being written.

  • **kwargs (dict) – Additional keyword arguments potentially used by subclass implementations. Any arguments allowed by a subclass’s _add_auxiliary_write_ops_and_update_doc method is allowed here.

Returns:

The identifier (_id value) of the main document that was written.

Return type:

bson.objectid.ObjectId

property global_idle_gate_name#

The (first) gate name that corresponds to a global idle operation.

property global_idle_layer_label#

Similar to global_idle_gate_name but include the appropriate sslbls (either None or all the qudits)

property idle_gate_names#

The gate names that correspond to idle operations.

property num_qubits#

The number of qudits.

property num_qudits#

The number of qudits.

property primitive_op_labels#

All the primitive operation labels derived from the gate names and availabilities

property qubit_graph#

The qubit graph (geometry).

property qubit_labels#

The qubit labels.