Skip to content

Commit b4aeaf9

Browse files
committed
Merge remote-tracking branch 'origin/dev' into dev
2 parents 63834db + c3ab28f commit b4aeaf9

File tree

1 file changed

+91
-57
lines changed

1 file changed

+91
-57
lines changed

src/Quantum/weight_dist.jl

Lines changed: 91 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -656,102 +656,121 @@ function random_information_set_minimum_distance_bound!(::HasGauges, ::IsCSS, ::
656656
S::AbstractSubsystemCode, which::Symbol, dressed::Bool, max_iters::Int, verbose::Bool)
657657
# this is a CSS subsystem code
658658

659+
n = S.n
659660
if dressed
660661
if which == :full
661662
verbose && println("Bounding the full dressed distance")
662-
stabs = _remove_empty(_rref_no_col_swap!(_Flint_matrix_to_Julia_T_matrix(
663-
stabilizers(S), UInt8)), :rows)
664-
gauges = _Flint_matrix_to_Julia_T_matrix(gauges_matrix(S), UInt8)
665-
logs = _Flint_matrix_to_Julia_T_matrix(logicals_matrix(S), UInt8)
663+
stabs = _Flint_matrix_to_Julia_T_matrix(stabilizers(S), Int)
664+
_rref_no_col_swap!(stabs)
665+
stabs = _remove_empty(stabs, :rows)
666+
gauges = _Flint_matrix_to_Julia_T_matrix(gauges_matrix(S), Int)
667+
logs = _Flint_matrix_to_Julia_T_matrix(logicals_matrix(S), Int)
666668
operators_to_reduce = vcat(stabs, gauges, logs)
667669
check_against = permutedims(logs[:, [n + 1:2n; 1:n]])
668670
curr_l_bound = S.l_bound_dressed
671+
verbose && println("Starting lower bound: $curr_l_bound")
669672

670673
# this is done in the constructor but the logical is not stored at the time
671674
# so must redo here
672-
_, mat = _rref_no_col_swap!(operators_to_reduce)
675+
mat = _rref_no_col_swap(operators_to_reduce)
673676
anti = mat * check_against
674-
curr_u_bound, index = findmin(row_wts_symplectic(mat[findall(!iszero(anti[i:i, :]) for i in axes(anti, 1)), :]))
677+
curr_u_bound, index = findmin(row_wts_symplectic(mat[findall(!iszero(anti[i, :]) for i in axes(anti, 1)), :]))
675678
found = operators_to_reduce[index, :]
679+
verbose && println("Starting upper bound: $curr_u_bound")
676680
elseif which == :X
677681
verbose && println("Bounding the dressed X-distance")
678-
stabs = _remove_empty(_rref_no_col_swap!(_Flint_matrix_to_Julia_T_matrix(
679-
X_stabilizers(S), UInt8)), :rows)
680-
gauges = _Flint_matrix_to_Julia_T_matrix(reduce(vcat, [log[1][:, 1:n] for log in S.gauge_ops]), UInt8)
681-
logs = _Flint_matrix_to_Julia_T_matrix(reduce(vcat, [log[1][:, 1:n] for log in S.logicals]), UInt8)
682+
stabs = _Flint_matrix_to_Julia_T_matrix(stabilizers(S), Int)
683+
_rref_no_col_swap!(stabs)
684+
stabs = _remove_empty(stabs, :rows)
685+
gauges = _Flint_matrix_to_Julia_T_matrix(reduce(vcat, [log[1][:, 1:n] for log in S.gauge_ops]), Int)
686+
logs = _Flint_matrix_to_Julia_T_matrix(reduce(vcat, [log[1][:, 1:n] for log in S.logicals]), Int)
682687
operators_to_reduce = vcat(stabs, gauges, logs)
683688
check_against = permutedims(reduce(vcat, [log[2][:, n + 1:end] for log in S.logicals])[:, [n + 1:2n; 1:n]])
684689
curr_l_bound = S.l_bound_dx_dressed
690+
verbose && println("Starting lower bound: $curr_l_bound")
685691

686692
# this is done in the constructor but the logical is not stored at the time
687693
# so must redo here
688-
_, mat = _rref_no_col_swap!(operators_to_reduce)
694+
mat = _rref_no_col_swap(operators_to_reduce)
689695
anti = mat * check_against
690-
curr_u_bound, index = findmin(row_wts(mat[findall(!iszero(anti[i:i, :]) for i in axes(anti, 1)), :]))
696+
curr_u_bound, index = findmin(row_wts_symplectic(mat[findall(!iszero(anti[i, :]) for i in axes(anti, 1)), :]))
691697
found = operators_to_reduce[index, :]
698+
verbose && println("Starting upper bound: $curr_u_bound")
692699
else
693700
verbose && println("Bounding the dressed Z-distance")
694-
stabs = _remove_empty(_rref_no_col_swap!(_Flint_matrix_to_Julia_T_matrix(
695-
Z_stabilizers(S), UInt8)), :rows)
696-
gauges = _Flint_matrix_to_Julia_T_matrix(reduce(vcat, [log[2][:, n + 1:end] for log in S.gauge_ops]), UInt8)
697-
logs = _Flint_matrix_to_Julia_T_matrix(reduce(vcat, [log[2][:, n + 1:end] for log in S.logicals]), UInt8)
701+
stabs = _Flint_matrix_to_Julia_T_matrix(stabilizers(S), Int)
702+
_rref_no_col_swap!(stabs)
703+
stabs = _remove_empty(stabs, :rows)
704+
gauges = _Flint_matrix_to_Julia_T_matrix(reduce(vcat, [log[2][:, n + 1:end] for log in S.gauge_ops]), Int)
705+
logs = _Flint_matrix_to_Julia_T_matrix(reduce(vcat, [log[2][:, n + 1:end] for log in S.logicals]), Int)
698706
operators_to_reduce = vcat(stabs, gauges, logs)
699707
check_against = permutedims(reduce(vcat, [log[1][:, 1:n] for log in S.logicals]))
700708
curr_l_bound = S.l_bound_dz_dressed
709+
verbose && println("Starting lower bound: $curr_l_bound")
701710

702711
# this is done in the constructor but the logical is not stored at the time
703712
# so must redo here
704-
_, mat = _rref_no_col_swap!(operators_to_reduce)
713+
mat = _rref_no_col_swap(operators_to_reduce)
705714
anti = mat * check_against
706-
curr_u_bound, index = findmin(row_wts(mat[findall(!iszero(anti[i:i, :]) for i in axes(anti, 1)), :]))
715+
curr_u_bound, index = findmin(row_wts_symplectic(mat[findall(!iszero(anti[i, :]) for i in axes(anti, 1)), :]))
707716
found = operators_to_reduce[index, :]
717+
verbose && println("Starting upper bound: $curr_u_bound")
708718
end
709719
else
710720
if which == :full
711721
verbose && println("Bounding the full bare distance")
712-
stabs = _remove_empty(_rref_no_col_swap!(_Flint_matrix_to_Julia_T_matrix(
713-
stabilizers(S), UInt8)), :rows)
714-
logs = _Flint_matrix_to_Julia_T_matrix(logicals_matrix(S), UInt8)
722+
stabs = _Flint_matrix_to_Julia_T_matrix(stabilizers(S), Int)
723+
_rref_no_col_swap!(stabs)
724+
stabs = _remove_empty(stabs, :rows)
725+
logs = _Flint_matrix_to_Julia_T_matrix(logicals_matrix(S), Int)
715726
operators_to_reduce = vcat(stabs, logs)
716727
check_against = permutedims(logs[:, [n + 1:2n; 1:n]])
717728
curr_l_bound = S.l_bound_bare
729+
verbose && println("Starting lower bound: $curr_l_bound")
718730

719731
# this is done in the constructor but the logical is not stored at the time
720732
# so must redo here
721-
_, mat = _rref_no_col_swap!(operators_to_reduce)
733+
mat = _rref_no_col_swap(operators_to_reduce)
722734
anti = mat * check_against
723-
curr_u_bound, index = findmin(row_wts_symplectic(mat[findall(!iszero(anti[i:i, :]) for i in axes(anti, 1)), :]))
735+
curr_u_bound, index = findmin(row_wts_symplectic(mat[findall(!iszero(anti[i, :]) for i in axes(anti, 1)), :]))
724736
found = operators_to_reduce[index, :]
737+
verbose && println("Starting upper bound: $curr_u_bound")
725738
elseif which == :X
726739
verbose && println("Bounding the bare X-distance")
727-
stabs = _remove_empty(_rref_no_col_swap!(_Flint_matrix_to_Julia_T_matrix(
728-
X_stabilizers(S), UInt8)), :rows)
729-
logs = _Flint_matrix_to_Julia_T_matrix(reduce(vcat, [log[1][:, 1:n] for log in S.logicals]), UInt8)
740+
stabs = _Flint_matrix_to_Julia_T_matrix(stabilizers(S), Int)
741+
_rref_no_col_swap!(stabs)
742+
stabs = _remove_empty(stabs, :rows)
743+
logs = _Flint_matrix_to_Julia_T_matrix(reduce(vcat, [log[1][:, 1:n] for log in S.logicals]), Int)
730744
operators_to_reduce = vcat(stabs, logs)
731745
check_against = permutedims(reduce(vcat, [log[2][:, n + 1:end] for log in S.logicals])[:, [n + 1:2n; 1:n]])
732746
curr_l_bound = S.l_bound_dx_bare
747+
verbose && println("Starting lower bound: $curr_l_bound")
733748

734749
# this is done in the constructor but the logical is not stored at the time
735750
# so must redo here
736-
_, mat = _rref_no_col_swap!(operators_to_reduce)
751+
mat = _rref_no_col_swap(operators_to_reduce)
737752
anti = mat * check_against
738-
curr_u_bound, index = findmin(row_wts(mat[findall(!iszero(anti[i:i, :]) for i in axes(anti, 1)), :]))
753+
curr_u_bound, index = findmin(row_wts_symplectic(mat[findall(!iszero(anti[i, :]) for i in axes(anti, 1)), :]))
739754
found = operators_to_reduce[index, :]
755+
verbose && println("Starting upper bound: $curr_u_bound")
740756
else
741757
verbose && println("Bounding the bare Z-distance")
742-
stabs = _remove_empty(_rref_no_col_swap!(_Flint_matrix_to_Julia_T_matrix(
743-
Z_stabilizers(S), UInt8)), :rows)
744-
logs = _Flint_matrix_to_Julia_T_matrix(reduce(vcat, [log[2][:, n + 1:end] for log in S.logicals]), UInt8)
758+
stabs = _Flint_matrix_to_Julia_T_matrix(stabilizers(S), Int)
759+
_rref_no_col_swap!(stabs)
760+
stabs = _remove_empty(stabs, :rows)
761+
logs = _Flint_matrix_to_Julia_T_matrix(reduce(vcat, [log[2][:, n + 1:end] for log in S.logicals]), Int)
745762
operators_to_reduce = vcat(stabs, logs)
746763
check_against = permutedims(reduce(vcat, [log[1][:, 1:n] for log in S.logicals]))
747764
curr_l_bound = S.l_bound_dx_bare
765+
verbose && println("Starting lower bound: $curr_l_bound")
748766

749767
# this is done in the constructor but the logical is not stored at the time
750768
# so must redo here
751-
_, mat = _rref_no_col_swap!(operators_to_reduce)
769+
mat = _rref_no_col_swap(operators_to_reduce)
752770
anti = mat * check_against
753-
curr_u_bound, index = findmin(row_wts(mat[findall(!iszero(anti[i:i, :]) for i in axes(anti, 1)), :]))
771+
curr_u_bound, index = findmin(row_wts_symplectic(mat[findall(!iszero(anti[i, :]) for i in axes(anti, 1)), :]))
754772
found = operators_to_reduce[index, :]
773+
verbose && println("Starting upper bound: $curr_u_bound")
755774
end
756775
end
757776

@@ -805,34 +824,40 @@ function random_information_set_minimum_distance_bound!(::HasNoGauges, ::IsCSS,
805824
verbose && println("Starting upper bound: $curr_u_bound")
806825
elseif which == :X
807826
verbose && println("Bounding the X-distance")
808-
stabs = _remove_empty(_rref_no_col_swap!(_Flint_matrix_to_Julia_T_matrix(
809-
X_stabilizers(S), UInt8)), :rows)
810-
logs = _Flint_matrix_to_Julia_T_matrix(reduce(vcat, [log[1][:, 1:n] for log in S.logicals]), UInt8)
827+
stabs = _Flint_matrix_to_Julia_T_matrix(stabilizers(S), Int)
828+
_rref_no_col_swap!(stabs)
829+
stabs = _remove_empty(stabs, :rows)
830+
logs = _Flint_matrix_to_Julia_T_matrix(reduce(vcat, [log[1][:, 1:n] for log in S.logicals]), Int)
811831
operators_to_reduce = vcat(stabs, logs)
812832
check_against = permutedims(reduce(vcat, [log[2][:, n + 1:end] for log in S.logicals])[:, [n + 1:2n; 1:n]])
813833
curr_l_bound = S.l_bound_dx
834+
verbose && println("Starting lower bound: $curr_l_bound")
814835

815836
# this is done in the constructor but the logical is not stored at the time
816837
# so must redo here
817-
_, mat = _rref_no_col_swap!(operators_to_reduce)
838+
mat = _rref_no_col_swap(operators_to_reduce)
818839
anti = mat * check_against
819-
curr_u_bound, index = findmin(row_wts(mat[findall(!iszero(anti[i:i, :]) for i in axes(anti, 1)), :]))
840+
curr_u_bound, index = findmin(row_wts_symplectic(mat[findall(!iszero(anti[i, :]) for i in axes(anti, 1)), :]))
820841
found = operators_to_reduce[index, :]
842+
verbose && println("Starting upper bound: $curr_u_bound")
821843
else
822844
verbose && println("Bounding the Z-distance")
823-
stabs = _remove_empty(_rref_no_col_swap!(_Flint_matrix_to_Julia_T_matrix(
824-
Z_stabilizers(S), UInt8)), :rows)
825-
logs = _Flint_matrix_to_Julia_T_matrix(reduce(vcat, [log[2][:, n + 1:end] for log in S.logicals]), UInt8)
845+
stabs = _Flint_matrix_to_Julia_T_matrix(stabilizers(S), Int)
846+
_rref_no_col_swap!(stabs)
847+
stabs = _remove_empty(stabs, :rows)
848+
logs = _Flint_matrix_to_Julia_T_matrix(reduce(vcat, [log[2][:, n + 1:end] for log in S.logicals]), Int)
826849
operators_to_reduce = vcat(stabs, logs)
827850
check_against = permutedims(reduce(vcat, [log[1][:, 1:n] for log in S.logicals]))
828851
curr_l_bound = S.l_bound_dx
852+
verbose && println("Starting lower bound: $curr_l_bound")
829853

830854
# this is done in the constructor but the logical is not stored at the time
831855
# so must redo here
832-
_, mat = _rref_no_col_swap!(operators_to_reduce)
856+
mat = _rref_no_col_swap(operators_to_reduce)
833857
anti = mat * check_against
834-
curr_u_bound, index = findmin(row_wts(mat[findall(!iszero(anti[i:i, :]) for i in axes(anti, 1)), :]))
858+
curr_u_bound, index = findmin(row_wts_symplectic(mat[findall(!iszero(anti[i, :]) for i in axes(anti, 1)), :]))
835859
found = operators_to_reduce[index, :]
860+
verbose && println("Starting upper bound: $curr_u_bound")
836861
end
837862

838863
uppers, founds = _RIS_bound_loop!(operators_to_reduce, check_against, curr_l_bound,
@@ -854,37 +879,44 @@ function random_information_set_minimum_distance_bound!(::HasGauges, ::IsNotCSS,
854879

855880
which == :full || throw(ArguementError(which, "Parameter is not valid for non-CSS codes."))
856881

882+
n = S.n
857883
if dressed
858884
verbose && println("Bounding the full dressed distance")
859-
stabs = _remove_empty(_rref_no_col_swap!(_Flint_matrix_to_Julia_T_matrix(
860-
stabilizers(S), UInt8)), :rows)
861-
gauges = _Flint_matrix_to_Julia_T_matrix(gauges_matrix(S), UInt8)
862-
logs = _Flint_matrix_to_Julia_T_matrix(logicals_matrix(S), UInt8)
885+
stabs = _Flint_matrix_to_Julia_T_matrix(stabilizers(S), Int)
886+
_rref_no_col_swap!(stabs)
887+
stabs = _remove_empty(stabs, :rows)
888+
gauges = _Flint_matrix_to_Julia_T_matrix(gauges_matrix(S), Int)
889+
logs = _Flint_matrix_to_Julia_T_matrix(logicals_matrix(S), Int)
863890
operators_to_reduce = vcat(stabs, gauges, logs)
864891
check_against = permutedims(logs[:, [n + 1:2n; 1:n]])
865892
curr_l_bound = S.l_bound_dressed
893+
verbose && println("Starting lower bound: $curr_l_bound")
866894

867895
# this is done in the constructor but the logical is not stored at the time
868896
# so must redo here
869-
_, mat = _rref_no_col_swap!(operators_to_reduce)
897+
mat = _rref_no_col_swap(operators_to_reduce)
870898
anti = mat * check_against
871899
curr_u_bound, index = findmin(row_wts_symplectic(mat[findall(!iszero(anti[i, :]) for i in axes(anti, 1)), :]))
872900
found = operators_to_reduce[index, :]
901+
verbose && println("Starting upper bound: $curr_u_bound")
873902
else
874903
verbose && println("Bounding the full bare distance")
875-
stabs = _remove_empty(_rref_no_col_swap!(_Flint_matrix_to_Julia_T_matrix(
876-
stabilizers(S), UInt8)), :rows)
877-
logs = _Flint_matrix_to_Julia_T_matrix(logicals_matrix(S), UInt8)
904+
stabs = _Flint_matrix_to_Julia_T_matrix(stabilizers(S), Int)
905+
_rref_no_col_swap!(stabs)
906+
stabs = _remove_empty(stabs, :rows)
907+
logs = _Flint_matrix_to_Julia_T_matrix(logicals_matrix(S), Int)
878908
operators_to_reduce = vcat(stabs, logs)
879909
check_against = permutedims(logs[:, [n + 1:2n; 1:n]])
880910
curr_l_bound = S.l_bound_bare
911+
verbose && println("Starting lower bound: $curr_l_bound")
881912

882913
# this is done in the constructor but the logical is not stored at the time
883914
# so must redo here
884-
_, mat = _rref_no_col_swap!(operators_to_reduce)
915+
mat = _rref_no_col_swap(operators_to_reduce)
885916
anti = mat * check_against
886917
curr_u_bound, index = findmin(row_wts_symplectic(mat[findall(!iszero(anti[i, :]) for i in axes(anti, 1)), :]))
887918
found = operators_to_reduce[index, :]
919+
verbose && println("Starting upper bound: $curr_u_bound")
888920
end
889921

890922
uppers, founds = _RIS_bound_loop!(operators_to_reduce, check_against, curr_l_bound,
@@ -904,20 +936,22 @@ function random_information_set_minimum_distance_bound!(::HasNoGauges, ::IsNotCS
904936

905937
which == :full || throw(ArguementError(which, "Parameter is not valid for non-CSS codes."))
906938

939+
n = S.n
907940
verbose && println("Bounding the full distance")
908-
stabs = _remove_empty(_rref_no_col_swap!(_Flint_matrix_to_Julia_T_matrix(
909-
stabilizers(S), UInt8)), :rows)
910-
logs = _Flint_matrix_to_Julia_T_matrix(logicals_matrix(S), UInt8)
941+
stabs = _Flint_matrix_to_Julia_T_matrix(stabilizers(S), Int)
942+
_rref_no_col_swap!(stabs)
943+
stabs = _remove_empty(stabs, :rows)
944+
logs = _Flint_matrix_to_Julia_T_matrix(logicals_matrix(S), Int)
911945
operators_to_reduce = vcat(stabs, logs)
912946
check_against = permutedims(logs[:, [n + 1:2n; 1:n]])
913947
curr_l_bound = S.l_bound
914948
verbose && println("Starting lower bound: $curr_l_bound")
915949

916950
# this is done in the constructor but the logical is not stored at the time
917951
# so must redo here
918-
_, mat = _rref_no_col_swap!(operators_to_reduce)
952+
mat = _rref_no_col_swap(operators_to_reduce)
919953
anti = mat * check_against
920-
curr_u_bound, index = findmin(row_wts_symplectic(mat[findall(!iszero(anti[i:i, :]) for i in axes(anti, 1)), :]))
954+
curr_u_bound, index = findmin(row_wts_symplectic(mat[findall(!iszero(anti[i, :]) for i in axes(anti, 1)), :]))
921955
found = operators_to_reduce[index, :]
922956
verbose && println("Starting upper bound: $curr_u_bound")
923957

0 commit comments

Comments
 (0)