parity_mapping

Tools to connect to the ParityOS cloud services and to process the results.

class parityos.encodings.parity_mapping.SourceQubitT

A TypeVar representing source qubits.

alias of TypeVar(‘SourceQubitT’, bound=Qubit)

class parityos.encodings.parity_mapping.TargetQubitT

A TypeVar representing target qubits.

alias of TypeVar(‘TargetQubitT’, bound=Qubit)

class parityos.encodings.parity_mapping.PhysicalQubitT

A TypeVar representing physical qubits.

alias of TypeVar(‘PhysicalQubitT’, bound=Qubit)

class parityos.encodings.parity_mapping.LogicalQubitT

A TypeVar representing logical qubits.

alias of TypeVar(‘LogicalQubitT’, bound=Qubit)

class parityos.encodings.parity_mapping.OperatorMap

Bases: Generic[SourceQubitT, TargetQubitT], ABC

Operator map that maps a source to a target operator product with a parity which acts as a sign.

target_product: OperatorProduct[Z[TargetQubitT]]

Target OperatorProduct of Z operators.

parity: Parity = False

The parity of this OperatorMap. Defaults to Parity.even.

abstract property source_product: OperatorProduct[Z[SourceQubitT]]

The source of the operator map.

Returns:

The source of the operator map as an OperatorProduct of Z operators.

property target_operators: frozenset[Z[TargetQubitT]]

The set of target operators the source_product maps to.

property target_qubits: frozenset[TargetQubitT]

The set of qubits the target_product acts on.

property source_operators: frozenset[Z[SourceQubitT]]

The set of source operators that get mapped onto target_product.

property source_qubits: frozenset[SourceQubitT]

The set of qubits the source_product acts on.

class parityos.encodings.parity_mapping.ProductToProduct(source_product: OperatorProduct[Z[SourceQubitT]], target_product: OperatorProduct[Z[TargetQubitT]], parity: Parity = Parity.even)

Bases: OperatorMap[SourceQubitT, TargetQubitT]

Map from an operator product to an operator product with a parity acting as a sign.

source_product: OperatorProduct[Z[SourceQubitT]]

Source OperatorProduct.

target_product: OperatorProduct[Z[TargetQubitT]]

Target OperatorProduct.

parity: Parity

The map’s parity. Defaults to Parity.even.

class parityos.encodings.parity_mapping.OperatorToProduct(source_operator: Z[SourceQubitT], target_product: OperatorProduct[Z[TargetQubitT]], parity: Parity = Parity.even)

Bases: OperatorMap[SourceQubitT, TargetQubitT]

Map from a single operator to an operator product with a parity acting as a sign.

source_operator: Z[SourceQubitT]

Source Z operator.

target_product: OperatorProduct[Z[TargetQubitT]]

Target OperatorProduct of Z operators.

parity: Parity

The map’s parity. Defaults to Parity.even.

source_product: OperatorProduct[Z[SourceQubitT]]
class parityos.encodings.parity_mapping.ParityMapping(encoding_map: OperatorToProduct[PhysicalQubitT, LogicalQubitT] | Iterable[OperatorToProduct[PhysicalQubitT, LogicalQubitT]], decoding_map: OperatorToProduct[PhysicalQubitT, LogicalQubitT] | Iterable[OperatorToProduct[PhysicalQubitT, LogicalQubitT]], constraints: ProductConstraint[PhysicalQubitT] | Iterable[ProductConstraint[PhysicalQubitT]], partial_encoding_terms: ProductToProduct[PhysicalQubitT, LogicalQubitT] | Iterable[ProductToProduct[PhysicalQubitT, LogicalQubitT]] = NOTHING)

Bases: Generic[LogicalQubitT, PhysicalQubitT]

Holds the Parity Architecture encoding and decoding maps.

In case of a partial parity mapping, there will be higher-order terms in an encoded Hamiltonian. Here these terms can be given as a ProductToProduct map in partial_encoding_terms.

encoding_map: frozenset[OperatorToProduct[PhysicalQubitT, LogicalQubitT]]

Encoding map as a frozenset of pairs. Specifies for each physical qubit, which logical qubits it encodes.

decoding_map: frozenset[OperatorToProduct[LogicalQubitT, PhysicalQubitT]]

Decoding map as a frozenset of pairs. Specifies for each logical qubit, which physical qubits multiply to it

constraints: frozenset[ProductConstraint[PhysicalQubitT]]

Specific set of constraints that can be implemented on the device to implement the specified encoding/decoding maps.

partial_encoding_terms: frozenset[ProductToProduct[PhysicalQubitT, LogicalQubitT]]

Higher-order mapping terms in case of a partial parity mapping. Optional.

logical_qubits: frozenset[LogicalQubitT]

Logical qubits.

The qubits as specified in the original problem.

physical_qubits: frozenset[PhysicalQubitT]

Physical qubits.

The qubits as specified in the compiled problem.

constrained_qubits: frozenset[PhysicalQubitT]

Physical qubits that are in constraints.

unconstrained_qubits: frozenset[PhysicalQubitT]

Physical qubits that are not in any constraint.

encode_state(state: PauliBasisState[LogicalQubitT, Z[Never]]) PauliBasisState[PhysicalQubitT, Z[Never]]

Convert a given state in the logical system to a state in the encoded physical system.

Parameters:

state – Logical state to encode.

Returns:

Encoded state in the physical qubits.

encode_problem(problem: ProblemRepresentation[LogicalQubitT]) ProblemRepresentation[PhysicalQubitT]

Convert a logical problem to a compiled problem encoded in the physical system.

Parameters:

problem – Logical input problem.

Returns:

Compiled problem encoded in terms of physical qubits.

encode_polynomial(polynomial: OperatorPolynomial[Z[LogicalQubitT]]) OperatorPolynomial[Z[PhysicalQubitT]]

Map a polynomial of Z operators in the logical system to a new polynomial in terms of Z operators in the encoded physical system using the encoding map.

Parameters:

polynomial – Operator polynomial of Z operator terms to encode.

Returns:

Encoded polynomial.