OperatorRepr
- class pulser.backend.OperatorRepr
Bases:
OperatorDefine a backend-independent quantum operator representation.
Allows the user to define a quantum operator with the dedicated class method from_operator_repr, which requires:
eigenstates: The basis states (e.g., (‘r’, ‘g’)).
n_qudits: Number of qudits in the system.
operations: A sequence of tuples weight, tensor operators on each qudit, as described in from_operator_repr.
The created operator, supports de/serialization methods for remote backend execution.
Examples
>>> eigenstates = ("r", "g") >>> n_qudits = 4 >>> # define X,Y,Z >>> X = {"gr": 1.0, "rg": 1.0} >>> Y = {"gr": 1.0j, "rg": -1.0j} >>> Z = {"rr": 1.0, "gg": -1.0} >>> # build for example 0.5*X0Y1X2Z3 >>> operations = [ >>> ( >>> 0.5, >>> [ >>> (X, [0, 2]), # acts on qudit 0 and 2 >>> (Y, [1]), >>> (Z, [3]), >>> ], >>> ) >>> ] >>> op = OperatorRepr.from_operator_repr( >>> eigenstates=eigenstates, >>> n_qudits=n_qudits, >>> operations=operations >>> )
Methods
apply_tonot implemented inOperatorRepr.expectnot implemented inOperatorRepr.Create an operator from the operator representation.
Signatures
- apply_to(state, /)
apply_tonot implemented inOperatorRepr.- Return type:
TypeVar(StateType, bound=State)
- expect(state, /)
expectnot implemented inOperatorRepr.- Return type:
None
- classmethod from_operator_repr(*, eigenstates, n_qudits, operations)
Create an operator from the operator representation.
Only operators constructed with this method are allowed in remote backend.
The full operator representation (
FullOp) is a weigthed sum of tensor operators (TensorOp), written as a sequence of coefficient and tensor operator pairs, ieFullOp = Sequence[tuple[ScalarType, TensorOp]]Each
TensorOpis itself a sequence of qudit operators (QuditOp) applied to mutually exclusive sets of qudits (represented by their indices), ieTensorOp = Sequence[tuple[QuditOp, Collection[int]]]Qudits without an associated
QuditOpare applied the identity operator.Finally, each
QuditOpis represented as weighted sum of pre-defined single-qudit operators. It is given as a mapping between a string representation of the single-qudit operator and its respective coefficient, ieQuditOp = Mapping[str, ScalarType]By default, it identifies strings
"ij"as single-qudit operators, whereiandjare eigenstates that denote|i><j|.- Parameters:
eigenstates (
Sequence[Literal['u','d','r','g','h','x'] |Literal['0','1']]) – The eigenstates to use.n_qudits (
int) – How many qudits there are in the system.operations (
Sequence[tuple[TypeVar(ArgScalarType),Sequence[tuple[Mapping[str,TypeVar(ArgScalarType)],Collection[int]]]]]) – The full operator representation.
- Return type:
TypeVar(OperatorType, bound= Operator)- Returns:
The constructed operator.