Skip to content

add panqec codes and decoders #23

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

Open
wants to merge 1 commit into
base: master
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
3 changes: 2 additions & 1 deletion CondaPkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ scipy = ""
pymatching = ""
ldpc = ">=2.2.8"
sinter = ">=1.14"
stim = ">=1.14"
stim = ">=1.14"
panqec = ">=0.1.7"
44 changes: 43 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,46 @@ julia> syndrome = PyArray(H)*error .% 2

julia> decoding = bpd.decode(np.array(syndrome))
Python: array([0, 1, 0])
```
```

## panqec

The python panqec module is immediately available:

```
julia> using PyQDecoders

julia> PyQDecoders.panqec
Python: <module 'panqec' from ...>
```

Running the example from `panqec` [original tutorial](https://panqec.readthedocs.io/en/latest/tutorials/Panqec%20basics.html):

```
julia> using PyQDecoders: panqec, panqecdecoders

julia> Toric2DCode = panqec.codes.Toric2DCode;

julia> PauliErrorModel = panqec.error_models.PauliErrorModel;

julia> MatchingDecoder = panqecdecoders.MatchingDecoder;

julia> code = Toric2DCode(4)

julia> error_model = PauliErrorModel(0.2, 0.3, 0.5)

julia> p = 0.1

julia> decoder = MatchingDecoder(code, error_model, p)

julia> errors = error_model.generate(code, p)

julia> syndrome = code.measure_syndrome(errors)

julia> println("Errors: ", errors)
Errors: [0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0
0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]

julia> println("Syndrome: ", syndrome)
Syndrome: [0 1 0 0 0 1 0 0 0 0 1 0 0 0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 1 1 0 0]
```
6 changes: 6 additions & 0 deletions src/PyQDecoders.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ const np = PythonCall.pynew()
const pm = PythonCall.pynew()
const ldpc = PythonCall.pynew()
const ldpccodes = PythonCall.pynew()
const panqec = PythonCall.pynew()
const panqeccodes = PythonCall.pynew()
const panqecdecoders = PythonCall.pynew()

function __init__()
PythonCall.pycopy!(sp, PythonCall.pyimport("scipy"))
Expand All @@ -15,6 +18,9 @@ function __init__()
PythonCall.pycopy!(pm, PythonCall.pyimport("pymatching"))
PythonCall.pycopy!(ldpc, PythonCall.pyimport("ldpc"))
PythonCall.pycopy!(ldpccodes, PythonCall.pyimport("ldpc.codes"))
PythonCall.pycopy!(panqec, PythonCall.pyimport("panqec"))
PythonCall.pycopy!(panqeccodes, PythonCall.pyimport("panqec.codes"))
PythonCall.pycopy!(panqecdecoders, PythonCall.pyimport("panqec.decoders"))
end

end # module
Loading