Pauli Class #66
dsvandet
started this conversation in
Project Notes
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
These notes are related to the Pauli class representing a Pauli Operators from the quantum_info modulo of qiskit-terra
These notes are in regards to satisfying the following requirement:
Location of Code
Currently these changes are staged at dsvandet/qiskit-terra/tree/paulilist_representations.
Modifications and additions to
Pauli
classMoved
_from_label
,_split_pauli_label
,_phase_from_complex
functions to the PauliRep class with some functions being updated to be more general etc. See PauliRep Class notes. PauliRep is now a base class of BasePauliRemoved _VALID_LABEL_PATTERN as no longer need here. A more general method can be found in PauliRep class. See PauliRep Class notes.
Added input variable to
__init__
method:input_qubit_order
with default value of"right-to-left"
. This flag controls the order in which input string representations are indexed for qubits. The internal order is not changed. The option"right-to-left"
reads a Pauli strings right to left. For example: the Pauli string"XZY"
would haveY
on qubit 0,Z
on qubit 1 andX
and qubit 2. Where as the value "left-to-right" option reads Pauli strings left to right. For example: the Pauli string"XZY"
would haveX
on qubit 0,Z
on qubit 1 andY
on qubit 2. The flag only has an effect on product string representations and not index representations.Added a new ability to use
QubitMaps
to access elements of a Pauli via labels defined in those Maps. For example ifP=Pauli("iXYZ")
then normallyP[0]
will return the Pauli attached to qubit 0 - soZ
in this example. If aQubitMap
is registered with the Pauli (instance or class) and is assigned/activated then a different indexing can be used based on that Map. For example: Consider theQubitMap
that has(0,0)->0, (0,1)->1, (1,0)->2
and(1,1)->3
. Then for the PauliP=Pauli("XYZI")
we would haveP[(0,1)]=Z
etc. See TranslationMap section below for more detailsTranslationMaps
For details on TranslationMap classes see Translation Classes
The
Pauli
andPauliLIst
class labels the quibts/Paulis as 0,1,2,... up tonum_qubits-1
/num_paulis-1
. The the__getitem__
method is set so that subelements are accessed via this index. For example ifP=Pauli("XZY")
thenP[0]=Y
and ifL=PauliList("ZYXI", "XXYZ")
thenP[0] = Pauli("ZYXI")
.It is often useful to be able to label and access these quits using different labels. This is done with the aid of
QubitMap
instance. A QubitMap is a specificTranslationMap
that maps labels into non-negative integers. To use aQubitMap
with aPauli
orPauliList
instance a map needs to be registered and then activated/assigned to the__getitem__
and/or__call__
methods.A
QubitMap
may be registered with either the instance or the class. If a map is registered with an instance then only that instance can use that map. If the map is registered with the class (say Pauli class for example) then any instance of that class (herePauli
instances) may use that map. A map can be registered with none, either or both class and instance. Registration is done using either of the following the registration methods:At the moment the individual registration methods are semi-private but this is easily changed. The override switch allows one to overwrite a map with the same identifier. If no identifier is provided then one will be automatically generated. To use a registered map the map needs to be activated or assigned. This is done with the following methods:
If no maps are to be used then the
use_no_map()
method can be used. You can check to see if a map is registered, with a given identifier, using one of the following methods:Examples:
See the TranslationMap Classes discussion for more examples and details TranslationMaps
The registered maps are stored in a dictionaries. These dictionaries can be accessed via the
class_map_dict()
andinstance_map_dict()
methods.The use of
QubitMap
s is done by changing the__getitem__
and__call__
methods. The__getitem__
method returns the__instance_getitem__
method which is either set to return the__getitem_map__
method or the__getitem_nomap__
method. The__instance_getitem__
method uses the QubitMap to translate the map labels or indices to the internal labels/indices. These translated labels are pass to the__getitem_nomap__
method. If noQubitMap
is being used then the__instance_getitem__
method simply returns the__getitem_nomap__
method.The
__call__
method will use to function method within theQubitMap
if one is present. The__getitem__
method on the other hand will use what ever method is configured within theQubitMap
.TODO: Currently the registration methods etc are coded into the
Pauli
class. We also need this for thePauliList
Class and a map may need to be useable in bothPauli
andPauliList
classes. Therefore we should move this capability to the BasePauli Class or some other class that can be used my other classes.Beta Was this translation helpful? Give feedback.
All reactions