1

I am trying to study Quantum LDPC code and have generated the A matrix by taking the hypergraph product of a classical LDPC code. Now my aim is to study those matrices by implementing the same on quantum channel.

Taken From the Book

Craig Gidney
  • 36,389
  • 1
  • 29
  • 95
  • Could you define what the "A matrix" is? Maybe give an explicit example you're currently working with? – Craig Gidney Aug 23 '22 at 13:14
  • Do you mean encoding a random state into a code or encoding the code space (logical zero)? – esabo Aug 23 '22 at 15:02
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Aug 24 '22 at 04:37
  • [link(https://arxiv.org/abs/2005.07016#:~:text=We%20show%20that%20belief%20propagation,constructed%20from%20the%20hypergraph%20product.) The paper gives the the construction of Quantum LDPC code and I want this code to be simulated and plot the logical error rate vs prob of error(p). The A matrix is the parity matrix defined as [Hx 0; 0 Hz] link here they have given the encoding of A matrix i.e., the stabilizer generator matrix/ parity check matrix. – Harsh Wadhwa Aug 24 '22 at 12:52
  • @HarshWadhwa Are you referring to the stabilizer tableau represented as a 2nx2n grid of bits? Where did you get the name "A matrix" from? – Craig Gidney Aug 24 '22 at 13:03
  • This paper is not a circuit-level simulation. It sounds like you want to encode logical 0 though. Simply set every qubit to |0>, measure each stabilizer, correct based on the measurement results, now measure logical Z. If the result is 0, you are properly encoded into logical 0. Otherwise, apply logical X. – esabo Aug 25 '22 at 00:47
  • @CraigGidney link This book discuss the "A Matrix" in chapter 9. I have included the image above. – Harsh Wadhwa Aug 25 '22 at 04:25
  • @esabo : Yes the paper is not about the circuit level simulation. The question which I have in my mind is how to make encoding circuit out of the parity matrix add depolarizing channel say, vary the probability of error and get corresponding the logical error. Is there any tool which can do the said work. Also the paper discuss about the some Belief Propagation decoding which works for Classical LDPC code can that decoding be implemented here at the circuit level too. – Harsh Wadhwa Aug 25 '22 at 04:31
  • What you are calling the A matrix is called the symplectic form of the stabilizer matrix. The answer to your question is given in Section 8.5.1 in the book. Or, just follow my comments above and plug into Craig's STIM. You will have to program your own decoder though. – esabo Aug 25 '22 at 14:35
  • Ah, I see you posted the image above. Note that in my copy, your chapter 9 is my chapter 8. The 9 I have is EAQECCs. – esabo Aug 25 '22 at 14:37
  • the codes in the paper are CSS codes and $H_X$ and $H_Z$ are decoded separately as classical codes (using BP + OSD decoder). The paper has a link to bp_osd python decoder which seems to run fine. This is not a circuit level sim as others have commented. I'd say that a circuit level sim for a code this size is not possible with current tools (>100 qubits, non-clifford operations,...) – unknown Aug 25 '22 at 17:01

1 Answers1

2

The first thing you'll want to do is to convert the raw matrix bits into objects Stim understands and can operate efficiently upon. Stim has a method stim.PauliString.from_numpy which helps with this conversion:

import stim
import numpy as np
from typing import List

def parity_check_matrix_to_stabilizers(matrix: np.ndarray) -> List[stim.PauliString]: num_rows, num_cols = matrix.shape assert num_cols % 2 == 0 num_qubits = num_cols // 2

matrix = matrix.astype(np.bool8)  # indicate the data isn't bit packed
return [
    stim.PauliString.from_numpy(
        xs=matrix[row, :num_qubits],
        zs=matrix[row, num_qubits:],
    )
    for row in range(num_rows)
]

You can expand the partial list of stabilizers into a tableau, with a full list of stabilizer generators alongside destabilizer generators, by using stim.Tableau.from_stabilizers. Then the last piece of the puzzle is stim.Tableau.to_circuit. This will produce a working (but not efficient or internally fault tolerant) encoding circuit:

def parity_check_matrix_to_encoder(matrix: np.ndarray) -> stim.Circuit:
    stabilizers = parity_check_matrix_to_stabilizers(matrix)
    tableau = stim.Tableau.from_stabilizers(
        stabilizers,
        allow_underconstrained=True,
    )
    return tableau.to_circuit(method='elimination')

Trying it out:

surface_code_2x2_encoder = parity_check_matrix_to_encoder(np.array([
    [1, 1, 1, 1, 0, 0, 0, 0],
    [0, 0, 0, 0, 1, 1, 0, 0],
    [0, 0, 0, 0, 0, 0, 1, 1],
]))
print(surface_code_2x2_encoder.diagram())
# prints:
# q0: -H-@-@---
#        | |
# q1: ---X-|---
#          |
# q2: -----|-X-
#          | |
# q3: -----X-@-
Craig Gidney
  • 36,389
  • 1
  • 29
  • 95
  • I used something similar based on your answer here https://quantumcomputing.stackexchange.com/questions/27326/how-to-go-from-matrix-to-tableau-to-circuit-in-qiskit-or-stim When's the next release of stim? I'm not used to working with dev versions – unknown Aug 25 '22 at 16:54
  • @unknown There's not really any schedule to them I just package them up now and then when I feel like there's enough to describe. – Craig Gidney Aug 25 '22 at 17:05