pyqonvert.noise.NoiseInserter
- class pyqonvert.noise.NoiseInserter(mode)
Provides functionality to insert noise Pragma operations into a circuit based on a given device.
Based on the information about the noise model for a specific device noise Pragma operations (PragmaNoiseOperation) can be placed in a Circuit to include the noise model in the circuit description.
The added noise is determined from the gate time obtained from a device and the qubit noise rates.
There are three modes of insertions (or in other words noise models) availables:
all_qubits - The noise model adds noise on all qubits that are involved in the whole Circuit after each gate operation
active_qubits_only - The noise model only adds noise on the qubits that are actively involved in the gate operation after each operation.
parallelization_blocks - The noise model only noise on all qubits that that are involved in the whole Circuit after each parallelization block marked by PragmaStopParallelBlock.
A noise inserter using each mode can be created using the corresponding methods all_qubits, active_qubits_only and parallelization_blocks.
Usually noise can be inserted with the insert_noise method providing Circuit and Device references.
- __init__()
Methods
__init__()add_noise_active_qubits(circuit, device, ...)Add noise Pragmas after gate operations based on device properties.
add_noise_all_qubits(circuit, device, ...)Add noise Pragmas after gate operations based on device properties.
add_noise_parallelization_blocks(circuit, ...)Add noise Pragmas after gate operations based on device properties.
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.
insert_noise(circuit, device)Inserts noise Pragmas (PragmaNoiseOperation) in circuit.
Insert noise Pragmas (PragmaNoiseOperation) in QuantumProgram.
Return the JsonSchema for the json serialisation of the class.
Return the minimum version of pyqonvert that supports this object.
Set placement of noise Pragmas to after gate.
Set placement of noise Pragmas to before gate.
Set placement of noise Pragmas to symmetric around gate.
Return the bincode representation of the Converter using the [bincode] crate.
to_json()Return the json representation of the Converter.
- add_noise_active_qubits(circuit, device, noise_models)
Add noise Pragmas after gate operations based on device properties.
Adds noise Pragmas (PragmaNoiseOperation) after each gate operation in a Circuit. The added noise is determined from the gate time obtained from a device and the qubit noise rates. The noise model here only adds noise on the qubits that are actively involved in the gate operation.
- Parameters:
circuit (Circuit) -- The circuit prividing the gate operations that determine the inserted Pragmas.
device (GenericDevice) -- The device providing the noise model.
noise_models (List[NoiseModel]) -- Noise models determining noise properties. Not used in conversions without noise.
- Returns:
- The Circuit with inserted PragmaNoiseOperations and the total
execution time.
- Return type:
(Circuit, float)
- Raises:
ValueError -- Could not convert inputs from Python.
ValueError -- Could not insert noise Pragmas.
- add_noise_all_qubits(circuit, device, noise_models)
Add noise Pragmas after gate operations based on device properties.
Adds noise Pragmas (PragmaNoiseOperation) after each gate operation in a Circuit. The added noise is determined from the gate time obtained from a device and the qubit noise rates. The noise model here adds noise on all qubits that are involved in the whole Circuit.
- Parameters:
circuit (Circuit) -- The circuit prividing the gate operations that determine the inserted Pragmas.
device (GenericDevice) -- The device providing the noise model.
noise_models (List[NoiseModel]) -- Noise models determining noise properties. Not used in conversions without noise.
- Returns:
- The Circuit with inserted PragmaNoiseOperations and the total
execution time.
- Return type:
(Circuit, float)
- Raises:
ValueError -- Could not convert inputs from Python.
ValueError -- Could not insert noise Pragmas.
- add_noise_parallelization_blocks(circuit, device, noise_models)
Add noise Pragmas after gate operations based on device properties.
Adds noise Pragmas (PragmaNoiseOperation) after each gate operation in a Circuit. The added noise is determined from the gate time obtained from a device and the qubit noise rates. The noise model here adds noise on all qubits that are involved in the whole Circuit after each parallelization block marked by PragmaStopParallelBlock.
- Parameters:
circuit (Circuit) -- The circuit prividing the gate operations that determine the inserted Pragmas.
device (GenericDevice) -- The device providing the noise model.
noise_models (List[NoiseModel]) -- Noise models determining noise properties. Not used in conversions without noise.
- Returns:
- The Circuit with inserted PragmaNoiseOperations and the total
execution time.
- Return type:
(Circuit, float)
- Raises:
ValueError -- Could not convert inputs from Python.
ValueError -- Could not insert noise Pragmas.
- convert(conversion_input, device, noise_models)
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:
ValueError -- Could not convert inputs from Python.
ValueError -- Could not insert noise Pragmas.
- 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.
- insert_noise(circuit, device)
Inserts noise Pragmas (PragmaNoiseOperation) in circuit.
The noise model or mode of insertion is determined by the mode set in the NoiseInserter. The original circuit is not modified but a new circuit with additional Pragmas is returned.
- Parameters:
circuit (Circuit) -- The circuit prividing the gate operations that determine the inserted Pragmas.
device (GenericDevice) -- The device providing the noise model.
- Returns:
The Circuit with inserted PragmaNoiseOperations.
- Return type:
Circuit
- insert_noise_quantum_program(quantum_program, device)
Insert noise Pragmas (PragmaNoiseOperation) in QuantumProgram.
The noise model or mode of insertion is determined by the mode set in the NoiseInserter. The original circuit is not modified but a new circuit with additional Pragmas is returned.
- Parameters:
quantum_program (QuantumProgram) -- The QuantumProgram containing the Circuit providing the gate operations that determine the inserted Pragmas.
device (GenericDevice) -- The device providing the noise model.
- Returns:
with inserted PragmaNoiseOperation.
- Return type:
QuantumProgram
- Raises:
ValueError -- Could not convert inputs from Python.
ValueError -- Could not insert noise Pragmas.
- 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
- noise_after_gate()
Set placement of noise Pragmas to after gate.
- Returns:
with After placement mode.
- Return type:
- noise_before_gate()
Set placement of noise Pragmas to before gate.
- Returns:
with Before placement mode.
- Return type:
- noise_symmetric_around_gate()
Set placement of noise Pragmas to symmetric around gate.
- Returns:
with Symmetric placement mode.
- Return type:
- 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.