QuantumError#

class QuantumError(noise_ops)[source]#

Bases: BaseQuantumError, TolerancesMixin

Quantum error class for 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 a QuantumChannel for a general CPTP map, or as a list of (circuit, p) pairs where circuit is a circuit-like object for the noise, and p is the probability of the noise event. Any type of input will be converted to the probabilistic mixture of circuit format.

Example

An example noise_ops for a bit-flip error with error probability p = 0.1 is:

noise_ops = [(IGate(), 0.9),
             (XGate(), 0.1)]

or specifying explicit qubit arguments,

noise_ops = [((IGate(), [0]), 0.9),
             ((XGate(), [0]), 0.1)]

The same error represented as a Kraus channel can be input as:

noise_ops = Kraus([np.sqrt(0.9) * np.array([[1, 0], [0, 1]]),
                   np.sqrt(0.1) * np.array([[0, 1], [1, 0]])])
Parameters:

noise_ops (QuantumChannel or Iterable) – Either a quantum channel or a list of (circuit, p) pairs, which represents a quantum error, where circuit is a circuit-like object for the noise, and p is the probability of the noise event. Circuit-like types include QuantumCircuit, (Instruction, qargs) and a list of (Instruction, qargs). Note that qargs should be a list of integers and can be omitted (default qubits are used in that case). See also examples above.

Raises:

NoiseError – If input noise_ops is invalid, e.g. it’s not a CPTP map.

Attributes

atol = 1e-08#
circuits#

Return the list of error circuits.

dim#

Return tuple (input_shape, output_shape).

id#

Return unique ID string for error

num_qubits#

Return the number of qubits if a N-qubit operator or None otherwise.

probabilities#

Return the list of error probabilities.

qargs#

Return the qargs for the operator.

rtol = 1e-05#
size#

Return the number of error circuit.

Methods

__call__(*qargs)[source]#

Return a shallow copy with qargs attribute set

compose(other, qargs=None, front=False)[source]#

Return the operator composition with another CLASS.

Parameters:
  • other (CLASS) – a CLASS object.

  • qargs (list or None) – Optional, a list of subsystem positions to apply other on. If None apply on all subsystems (default: None).

  • front (bool) – If True compose using right operator multiplication, instead of left multiplication [default: False].

Returns:

The composed CLASS.

Return type:

CLASS

Raises:

QiskitError – if other cannot be converted to an operator, or has incompatible dimensions for specified subsystems.

Note

Composition (&) by default is defined as left matrix multiplication for matrix operators, while @ (equivalent to dot()) is defined as right matrix multiplication. That is that A & B == A.compose(B) is equivalent to B @ A == B.dot(A) when A and B are of the same type.

Setting the front=True kwarg changes this to right matrix multiplication and is equivalent to the dot() method A.dot(B) == A.compose(B, front=True).

copy()[source]#

Make a copy of current QuantumError.

dot(other, qargs=None) Self[source]#

Return the right multiplied operator self * other.

Parameters:
  • other (Operator) – an operator object.

  • qargs (list or None) – Optional, a list of subsystem positions to apply other on. If None apply on all subsystems (default: None).

Returns:

The right matrix multiplied Operator.

Return type:

Operator

Note

The dot product can be obtained using the @ binary operator. Hence a.dot(b) is equivalent to a @ b.

error_term(position)[source]#

Return a single term from the error.

Parameters:

position (int) – the position of the error term.

Returns:

A pair (circuit, p) 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(other)[source]#

Return the reverse-order tensor product with another CLASS.

Parameters:

other (CLASS) – a CLASS object.

Returns:

the tensor product \(b \otimes a\), where \(a\)

is the current CLASS, and \(b\) is the other CLASS.

Return type:

CLASS

static from_dict(error)[source]#

Implement current error from a dictionary.

ideal()[source]#

Return True if this error object is composed only of identity operations. Note that the identity check is best effort and up to global phase.

input_dims(qargs=None)[source]#

Return tuple of input dimension for specified subsystems.

output_dims(qargs=None)[source]#

Return tuple of output dimension for specified subsystems.

power(n) Self[source]#

Return the compose of a operator with itself n times.

Parameters:

n (int) – the number of times to compose with self (n>0).

Returns:

the n-times composed operator.

Return type:

Clifford

Raises:

QiskitError – if the input and output dimensions of the operator are not equal, or the power is not a positive integer.

reshape(input_dims: None | tuple | int = None, output_dims: None | tuple | int = None, num_qubits: None | int = None) BaseOperator[source]#

Return a shallow copy with reshaped input and output subsystem dimensions.

Parameters:
  • input_dims (None or tuple) – new subsystem input dimensions. If None the original input dims will be preserved [Default: None].

  • output_dims (None or tuple) – new subsystem output dimensions. If None the original output dims will be preserved [Default: None].

  • num_qubits (None or int) – reshape to an N-qubit operator [Default: None].

Returns:

returns self with reshaped input and output dimensions.

Return type:

BaseOperator

Raises:

QiskitError – if combined size of all subsystem input dimension or subsystem output dimensions is not constant.

tensor(other)[source]#

Return the tensor product with another CLASS.

Parameters:

other (CLASS) – a CLASS object.

Returns:

the tensor product \(a \otimes b\), where \(a\)

is the current CLASS, and \(b\) is the other CLASS.

Return type:

CLASS

Note

The tensor product can be obtained using the ^ binary operator. Hence a.tensor(b) is equivalent to a ^ b.

to_dict()[source]#

Return the current error as a dictionary.

to_instruction()[source]#

Convert the QuantumError to a circuit Instruction.

to_quantumchannel()[source]#

Convert the QuantumError to a SuperOp quantum channel. Required to enable SuperOp(QuantumError).