Open Fe-r-oz opened 3 months ago
It seems the issue is not specific to MixedDestabilizer
as the title suggests, but it's related to type compatibility and infinite recursion stemming from tensor(ops::AbstractStabilizer...)
in linalg.jl
. TODO at line 164
provides helpful optimization suggestion about converting to common type.
In general, The unmarked tasks give error at the moment as seen from the MREs.
Stabilizer ⊗ Destabilizer
Destabilizer ⊗ Destabilizer
MixedStabilizer ⊗ MixedStabilizer
MixedStabilizer ⊗ Stabilizer
MixedDestabilizer ⊗ Stabilizer
All good:
Stabilizer ⊗ Stabilizer
MixedDestabilizer ⊗ MixedDestabilizer
Minimal Reproducible Example 2 👇
julia> random_stabilizer(1) ⊗ random_destabilizer(2)
Error & Stacktrace or other complete output produced by the MRE 2 ⚠️
ERROR: StackOverflowError:
Stacktrace:
[1] tensor(::Stabilizer{QuantumClifford.Tableau{…}}, ::Destabilizer{QuantumClifford.Tableau{…}})
@ QuantumClifford ~/Desktop/New/NONSTABILIZER/tasksone/QuantumClifford.jl/src/linalg.jl:165
[2] (::Base.BottomRF{…})(acc::Stabilizer{…}, x::Destabilizer{…})
@ Base ./reduce.jl:86
[3] afoldl(op::Base.BottomRF{…}, a::Stabilizer{…}, bs::Destabilizer{…})
@ Base ./operators.jl:544
[4] _foldl_impl(op::Base.BottomRF{…}, init::Stabilizer{…}, itr::Tuple{…})
@ Base ./reduce.jl:68
[5] foldl_impl(op::Base.BottomRF{typeof(tensor)}, nt::Stabilizer{QuantumClifford.Tableau{…}}, itr::Tuple{Destabilizer{…}})
@ Base ./reduce.jl:48
[6] mapfoldl_impl(f::typeof(identity), op::typeof(tensor), nt::Stabilizer{…}, itr::Tuple{…})
@ Base ./reduce.jl:44
[7] mapfoldl(f::Function, op::Function, itr::Tuple{Destabilizer{…}}; init::Stabilizer{QuantumClifford.Tableau{…}})
@ Base ./reduce.jl:175
[8] mapfoldl
@ ./reduce.jl:175 [inlined]
[9] #foldl#299
@ ./reduce.jl:198 [inlined]
--- the last 9 lines are repeated 6664 more times ---
[59986] tensor(::Stabilizer{QuantumClifford.Tableau{…}}, ::Destabilizer{QuantumClifford.Tableau{…}})
@ QuantumClifford ~/Desktop/New/NONSTABILIZER/tasksone/QuantumClifford.jl/src/linalg.jl:165
Some type information was truncated. Use `show(err)` to see complete types
Minimal Reproducible Example 3 👇
julia> random_destabilizer(2) ⊗ random_destabilizer(2)
Error & Stacktrace or other complete output produced by the MRE 3 ⚠️
ERROR: StackOverflowError:
Stacktrace:
[1] afoldl(op::Base.BottomRF{…}, a::Destabilizer{…}, bs::Destabilizer{…})
@ Base ./operators.jl:540
[2] _foldl_impl(op::Base.BottomRF{typeof(tensor)}, init::Destabilizer{QuantumClifford.Tableau{…}}, itr::Tuple{Destabilizer{…}})
@ Base ./reduce.jl:68
[3] foldl_impl(op::Base.BottomRF{typeof(tensor)}, nt::Destabilizer{QuantumClifford.Tableau{…}}, itr::Tuple{Destabilizer{…}})
@ Base ./reduce.jl:48
[4] mapfoldl_impl(f::typeof(identity), op::typeof(tensor), nt::Destabilizer{…}, itr::Tuple{…})
@ Base ./reduce.jl:44
[5] mapfoldl(f::Function, op::Function, itr::Tuple{Destabilizer{…}}; init::Destabilizer{QuantumClifford.Tableau{…}})
@ Base ./reduce.jl:175
[6] mapfoldl
@ ./reduce.jl:175 [inlined]
[7] #foldl#299
@ ./reduce.jl:198 [inlined]
[8] tensor(::Destabilizer{QuantumClifford.Tableau{…}}, ::Destabilizer{QuantumClifford.Tableau{…}})
@ QuantumClifford ~/Desktop/New/NONSTABILIZER/tasksone/QuantumClifford.jl/src/linalg.jl:165
[9] (::Base.BottomRF{typeof(tensor)})(acc::Destabilizer{QuantumClifford.Tableau{…}}, x::Destabilizer{QuantumClifford.Tableau{…}})
@ Base ./reduce.jl:86
[10] afoldl(op::Base.BottomRF{…}, a::Destabilizer{…}, bs::Destabilizer{…})
@ Base ./operators.jl:544
--- the last 9 lines are repeated 6664 more times ---
[59987] _foldl_impl(op::Base.BottomRF{typeof(tensor)}, init::Destabilizer{QuantumClifford.Tableau{…}}, itr::Tuple{Destabilizer{…}})
@ Base ./reduce.jl:68
[59988] foldl_impl(op::Base.BottomRF{typeof(tensor)}, nt::Destabilizer{QuantumClifford.Tableau{…}}, itr::Tuple{Destabilizer{…}})
@ Base ./reduce.jl:48
Some type information was truncated. Use `show(err)` to see complete types.
Minimal Reproducible Example 4 👇
julia> mixeds = MixedStabilizer(S"XXX ZZ_ _ZZ");
julia> mixeds ⊗ mixeds
Error & Stacktrace or other complete output produced by the MRE 4 ⚠️
ERROR: StackOverflowError:
Stacktrace:
[1] mapfoldl(f::Function, op::Function, itr::Tuple{MixedStabilizer{…}}; init::MixedStabilizer{QuantumClifford.Tableau{…}})
@ Base ./reduce.jl:175
[2] mapfoldl
@ ./reduce.jl:175 [inlined]
[3] #foldl#299
@ ./reduce.jl:198 [inlined]
[4] tensor(::MixedStabilizer{QuantumClifford.Tableau{…}}, ::MixedStabilizer{QuantumClifford.Tableau{…}})
@ QuantumClifford ~/Desktop/New/NONSTABILIZER/tasksone/QuantumClifford.jl/src/linalg.jl:165
[5] (::Base.BottomRF{…})(acc::MixedStabilizer{…}, x::MixedStabilizer{…})
@ Base ./reduce.jl:86
[6] afoldl(op::Base.BottomRF{…}, a::MixedStabilizer{…}, bs::MixedStabilizer{…})
@ Base ./operators.jl:544
[7] _foldl_impl(op::Base.BottomRF{…}, init::MixedStabilizer{…}, itr::Tuple{…})
@ Base ./reduce.jl:68
[8] foldl_impl(op::Base.BottomRF{typeof(tensor)}, nt::MixedStabilizer{QuantumClifford.Tableau{…}}, itr::Tuple{MixedStabilizer{…}})
@ Base ./reduce.jl:48
[9] mapfoldl_impl(f::typeof(identity), op::typeof(tensor), nt::MixedStabilizer{…}, itr::Tuple{…})
@ Base ./reduce.jl:44
--- the last 9 lines are repeated 6664 more times ---
[59986] mapfoldl(f::Function, op::Function, itr::Tuple{MixedStabilizer{…}}; init::MixedStabilizer{QuantumClifford.Tableau{…}})
@ Base ./reduce.jl:175
[59987] mapfoldl
@ ./reduce.jl:175 [inlined]
Some type information was truncated. Use `show(err)` to see complete types.
Compared to MRE4, these all good:
julia> ghz(3) ⊗ ghz(3)
+ XXX___
+ ZZ____
+ _ZZ___
+ ___XXX
+ ___ZZ_
+ ____ZZ
julia> random_stabilizer(1) ⊗ random_stabilizer(1)
- Y_
+ _Z
julia> random_stabilizer(2) ⊗ random_stabilizer(2)
- ZZ__
- XX__
- __Y_
- ___X
Describe the bug 🐞
My assumption is that since we have to implement
sm ⊗ S"X"
wheresm.stab
of same type asmd
, therefore thismd ⊗ S"X"
should work?Expected behavior
Since there is no method definition error which means that there should be no stackoverflow error hopefully.
Minimal Reproducible Example 👇
Error & Stacktrace or other complete output produced by the MRE ⚠️
Environment (please complete the following information):
using Pkg; Pkg.status()
using Pkg; Pkg.status(; mode = PKGMODE_MANIFEST)
versioninfo()