pyqonvert.routing.SingleOperationSwapRouter
- class pyqonvert.routing.SingleOperationSwapRouter(swap_back, only_before_decomposition)
Converter that inserts SWAP operations in Circuit to enable operations on limited connectivity.
Noise mapping becomes difficult when circuit operations are remapped inside a Decomposition block. On the other hand swapping back after routing for each single operation is highly inefficient.
Often the majority of Decomposition blocks only involve one or two qubit operations. To save the amount of SWAPS and enable remapping without breaking noise mapping, the SWAPS can be inserted only before decomposition blocks that invovle one and two qubits and remapping all following operations. This is activated with the only_before_decomposition option. With this option the SWAPS will also be inserted as decomposition blocks which is necessary for noise mapping when the SWAPS occur between decomposition blocks.
Note that this can not route all operations in the Circuit (especially decomposition blocks involving more qubits in the first place). For full routing a second pass with swap_back=true is necessary.
- __init__()
Methods
__init__()convert(conversion_input, device[, noise_models])Convert Circuits or QuantumPrograms for decomposition, optimization and adding noise.
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.
Return the JsonSchema for the json serialisation of the class.
Return the minimum version of pyqonvert that supports this object.
Return the bincode representation of the Converter using the [bincode] crate.
to_json()Return the json representation of the Converter.
- 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. --
- 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.