Skip to content

Commit 5341f9d

Browse files
authored
an assortment of small ecc cleanup tasks (#486)
* an assortment of small ecc cleanup tasks * bump version number and changelog * typo
1 parent 0035c32 commit 5341f9d

File tree

5 files changed

+20
-11
lines changed

5 files changed

+20
-11
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55

66
# News
77

8+
## v0.9.18 - 2025-02-19
9+
10+
- Fixes for rare crashes in the python BP decoders.
11+
- Less repetitive error messages.
12+
813
## v0.9.17 - 2025-02-18
914

1015
- New memory structure and matrix inversion function for `random_destabilizer`, to reduce allocations and speed up repeated generation of many random destabilizers.

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "QuantumClifford"
22
uuid = "0525e862-1e90-11e9-3e4d-1b39d7109de1"
33
authors = ["Stefan Krastanov <[email protected]> and QuantumSavory community members"]
4-
version = "0.9.17"
4+
version = "0.9.18"
55

66
[deps]
77
Combinatorics = "861a8166-3701-5b0c-9a16-15d98fcdc6aa"

ext/QuantumCliffordHeckeExt/QuantumCliffordHeckeExt.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module QuantumCliffordHeckeExt
33
using DocStringExtensions
44

55
import QuantumClifford, LinearAlgebra
6-
import Hecke: Group, GroupElem, AdditiveGroup, AdditiveGroupElem,
6+
import Hecke: Group, GroupElem, AdditiveGroupElem,
77
GroupAlgebra, GroupAlgebraElem, FqFieldElem, representation_matrix, dim, base_ring,
88
multiplication_table, coefficients, abelian_group, group_algebra, rand
99
import Nemo

ext/QuantumCliffordPyQDecodersExt/QuantumCliffordPyQDecodersExt.jl

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ function PyBeliefPropOSDecoder(c; maxiter=nothing, bpmethod=nothing, errorrate=n
5959
error_rate = isnothing(errorrate) ? PythonCall.Py(0.0001) : errorrate
6060
isnothing(osdmethod) || osdmethod (:zeroorder, :exhaustive, :combinationsweep) || error(lazy"PyBeliefPropOSDecoder got an unknown OSD method argument. `osdmethod` must be one of :zeroorder, :exhaustive, :combinationsweep.")
6161
osd_method = get(Dict(:zeroorder => "OSD_0", :exhaustive => "OSD_E", :combinationsweep => "OSD_CS"), osdmethod, 0)
62-
0osdorder || error(lazy"PyBeliefPropOSDecoder got an invalid OSD order argument. `osdorder` must be ≥0.")
62+
osdorder0 || error(lazy"PyBeliefPropOSDecoder got an invalid OSD order argument. `osdorder` must be ≥0.")
6363
osd_order = osdorder
6464
pyx = ldpc.BpOsdDecoder(np.array(Hx); max_iter, bp_method, error_rate, osd_method, osd_order) # TODO should be sparse
6565
pyz = ldpc.BpOsdDecoder(np.array(Hz); max_iter, bp_method, error_rate, osd_method, osd_order) # TODO should be sparse
@@ -69,11 +69,13 @@ end
6969
parity_checks(d::PyBP) = d.H
7070

7171
function decode(d::PyBP, syndrome_sample)
72-
row_x = @view syndrome_sample[1:d.nx]
72+
row_x = @view syndrome_sample[1:d.nx] # TODO figure out a lower-overhead way to move data to python (and make sure the ecc wiki still works after that change -- a lot of the cruft here is because of rare crashes when running the wiki evaluator)
7373
row_z = @view syndrome_sample[d.nx+1:end]
74-
guess_z_errors = PythonCall.PyArray(d.pyx.decode(np.array(row_x)))
75-
guess_x_errors = PythonCall.PyArray(d.pyz.decode(np.array(row_z)))
76-
vcat(guess_x_errors, guess_z_errors)
74+
PythonCall.GIL.@lock begin
75+
guess_z_errors = PythonCall.PyArray(d.pyx.decode(PythonCall.Py(row_x).to_numpy()))
76+
guess_x_errors = PythonCall.PyArray(d.pyz.decode(PythonCall.Py(row_z).to_numpy()))
77+
vcat(guess_x_errors, guess_z_errors)
78+
end
7779
end
7880

7981
struct PyMatchingDecoder <: AbstractSyndromeDecoder # TODO all these decoders have the same fields, maybe we can factor out a common type
@@ -108,9 +110,11 @@ parity_checks(d::PyMatchingDecoder) = d.H
108110
function decode(d::PyMatchingDecoder, syndrome_sample)
109111
row_x = @view syndrome_sample[1:d.nx]
110112
row_z = @view syndrome_sample[d.nx+1:end]
111-
guess_z_errors = PythonCall.PyArray(d.pyx.decode(row_x))
112-
guess_x_errors = PythonCall.PyArray(d.pyz.decode(row_z))
113-
vcat(guess_x_errors, guess_z_errors)
113+
PythonCall.GIL.@lock begin
114+
guess_z_errors = PythonCall.PyArray(d.pyx.decode(PythonCall.Py(row_x).to_numpy()))
115+
guess_x_errors = PythonCall.PyArray(d.pyz.decode(PythonCall.Py(row_z).to_numpy()))
116+
vcat(guess_x_errors, guess_z_errors)
117+
end
114118
end
115119

116120
function batchdecode(d::PyMatchingDecoder, syndrome_samples)

src/ecc/ECC.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ function faults_matrix(c::Stabilizer)
314314
s, n = size(c)
315315
r = rank(md)
316316
k = n - r
317-
k == n-s || @warn "`faults_matrix` was called on an ECC that has redundant rows (is rank-deficient). `faults_matrix` corrected for that, however this is a frequent source of mistakes and inefficiencies. We advise you remove redundant rows from your ECC."
317+
k == n-s || @warn "`faults_matrix` was called on an ECC that has redundant rows (is rank-deficient). `faults_matrix` corrected for that, however this is a frequent source of mistakes and inefficiencies. We advise you remove redundant rows from your ECC." maxlog=1
318318
O = falses(2k, 2n)
319319
logviews = [logicalxview(md); logicalzview(md)]
320320
errors = [one(Stabilizer,n; basis=:X);one(Stabilizer,n)]

0 commit comments

Comments
 (0)