Skip to content

add mwpf decoder #24

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 2 commits 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"
mwpf = ">=0.2.6"
53 changes: 53 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,57 @@ julia> syndrome = PyArray(H)*error .% 2

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

## `mwpf`

The python mwpf module is immediately available:

```
julia> using PyQDecoders

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

Running the example from `mwpf`'s [original Readme](https://github.com/yuewuo/mwpf):

```
julia> using PyQDecoders: mwpf

julia> HyperEdge = mwpf.HyperEdge;

julia> SolverInitializer = mwpf.SolverInitializer;

julia> SolverSerialJointSingleHair = mwpf.SolverSerialJointSingleHair;

julia> SyndromePattern = mwpf.SyndromePattern;

julia> vertex_num = 4;

julia> weighted_edges = [
HyperEdge([0, 1], 100), # [vertices], weight
HyperEdge([1, 2], 100),
HyperEdge([2, 3], 100),
HyperEdge([0], 100), # boundary vertex
HyperEdge([0, 1, 2], 60), # hyperedge
];

julia> initializer = SolverInitializer(vertex_num, weighted_edges);

julia> hyperion = SolverSerialJointSingleHair(initializer);

julia> syndrome = [0, 1, 3];

julia> hyperion.solve(SyndromePattern(syndrome));

julia> hyperion_subgraph = hyperion.subgraph();

julia> println("Hyperion Subgraph: ", hyperion_subgraph)
Hyperion Subgraph: [2, 4]

julia> _, bound = hyperion.subgraph_range();

julia> println("Subgraph Range: ", (bound.lower, bound.upper))
Subgraph Range: (<py OrderedFloat(160.0)>, <py OrderedFloat(160.0)>)
```
2 changes: 2 additions & 0 deletions src/PyQDecoders.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const np = PythonCall.pynew()
const pm = PythonCall.pynew()
const ldpc = PythonCall.pynew()
const ldpccodes = PythonCall.pynew()
const mwpf = PythonCall.pynew()

function __init__()
PythonCall.pycopy!(sp, PythonCall.pyimport("scipy"))
Expand All @@ -15,6 +16,7 @@ function __init__()
PythonCall.pycopy!(pm, PythonCall.pyimport("pymatching"))
PythonCall.pycopy!(ldpc, PythonCall.pyimport("ldpc"))
PythonCall.pycopy!(ldpccodes, PythonCall.pyimport("ldpc.codes"))
PythonCall.pycopy!(mwpf, PythonCall.pyimport("mwpf"))
end

end # module
Loading