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

Calculate the exact distance of binary codes with brute force in cython #211

Merged
merged 67 commits into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
7562154
add fast distance calculation for CSS codes with <= 64 qubits
perlinm Jan 28, 2025
0812e23
remove exact distance from surface code
perlinm Jan 28, 2025
8f41be4
add pyx file forgotten before, also add > 64-qubit distance calculation
perlinm Jan 28, 2025
1e21bde
choose distance method based on qubit number
perlinm Jan 28, 2025
8119d55
more distance calculations
perlinm Jan 28, 2025
0b8cb41
use c++
perlinm Jan 28, 2025
e010706
revert to using c and fix array bug
perlinm Jan 28, 2025
be4f30d
better test
perlinm Jan 28, 2025
06beb1c
only brute-force distance up to n=64
perlinm Jan 28, 2025
4cf213f
add cython distance calculation
perlinm Jan 28, 2025
cbce06c
minor cleanup of _distance.pyx
perlinm Jan 28, 2025
2b89ed3
add type hint
perlinm Jan 28, 2025
27c033d
clean up build.py
perlinm Jan 28, 2025
4d740e0
nit rearrangement
perlinm Jan 28, 2025
6a32e10
typing fix
perlinm Jan 28, 2025
74eac6a
rename functions
perlinm Jan 28, 2025
c2350e9
ignore cython build artifacts
perlinm Jan 28, 2025
f9dd865
fix typo
perlinm Jan 28, 2025
f0d1230
fix typo
perlinm Jan 28, 2025
e1a6cd6
typing fix and remove test.py file
perlinm Jan 28, 2025
474be53
Merge branch 'main' into fast-distance
perlinm Jan 28, 2025
ca59026
Merge branch 'main' into fast-distance
perlinm Jan 28, 2025
67338e1
fix coverage
perlinm Jan 28, 2025
8e45cbf
modify error message to accomodate classical codes
perlinm Jan 28, 2025
92a4da8
rename build.py to build-cython.py
perlinm Jan 29, 2025
15ad2a7
formatting fix
perlinm Jan 29, 2025
f4a6785
add cython-lint options to pyproject.toml
perlinm Jan 29, 2025
0f25a57
nit variable rename
perlinm Jan 29, 2025
26e28cf
add calculation of distance for QuditCodes on <= 32 qubits
perlinm Jan 29, 2025
3722ca4
fix coverage
perlinm Jan 29, 2025
046e7ea
fix check for number of qubits
perlinm Jan 29, 2025
803858b
remove debugging artifact
perlinm Jan 29, 2025
87bb743
typo fix
perlinm Jan 29, 2025
8dfaead
one more typo
perlinm Jan 29, 2025
e30def4
rename get_gistance_subcode_64 to get_distance_sector_xz_64
perlinm Jan 29, 2025
85232ec
ctzll for gray code counter
perlinm Jan 29, 2025
2416c26
remove leading underscore from functions not accessible to python
perlinm Jan 29, 2025
06a61db
make rows_to_uint64 return a 2D array
perlinm Jan 29, 2025
64fe6fa
typecast
perlinm Jan 29, 2025
6e7a609
Merge branch 'main' into fast-distance
perlinm Jan 29, 2025
87104a3
type fix
perlinm Jan 29, 2025
1f034fc
add comments
perlinm Jan 29, 2025
b022dfc
add distance calculation for classical codes with arbitrary block len…
perlinm Jan 29, 2025
8f6c933
fix bug in QuditCode distance calculation
perlinm Jan 29, 2025
b942e4d
add distance calculation for quantum codes with arbitrary block length
perlinm Jan 29, 2025
1d94628
some code rearranging
perlinm Jan 30, 2025
8d14312
balanced surface/toric codes
perlinm Jan 30, 2025
a7ab43a
Revert "balanced surface/toric codes"
perlinm Jan 30, 2025
37e93f8
properly balance surface and toric codes
perlinm Jan 30, 2025
e4c4959
split off distance calculations by block length
perlinm Jan 30, 2025
261307f
fix QuditCode distance calculation
perlinm Jan 30, 2025
3dfeb5b
clean up weight_func construction
perlinm Jan 30, 2025
cd41cc9
renaming and comments
perlinm Jan 30, 2025
ab91925
add comment
perlinm Jan 30, 2025
160f262
bugfix in QuditCode distance
perlinm Jan 30, 2025
1abbb8c
rename function
perlinm Jan 30, 2025
e781e89
Merge branch 'main' into fast-distance
perlinm Jan 30, 2025
ae7b4e3
add cython-lint to pyproject.toml
perlinm Jan 30, 2025
e833bb9
more cleanup and helpful commenting
perlinm Jan 30, 2025
4c71887
add 128-bit classical code distance
perlinm Jan 30, 2025
3dbbb98
word
perlinm Jan 30, 2025
233b374
minor bugfix for balanced CSS codes and warnings about runtime
perlinm Jan 30, 2025
384a8a0
workflow update
perlinm Jan 30, 2025
9f4ebc2
add cython language_level
perlinm Jan 30, 2025
032e8bb
move language_level:3 and add comment
perlinm Jan 30, 2025
166d491
increase timeout limit for the installation check
perlinm Jan 30, 2025
e5a7319
fix string matching
perlinm Jan 30, 2025
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
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
push:
branches: [ main ]
pull_request:
types: [ opened, synchronize, reopened, ready_for_review ] # these are the defaults, plus ready_for_review
types: [ opened, synchronize, reopened, ready_for_review ] # defaults plus ready_for_review
branches: [ main ]
workflow_dispatch:
workflow_call:
Expand All @@ -17,7 +17,7 @@ jobs:
name: Installation check
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
timeout-minutes: 2
timeout-minutes: 3
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.11
Expand All @@ -27,7 +27,7 @@ jobs:
- uses: actions/cache@v4
with:
path: ${{ env.pythonLocation }}
key: ${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}
key: ${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml', 'build-cython.py') }}
- name: Install package and dependencies
run: |
python3 -m pip install --upgrade pip
Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,8 @@ __pycache__

# sphinx documentation
docs/build

# cython build artifacts
build
*.c
*.so
32 changes: 32 additions & 0 deletions build-cython.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env python3
import os
import shutil
from distutils.command.build_ext import build_ext
from distutils.core import Distribution, Extension

import numpy
from Cython.Build import cythonize


def build_cython() -> None:
extension = Extension(
"*",
["*/**/*.pyx"],
include_dirs=[numpy.get_include()],
extra_compile_args=["-O3", "-march=native", "-Wall"],
)
ext_modules = cythonize(extension, compiler_directives={"language_level": "3"})
distribution = Distribution(dict(ext_modules=ext_modules))

cmd = build_ext(distribution)
cmd.ensure_finalized()
cmd.run()

# copy *.so files to their respective *.pyx directories
for output in cmd.get_outputs():
relative_extension = os.path.relpath(output, cmd.build_lib)
shutil.copyfile(output, relative_extension)


if __name__ == "__main__":
build_cython()
9 changes: 8 additions & 1 deletion checks/pytest_.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@

import checks_superstaq

EXCLUDE = ("checks/*.py", "experiments/*.py", "*/__init__.py", "docs/source/conf.py")
EXCLUDE = (
"*/__init__.py",
"checks/*.py",
"examples/*.py",
"experiments/*.py",
"build-cython.py",
"docs/source/conf.py",
)

if __name__ == "__main__":
exit(checks_superstaq.pytest_.run(*sys.argv[1:], exclude=EXCLUDE))
12 changes: 10 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
[build-system]
requires = ["poetry-core>=1.0.0"]
requires = ["poetry-core>=1.0.0", "cython", "setuptools", "numpy"]
build-backend = "poetry.core.masonry.api"

[tool.poetry.build]
generate-setup-file = false
script = "build-cython.py"

[tool.poetry]
name = "qLDPC"
version = "0.0.24"
Expand All @@ -23,7 +27,7 @@ classifiers = [
"Topic :: Scientific/Engineering :: Mathematics",
"Topic :: Scientific/Engineering :: Physics",
]
include = ["qldpc/py.typed"]
include = ["qldpc/py.typed", { path = "qldpc/**/*.so", format = "wheel" }]

[tool.poetry.dependencies]
python = "^3.10"
Expand All @@ -41,6 +45,7 @@ stim = ">=1.14.0"
sympy = ">=1.12"

checks-superstaq = { version = ">=0.5.34", optional = true }
cython-lint = { version = ">=0.16.6", optional = true }

[tool.poetry.extras]
dev = ["checks-superstaq"]
Expand Down Expand Up @@ -75,3 +80,6 @@ exclude_lines = ["pragma: no cover", "if TYPE_CHECKING:"]

[tool.coverage.run]
include = ["./*"]

[tool.cython-lint]
max-line-length = 100
Loading