Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 434: Update base code library #435

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 2 additions & 15 deletions DATABASE_NOTES
Original file line number Diff line number Diff line change
@@ -1,18 +1,5 @@

Important Notes:
Some of the larger database files come gzipped. The database will now load these so you do not need to unzip them. If you would prefer to have them as json text files then they can simply be unzipped with gunzip. The library will load them.

Only the Standard Codebase (qec_standard_subsystem_codebase, currently located in https://github.ibm.com/Grace-Harper/ibm-codebase-repo/ )
is considered verified. Nothing in playground is verified.

The Standard Codebase is *NOT* complete. If you query for some n,k code and receive fewer results
than you expect (including no results at all), this is likely due to the those codes missing from the codebase.


Incomplete properties for
[[9,2]] - only computed css, tri, and gf4linear for d=3
[[9,3]] - only computed css, tri, and gf4linear for d=3
[[9,4]] - did not compute css or gf4linear
[[10,0]]
[[10,1]]
[[10,6]]
If both the gzipped file and the text file exit then the json text file will be used.

20 changes: 16 additions & 4 deletions src/qiskit_qec/codes/codebase/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from typing import Union, List, Optional, Tuple, Dict, Callable
import configparser
from itertools import product
import gzip

from qiskit.exceptions import QiskitError

Expand Down Expand Up @@ -57,7 +58,7 @@ def __init__(self, name: str, path: str, config_filename: str) -> None:
_library_config = configparser.ConfigParser()
_library_config.read(self.config_file)

# Set the location fort the data files (data_path)
# Set the location for the data files (data_path)
try:
data_dir = _library_config["Data Directory"]["data_dir"]
except KeyError:
Expand Down Expand Up @@ -131,7 +132,18 @@ def __init__(self, name: str, path: str, config_filename: str) -> None:
int(index): data
for index, data in json.load(codes_json_file).items()
}

else:
file_to_load = file_to_load + ".gz"
if os.path.exists(file_to_load):
with gzip.open(file_to_load, "rb") as file:
json_bytes = file.read() # Read the entire file as bytes
codes_json_file = json_bytes.decode(
"utf-8"
) # Decode bytes to string
# index needs to be converted to integer from string
self.data[n][k] = {int(index): data for index, data in json.loads(codes_json_file).items()}


@staticmethod
def data2code(**record) -> Code:
"""_summary_
Expand Down Expand Up @@ -216,7 +228,7 @@ def _search(
codes.append(Properties(**code_data))
else:
codes.append(self.data2code(**code_data))
except KeyError:
except KeyError as e:
pass
return codes

Expand Down Expand Up @@ -320,7 +332,7 @@ def __init__(self, config: Optional[str] = None) -> None:

# Read the config file to determine which method
# (memory, file or http) to use for each
# code library. Default is order is http, file, memory
# code library. Default order is http, file, memory
_config = configparser.ConfigParser()
if config is None:
_config.read(default_config)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
{
"0": {
"isotropic_generators": [
"X0"
"aut_group_generators": [
"V0"
],
"is_subsystem": 1,
"index": "0",
"code_type": "StabSubSystemCode",
"aut_group_size": 2,
"is_decomposable": 0,
"weight_enumerator": [
1,
1
],
"code_type": "StabSubSystemCode",
"d": 1,
"index": 0,
"is_css": 1,
"uuid": "47bdd04c-93fc-4f65-87d7-7cdda8baa4ac",
"is_decomposable": 0,
"is_degenerate": 0,
"d": 1,
"is_gf4linear": 0,
"is_subsystem": 1,
"isotropic_generators": [
"X0"
],
"k": 0,
"n": 1
"logical_ops": [],
"n": 1,
"uuid": "0d67535e-fa66-46c6-9be5-01bb3dac5512",
"weight_enumerator": [
1,
1
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"0": {
"aut_group_generators": [
"R0",
"S0"
],
"aut_group_size": 6,
"code_type": "StabSubSystemCode",
"d": 1,
"index": 0,
"is_css": 1,
"is_decomposable": 0,
"is_degenerate": 0,
"is_gf4linear": 0,
"is_subsystem": 1,
"isotropic_generators": [
"I"
],
"k": 1,
"logical_ops": [
"X0",
"Z0"
],
"n": 1,
"uuid": "ac86a85a-dce3-45da-b5f9-6ba51709df70",
"weight_enumerator": [
1
]
}
}
Original file line number Diff line number Diff line change
@@ -1,49 +1,60 @@
{
"0": {
"aut_group_generators": [
"V1",
"V0",
"(0,1)"
],
"aut_group_size": 8,
"code_type": "StabSubSystemCode",
"d": 1,
"index": 0,
"is_css": 1,
"is_decomposable": 1,
"is_degenerate": 0,
"is_gf4linear": 0,
"is_subsystem": 1,
"isotropic_generators": [
"X0",
"X1"
],
"is_subsystem": 1,
"index": "0",
"code_type": "StabSubSystemCode",
"aut_group_size": 8,
"is_decomposable": 1,
"k": 0,
"logical_ops": [],
"n": 2,
"uuid": "19bd6e1e-f908-4bf5-b089-2abed9863323",
"weight_enumerator": [
1,
2,
1
],
"is_css": 1,
"uuid": "edf0e443-0d46-4f01-9b6d-1eb49b923ce0",
"is_degenerate": 0,
"d": 1,
"is_gf4linear": 0,
"k": 0,
"n": 2
]
},
"1": {
"isotropic_generators": [
"X0X1",
"Z0Z1"
"aut_group_generators": [
"S0S1",
"(0,1)",
"H0H1"
],
"is_subsystem": 1,
"index": "1",
"code_type": "StabSubSystemCode",
"aut_group_size": 12,
"is_triorthogonal": 0,
"code_type": "StabSubSystemCode",
"d": 2,
"index": 1,
"is_css": 1,
"is_decomposable": 0,
"is_degenerate": 0,
"is_gf4linear": 1,
"is_subsystem": 1,
"isotropic_generators": [
"Z0Z1",
"X0X1"
],
"k": 0,
"logical_ops": [],
"n": 2,
"uuid": "9e7112a5-868b-4832-bd42-2eaf5f1182de",
"weight_enumerator": [
1,
0,
3
],
"is_css": 1,
"uuid": "0e87acfc-26b1-410a-9ce4-908829f03ce5",
"is_degenerate": 0,
"d": 2,
"is_gf4linear": 1,
"k": 0,
"n": 2
]
}
}
Original file line number Diff line number Diff line change
@@ -1,54 +1,64 @@
{
"0": {
"aut_group_generators": [
"V1",
"V0",
"(0,1)"
],
"aut_group_size": 8,
"code_type": "StabSubSystemCode",
"d": 1,
"index": 0,
"is_css": 1,
"is_decomposable": 0,
"is_degenerate": 0,
"is_gf4linear": 0,
"is_subsystem": 1,
"isotropic_generators": [
"X0X1"
],
"k": 1,
"logical_ops": [
"X1",
"Z0Z1"
],
"is_subsystem": 1,
"index": "0",
"code_type": "StabSubSystemCode",
"aut_group_size": 8,
"is_decomposable": 0,
"n": 2,
"uuid": "7c554aa2-5d49-4bd8-ad61-815607c683a2",
"weight_enumerator": [
1,
0,
1
]
},
"1": {
"aut_group_generators": [
"V0",
"H0",
"V1"
],
"aut_group_size": 12,
"code_type": "StabSubSystemCode",
"d": 1,
"index": 1,
"is_css": 1,
"uuid": "ab1e133f-0b63-4087-b8f5-4b6a39d33f1f",
"is_decomposable": 1,
"is_degenerate": 0,
"d": 1,
"is_gf4linear": 0,
"k": 1,
"n": 2
},
"1": {
"is_subsystem": 1,
"isotropic_generators": [
"X0"
"X1"
],
"k": 1,
"logical_ops": [
"X1",
"Z1"
"X0",
"Z0"
],
"is_subsystem": 1,
"index": "1",
"code_type": "StabSubSystemCode",
"aut_group_size": 12,
"is_decomposable": 0,
"n": 2,
"uuid": "6bb4ee57-b3b7-4e2a-93b4-e5eccec8809a",
"weight_enumerator": [
1,
1,
0
],
"is_css": 1,
"uuid": "59bfbb3d-aeb6-49b3-a9ad-285e8383de6d",
"is_degenerate": 0,
"d": 1,
"is_gf4linear": 0,
"k": 1,
"n": 2
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"0": {
"aut_group_generators": [
"R0",
"S0",
"R1",
"S1",
"(0, 1)"
],
"aut_group_size": 6,
"code_type": "StabSubSystemCode",
"d": 1,
"index": 0,
"is_css": 1,
"is_decomposable": 1,
"is_degenerate": 0,
"is_gf4linear": 0,
"is_subsystem": 1,
"isotropic_generators": [
"II"
],
"k": 1,
"logical_ops": [
"X0",
"Z0",
"X1",
"Z1"
],
"n": 1,
"uuid": "1e334ccc-1d59-4d7d-a6c5-ffeaf20c5a1d",
"weight_enumerator": [
1
]
}
}
Loading
Loading