qec 0.3.0__py3-none-any.whl → 0.3.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,66 @@
1
+ import ldpc.codes.rep_code
2
+
3
+ import ldpc.codes
4
+ from qec.code_constructions import HypergraphProductCode
5
+
6
+
7
+ class SurfaceCode(HypergraphProductCode):
8
+ """
9
+ Represents a Surface Code, which is a type of quantum error correction code.
10
+
11
+ The Surface Code is constructed using two repetition codes, one for the X stabilizers
12
+ and one for the Z stabilizers. The distances dx and dz specify the code distances
13
+ for the X and Z stabilizers, respectively, corresponding to the height and width of the lattice.
14
+
15
+ The Surface Code is a specific instance of a Hypergraph Product Code. The hypergraph product
16
+ construction allows for the creation of quantum error correction codes with desirable properties
17
+ such as high distance and low-weight stabilizers. In this construction, two classical codes are
18
+ used to generate the quantum code. For the Surface Code, these classical codes are simple repetition
19
+ codes.
20
+
21
+ Parameters
22
+ ----------
23
+ dx : int, optional
24
+ The code distance for the X stabilizers (width of the lattice). If not specified, it will be set to the value of dz.
25
+ dz : int, optional
26
+ The code distance for the Z stabilizers (height of the lattice). If not specified, it will be set to the value of dx.
27
+
28
+ Raises
29
+ ------
30
+ ValueError
31
+ If both dx and dz are not specified.
32
+
33
+ Attributes
34
+ ----------
35
+ x_code_distance : int
36
+ The code distance for X errors.
37
+ z_code_distance : int
38
+ The code distance for Z errors.
39
+ code_distance : int
40
+ The minimum of x_code_distance and z_code_distance.
41
+
42
+ Notes
43
+ -----
44
+ The Surface Code is constructed using the hypergraph product of two repetition codes. The repetition
45
+ code is a simple classical code where each bit is repeated multiple times to provide redundancy. By
46
+ taking the hypergraph product of two such codes, we obtain a quantum code with stabilizers that are
47
+ low-weight and a code distance that is determined by the distances of the original repetition codes.
48
+ """
49
+
50
+ def __init__(self, dx: int = None, dz: int = None):
51
+ if dx is None and dz is None:
52
+ raise ValueError("Please specify dx or dz")
53
+ if dx is None:
54
+ dx = dz
55
+ if dz is None:
56
+ dz = dx
57
+
58
+ h1 = ldpc.codes.rep_code(dz)
59
+ h2 = ldpc.codes.rep_code(dx)
60
+
61
+ super().__init__(h1, h2, name=f"({dx}x{dz})-Surface Code")
62
+
63
+ self.x_code_distance = dx
64
+ self.z_code_distance = dz
65
+
66
+ self.code_distance = min(self.x_code_distance, self.z_code_distance)
@@ -0,0 +1,56 @@
1
+ import ldpc.codes
2
+ from qec.code_constructions import HypergraphProductCode
3
+
4
+
5
+ class ToricCode(HypergraphProductCode):
6
+ """
7
+ Represents a Toric Code, which is a type of quantum error correction code.
8
+
9
+ The Toric Code is constructed using two ring codes, one for the X stabilizers
10
+ and one for the Z stabilizers. The distances dx and dz specify the code distances
11
+ for the X and Z stabilizers, respectively, corresponding to the height and width of the lattice.
12
+
13
+ The Toric Code is defined on a torus and is the generalization of the Surface Code with periodic
14
+ boundary conditions. The Toric Code has a logical qubit count of 2.
15
+
16
+ Parameters
17
+ ----------
18
+ dx : int, optional
19
+ The code distance for the X stabilizers (width of the lattice). If not specified, it will be set to the value of dz.
20
+ dz : int, optional
21
+ The code distance for the Z stabilizers (height of the lattice). If not specified, it will be set to the value of dx.
22
+
23
+ Raises
24
+ ------
25
+ ValueError
26
+ If both dx and dz are not specified.
27
+
28
+ Attributes
29
+ ----------
30
+ x_code_distance : int
31
+ The code distance the X errors.
32
+ z_code_distance : int
33
+ The code distance for Z errors.
34
+ code_distance : int
35
+ The minimum of x_code_distance and z_code_distance.
36
+ logical_qubit_count : int
37
+ The number of logical qubits in the code, which is 2 for the Toric Code.
38
+ """
39
+
40
+ def __init__(self, dx: int = None, dz: int = None):
41
+ if dx is None and dz is None:
42
+ raise ValueError("Please specify dx or dz")
43
+ if dx is None:
44
+ dx = dz
45
+ if dz is None:
46
+ dz = dx
47
+
48
+ h1 = ldpc.codes.ring_code(dz)
49
+ h2 = ldpc.codes.ring_code(dx)
50
+
51
+ super().__init__(h1, h2, name=f"({dx}x{dz})-Toric Code")
52
+
53
+ self.x_code_distance = dx
54
+ self.z_code_distance = dz
55
+
56
+ self.code_distance = min(self.x_code_distance, self.z_code_distance)
@@ -0,0 +1,5 @@
1
+ from .five_qubit_code import FiveQubitCode
2
+
3
+ __all__ = [
4
+ "FiveQubitCode",
5
+ ]
@@ -0,0 +1,67 @@
1
+ from qec.code_constructions import StabilizerCode
2
+
3
+
4
+ class FiveQubitCode(StabilizerCode):
5
+ """
6
+ Five-Qubit Quantum Error-Correcting Code.
7
+
8
+ The `FiveQubitCode` class implements the [[5, 1, 3]] quantum stabilizer code,
9
+ which is the smallest possible quantum error-correcting code capable of
10
+ correcting an arbitrary single-qubit error. This code encodes one logical
11
+ qubit into five physical qubits and has a distance of three, allowing it
12
+ to detect up to two errors and correct one.
13
+
14
+ Parameters
15
+ ----------
16
+ None
17
+
18
+ Attributes
19
+ ----------
20
+ code_distance : int
21
+ The distance of the quantum code. For the five-qubit code, this is set to 3.
22
+
23
+ Inherits
24
+ --------
25
+ StabilizerCode
26
+ The base class providing functionalities for stabilizer-based quantum
27
+ error-correcting codes, including initialization, distance computation,
28
+ and parameter retrieval.
29
+
30
+ Examples
31
+ --------
32
+ >>> five_qubit = FiveQubitCode()
33
+ >>> five_qubit.phyiscal_qubit_count
34
+ 5
35
+ >>> five_qubit.logical_qubit_count
36
+ 1
37
+ >>> five_qubit.code_distance
38
+ 3
39
+ """
40
+
41
+ def __init__(self):
42
+ """
43
+ Initialize the Five-Qubit Code with predefined Pauli stabilizers.
44
+
45
+ The constructor sets up the stabilizer generators for the [[5, 1, 3]]
46
+ quantum code using their corresponding Pauli strings. It then calls the
47
+ superclass initializer to establish the stabilizer matrix and other
48
+ essential parameters.
49
+
50
+ Parameters
51
+ ----------
52
+ None
53
+
54
+ Raises
55
+ ------
56
+ ValueError
57
+ If the provided stabilizer generators do not satisfy the necessary
58
+ commutation relations required for a valid stabilizer code.
59
+ """
60
+ # Define the Pauli stabilizer generators for the five-qubit code
61
+ pauli_stabilizers = [["XZZXI"], ["IXZZX"], ["XIXZZ"], ["ZXIXZ"]]
62
+
63
+ # Initialize the StabilizerCode with the defined stabilizers and a custom name
64
+ super().__init__(stabilizers=pauli_stabilizers, name="5-Qubit Code")
65
+
66
+ # Set the distance attribute specific to the five-qubit code
67
+ self.code_distance = 3
@@ -1,30 +1,30 @@
1
1
  {
2
- "class_name": "HypergraphProductCode",
3
- "name": "Hypergraph product code",
4
- "physical_qubit_count": 512,
5
- "logical_qubit_count": 8,
6
- "code_distance": 4,
7
- "x_code_distance": 4,
8
- "z_code_distance": 4,
9
- "seed_matrix_1": {
10
- "indices": [0, 1, 4, 5, 2, 6, 7, 12, 3, 4, 6, 13, 5, 8, 9, 15, 1, 7, 8, 11, 8, 12, 13, 14, 0, 7, 13, 15, 3, 5, 10, 12, 2, 3, 11, 15, 4, 9, 10, 11, 1, 6, 10, 14, 0, 2, 9, 14, 2, 3, 11, 15, 4, 5, 9, 10, 11, 1, 6, 10, 14, 0, 2, 8, 9, 14],
11
- "indptr": [0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 57, 61, 66],
12
- "shape": [16, 16]
2
+ "class_name": "CSSCode",
3
+ "name": "Steane",
4
+ "physical_qubit_count": 7,
5
+ "logical_qubit_count": 1,
6
+ "code_distance": 3,
7
+ "x_code_distance": 3,
8
+ "z_code_distance": 3,
9
+ "x_stabilizer_matrix": {
10
+ "indices": [0, 3, 5, 6, 1, 3, 4, 6, 2, 4, 5, 6],
11
+ "indptr": [0, 4, 8, 12],
12
+ "shape": [3, 7]
13
13
  },
14
- "seed_matrix_2": {
15
- "indices": [0, 1, 4, 5, 2, 6, 7, 12, 3, 4, 6, 13, 5, 8, 9, 15, 1, 7, 8, 11, 8, 12, 13, 14, 0, 7, 13, 15, 3, 5, 10, 12, 2, 3, 11, 15, 4, 9, 10, 11, 1, 6, 10, 14, 0, 2, 9, 14, 2, 3, 11, 15, 4, 5, 9, 10, 11, 1, 6, 10, 14, 0, 2, 8, 9, 14],
16
- "indptr": [0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 57, 61, 66],
17
- "shape": [16, 16]
14
+ "z_stabilizer_matrix": {
15
+ "indices": [0, 3, 5, 6, 1, 3, 4, 6, 2, 4, 5, 6],
16
+ "indptr": [0, 4, 8, 12],
17
+ "shape": [3, 7]
18
18
  },
19
19
  "x_logical_operator_basis": {
20
- "indices": [17, 20, 23, 26, 28, 29, 17, 19, 20, 23, 25, 28, 30, 31, 49, 52, 55, 58, 60, 61, 49, 51, 52, 55, 57, 60, 62, 63, 424, 488, 426, 490, 392, 456, 394, 458],
21
- "indptr": [0, 6, 14, 20, 28, 30, 32, 34, 36],
22
- "shape": [8, 512]
20
+ "indices": [0, 1, 3],
21
+ "indptr": [0, 3],
22
+ "shape": [1, 7]
23
23
  },
24
24
  "z_logical_operator_basis": {
25
- "indices": [17, 65, 113, 161, 193, 209, 19, 67, 115, 163, 195, 211, 17, 49, 65, 113, 145, 193, 225, 241, 19, 51, 67, 115, 147, 195, 227, 243, 394, 398, 392, 396, 426, 430, 424, 428],
26
- "indptr": [0, 6, 12, 20, 28, 30, 32, 34, 36],
27
- "shape": [8, 512]
25
+ "indices": [0, 1, 3],
26
+ "indptr": [0, 3],
27
+ "shape": [1, 7]
28
28
  },
29
- "notes": ""
29
+ "notes": "This is the standard Steane code constructed by setting both Hx and Hz to be the rank 3 Hamming Code."
30
30
  }
@@ -0,0 +1,30 @@
1
+ {
2
+ "notes": "Code source: https://arxiv.org/abs/2005.07016. This code is the hypergraph product of two seed codes that have been designed to have minimum-girth 6.",
3
+ "class_name": "HypergraphProductCode",
4
+ "name": "Hypergraph product code",
5
+ "physical_qubit_count": 400,
6
+ "logical_qubit_count": 16,
7
+ "code_distance": 6,
8
+ "x_code_distance": 6,
9
+ "z_code_distance": 6,
10
+ "seed_matrix_1": {
11
+ "indices": [0, 1, 4, 5, 2, 6, 7, 12, 3, 4, 6, 13, 5, 8, 9, 15, 1, 7, 8, 11, 8, 12, 13, 14, 0, 7, 13, 15, 3, 5, 10, 12, 2, 3, 11, 15, 4, 9, 10, 11, 1, 6, 10, 14, 0, 2, 9, 14],
12
+ "indptr": [0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48],
13
+ "shape": [12, 16]
14
+ },
15
+ "seed_matrix_2": {
16
+ "indices": [0, 1, 4, 5, 2, 6, 7, 12, 3, 4, 6, 13, 5, 8, 9, 15, 1, 7, 8, 11, 8, 12, 13, 14, 0, 7, 13, 15, 3, 5, 10, 12, 2, 3, 11, 15, 4, 9, 10, 11, 1, 6, 10, 14, 0, 2, 9, 14],
17
+ "indptr": [0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48],
18
+ "shape": [12, 16]
19
+ },
20
+ "x_logical_operator_basis": {
21
+ "indices": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79],
22
+ "indptr": [0, 16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 176, 192, 208, 224, 240, 256],
23
+ "shape": [16, 400]
24
+ },
25
+ "z_logical_operator_basis": {
26
+ "indices": [0, 16, 32, 64, 80, 96, 112, 128, 176, 192, 1, 17, 33, 65, 81, 97, 113, 129, 177, 193, 3, 19, 35, 67, 83, 99, 115, 131, 179, 195, 4, 20, 36, 68, 84, 100, 116, 132, 180, 196, 0, 32, 80, 96, 128, 160, 176, 208, 1, 33, 81, 97, 129, 161, 177, 209, 3, 35, 83, 99, 131, 163, 179, 211, 4, 36, 84, 100, 132, 164, 180, 212, 0, 16, 32, 112, 128, 144, 176, 224, 1, 17, 33, 113, 129, 145, 177, 225, 3, 19, 35, 115, 131, 147, 179, 227, 4, 20, 36, 116, 132, 148, 180, 228, 16, 48, 80, 96, 112, 240, 17, 49, 81, 97, 113, 241, 19, 51, 83, 99, 115, 243, 20, 52, 84, 100, 116, 244],
27
+ "indptr": [0, 10, 20, 30, 40, 48, 56, 64, 72, 80, 88, 96, 104, 110, 116, 122, 128],
28
+ "shape": [16, 400]
29
+ }
30
+ }
@@ -0,0 +1,30 @@
1
+ {
2
+ "notes": "Code source: https://arxiv.org/abs/2005.07016. This code is the hypergraph product of two seed codes that have been designed to have minimum-girth 6.",
3
+ "class_name": "HypergraphProductCode",
4
+ "name": "Hypergraph product code",
5
+ "physical_qubit_count": 625,
6
+ "logical_qubit_count": 25,
7
+ "code_distance": 8,
8
+ "x_code_distance": 8,
9
+ "z_code_distance": 8,
10
+ "seed_matrix_1": {
11
+ "indices": [3, 4, 17, 19, 1, 6, 14, 19, 5, 9, 15, 16, 2, 6, 13, 16, 8, 9, 11, 18, 4, 10, 14, 15, 7, 9, 12, 17, 1, 2, 3, 12, 5, 8, 12, 14, 7, 10, 11, 16, 3, 5, 7, 18, 0, 11, 13, 19, 0, 4, 6, 18, 0, 2, 8, 15, 1, 10, 13, 17],
12
+ "indptr": [0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60],
13
+ "shape": [15, 20]
14
+ },
15
+ "seed_matrix_2": {
16
+ "indices": [3, 4, 17, 19, 1, 6, 14, 19, 5, 9, 15, 16, 2, 6, 13, 16, 8, 9, 11, 18, 4, 10, 14, 15, 7, 9, 12, 17, 1, 2, 3, 12, 5, 8, 12, 14, 7, 10, 11, 16, 3, 5, 7, 18, 0, 11, 13, 19, 0, 4, 6, 18, 0, 2, 8, 15, 1, 10, 13, 17],
17
+ "indptr": [0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60],
18
+ "shape": [15, 20]
19
+ },
20
+ "x_logical_operator_basis": {
21
+ "indices": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99],
22
+ "indptr": [0, 20, 40, 60, 80, 100, 120, 140, 160, 180, 200, 220, 240, 260, 280, 300, 320, 340, 360, 380, 400, 420, 440, 460, 480, 500],
23
+ "shape": [25, 625]
24
+ },
25
+ "z_logical_operator_basis": {
26
+ "indices": [0, 40, 100, 120, 140, 160, 220, 240, 280, 300, 1, 41, 101, 121, 141, 161, 221, 241, 281, 301, 2, 42, 102, 122, 142, 162, 222, 242, 282, 302, 3, 43, 103, 123, 143, 163, 223, 243, 283, 303, 4, 44, 104, 124, 144, 164, 224, 244, 284, 304, 0, 20, 60, 80, 140, 160, 180, 260, 280, 320, 1, 21, 61, 81, 141, 161, 181, 261, 281, 321, 2, 22, 62, 82, 142, 162, 182, 262, 282, 322, 3, 23, 63, 83, 143, 163, 183, 263, 283, 323, 4, 24, 64, 84, 144, 164, 184, 264, 284, 324, 0, 40, 60, 100, 120, 180, 200, 220, 280, 340, 1, 41, 61, 101, 121, 181, 201, 221, 281, 341, 2, 42, 62, 102, 122, 182, 202, 222, 282, 342, 3, 43, 63, 103, 123, 183, 203, 223, 283, 343, 4, 44, 64, 104, 124, 184, 204, 224, 284, 344, 0, 20, 100, 160, 180, 200, 220, 240, 280, 360, 1, 21, 101, 161, 181, 201, 221, 241, 281, 361, 2, 22, 102, 162, 182, 202, 222, 242, 282, 362, 3, 23, 103, 163, 183, 203, 223, 243, 283, 363, 4, 24, 104, 164, 184, 204, 224, 244, 284, 364, 0, 20, 40, 60, 120, 140, 200, 240, 280, 380, 1, 21, 41, 61, 121, 141, 201, 241, 281, 381, 2, 22, 42, 62, 122, 142, 202, 242, 282, 382, 3, 23, 43, 63, 123, 143, 203, 243, 283, 383, 4, 24, 44, 64, 124, 144, 204, 244, 284, 384],
27
+ "indptr": [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250],
28
+ "shape": [25, 625]
29
+ }
30
+ }
@@ -0,0 +1,30 @@
1
+ {
2
+ "notes": "Code source: https://arxiv.org/abs/2005.07016. This code is the hypergraph product of two seed codes that have been designed to have minimum-girth 6.",
3
+ "class_name": "HypergraphProductCode",
4
+ "name": "Hypergraph product code",
5
+ "physical_qubit_count": 900,
6
+ "logical_qubit_count": 36,
7
+ "code_distance": 10,
8
+ "x_code_distance": 10,
9
+ "z_code_distance": 10,
10
+ "seed_matrix_1": {
11
+ "indices": [1, 14, 15, 18, 6, 7, 15, 22, 3, 8, 19, 23, 2, 11, 13, 23, 9, 11, 16, 19, 5, 8, 17, 22, 0, 1, 7, 16, 5, 12, 13, 14, 0, 10, 18, 23, 4, 16, 21, 22, 1, 4, 6, 11, 3, 7, 14, 17, 8, 10, 20, 21, 0, 4, 19, 20, 2, 5, 6, 10, 9, 13, 18, 21, 2, 12, 15, 17, 3, 9, 12, 20],
12
+ "indptr": [0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68, 72],
13
+ "shape": [18, 24]
14
+ },
15
+ "seed_matrix_2": {
16
+ "indices": [1, 14, 15, 18, 6, 7, 15, 22, 3, 8, 19, 23, 2, 11, 13, 23, 9, 11, 16, 19, 5, 8, 17, 22, 0, 1, 7, 16, 5, 12, 13, 14, 0, 10, 18, 23, 4, 16, 21, 22, 1, 4, 6, 11, 3, 7, 14, 17, 8, 10, 20, 21, 0, 4, 19, 20, 2, 5, 6, 10, 9, 13, 18, 21, 2, 12, 15, 17, 3, 9, 12, 20],
17
+ "indptr": [0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68, 72],
18
+ "shape": [18, 24]
19
+ },
20
+ "x_logical_operator_basis": {
21
+ "indices": [0, 1, 4, 7, 9, 12, 14, 15, 16, 18, 1, 3, 4, 5, 6, 9, 11, 13, 15, 16, 17, 19, 1, 2, 3, 4, 5, 8, 9, 12, 13, 14, 16, 20, 0, 2, 4, 5, 6, 7, 10, 13, 17, 21, 0, 1, 3, 4, 6, 8, 9, 10, 11, 13, 14, 22, 1, 2, 7, 8, 9, 10, 11, 12, 13, 15, 17, 23, 24, 25, 28, 31, 33, 36, 38, 39, 40, 42, 25, 27, 28, 29, 30, 33, 35, 37, 39, 40, 41, 43, 25, 26, 27, 28, 29, 32, 33, 36, 37, 38, 40, 44, 24, 26, 28, 29, 30, 31, 34, 37, 41, 45, 24, 25, 27, 28, 30, 32, 33, 34, 35, 37, 38, 46, 25, 26, 31, 32, 33, 34, 35, 36, 37, 39, 41, 47, 48, 49, 52, 55, 57, 60, 62, 63, 64, 66, 49, 51, 52, 53, 54, 57, 59, 61, 63, 64, 65, 67, 49, 50, 51, 52, 53, 56, 57, 60, 61, 62, 64, 68, 48, 50, 52, 53, 54, 55, 58, 61, 65, 69, 48, 49, 51, 52, 54, 56, 57, 58, 59, 61, 62, 70, 49, 50, 55, 56, 57, 58, 59, 60, 61, 63, 65, 71, 72, 73, 76, 79, 81, 84, 86, 87, 88, 90, 73, 75, 76, 77, 78, 81, 83, 85, 87, 88, 89, 91, 73, 74, 75, 76, 77, 80, 81, 84, 85, 86, 88, 92, 72, 74, 76, 77, 78, 79, 82, 85, 89, 93, 72, 73, 75, 76, 78, 80, 81, 82, 83, 85, 86, 94, 73, 74, 79, 80, 81, 82, 83, 84, 85, 87, 89, 95, 96, 97, 100, 103, 105, 108, 110, 111, 112, 114, 97, 99, 100, 101, 102, 105, 107, 109, 111, 112, 113, 115, 97, 98, 99, 100, 101, 104, 105, 108, 109, 110, 112, 116, 96, 98, 100, 101, 102, 103, 106, 109, 113, 117, 96, 97, 99, 100, 102, 104, 105, 106, 107, 109, 110, 118, 97, 98, 103, 104, 105, 106, 107, 108, 109, 111, 113, 119, 120, 121, 124, 127, 129, 132, 134, 135, 136, 138, 121, 123, 124, 125, 126, 129, 131, 133, 135, 136, 137, 139, 121, 122, 123, 124, 125, 128, 129, 132, 133, 134, 136, 140, 120, 122, 124, 125, 126, 127, 130, 133, 137, 141, 120, 121, 123, 124, 126, 128, 129, 130, 131, 133, 134, 142, 121, 122, 127, 128, 129, 130, 131, 132, 133, 135, 137, 143],
22
+ "indptr": [0, 10, 22, 34, 44, 56, 68, 78, 90, 102, 112, 124, 136, 146, 158, 170, 180, 192, 204, 214, 226, 238, 248, 260, 272, 282, 294, 306, 316, 328, 340, 350, 362, 374, 384, 396, 408],
23
+ "shape": [36, 900]
24
+ },
25
+ "z_logical_operator_basis": {
26
+ "indices": [0, 24, 96, 168, 216, 288, 336, 360, 384, 432, 1, 25, 97, 169, 217, 289, 337, 361, 385, 433, 2, 26, 98, 170, 218, 290, 338, 362, 386, 434, 3, 27, 99, 171, 219, 291, 339, 363, 387, 435, 4, 28, 100, 172, 220, 292, 340, 364, 388, 436, 5, 29, 101, 173, 221, 293, 341, 365, 389, 437, 24, 72, 96, 120, 144, 216, 264, 312, 360, 384, 408, 456, 25, 73, 97, 121, 145, 217, 265, 313, 361, 385, 409, 457, 26, 74, 98, 122, 146, 218, 266, 314, 362, 386, 410, 458, 27, 75, 99, 123, 147, 219, 267, 315, 363, 387, 411, 459, 28, 76, 100, 124, 148, 220, 268, 316, 364, 388, 412, 460, 29, 77, 101, 125, 149, 221, 269, 317, 365, 389, 413, 461, 24, 48, 72, 96, 120, 192, 216, 288, 312, 336, 384, 480, 25, 49, 73, 97, 121, 193, 217, 289, 313, 337, 385, 481, 26, 50, 74, 98, 122, 194, 218, 290, 314, 338, 386, 482, 27, 51, 75, 99, 123, 195, 219, 291, 315, 339, 387, 483, 28, 52, 76, 100, 124, 196, 220, 292, 316, 340, 388, 484, 29, 53, 77, 101, 125, 197, 221, 293, 317, 341, 389, 485, 0, 48, 96, 120, 144, 168, 240, 312, 408, 504, 1, 49, 97, 121, 145, 169, 241, 313, 409, 505, 2, 50, 98, 122, 146, 170, 242, 314, 410, 506, 3, 51, 99, 123, 147, 171, 243, 315, 411, 507, 4, 52, 100, 124, 148, 172, 244, 316, 412, 508, 5, 53, 101, 125, 149, 173, 245, 317, 413, 509, 0, 24, 72, 96, 144, 192, 216, 240, 264, 312, 336, 528, 1, 25, 73, 97, 145, 193, 217, 241, 265, 313, 337, 529, 2, 26, 74, 98, 146, 194, 218, 242, 266, 314, 338, 530, 3, 27, 75, 99, 147, 195, 219, 243, 267, 315, 339, 531, 4, 28, 76, 100, 148, 196, 220, 244, 268, 316, 340, 532, 5, 29, 77, 101, 149, 197, 221, 245, 269, 317, 341, 533, 24, 48, 168, 192, 216, 240, 264, 288, 312, 360, 408, 552, 25, 49, 169, 193, 217, 241, 265, 289, 313, 361, 409, 553, 26, 50, 170, 194, 218, 242, 266, 290, 314, 362, 410, 554, 27, 51, 171, 195, 219, 243, 267, 291, 315, 363, 411, 555, 28, 52, 172, 196, 220, 244, 268, 292, 316, 364, 412, 556, 29, 53, 173, 197, 221, 245, 269, 293, 317, 365, 413, 557],
27
+ "indptr": [0, 10, 20, 30, 40, 50, 60, 72, 84, 96, 108, 120, 132, 144, 156, 168, 180, 192, 204, 214, 224, 234, 244, 254, 264, 276, 288, 300, 312, 324, 336, 348, 360, 372, 384, 396, 408],
28
+ "shape": [36, 900]
29
+ }
30
+ }
@@ -0,0 +1,3 @@
1
+ from .codetables_de import CodeTablesDE
2
+
3
+ __all__ = ["CodeTablesDE"]
@@ -0,0 +1,97 @@
1
+ import numpy as np
2
+ from qec.code_constructions import StabilizerCode
3
+ from qec.utils.codetables_de_utils import get_codetables_de_matrix, pcm_to_csr_matrix
4
+
5
+
6
+ class CodeTablesDE(StabilizerCode):
7
+ """
8
+ A code object built from data obtained from Markus Grassl's codetables.de website (with `q=4`).
9
+
10
+ This class inherits from `StabilizerCode` and initialises the code
11
+ by querying the codetables.de website for the specified parameters `(n, k)`,
12
+ constructing the stabilizer (PCM) matrix, and passing it up to the
13
+ `StabilizerCode` parent class.
14
+
15
+ Parameters
16
+ ----------
17
+ physical_qubit_count : int
18
+ Length of the code (number of physical qubits).
19
+ logical_qubit_count : int
20
+ Dimension of the code (number of logical qubits).
21
+
22
+ Attributes
23
+ ----------
24
+ name : str
25
+ Name assigned to this code instance. Defaults to "CodeTablesDE".
26
+ url : str
27
+ The URL from which this code's data was retrieved.
28
+ code_distance : int
29
+ The code's minimum distance. This is updated if the reported upper bound
30
+ from the codetables.de website is smaller than the base class default.
31
+
32
+ See Also
33
+ --------
34
+ StabilizerCode : Parent class providing stabilizer code functionality.
35
+ get_codetables_de_matrix : Function that queries codetables.de to retrieve code data.
36
+ pcm_to_csr_matrix : Function that converts a PCM-like list of column indices into a CSR matrix.
37
+
38
+ Notes
39
+ -----
40
+ - The data is retrieved from:
41
+ https://codetables.de
42
+ maintained by Markus Grassl.
43
+ """
44
+
45
+ def __init__(self, physical_qubit_count: int, logical_qubit_count: int):
46
+ """
47
+ Initialise a code from Markus Grassl's codetables.de website with `q=4`, `n`, and `k`.
48
+
49
+ This method queries the codetables.de database for a stabilizer matrix
50
+ describing a code with parameters (q=4, n, k). The matrix is then
51
+ converted to a CSR (Compressed Sparse Row) format and passed to
52
+ the parent `StabilizerCode` class.
53
+
54
+ Parameters
55
+ ----------
56
+ n : int
57
+ Length of the code (number of physical qubits).
58
+ k : int
59
+ Dimension of the code (number of logical qubits).
60
+
61
+ Notes
62
+ -----
63
+ - `d_upper` from the query result is used to potentially update `self.code_distance`
64
+ if it is smaller than the default distance assigned by `StabilizerCode`.
65
+ - Since this code is defined over GF(4), `q` is hardcoded as 4.
66
+ - Data is retrieved from Markus Grassl's website (https://codetables.de).
67
+
68
+ Raises
69
+ ------
70
+ ValueError
71
+ If no valid matrix data can be retrieved from codetables.de, or
72
+ if the site indicates that such a code does not exist.
73
+ """
74
+ # Retrieve code data from codetables.de
75
+ ct_dict = get_codetables_de_matrix(
76
+ q=4, n=physical_qubit_count, k=logical_qubit_count
77
+ )
78
+
79
+ # Construct the stabilizer matrix in CSR format
80
+ # The matrix is 2*n columns wide, as is typical for GF(4) stabilizers.
81
+ stabilizer_matrix = pcm_to_csr_matrix(
82
+ ct_dict["pcm"], num_cols=2 * int(ct_dict["n"])
83
+ )
84
+
85
+ # Initialise the parent class with this stabilizer matrix
86
+ super().__init__(stabilizers=stabilizer_matrix)
87
+
88
+ # Name of this code and the URL from which we retrieved it
89
+ self.name = "CodeTablesDE"
90
+ self.url = ct_dict["url"]
91
+
92
+ # Update distance if the reported upper bound is smaller than the default
93
+ if self.code_distance is None:
94
+ self.code_distance = np.inf
95
+
96
+ if int(ct_dict["d_upper"]) < self.code_distance:
97
+ self.code_distance = int(ct_dict["d_upper"])
qec/utils/__init__.py ADDED
@@ -0,0 +1,6 @@
1
+ from qec.utils.load_code_util import load_code, load_code_from_id
2
+
3
+ __all__ = [
4
+ "load_code",
5
+ "load_code_from_id",
6
+ ]