diff --git a/CondaPkg.toml b/CondaPkg.toml index a8db9b1..30cae58 100644 --- a/CondaPkg.toml +++ b/CondaPkg.toml @@ -7,4 +7,5 @@ scipy = "" pymatching = "" ldpc = ">=2.2.8" sinter = ">=1.14" -stim = ">=1.14" \ No newline at end of file +stim = ">=1.14" +quantum-pecos = ">=0.2.0" diff --git a/README.md b/README.md index d64107b..28a7158 100644 --- a/README.md +++ b/README.md @@ -99,4 +99,51 @@ julia> syndrome = PyArray(H)*error .% 2 julia> decoding = bpd.decode(np.array(syndrome)) Python: array([0, 1, 0]) -``` \ No newline at end of file +``` + +## `pecos` + +The python pecos module is immediately available: + +``` +julia> using PyQDecoders + +julia> PyQDecoders.pecos +Python: +``` + +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}}]) +``` diff --git a/src/PyQDecoders.jl b/src/PyQDecoders.jl index 570fbca..3cd43d0 100644 --- a/src/PyQDecoders.jl +++ b/src/PyQDecoders.jl @@ -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")) @@ -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