Skip to content

Commit

Permalink
iterate
Browse files Browse the repository at this point in the history
  • Loading branch information
Strilanc committed Dec 14, 2023
1 parent 028f048 commit d1821d8
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 48 deletions.
23 changes: 1 addition & 22 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
env:
CIBW_BUILD: "${{ matrix.os_dist.dist }}"
CIBW_ARCHS_MACOS: "${{ matrix.os_dist.macosarch }}"
CIBW_TEST_REQUIRES: pytest stim
CIBW_TEST_REQUIRES: pytest stim sinter
CIBW_TEST_COMMAND: pytest {project}/src
steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -107,27 +107,6 @@ jobs:
- run: cmake . -DCMAKE_C_COMPILER=cc -DCMAKE_CXX_COMPILER=c++
- run: cmake --build .
- run: out/chromobius --help
build_lib:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- run: cmake .
- run: make libchromobius -j 2
- run: echo -e '#include "chromobius.h"\nint main(int argc,const char **argv) {return (int)(chromobius::obsmask_int)0;}' > test.cc
- run: g++ -std=c++20 test.cc out/libchromobius.a -I src
- run: ./a.out
build_lib_install:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- run: mkdir install_dir
- run: cmake . -DCMAKE_INSTALL_PREFIX=install_dir
- run: make -j 2
- run: make install
- run: echo -e '#include "chromobius.h"\nint main(int argc,const char **argv) {return (int)(chromobius::obsmask_int)0;}' > test.cc
- run: g++ -std=c++20 test.cc out/libchromobius.a -I install_dir/include
- run: ./a.out
- run: install_dir/bin/chromobius --help
perf:
runs-on: ubuntu-latest
steps:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,5 @@ build
package_data
.eggs
dist
MODULE.bazel
MODULE.bazel.lock
16 changes: 8 additions & 8 deletions doc/chromobius.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class CompiledDecoder:
>>> import stim
>>> import chromobius
>>>
>>> dem = stim.Circuit("""
>>> dem = stim.Circuit('''
... X_ERROR(0.1) 0 1 2 3 4 5 6 7
... MPP Z0*Z1*Z2 Z1*Z2*Z3 Z2*Z3*Z4 Z3*Z4*Z5
... DETECTOR(0, 0, 0, 1) rec[-4]
Expand All @@ -25,7 +25,7 @@ class CompiledDecoder:
... DETECTOR(3, 0, 0, 1) rec[-1]
... M 0
... OBSERVABLE_INCLUDE(0) rec[-1]
... """).detector_error_model()
... ''').detector_error_model()
...
... decoder = chromobius.CompiledDecoder.from_dem(dem)
"""
Expand Down Expand Up @@ -70,7 +70,7 @@ class CompiledDecoder:
>>> import stim
>>> import chromobius
>>>
>>> dem = stim.Circuit("""
>>> dem = stim.Circuit('''
... X_ERROR(0.1) 0 1 2 3 4 5 6 7
... MPP Z0*Z1*Z2 Z1*Z2*Z3 Z2*Z3*Z4 Z3*Z4*Z5
... DETECTOR(0, 0, 0, 1) rec[-4]
Expand All @@ -79,7 +79,7 @@ class CompiledDecoder:
... DETECTOR(3, 0, 0, 1) rec[-1]
... M 0
... OBSERVABLE_INCLUDE(0) rec[-1]
... """).detector_error_model()
... ''').detector_error_model()
...
... decoder = chromobius.CompiledDecoder.from_dem(dem)
"""
Expand Down Expand Up @@ -122,7 +122,7 @@ class CompiledDecoder:
>>> import chromobius
>>> import numpy as np
>>>
>>> repetition_color_code = stim.Circuit("""
>>> repetition_color_code = stim.Circuit('''
... # Apply noise.
... X_ERROR(0.1) 0 1 2 3 4 5 6 7
... # Measure three-body stabilizers to catch errors.
Expand All @@ -139,7 +139,7 @@ class CompiledDecoder:
... # Check on the message.
... M 0
... OBSERVABLE_INCLUDE(0) rec[-1]
... """)
... ''')
...
... # Sample the circuit.
... shots = 4096
Expand Down Expand Up @@ -200,7 +200,7 @@ def compile_decoder_for_dem(
>>> import stim
>>> import chromobius
>>>
>>> dem = stim.Circuit("""
>>> dem = stim.Circuit('''
... X_ERROR(0.1) 0 1 2 3 4 5 6 7
... MPP Z0*Z1*Z2 Z1*Z2*Z3 Z2*Z3*Z4 Z3*Z4*Z5
... DETECTOR(0, 0, 0, 1) rec[-4]
Expand All @@ -209,7 +209,7 @@ def compile_decoder_for_dem(
... DETECTOR(3, 0, 0, 1) rec[-1]
... M 0
... OBSERVABLE_INCLUDE(0) rec[-1]
... """).detector_error_model()
... ''').detector_error_model()
...
... decoder = chromobius.compile_decoder_for_dem(dem)
"""
Expand Down
16 changes: 8 additions & 8 deletions doc/chromobius_api_reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def compile_decoder_for_dem(
>>> import stim
>>> import chromobius
>>>
>>> dem = stim.Circuit("""
>>> dem = stim.Circuit('''
... X_ERROR(0.1) 0 1 2 3 4 5 6 7
... MPP Z0*Z1*Z2 Z1*Z2*Z3 Z2*Z3*Z4 Z3*Z4*Z5
... DETECTOR(0, 0, 0, 1) rec[-4]
Expand All @@ -69,7 +69,7 @@ def compile_decoder_for_dem(
... DETECTOR(3, 0, 0, 1) rec[-1]
... M 0
... OBSERVABLE_INCLUDE(0) rec[-1]
... """).detector_error_model()
... ''').detector_error_model()
...
... decoder = chromobius.compile_decoder_for_dem(dem)
"""
Expand Down Expand Up @@ -105,7 +105,7 @@ class CompiledDecoder:
>>> import stim
>>> import chromobius
>>>
>>> dem = stim.Circuit("""
>>> dem = stim.Circuit('''
... X_ERROR(0.1) 0 1 2 3 4 5 6 7
... MPP Z0*Z1*Z2 Z1*Z2*Z3 Z2*Z3*Z4 Z3*Z4*Z5
... DETECTOR(0, 0, 0, 1) rec[-4]
Expand All @@ -114,7 +114,7 @@ class CompiledDecoder:
... DETECTOR(3, 0, 0, 1) rec[-1]
... M 0
... OBSERVABLE_INCLUDE(0) rec[-1]
... """).detector_error_model()
... ''').detector_error_model()
...
... decoder = chromobius.CompiledDecoder.from_dem(dem)
"""
Expand Down Expand Up @@ -166,7 +166,7 @@ def from_dem(
>>> import stim
>>> import chromobius
>>>
>>> dem = stim.Circuit("""
>>> dem = stim.Circuit('''
... X_ERROR(0.1) 0 1 2 3 4 5 6 7
... MPP Z0*Z1*Z2 Z1*Z2*Z3 Z2*Z3*Z4 Z3*Z4*Z5
... DETECTOR(0, 0, 0, 1) rec[-4]
Expand All @@ -175,7 +175,7 @@ def from_dem(
... DETECTOR(3, 0, 0, 1) rec[-1]
... M 0
... OBSERVABLE_INCLUDE(0) rec[-1]
... """).detector_error_model()
... ''').detector_error_model()
...
... decoder = chromobius.CompiledDecoder.from_dem(dem)
"""
Expand Down Expand Up @@ -225,7 +225,7 @@ def predict_obs_flips_from_dets_bit_packed(
>>> import chromobius
>>> import numpy as np
>>>
>>> repetition_color_code = stim.Circuit("""
>>> repetition_color_code = stim.Circuit('''
... # Apply noise.
... X_ERROR(0.1) 0 1 2 3 4 5 6 7
... # Measure three-body stabilizers to catch errors.
Expand All @@ -242,7 +242,7 @@ def predict_obs_flips_from_dets_bit_packed(
... # Check on the message.
... M 0
... OBSERVABLE_INCLUDE(0) rec[-1]
... """)
... ''')
...
... # Sample the circuit.
... shots = 4096
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
PERF_FILES = glob.glob("src/**/*.perf.cc", recursive=True)
MAIN_FILES = glob.glob("src/**/main.cc", recursive=True)
HEADER_FILES = glob.glob("src/**/*.h", recursive=True) + glob.glob("src/**/*.inl", recursive=True)
EXTRA_FILES = ['CMakeLists.txt']
RELEVANT_SOURCE_FILES = sorted((set(EXTRA_FILES) | set(ALL_SOURCE_FILES) | set(HEADER_FILES)) - set(TEST_FILES + PERF_FILES + MAIN_FILES + MUX_SOURCE_FILES))
CMAKE_FILES = ['CMakeLists.txt', *glob.glob("file_lists/**", recursive=True)]
RELEVANT_SOURCE_FILES = sorted((set(CMAKE_FILES) | set(ALL_SOURCE_FILES) | set(HEADER_FILES)) - set(TEST_FILES + PERF_FILES + MAIN_FILES + MUX_SOURCE_FILES))


class CMakeExtension(setuptools.Extension):
Expand Down
16 changes: 8 additions & 8 deletions src/chromobius/pybind/chromobius.pybind.cc
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ PYBIND11_MODULE(chromobius, m) {
>>> import stim
>>> import chromobius
>>>
>>> dem = stim.Circuit("""
>>> dem = stim.Circuit('''
... X_ERROR(0.1) 0 1 2 3 4 5 6 7
... MPP Z0*Z1*Z2 Z1*Z2*Z3 Z2*Z3*Z4 Z3*Z4*Z5
... DETECTOR(0, 0, 0, 1) rec[-4]
Expand All @@ -145,7 +145,7 @@ PYBIND11_MODULE(chromobius, m) {
... DETECTOR(3, 0, 0, 1) rec[-1]
... M 0
... OBSERVABLE_INCLUDE(0) rec[-1]
... """).detector_error_model()
... ''').detector_error_model()
...
... decoder = chromobius.CompiledDecoder.from_dem(dem)
)DOC")
Expand Down Expand Up @@ -192,7 +192,7 @@ PYBIND11_MODULE(chromobius, m) {
>>> import chromobius
>>> import numpy as np
>>>
>>> repetition_color_code = stim.Circuit("""
>>> repetition_color_code = stim.Circuit('''
... # Apply noise.
... X_ERROR(0.1) 0 1 2 3 4 5 6 7
... # Measure three-body stabilizers to catch errors.
Expand All @@ -209,7 +209,7 @@ PYBIND11_MODULE(chromobius, m) {
... # Check on the message.
... M 0
... OBSERVABLE_INCLUDE(0) rec[-1]
... """)
... ''')
...
... # Sample the circuit.
... shots = 4096
Expand Down Expand Up @@ -275,7 +275,7 @@ PYBIND11_MODULE(chromobius, m) {
>>> import stim
>>> import chromobius
>>>
>>> dem = stim.Circuit("""
>>> dem = stim.Circuit('''
... X_ERROR(0.1) 0 1 2 3 4 5 6 7
... MPP Z0*Z1*Z2 Z1*Z2*Z3 Z2*Z3*Z4 Z3*Z4*Z5
... DETECTOR(0, 0, 0, 1) rec[-4]
Expand All @@ -284,7 +284,7 @@ PYBIND11_MODULE(chromobius, m) {
... DETECTOR(3, 0, 0, 1) rec[-1]
... M 0
... OBSERVABLE_INCLUDE(0) rec[-1]
... """).detector_error_model()
... ''').detector_error_model()
...
... decoder = chromobius.compile_decoder_for_dem(dem)
)DOC")
Expand Down Expand Up @@ -333,7 +333,7 @@ PYBIND11_MODULE(chromobius, m) {
>>> import stim
>>> import chromobius
>>>
>>> dem = stim.Circuit("""
>>> dem = stim.Circuit('''
... X_ERROR(0.1) 0 1 2 3 4 5 6 7
... MPP Z0*Z1*Z2 Z1*Z2*Z3 Z2*Z3*Z4 Z3*Z4*Z5
... DETECTOR(0, 0, 0, 1) rec[-4]
Expand All @@ -342,7 +342,7 @@ PYBIND11_MODULE(chromobius, m) {
... DETECTOR(3, 0, 0, 1) rec[-1]
... M 0
... OBSERVABLE_INCLUDE(0) rec[-1]
... """).detector_error_model()
... ''').detector_error_model()
...
... decoder = chromobius.CompiledDecoder.from_dem(dem)
)DOC")
Expand Down

0 comments on commit d1821d8

Please sign in to comment.