pyqonvert.optimization.VirtualZGateReplacement

class pyqonvert.optimization.VirtualZGateReplacement

Converter that applies virtual Z gate optimization.

On platforms where the RotateXY gate is available and the natural two-qubit gate is diagonal in the Z-basis, it is possible to replace RotateZ gates by virtual changes (rotations) of the qubit basis in the XY-Plane. This is what we implement here.

This is also referred to as VirtualRotateZ gates optimisation in the literature.

__init__()

Methods

__init__()

apply_final_rotz(apply_final_rotz)

Change whether the VirtualZGateReplacement applies RotateZ gates at the end of the circuit.

convert(conversion_input, device[, noise_models])

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

current_version()

Returns the current version of the pyqonvert library .

from_bincode(input)

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

from_json(json_string)

Convert the json representation of a Converter to a Converter.

json_schema()

Return the JsonSchema for the json serialisation of the class.

min_supported_version()

Return the minimum version of pyqonvert that supports this object.

to_bincode()

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

to_json()

Return the json representation of the Converter.

apply_final_rotz(apply_final_rotz)

Change whether the VirtualZGateReplacement applies RotateZ gates at the end of the circuit.

When true, at the end of the circuit, the changes in the qubit basis that have been picked up during the circuit will be undone with RotateZ`gates. This is not necessary when the qubits are measured immediately afterwards. The `apply_final_rotz parameter only affects conversions of Circuits, not QuantumPrograms.

Parameters:

apply_final_rotz (bool) -- Whether to apply RotateZ gates at the end of a Circuit.

Returns:

self instance with modified apply_final_rotz boolean.

Return type:

Self

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 conversion of the inputs.

  • ValueError -- Error in the VirtualZGateReplacement optimisation.

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.