# Converting $T_1$ and $T_2$ decay rates to noise supported by stim

Stim only supports Pauli noises like DEPOLARIZE1, DEPOLARIZE2, X_ERROR, Z_ERROR. Given $$T_1$$, $$T_2$$ values of qubits, how would I adjust a stim circuit file to reflect these? For instance, we might have qubits with different $$T_1$$ and $$T_2$$ values. How would I decide the magnitudes of the DEPOLARIZE1 errors on them when they are idle?

We've read the post Incorporating idling errors while using stim, but a more detailed explanation would be helpful.

You can use equations 9-10 of this paper to extract the corresponding Pauli error probabilities: https://arxiv.org/pdf/1404.3747.pdf

$$p_X = p_Y = \frac{1-e^{-t/T_1}}{4}$$ $$p_Z = \frac{1-e^{-t/T_2}}{2} - \frac{1-e^{-t/T_1}}{4}$$

The quantity $$t$$ would correspond to the duration of a given idle. To add these errors to a stim.Circuit at a given point, you could use

stim_circuit.append("PAULI_CHANNEL_1", (target,), (pX,pY,pZ))


where target is the qubit receiving noise.

These expressions are generally valid only for idles, not during a gate. Accurately accounting for decoherence during the actual gate implementation would require a bit more work... A slightly more accurate way to do this is to apply "half" of the error before the gate and "half" after the gate. You could generalize to 2-qubit gates by just applying the above prescription individually to each qubit.

## Trouble with amplitude damping channel

Phase damping channel is implemented in stim as Z_ERROR, see here. Amplitude damping is not supported as explicitly stated in limitations

stim.Circuit only supports Pauli noise channels (eg. no amplitude decay). For more complex noise you must manually drive a stim.TableauSimulator.

In fact, all noise channels currently supported by stim are Pauli channels. In particular, they are all unital$$^1$$ channels. Moreover, unitary gates are unital and the composition (and tensor product) of unital channels is a unital channel. On the other hand, amplitude damping is not, so no combination of unitary gates and stim noise channels can be used to exactly implement the amplitude damping channel.

## Tableau and Pauli frame simulators

Stim consists of two simulators. A relatively more expensive Tableau simulator which computes a noiseless reference sample and a very cheap Pauli frame simulator which determines which measurement outcomes are flipped with respect to the reference sample. Stim achieves its very high sample rate by computing the reference sample once and reusing it to generate multiple samples using the Pauli frame simulator.

As the quote above indicates, you can implement a variety of complex noise channels, including amplitude damping, by manually driving the Tableau simulator. This entails using the expensive simulator for every sample, so the approach incurs relatively high cost. However, it allows you to implement the amplitude damping channel exactly for example via probabilistic reset. See below.

Alternatively, you can choose to approximate the amplitude damping channel with a Pauli channel, supported in stim via PAULI_CHANNEL_1. This approach is compatible with Pauli frame simulation and retains stim's very high sample rate. See text surrounding equation $$(10)$$ in this paper for details.

## Amplitude damping from probabilistic reset

Let $$\mathcal{A}_\gamma$$ and $$\mathcal{F}_\lambda$$ denote the amplitude and phase damping channels, respectively \begin{align} \mathcal{A}_\gamma(\rho)=E_\gamma\rho E_\gamma^\dagger+F_\gamma\rho F_\gamma^\dagger\tag1\\ \mathcal{F}_\lambda(\rho)=E_\lambda\rho E_\lambda^\dagger+G_\lambda\rho G_\lambda^\dagger\tag2 \end{align} where $$E_\alpha=\begin{bmatrix}1&0\\0&\sqrt{1-\alpha}\end{bmatrix}\quad F_\alpha=\begin{bmatrix}0&\sqrt{\alpha}\\0&0\end{bmatrix}\quad G_\alpha=\begin{bmatrix}0&0\\0&\sqrt{\alpha}\end{bmatrix}.\tag3$$ Setting $$\rho:=\begin{bmatrix}a&b\\b^*&c\end{bmatrix}$$, we have \begin{align} \mathcal{A}_\gamma(\rho)&=\begin{bmatrix}a+\gamma c&\sqrt{1-\gamma}b\\\sqrt{1-\gamma}b^*&(1-\gamma)c\end{bmatrix}\tag4\\ \mathcal{F}_\lambda(\rho)&=\begin{bmatrix}a&\sqrt{1-\lambda}b\\\sqrt{1-\lambda}b^*&c\end{bmatrix}\tag5 \end{align} so $$\mathcal{A}_\gamma$$ and $$\mathcal{F}_\lambda$$ commute and \begin{align} \mathcal{A}_\gamma(\mathcal{F}_\lambda(\rho))&=\begin{bmatrix}a+\gamma c&\sqrt{(1-\gamma)(1-\lambda)}b\\\sqrt{(1-\gamma)(1-\lambda)}b^*&(1-\gamma)c\end{bmatrix}\tag6 \end{align} where \begin{align} 1-\gamma&=e^{-t/T_1}\tag7\\ \sqrt{(1-\gamma)(1-\lambda)}&=e^{-t/T_2}.\tag8 \end{align} Now, assume for a moment that $$T_1=T_2$$. Then $$\gamma=\lambda=:p$$ and \begin{align} \mathcal{A}_p(\mathcal{F}_p(\rho))&=\begin{bmatrix}a+pc&(1-p)b\\(1-p)b^*&(1-p)c\end{bmatrix},\tag9 \end{align} which is the probabilistic reset channel $$\mathcal{R}_p(\rho)=(1-p)\rho+p\mathcal{A}_1(\rho).\tag{10}$$ Stim doesn't support it (since it's incompatible with its goals and design philosophy), but it can be effected by manually driving stim.TableauSimulator.

Returning to the general case $$T_1\ne T_2$$, set $$\kappa:=1-\frac{1-\lambda}{1-\gamma}=1-\exp\left(\frac{2t}{T_1}-\frac{2t}{T_2}\right)$$. One might hope that $$\mathcal{A}_\gamma\circ\mathcal{F}_\lambda=\mathcal{A}_\gamma\circ\mathcal{F}_\gamma\circ\mathcal{F}_\kappa=\mathcal{R}_\gamma\circ\mathcal{F}_\kappa\tag{11}$$ but $$\mathcal{F}_\kappa$$ is not a quantum channel if $$\kappa<0$$. However, in practice $$T_1$$ is often greater than $$T_2$$. For example, according to this post on IBM Research Blog

$$\begin{array}{c|c|c|c} & \text{Tenerife} & \text{Tokyo} & \text{Poughkeepsie} & \text{IBM Q System One}\\ \hline \text{mean}\,\,T_1 & 51.1\mu s & 84.3\mu s & 73.2\mu s & 73.9\mu s\\ \text{mean}\,\,T_2 & 25.9\mu s & 49.6\mu s & 66.2\mu s & 69.1\mu s \end{array}$$ Similarly, Rigetti's Aspen-M-2 shows $$T_1=26\mu s$$ and $$T_2=18\mu s$$ right now. And if $$T_1>T_2$$, then $$\gamma<\lambda$$ and $$\kappa>0$$, so $$\mathcal{F}_\kappa$$ is in fact a quantum channel. Thus, for real-world values of $$T_1$$ and $$T_2$$ the combined amplitude and phase damping channel can be realized in stim's Tableau simulator using probabilistic reset and Z_ERROR.

$$^1$$ A quantum channel is called unital if it sends identity to identity.