I have a CSS code defined through binary matrices $H_X$ and $H_Z$. I also have the logicals $L_X$ and $L_Z$ as binary matrices. I decode $H_X$ and $H_Z$ independently as classical codes. The decoder outputs the corrected codewords (from which I can calculate the residual errors). How do I calculate whether the residual error results in a logical error or not? It should be a (simple?) operation involving $L_X$ and $L_Z$ but I'm not clear on the details.

  • $\begingroup$ Do you mean $L_X$ and $L_Z$ as binary vectors? $\endgroup$
    – ChrisD
    Commented Sep 28, 2023 at 4:20
  • $\begingroup$ @ChrisD they would be vectors if the code has k=1; otherwise each is a $k \times n$ matrix for an $[[n,k,d]]$ code. $\endgroup$
    – unknown
    Commented Sep 28, 2023 at 15:26
  • 1
    $\begingroup$ Ok. A logical error is just when the residual error applies a logical operation. So you could just check whether it is a non-trivial linear combination of the $L_X$ ($L_Z$). Or alternatively whether it anti-commutes with any of the $L_Z$ ($L_X$), for a CSS code this is equivalent to whether $l_Z \cdot r = 1$ for any row $l_Z$ of $L_Z$. $\endgroup$
    – ChrisD
    Commented Sep 29, 2023 at 0:07
  • $\begingroup$ @ChrisD I tried this before posting the question but the simulation results didn't seem right...now it's possible there's a simulation bug somewhere. At any rate if you have a reference for the the above then please post it as an answer; if things checkout I'll be happy to accept. $\endgroup$
    – unknown
    Commented Sep 29, 2023 at 2:55

1 Answer 1


We have a stabilizer code $C(S)$, formed from stabilizer group $S$, with a set of stabilizer generators $\{S_i\}_i$, and a set of logical operators representatives $\{\bar{X}_i\}_i \cup \{\bar{Z}_i\}_i$.

We know that the logical operators all commute with the stabilizers. We can check this by confirming that $$ [\bar{X}_i, S_j] = 0, \quad\text{for all } i,j, \\ [\bar{Z}_i, S_j] = 0, \quad\text{for all } i,j. $$

At the same time not all logical operators commute with each other (see this Q&A). We have the conditions that $$ [\bar{X}_i, \bar{Z}_i] \ne 0, \quad\text{for all } i,\\ [\bar{X}_i, \bar{X}_j] = 0, \quad\text{for all } i,j,\\ [\bar{Z}_i, \bar{Z}_j] = 0, \quad\text{for all } i,j. $$

Now, our encoded code state $\psi\rangle$ encountered an error $E$, and the decoder provided recovery operation $R$, which leads to what you call the residual error $RE$. Assume that $RE$ brings the state back inside the code, i.e. $RE|\bar\psi\rangle \in C$. Then there are two possibilities,

  • Either $RE \in S$ (successful recovery), or
  • $RE = \bar{A}_i$ for some $A \in \{X,Z\}$ and $i$ (logical error).

To check which case occurred, we can use the second set of commutation relation above. We evaluate $$ [RE, \bar{A}_i] \text{ for all } A \in \{X, Y\}, i. $$

If $[RE, \bar{X}_j] \ne 0$, then that means that $RE = \bar{Z}_j$. Similarly, if $[RE, \bar{Z}_j] \ne 0$, then $RE = \bar{X}_i$.

Checks in the binary vector representation

Suppose the code in question is a $[[n,k,d]]$ code with $m=n-k$ stabilizer generators. Let there be $m_X$ pure-$X$ generators and $m_Z$ pure-$Z$ generators, such that $m_X + m_Z = m$.

We will represent elements of the Pauli group $\mathcal{P}_n$ by binary vectors of length $2n$, with the first $n$ bits acting as the $X$-part and the rest for the $Z$-part. Let us use small letters to label them.

In this picture, the $k$ logical $X$ operators $\{\bar{X}_i\}$ are represented by a $k \times 2n$ matrix $L^X$. The $i$th operator will the $i$th row of the matrix $L^X_i$. Similarly, for the logical $Z$ operators. You have not mentioned in your question if the logical operators of your code are pure $X$ or $Z$. So, I will not assume this to be so.

The error is vector $e$ and recovery operation (provided by the decoder) is vector $r$. The residual error is $f = r+e$, where the addition is modulo 2.

The check $[RE, \bar{X}_j]$, in the binary vector picture translates to the symplectic inner product $f \cdot L^X_j$.

Similarly, the check $[RE, \bar{Z}_j]$ translates to $f\cdot L^Z_j$.

That is all. For checking if the recovery made a logical error, you only need to evaluate these $2k$ symplectic inner products. If your logical operators are pure $X$ and pure $Z$ types, then the symplectic inner products will naturally simplify to normal inner products.

What if the decoder is faulty

The decoder could return a recovery operation $R$ such that $RE|\bar\psi\rangle \not\in C$. To check this, you should verify that $$ [RE,S_i] = 0 \quad \text{ for all } i. $$

In the binary vector picture you will first have to expand $H^X$ to a $m_X \times 2n$ matrix. Similarly $H^Z$. Then $[RE,S_i]$ translates to computing the symplectic inner product $f\cdot s_i$.

  • $\begingroup$ All this looks reasonable but can you translate the process in terms of $H_X,H_Z,L_X,L_Z$. To simplify things you can consider $H_X$ and $L_Z$ only since I'm decoding the two classical codes independently. Are you saying that just calculate the "syndrome" of the residual error $r$ and $L_Z$? that is a logical error is when $r \cdot L_Z \neq 0$? Is $r \cdot H_X$ relevant? either way a reference would make things complete especially if it works with matrices, dot products, ... $\endgroup$
    – unknown
    Commented Sep 29, 2023 at 18:49
  • $\begingroup$ I have added more details. Hopefully this clarifies more. I have not particularly discussed how things simplify if you are decoding the two classical codes separately. Need too much notation for it. But roughly, if your logical operators are pure $X$ or $Z$, you can determine the residual $X$ error from the physical $X$ errors and the $X$ part of the recovery. If that is $f_X$, then indeed $f_X \cdot L^Z_i \ne 0$ will tell you if a logical error has occurred. $\endgroup$ Commented Sep 30, 2023 at 4:58
  • $\begingroup$ I appreciate the added details, but the case of the "decoder is faulty" isn't clear. If $f \cdot s_i \neq 0$ then this is not considered a logical error?. To keep things simple you can just work with $H_X, L_Z$ and assume the error is a $Z$ error; no need to go to Pauli operators or symplectic products $\endgroup$
    – unknown
    Commented Oct 2, 2023 at 19:55
  • $\begingroup$ I call a decoder-faulty error one in which the recovery operation fails to return the state back to the Code. I call a logical error one in which the state is returned back to the Code, but perturbed by some logical operation on the qubits. Though I think that papers call the union of the two the logical error rate. $\endgroup$ Commented Oct 2, 2023 at 21:53
  • $\begingroup$ this ambiguity is what motivated the question. I see "logical error rate" plots everywhere in papers but I can't find a definitive reference where it's exactly defined $\endgroup$
    – unknown
    Commented Oct 3, 2023 at 0:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.