Noisy state preparation¶

The QLM's noise models include noisy state preparations. To describe those, you will need to specify the initial density matrix.

Simple example¶

Here is a code snippet where we specify a perfect initial state $|0\rangle \langle 0|$ and imperfect measurement:

In [1]:
import numpy as np
from qat.hardware import DefaultGatesSpecification, HardwareModel

eps=0.1

gates_spec = DefaultGatesSpecification(gate_times = {"state_prep": 1, "meas": 1, "X": 10},
                                       state_prep=np.array([[1.0, 0.0],
                                                           [0.0, 0.0]]),
                                       meas=np.array([[eps, 0.0],
                                                      [0.0, 1.0-eps]]))

hw_model = HardwareModel(gates_spec)

Note that we suppose that the initial density matrix is factorized among the different qubits:

$$\rho_0 = \rho^{(1)} \otimes \rho^{(2)} \dots \otimes \rho^{(n)}$$

and we input, in the state_prep field, the density matrix $\rho_0 = \rho^{i}$ (assuming all qubits are initialized to the same density matrix). Note that one can also specify a different density matrix for each qubit by input a dictionary instead (see below).

As for the measurement observable, it is also assumed to be factorizable among all qubits. At the qubit level, it is specified as a two-outcome POVM $\lbrace I -E, E \rbrace$. The operation elements $E$ and $I-E$ are positive semi definite. The outcome probabilities are given by $p(0) = Tr(\rho (I-E))$ and $p(1) = Tr(\rho E)$. A perfect measurement is described by $E = |1\rangle \langle 1|$.

Qubit-wise specification¶

One can also specify different initial states for each qubit by replacing the np.array by a dictionary, with one key per qubit:

In [2]:
eps0, eps1 = 0.1, 0.05
gates_spec = DefaultGatesSpecification(gate_times = {"state_prep": 1, "meas": 1, "X": 10},
                                       state_prep={0: np.array([[1.0, 0.0],
                                                           [0.0, 0.0]]),
                                                   1: np.array([[1.0, 0.0],
                                                           [0.0, 0.0]])},
                                       meas={0: np.array([[eps0, 0.0],
                                                         [0.0, 1.0-eps0]]),
                                             1: np.array([[eps1, 0.0],
                                                        [0.0, 1.0-eps1]])}
                                      )
hw_model = HardwareModel(gates_spec)