Skip to content

add pecos #22

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 3 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"
quantum-pecos = ">=0.2.0"
49 changes: 48 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,51 @@ julia> syndrome = PyArray(H)*error .% 2

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

## `pecos`

The python pecos module is immediately available:

```
julia> using PyQDecoders

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

Running the example from `pecos`'s [original example](https://quantum-pecos.readthedocs.io/en/latest/api_guide/decoders.html)
on 2D version of minimum-weight-perfect-matching decoder:

```
julia> using PyQDecoders: pecos, pecosdecoders

julia> depolar = pecos.error_gens.DepolarGen(model_level="code_capacity");

julia> surface = pecos.qeccs.Surface4444(distance=3);

julia> logic = pecos.circuits.LogicalCircuit();

julia> logic.append(surface.gate("ideal init |0>"));

julia> logic.append(surface.gate("I", num_syn_extract=1));

julia> circ_runner = pecos.circuit_runners.Standard(seed=1);

julia> state = pecos.simulators.SparseSim(surface.num_qudits);

julia> decode = pecosdecoders.MWPM2D(surface).decode;

julia> meas, err = circ_runner.run(state, logic, error_gen=depolar, error_params=Dict("p" => 0.1));

julia> print("Measurement outcomes (syndrome):", meas)
Measurement outcomes (syndrome):{(1, 0, 7): {3: 1, 5: 1, 15: 1}}

julia> print("Errors introduced:", err)
Errors introduced:{(1, 0, 0): {'after': QuantumCircuit(params={'circuit_type': 'faults'}, ticks=[{'Z': {4}, 'X': {10}}])}}

julia> recovery_circuit = decode(meas);

julia> print("Recovery circuit from MWPM2D decoder:", recovery_circuit)
Recovery circuit from MWPM2D decoder:QuantumCircuit([{'Z': {4}, 'X': {10}}])
```
4 changes: 4 additions & 0 deletions src/PyQDecoders.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ const np = PythonCall.pynew()
const pm = PythonCall.pynew()
const ldpc = PythonCall.pynew()
const ldpccodes = PythonCall.pynew()
const pecos = PythonCall.pynew()
const pecosdecoders = PythonCall.pynew()

function __init__()
PythonCall.pycopy!(sp, PythonCall.pyimport("scipy"))
Expand All @@ -15,6 +17,8 @@ function __init__()
PythonCall.pycopy!(pm, PythonCall.pyimport("pymatching"))
PythonCall.pycopy!(ldpc, PythonCall.pyimport("ldpc"))
PythonCall.pycopy!(ldpccodes, PythonCall.pyimport("ldpc.codes"))
PythonCall.pycopy!(pecos, PythonCall.pyimport("pecos"))
PythonCall.pycopy!(pecosdecoders, PythonCall.pyimport("pecos.decoders"))
end

end # module
Loading