diff --git a/CondaPkg.toml b/CondaPkg.toml index a8db9b1..6df94be 100644 --- a/CondaPkg.toml +++ b/CondaPkg.toml @@ -5,6 +5,7 @@ python = ">=3.10" numpy = "" scipy = "" pymatching = "" -ldpc = ">=2.2.8" +ldpc = "" sinter = ">=1.14" -stim = ">=1.14" \ No newline at end of file +stim = ">=1.14" +mqt-qecc = ">=1.9.0" diff --git a/README.md b/README.md index d64107b..876219d 100644 --- a/README.md +++ b/README.md @@ -99,4 +99,64 @@ julia> syndrome = PyArray(H)*error .% 2 julia> decoding = bpd.decode(np.array(syndrome)) Python: array([0, 1, 0]) +``` + +## `mqt.qecc` + +The python mqt.qecc module is immediately available: + +``` +julia> using PyQDecoders + +julia> PyQDecoders.mqt_qecc +Python: +``` + +Running the example from `mqt_qecc`'s original Readme: + +``` +julia> using PyQDecoders: np, mqt_qecc; + +julia> H = [[1, 0, 0, 1, 0, 1, 1], [0, 1, 0, 1, 1, 0, 1], [0, 0, 1, 0, 1, 1, 1]]; + +julia> code = mqt_qecc.Code(H, H); + +julia> UFHeuristic = mqt_qecc.UFHeuristic; + +julia> decoder = mqt_qecc.UFHeuristic(); + +julia> decoder.set_code(code); + +julia> sample_iid_pauli_err = mqt_qecc.sample_iid_pauli_err; + +julia> x_err = sample_iid_pauli_err(code.n, 0.05); + +julia> decoder.decode(code.get_x_syndrome(x_err)); + +julia> result = decoder.result; + +julia> residual_err = np.array(x_err) .⊻ np.array(result.estimate); + +julia> is_stabilizer = code.is_x_stabilizer(residual_err); + +julia> println("Is residual error a stabilizer? ", is_stabilizer); +``` + +LightsOut decoder for color codes + +``` +julia> using PyQDecoders: np, mqt_qecc, cc_decoder; + +julia> side_length = 3; + +julia> lattice = mqt_qecc.codes.HexagonalColorCode(side_length); + +julia> problem = cc_decoder.LightsOut(lattice.faces_to_qubits, lattice.qubits_to_faces); + +julia> problem.preconstruct_z3_instance(); + +julia> lights = [true, false, false]; + +julia> switches, constr_time, solve_time = problem.solve(lights) +Python: ([0, 1, 0, 0, 0, 0, 0], 0.06688149999990856, 0.001489878000029421) ``` \ No newline at end of file diff --git a/src/PyQDecoders.jl b/src/PyQDecoders.jl index 570fbca..e99f6ac 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 mqt_qecc = PythonCall.pynew() +const cc_decoder = 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!(mqt_qecc, PythonCall.pyimport("mqt.qecc")) + PythonCall.pycopy!(cc_decoder, PythonCall.pyimport("mqt.qecc.cc_decoder.decoder")) end end # module