Skip to content

Commit 5f439bd

Browse files
committed
updates, some bugs
1 parent 62bb646 commit 5f439bd

File tree

6 files changed

+123
-75
lines changed

6 files changed

+123
-75
lines changed

Manifest.toml

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
julia_version = "1.10.5"
44
manifest_format = "2.0"
5-
project_hash = "ba220f86c22c8d12de7c0e641c76d64b2e51180c"
5+
project_hash = "26354b5f3440d58ba825c3a08bb43d55c1f95c59"
66

77
[[deps.ASL_jll]]
88
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
@@ -12,9 +12,9 @@ version = "0.1.3+0"
1212

1313
[[deps.AbstractAlgebra]]
1414
deps = ["InteractiveUtils", "LinearAlgebra", "MacroTools", "Preferences", "Random", "RandomExtensions", "SparseArrays", "Test"]
15-
git-tree-sha1 = "420d38fe3940615fdba29fcf9cbcb41403e7ed5e"
15+
git-tree-sha1 = "45e46834b8fcfd59389939445267047577b19df5"
1616
uuid = "c3fe647b-3220-5bb0-a1ea-a7954cac585d"
17-
version = "0.42.6"
17+
version = "0.43.1"
1818

1919
[[deps.AbstractFFTs]]
2020
deps = ["LinearAlgebra"]
@@ -32,9 +32,9 @@ version = "1.5.0"
3232

3333
[[deps.AlgebraicSolving]]
3434
deps = ["LinearAlgebra", "Logging", "Markdown", "Nemo", "Printf", "Random", "StaticArrays", "Test", "msolve_jll"]
35-
git-tree-sha1 = "62f48f1110bcdfc7d7b99e4e8159959d071e13d1"
35+
git-tree-sha1 = "59b14f801f508a03b0643713b22c4696bc52e445"
3636
uuid = "66b61cbe-0446-4d5d-9090-1ff510639f9d"
37-
version = "0.5.1"
37+
version = "0.7.0"
3838

3939
[[deps.AliasTables]]
4040
deps = ["PtrArrays", "Random"]
@@ -195,9 +195,9 @@ weakdeps = ["PDMats", "SparseArrays", "Statistics"]
195195

196196
[[deps.GAP]]
197197
deps = ["AbstractAlgebra", "Artifacts", "Compat", "Downloads", "GAP_jll", "GAP_lib_jll", "GAP_pkg_juliainterface_jll", "InteractiveUtils", "Libdl", "MacroTools", "Markdown", "Ncurses_jll", "Pidfile", "Pkg", "REPL", "Random", "Scratch"]
198-
git-tree-sha1 = "b61baecbdc18c8e3bd4e3e0d97e776816ffb2860"
198+
git-tree-sha1 = "b045754f9aae9f79df4b18b2e4df84887897105d"
199199
uuid = "c863536a-3901-11e9-33e7-d5cd0df7b904"
200-
version = "0.11.3"
200+
version = "0.11.4"
201201

202202
[[deps.GAP_jll]]
203203
deps = ["Artifacts", "GMP_jll", "JLLWrappers", "Libdl", "Readline_jll", "Zlib_jll"]
@@ -236,9 +236,9 @@ version = "1.11.2"
236236

237237
[[deps.Hecke]]
238238
deps = ["AbstractAlgebra", "Dates", "Distributed", "InteractiveUtils", "LazyArtifacts", "Libdl", "LinearAlgebra", "Markdown", "Nemo", "Pkg", "Printf", "Random", "RandomExtensions", "Serialization", "SparseArrays"]
239-
git-tree-sha1 = "623437095815b94fc796187c62c82f7c84b21f32"
239+
git-tree-sha1 = "9257286b6ada9e8d0ae2a629bf13c51a149c5562"
240240
uuid = "3e1990a7-5d81-5526-99ce-9ba3ff248f21"
241-
version = "0.33.8"
241+
version = "0.34.3"
242242
weakdeps = ["GAP", "Polymake"]
243243

244244
[deps.Hecke.extensions]
@@ -450,9 +450,9 @@ version = "6.5.0+0"
450450

451451
[[deps.Nemo]]
452452
deps = ["AbstractAlgebra", "FLINT_jll", "Libdl", "LinearAlgebra", "Pkg", "Random", "RandomExtensions", "SHA"]
453-
git-tree-sha1 = "71cff3f853e1cb2c6d5d75ab5e0092058936c460"
453+
git-tree-sha1 = "a644b4943424d9f1ffe7a7a1cdda617053bac5c0"
454454
uuid = "2edaba10-b0f1-5616-af89-8c11ac63239a"
455-
version = "0.46.2"
455+
version = "0.47.1"
456456

457457
[[deps.NetworkOptions]]
458458
uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908"
@@ -482,9 +482,9 @@ version = "0.8.1+2"
482482

483483
[[deps.OpenSSL_jll]]
484484
deps = ["Artifacts", "JLLWrappers", "Libdl"]
485-
git-tree-sha1 = "a12e56c72edee3ce6b96667745e6cbbe5498f200"
485+
git-tree-sha1 = "ad31332567b189f508a3ea8957a2640b1147ab00"
486486
uuid = "458c3c95-2e84-50aa-8efc-19380b2a3a95"
487-
version = "1.1.23+0"
487+
version = "1.1.23+1"
488488

489489
[[deps.OpenSpecFun_jll]]
490490
deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "Libdl", "Pkg"]
@@ -499,7 +499,7 @@ version = "1.6.3"
499499

500500
[[deps.Oscar]]
501501
deps = ["AbstractAlgebra", "AlgebraicSolving", "Distributed", "GAP", "Hecke", "JSON", "JSON3", "LazyArtifacts", "Markdown", "Nemo", "Pkg", "Polymake", "Random", "RandomExtensions", "Serialization", "Singular", "TOPCOM_jll", "UUIDs", "cohomCalg_jll"]
502-
git-tree-sha1 = "43d564762b225a95ea1eb26e18b52f7e9d2fbcbc"
502+
git-tree-sha1 = "6e9ad54815c837a1a27d19280dddfca5f0f5bf03"
503503
repo-rev = "master"
504504
repo-url = "https://github.com/oscar-system/Oscar.jl.git"
505505
uuid = "f1435218-dba5-11e9-1e4d-f1a5fab5fc13"
@@ -542,9 +542,9 @@ version = "1.10.0"
542542

543543
[[deps.Polymake]]
544544
deps = ["AbstractAlgebra", "BinaryWrappers", "CxxWrap", "Downloads", "JSON", "Libdl", "Mongoc", "NetworkOptions", "Ninja_jll", "Perl_jll", "Pidfile", "Pkg", "REPL", "Scratch", "SparseArrays", "TOPCOM_jll", "lib4ti2_jll", "libpolymake_julia_jll", "polymake_jll", "polymake_oscarnumber_jll"]
545-
git-tree-sha1 = "a2a6d388848beba30834c45192e7318098e96f99"
545+
git-tree-sha1 = "fa518c47ef32714e99cb0915c45b564fb91fe5bc"
546546
uuid = "d720cf60-89b5-51f5-aff5-213f193123e7"
547-
version = "0.11.20"
547+
version = "0.11.21"
548548

549549
[[deps.PrecompileTools]]
550550
deps = ["Preferences"]
@@ -569,9 +569,9 @@ version = "1.2.1"
569569

570570
[[deps.QuadGK]]
571571
deps = ["DataStructures", "LinearAlgebra"]
572-
git-tree-sha1 = "1d587203cf851a51bf1ea31ad7ff89eff8d625ea"
572+
git-tree-sha1 = "cda3b045cf9ef07a08ad46731f5a3165e56cf3da"
573573
uuid = "1fd47b50-473d-5c70-9696-f719f8f3bcdc"
574-
version = "2.11.0"
574+
version = "2.11.1"
575575

576576
[deps.QuadGK.extensions]
577577
QuadGKEnzymeExt = "Enzyme"
@@ -653,15 +653,15 @@ version = "0.9.4"
653653

654654
[[deps.Singular]]
655655
deps = ["AbstractAlgebra", "BinaryWrappers", "CxxWrap", "Libdl", "LinearAlgebra", "Nemo", "Pidfile", "Pkg", "Random", "RandomExtensions", "Singular_jll", "Statistics", "lib4ti2_jll", "libsingular_julia_jll"]
656-
git-tree-sha1 = "1490e197db038b23960cef430c56fb277fdf29a6"
656+
git-tree-sha1 = "9b6135b5c8081f83eb2c334d7a7b903c2076aef7"
657657
uuid = "bcd08a7b-43d2-5ff7-b6d4-c458787f915c"
658-
version = "0.23.5"
658+
version = "0.23.7"
659659

660660
[[deps.Singular_jll]]
661661
deps = ["Artifacts", "FLINT_jll", "GMP_jll", "JLLWrappers", "Libdl", "MPFR_jll", "cddlib_jll"]
662-
git-tree-sha1 = "08aa95d0abd0218afaffe2d41ec93194c131128e"
662+
git-tree-sha1 = "052417021e25f7aca4e81e17f5e12feb53f7ef00"
663663
uuid = "43d676ae-4934-50ba-8046-7a96366d613b"
664-
version = "404.0.504+0"
664+
version = "404.0.605+0"
665665

666666
[[deps.Sockets]]
667667
uuid = "6462fe0b-24de-5631-8697-dd941f90decc"
@@ -864,9 +864,9 @@ version = "0.3.3+0"
864864

865865
[[deps.msolve_jll]]
866866
deps = ["Artifacts", "CompilerSupportLibraries_jll", "FLINT_jll", "GMP_jll", "JLLWrappers", "LLVMOpenMP_jll", "Libdl", "MPFR_jll"]
867-
git-tree-sha1 = "0b408d2693c1389e2817f1a3468d02783161cd33"
867+
git-tree-sha1 = "7324fd011ebc4b9e43d9aa365c79797860459d0a"
868868
uuid = "6d01cc9a-e8f6-580e-8c54-544227e08205"
869-
version = "0.600.800+0"
869+
version = "0.700.200+0"
870870

871871
[[deps.nauty_jll]]
872872
deps = ["Artifacts", "GMP_jll", "JLLWrappers", "Libdl", "Pkg"]

src/Classical/linear_code.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ set to `true`, a linear code is built with `G` as the parity-check matrix. If th
1616
`brute_force_WE` is `true`, the weight enumerator and (and therefore the distance) is calculated when
1717
there are fewer than 1.5e5 codewords.
1818
"""
19-
function LinearCode(G::CTMatrixTypes, parity::Bool=false, brute_force_WE::Bool=true)
19+
function LinearCode(G::CTMatrixTypes, parity::Bool = false, brute_force_WE::Bool = true)
2020
iszero(G) && return parity ? IdentityCode(base_ring(G), ncols(G)) : ZeroCode(base_ring(G), ncols(G))
2121

2222
G_new = deepcopy(G)
@@ -75,7 +75,7 @@ function LinearCode(G::CTMatrixTypes, parity::Bool=false, brute_force_WE::Bool=t
7575
end
7676

7777
# TODO: add doc strings
78-
function LinearCode(G::T, H::T, brute_force_WE::Bool=true) where T <: CTMatrixTypes
78+
function LinearCode(G::T, H::T, brute_force_WE::Bool = true) where T <: CTMatrixTypes
7979
ncols(G) == ncols(H) ||
8080
throw(ArgumentError("The number of columns of G and H should be the same (received ncols(G) = $(ncols(G)), ncols(H) = $(ncols(H)))"))
8181
base_ring(G) == base_ring(H) || throw(ArgumentError("G and H are not over the same field"))
@@ -103,7 +103,7 @@ function LinearCode(G::T, H::T, brute_force_WE::Bool=true) where T <: CTMatrixTy
103103
return C
104104
end
105105

106-
function LinearCode(G::Matrix{Int}, q::Int, parity::Bool=false)
106+
function LinearCode(G::Matrix{Int}, q::Int, parity::Bool = false)
107107
factors = Nemo.factor(q)
108108
(length(factors) == 1 && q > 1) || throw(ArgumentError("There is no finite field of order $q."))
109109

@@ -123,7 +123,7 @@ function LinearCode(Gs::Vector{<:CTMatrixTypes})
123123
return LinearCode(G)
124124
end
125125

126-
function LinearCode(Gs::Vector{Vector{Int}}, q::Int, parity::Bool=false)
126+
function LinearCode(Gs::Vector{Vector{Int}}, q::Int, parity::Bool = false)
127127
s = size(Gs[1])
128128
all(s == size(Gs[i]) for i in 2:length(Gs)) || throw(ArgumentError("Not all vectors in `Gs` were the same size."))
129129

src/Classical/weight_dist.jl

Lines changed: 62 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,15 +1020,73 @@ function minimum_words(C::AbstractLinearCode)
10201020
end
10211021

10221022

1023-
# classical version of QDistRnd here
1024-
1025-
1026-
1023+
function random_information_set_minimum_distance_bound!(C::AbstractLinearCode; max_iters::Int = 10000, verbose::Bool = false)
1024+
1025+
order(field(C)) == 2 || throw(DomainError(C, "Currently only implemented for binary codes."))
1026+
is_positive(max_iters) || throw(DomainError(max_iters, "The number of iterations must be a positive integer."))
1027+
1028+
!ismissing(C.d) && (println("Distance already known"); return C.d;)
1029+
verbose && println("Bounding the distance")
1030+
G = _Flint_matrix_to_Julia_T_matrix(_rref_no_col_swap(C.G), UInt8)
1031+
upper, ind = _min_wt_row(G)
1032+
found = _Flint_matrix_to_Julia_T_matrix(G[ind:ind, :], UInt8)
1033+
# TODO this can contradict C.u_bound cause that requires a different found
1034+
verbose && println("Starting lower bound: $(C.l_bound)")
1035+
verbose && println("Starting upper bound: $upper")
1036+
1037+
uppers, founds = _RIS_bound_loop(G, C.l_bound, upper, found, max_iters, C.n, verbose)
1038+
loc = argmin(uppers)
1039+
C.u_bound = uppers[loc]
1040+
verbose && println("Ending $max_iters iterations with an upper bound of $(uppers[loc])")
1041+
return uppers[loc], matrix(field(C), permutedims(founds[loc]))
1042+
end
10271043

1044+
function _RIS_bound_loop!(operators_to_reduce::Matrix{T}, curr_l_bound::Int, curr_u_bound::Int,
1045+
found::Vector{T}, max_iters::Int, n::Int, verbose::Bool) where T <: Integer
10281046

1047+
num_thrds = Threads.nthreads()
1048+
verbose && println("Detected $num_thrds threads.")
10291049

1050+
flag = Threads.Atomic{Bool}(true)
1051+
uppers = [curr_u_bound for _ in 1:num_thrds]
1052+
founds = [found for _ in 1:num_thrds]
1053+
thread_load = Int(floor(max_iters / num_thrds))
1054+
remaining = max_iters - thread_load * num_thrds
1055+
Threads.@threads for t in 1:num_thrds
1056+
orig_ops = deepcopy(operators_to_reduce)
1057+
perm_ops = similar(orig_ops)
1058+
ops = similar(orig_ops)
1059+
perm = collect(1:n)
1060+
for _ in 1:(thread_load + (t <= remaining ? 1 : 0))
1061+
if flag[]
1062+
shuffle!(perm)
1063+
_col_permutation!(perm_ops, orig_ops, perm)
1064+
_rref_no_col_swap_binary!(perm_ops)
1065+
_col_permutation!(ops, perm_ops, invperm(perm))
1066+
1067+
for i in axes(perm_ops, 1)
1068+
w = 0
1069+
@inbounds for j in 1:n
1070+
isodd(ops[i, j]) && (w += 1;)
1071+
end
10301072

1073+
if uppers[t] > w
1074+
uppers[t] = w
1075+
founds[t] .= ops[i, :]
1076+
verbose && println("Adjusting (thread's local) upper bound: $w")
1077+
if curr_l_bound == w
1078+
verbose && println("Found a logical that matched the lower bound of $curr_l_bound")
1079+
Threads.atomic_cas!(flag, true, false)
1080+
break
1081+
end
1082+
end
1083+
end
1084+
end
1085+
end
1086+
end
10311087

1088+
return uppers, founds
1089+
end
10321090

10331091
#############################
10341092
# Weight Enumerators

src/LDPC/codes.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ LDPCCode(C::AbstractLinearCode) = LDPCCode(parity_check_matrix(C))
6363
Return a random regular LDPC code over `GF(q)` of length `n` with column degree `l`
6464
and row degree `r`.
6565
66-
If a seed is given, i.e. `regulardLDPCCode(4, 1200, 3, 6, seed=123)`, the
66+
If a seed is given, i.e. `regular_LDPC_Code(4, 1200, 3, 6, seed=123)`, the
6767
results are reproducible.
6868
"""
6969
function regular_LDPC_code(q::Int, n::Int, l::Int, r::Int; seed::Union{Nothing, Int} = nothing)

src/Quantum/weight_dist.jl

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -815,7 +815,7 @@ function random_information_set_minimum_distance_bound!(::HasGauges, ::IsNotCSS,
815815

816816
n = S.n
817817
!ismissing(S.d_dressed) && (println("Dressed distance already known"); return S.d_dressed;)
818-
stabs = _Flint_matrix_to_Julia_T_matrix(stabilizers(S), Int)
818+
stabs = _Flint_matrix_to_Julia_T_matrix(stabilizers(S), UInt8)
819819
_rref_no_col_swap_binary!(stabs)
820820
stabs = _remove_empty(stabs, :rows)
821821
if dressed
@@ -825,7 +825,7 @@ function random_information_set_minimum_distance_bound!(::HasGauges, ::IsNotCSS,
825825
else
826826
verbose && println("Bounding the full bare distance")
827827
end
828-
logs = _Flint_matrix_to_Julia_T_matrix(logicals_matrix(S), Int)
828+
logs = _Flint_matrix_to_Julia_T_matrix(logicals_matrix(S), UInt8)
829829
operators_to_reduce = vcat(stabs, logs)
830830
check_against = permutedims(logs[:, [n + 1:2n; 1:n]])
831831
curr_l_bound = if dressed
@@ -864,11 +864,15 @@ function random_information_set_minimum_distance_bound!(::HasNoGauges, ::IsNotCS
864864
n = S.n
865865
!ismissing(S.d) && (println("Distance already known"); return S.d;)
866866
verbose && println("Bounding the full distance")
867-
stabs = _Flint_matrix_to_Julia_T_matrix(stabilizers(S), Int)
867+
stabs = _Flint_matrix_to_Julia_T_matrix(stabilizers(S), UInt8)
868868
_rref_no_col_swap_binary!(stabs)
869+
# display(stabs)
869870
stabs = _remove_empty(stabs, :rows)
870-
logs = _Flint_matrix_to_Julia_T_matrix(logicals_matrix(S), Int)
871+
logs = _Flint_matrix_to_Julia_T_matrix(logicals_matrix(S), UInt8)
871872
operators_to_reduce = vcat(stabs, logs)
873+
# println(" ")
874+
# display(operators_to_reduce)
875+
# println(" ")
872876
check_against = permutedims(logs[:, [n + 1:2n; 1:n]])
873877
curr_l_bound = S.l_bound
874878
verbose && println("Starting lower bound: $curr_l_bound")
@@ -886,7 +890,7 @@ function random_information_set_minimum_distance_bound!(::HasNoGauges, ::IsNotCS
886890
loc = argmin(uppers)
887891
S.u_bound = uppers[loc]
888892
verbose && println("Ending $max_iters iterations with an upper bound of $(uppers[loc])")
889-
return uppers[loc], founds[loc]
893+
return uppers[loc], matrix(field(S), permutedims(founds[loc]))
890894
end
891895

892896
# TODO rewrite all for graph states
@@ -896,7 +900,9 @@ end
896900

897901
# end
898902

899-
function _RIS_bound_loop_symp!(operators_to_reduce, check_against, curr_l_bound::Int, curr_u_bound::Int, found, max_iters::Int, n::Int, verbose::Bool)
903+
function _RIS_bound_loop_symp!(operators_to_reduce::Matrix{T}, check_against::Matrix{T},
904+
curr_l_bound::Int, curr_u_bound::Int, found::Vector{T}, max_iters::Int, n::Int,
905+
verbose::Bool) where T <: Integer
900906

901907
num_thrds = Threads.nthreads()
902908
verbose && println("Detected $num_thrds threads.")
@@ -913,15 +919,16 @@ function _RIS_bound_loop_symp!(operators_to_reduce, check_against, curr_l_bound:
913919
perm_ops = similar(orig_ops)
914920
ops = similar(orig_ops)
915921
perm = collect(1:n)
916-
# perm2 = [perm; perm]
917922
for _ in 1:(thread_load + (t <= remaining ? 1 : 0))
918923
if flag[]
919924
shuffle!(perm)
920-
# perm2[1:n] .= perm
921-
# perm2[n + 1:end] .= (perm .+ n)
925+
# println("original")
926+
# display(orig_ops)
927+
# display(perm)
922928
_col_permutation_symp!(perm_ops, orig_ops, perm)
923-
# modifying this in place is not thread safe (apparently)
924-
# perm_ops = _rref_no_col_swap_binary(perm_ops)
929+
# println("permuted")
930+
# display(perm_ops)
931+
# return
925932
_rref_no_col_swap_binary!(perm_ops)
926933
_col_permutation_symp!(ops, perm_ops, invperm(perm))
927934
LinearAlgebra.mul!(log_test, ops, check_against)
@@ -952,7 +959,9 @@ function _RIS_bound_loop_symp!(operators_to_reduce, check_against, curr_l_bound:
952959
return uppers, founds
953960
end
954961

955-
function _RIS_bound_loop!(operators_to_reduce, check_against, curr_l_bound::Int, curr_u_bound::Int, found, max_iters::Int, n::Int, verbose::Bool)
962+
function _RIS_bound_loop!(operators_to_reduce::Matrix{T}, check_against::Matrix{T},
963+
curr_l_bound::Int, curr_u_bound::Int, found::Vector{T}, max_iters::Int, n::Int,
964+
verbose::Bool) where T <: Integer
956965

957966
num_thrds = Threads.nthreads()
958967
verbose && println("Detected $num_thrds threads.")

0 commit comments

Comments
 (0)