qiskit.providers.aer.noise.QuantumError
class QuantumError(noise_ops, number_of_qubits=None, standard_gates=True, atol=1e-08)
Quantum error class for Qiskit Aer noise model
WARNING: The init interface for this class is not finalized and may
change in future releases. For maximum backwards compatibility use the QuantumError generating functions in the noise.errors module.
Create a quantum error for a noise model.
Noise ops may either be specified as list of Kraus operators for a general CPTP map, or as a list of (circuit, p)
pairs where circuit
is a qobj circuit for the noise, and p
is the probability of the error circuit. If the input is Kraus operators they will be converted to the circuit format, with checks applied for determining if any Kraus operators are unitary matrices.
Example
An example noise_ops for a bit-flip error with error probability p = 0.1
is:
noise_ops = [([{"name": "id", "qubits": 0}], 0.9),
([{"name": "x", "qubits": 0}], 0.1)]
The same error represented as a Kraus channel can be input as:
noise_ops = [np.sqrt(0.9) * np.array([[1, 0], [0, 1]]),
np.sqrt(0.1) * np.array([[0, 1], [1, 0]])]
Parameters
- noise_ops (list) – A list of noise ops. See additional information.
- number_of_qubits (int) – specify the number of qubits for the error. If None this will be determined automatically (default None).
- standard_gates (bool) – Check if input matrices are standard gates.
- atol (double) – Threshold for testing if probabilities are equal to 0 or 1 (Default: 1e-8).
Raises
NoiseError – If input noise_ops are not a CPTP map.
__init__
__init__(noise_ops, number_of_qubits=None, standard_gates=True, atol=1e-08)
Create a quantum error for a noise model.
Noise ops may either be specified as list of Kraus operators for a general CPTP map, or as a list of (circuit, p)
pairs where circuit
is a qobj circuit for the noise, and p
is the probability of the error circuit. If the input is Kraus operators they will be converted to the circuit format, with checks applied for determining if any Kraus operators are unitary matrices.
Example
An example noise_ops for a bit-flip error with error probability p = 0.1
is:
noise_ops = [([{"name": "id", "qubits": 0}], 0.9),
([{"name": "x", "qubits": 0}], 0.1)]
The same error represented as a Kraus channel can be input as:
noise_ops = [np.sqrt(0.9) * np.array([[1, 0], [0, 1]]),
np.sqrt(0.1) * np.array([[0, 1], [1, 0]])]
Parameters
- noise_ops (list) – A list of noise ops. See additional information.
- number_of_qubits (int) – specify the number of qubits for the error. If None this will be determined automatically (default None).
- standard_gates (bool) – Check if input matrices are standard gates.
- atol (double) – Threshold for testing if probabilities are equal to 0 or 1 (Default: 1e-8).
Raises
NoiseError – If input noise_ops are not a CPTP map.
Methods
__init__ (noise_ops[, number_of_qubits, …]) | Create a quantum error for a noise model. |
compose (other[, front]) | Return the composition error channel other * self. |
copy () | Make a copy of current QuantumError. |
dot (other) | Return the composition error channel self * other. |
error_term (position) | Return a single term from the error. |
expand (other) | Return the tensor product quantum error channel self ⊗ other. |
ideal () | Return True if current error object is an identity |
power (n) | Return the compose of a error channel with itself n times. |
set_atol (value) | Set the class default absolute tolerance parameter for float comparisons. |
set_rtol (value) | Set the class default relative tolerance parameter for float comparisons. |
tensor (other) | Return the tensor product quantum error channel self ⊗ other. |
to_dict () | Return the current error as a dictionary. |
to_instruction () | Convert the QuantumError to a circuit Instruction. |
to_quantumchannel () | Convert the QuantumError to a SuperOp quantum channel. |
Attributes
atol | The default absolute tolerance parameter for float comparisons. |
circuits | Return the list of error circuits. |
number_of_qubits | Return the number of qubits for the error. |
probabilities | Return the list of error probabilities. |
rtol | The relative tolerance parameter for float comparisons. |
size | Return the number of error circuit. |
atol
The default absolute tolerance parameter for float comparisons.
circuits
Return the list of error circuits.
compose
compose(other, front=False)
Return the composition error channel other * self.
Note that for front=True this is equivalent to the QuantumError.dot()
method.
Parameters
- other (QuantumError) – a quantum error channel.
- front (bool) – If True return the reverse order composation self * other instead [default: False].
Returns
The composition error channel.
Return type
Raises
- NoiseError – if other cannot be converted into a QuantumError,
- or has incompatible dimensions. –
copy
copy()
Make a copy of current QuantumError.
dot
dot(other)
Return the composition error channel self * other.
Parameters
other (QuantumError) – a quantum error channel.
Returns
The composition error channel.
Return type
Raises
- NoiseError – if other cannot be converted into a QuantumError,
- or has incompatible dimensions. –
error_term
error_term(position)
Return a single term from the error.
Parameters
position (int) – the position of the error term.
Returns
A pair (p, circuit) for error term at position < size where p is the probability of the error term, and circuit is the list of qobj instructions for the error term.
Return type
tuple
Raises
- NoiseError – If the position is greater than the size of
- the quantum error. –
expand
expand(other)
Return the tensor product quantum error channel self ⊗ other.
Parameters
other (QuantumError) – a quantum error channel.
Returns
the tensor product error channel other ⊗ self.
Return type
Raises
NoiseError – if other cannot be converted to a QuantumError.
ideal
ideal()
Return True if current error object is an identity
number_of_qubits
Return the number of qubits for the error.
power
power(n)
Return the compose of a error channel with itself n times.
Parameters
n (int) – the number of times to compose with self (n>0).
Returns
the n-times composition error channel.
Return type
Raises
NoiseError – if the power is not a positive integer.
probabilities
Return the list of error probabilities.
rtol
The relative tolerance parameter for float comparisons.
set_atol
classmethod set_atol(value)
Set the class default absolute tolerance parameter for float comparisons.
set_rtol
classmethod set_rtol(value)
Set the class default relative tolerance parameter for float comparisons.
size
Return the number of error circuit.
tensor
tensor(other)
Return the tensor product quantum error channel self ⊗ other.
Parameters
other (QuantumError) – a quantum error channel.
Returns
the tensor product error channel self ⊗ other.
Return type
Raises
NoiseError – if other cannot be converted to a QuantumError.
to_dict
to_dict()
Return the current error as a dictionary.
to_instruction
to_instruction()
Convert the QuantumError to a circuit Instruction.
to_quantumchannel
to_quantumchannel()
Convert the QuantumError to a SuperOp quantum channel.