pyqonvert.decompositions

Two- and single-qubit decompisitions.

single_qubit_gate_decomposition(circuit, device)

Perform the single-qubit gate decomposition of a given Circuit to the gates that are executable on the given Device.

single_qubit_decomposition_quantum_program(...)

Perform the single-qubit gate decomposition of a given QuantumProgram to the gates that are executable on the given Device.

two_qubit_gate_decomposition(circuit, device)

Perform the two-qubit gate decomposition of a given Circuit to the gates that are executable on the given Device.

two_qubit_decomposition_quantum_program(...)

Perform the two-qubit gate decomposition of a given QuantumProgram to the gates that are executable on the given Device.

Functions

single_qubit_decomposition_quantum_program(...)

Perform the single-qubit gate decomposition of a given QuantumProgram to the gates that are executable on the given Device.

single_qubit_gate_decomposition(circuit, device)

Perform the single-qubit gate decomposition of a given Circuit to the gates that are executable on the given Device.

two_qubit_decomposition_quantum_program(...)

Perform the two-qubit gate decomposition of a given QuantumProgram to the gates that are executable on the given Device.

two_qubit_gate_decomposition(circuit, device)

Perform the two-qubit gate decomposition of a given Circuit to the gates that are executable on the given Device.

Classes

SingleQubitGateDecomposer()

Converter that decomposes general single-qubit gates to native gates.

TwoQubitGateDecomposer()

Converter that decomposes general two-qubit gates to native gates.

class pyqonvert.decompositions.SingleQubitGateDecomposer

Converter that decomposes general single-qubit gates to native gates.

The SingleQubitGateDecomposer can decompose a single-qubit operation into the following sets of gates: * ["GPi"] * ["GPi2"] * ["GPi2", "RotateZ"] * ["PauliX"] * ["PhaseShiftState1"] * ["PhaseShiftState1", "RotateX"] * ["RotateX"] * ["RotateXY"] * ["RotateY"] * ["RotateX", "RotateY"] * ["RotateZ"] * ["RotateZ", "PauliX"] * ["RotateZ", "RotateAroundSphericalAxis"] * ["RotateZ", "RotateX"] * ["RotateZ", "RotateXY"] * ["RotateZ", "RotateY"] * ["RotateZ", "SqrtPauliX", "InvSqrtPauliX"] * ["RotateZ", "SqrtPauliX"] * ["RotateZ", "SqrtPauliY", "InvSqrtPauliY"] * ["SqrtPauliX"] * ["SqrtPauliY"]

Note that not all gates can be decomposed into each of these gate sets.

convert(conversion_input, device, noise_models=None)

Convert Circuits or QuantumPrograms for decomposition, optimization and adding noise.

Parameters:
  • conversion_input -- Circuit or QuantumProgram to be converted.

  • device (Device) -- determines connectivity and gate times.

  • noise_models (List[NoiseModel]) -- Noise models determining noise properties. Not used in conversions without noise.

Returns:

Output of converted Circuit when input is a Circuit. QuantumProgram: Output of converted QuantumProgram when input is a QuantumProgram.

Return type:

Circuit

Raises:
  • RuntimeError -- Error occured in the decomposition.

  • ValueError -- Could not convert inputs from Python.

static current_version()

Returns the current version of the pyqonvert library .

Returns:

The current version of the library.

Return type:

str

static from_bincode(input)

Convert the bincode representation of the Converter to a Converter using the [bincode] crate.

Parameters:

input (ByteArray) -- The serialized Converter (in [bincode] form).

Returns:

The deserialized Converter.

Return type:

Converter

Raises:
  • TypeError -- Input cannot be converted to byte array.

  • ValueError -- Input cannot be deserialized to Converter.

static from_json(json_string)

Convert the json representation of a Converter to a Converter.

Parameters:

input (str) -- The serialized Converter in json form.

Returns:

The deserialized Converter.

Return type:

Converter

Raises:

ValueError -- Input cannot be deserialized to Converter.

static json_schema()

Return the JsonSchema for the json serialisation of the class.

Returns:

The json schema serialized to json

Return type:

str

min_supported_version()

Return the minimum version of pyqonvert that supports this object.

Returns:

The minimum version of the pyqonvert library to deserialize this object.

Return type:

str

to_bincode()

Return the bincode representation of the Converter using the [bincode] crate.

Returns:

The serialized Converter (in [bincode] form).

Return type:

ByteArray

Raises:

ValueError -- Cannot serialize Converter to bytes.

to_json()

Return the json representation of the Converter.

Returns:

The serialized form of Converter.

Return type:

str

Raises:

ValueError -- Cannot serialize Converter to json.

class pyqonvert.decompositions.TwoQubitGateDecomposer

Converter that decomposes general two-qubit gates to native gates.

The TwoQubitGateDecomposer can decompose a two-qubit operation into the following sets of gates: * ["CNOT"] * ["ControlledPhaseShift"] * ["ControlledPauliZ"] * ["MolmerSorensenXX"] * ["PhaseShiftedControlledZ"] * ["VariableMSXX"]

Note that not all gates can be decomposed into each of these gate sets.

convert(conversion_input, device, noise_models=None)

Convert Circuits or QuantumPrograms for decomposition, optimization and adding noise.

Parameters:
  • conversion_input -- Circuit or QuantumProgram to be converted.

  • device (Device) -- determines connectivity and gate times.

  • noise_models (List[NoiseModel]) -- Noise models determining noise properties. Not used in conversions without noise.

Returns:

Output of converted Circuit when input is a Circuit. QuantumProgram: Output of converted QuantumProgram when input is a QuantumProgram.

Return type:

Circuit

Raises:
  • RuntimeError -- Error occured in the decomposition.

  • ValueError -- Could not convert inputs from Python.

static current_version()

Returns the current version of the pyqonvert library .

Returns:

The current version of the library.

Return type:

str

static from_bincode(input)

Convert the bincode representation of the Converter to a Converter using the [bincode] crate.

Parameters:

input (ByteArray) -- The serialized Converter (in [bincode] form).

Returns:

The deserialized Converter.

Return type:

Converter

Raises:
  • TypeError -- Input cannot be converted to byte array.

  • ValueError -- Input cannot be deserialized to Converter.

static from_json(json_string)

Convert the json representation of a Converter to a Converter.

Parameters:

input (str) -- The serialized Converter in json form.

Returns:

The deserialized Converter.

Return type:

Converter

Raises:

ValueError -- Input cannot be deserialized to Converter.

static json_schema()

Return the JsonSchema for the json serialisation of the class.

Returns:

The json schema serialized to json

Return type:

str

min_supported_version()

Return the minimum version of pyqonvert that supports this object.

Returns:

The minimum version of the pyqonvert library to deserialize this object.

Return type:

str

to_bincode()

Return the bincode representation of the Converter using the [bincode] crate.

Returns:

The serialized Converter (in [bincode] form).

Return type:

ByteArray

Raises:

ValueError -- Cannot serialize Converter to bytes.

to_json()

Return the json representation of the Converter.

Returns:

The serialized form of Converter.

Return type:

str

Raises:

ValueError -- Cannot serialize Converter to json.

pyqonvert.decompositions.single_qubit_decomposition_quantum_program(quantum_program, device)

Perform the single-qubit gate decomposition of a given QuantumProgram to the gates that are executable on the given Device.

Parameters:
  • quantum_program (QuantumProgram) -- The QuantumProgram to be decomposed.

  • device (AllToAllDevice) -- The Device containing the native gate set information.

Returns:

with the Circuit decomposed into the gates that can be executed on the Device.

Return type:

QuantumProgram

Raises:
  • RuntimeError -- Error occured in the decomposition.

  • ValueError -- Could not convert inputs from Python.

pyqonvert.decompositions.single_qubit_gate_decomposition(circuit, device)

Perform the single-qubit gate decomposition of a given Circuit to the gates that are executable on the given Device.

Parameters:
  • circuit (Circuit) -- The Circuit to be decomposed.

  • device (AllToAllDevice) -- The Device containing the native gate set information.

Returns:

decomposed into the gates that can be executed on the Device.

Return type:

Circuit

Raises:
  • RuntimeError -- Error occured in the decomposition.

  • ValueError -- Could not convert inputs from Python.

pyqonvert.decompositions.two_qubit_decomposition_quantum_program(quantum_program, device)

Perform the two-qubit gate decomposition of a given QuantumProgram to the gates that are executable on the given Device.

Parameters:
  • quantum_program (QuantumProgram) -- The QuantumProgram to be decomposed.

  • device (AllToAllDevice) -- The Device containing the native gate set information.

Returns:

with the Circuit decomposed into the gates that can be executed on the Device.

Return type:

QuantumProgram

Raises:
  • RuntimeError -- Error occured in the decomposition.

  • ValueError -- Could not convert inputs from Python.

pyqonvert.decompositions.two_qubit_gate_decomposition(circuit, device)

Perform the two-qubit gate decomposition of a given Circuit to the gates that are executable on the given Device.

Parameters:
  • circuit (Circuit) -- The Circuit to be decomposed.

  • device (AllToAllDevice) -- The Device containing the native gate set information.

Returns:

decomposed into the gates that can be executed on the Device.

Return type:

Circuit

Raises:
  • RuntimeError -- Error occured in the decomposition.

  • ValueError -- Could not convert inputs from Python.