Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no method matching affectedqubits(::NoiseOpAll) and apply!(::PauliFrame{...}, ::BellMeasurement) #337

Open
Fe-r-oz opened this issue Aug 8, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@Fe-r-oz
Copy link
Contributor

Fe-r-oz commented Aug 8, 2024

Describe the bug 🐞

Whilst going through the examples of noisy circuits, there are two methods that are not defined which are detailed below.

Expected behavior

Either it's a documentation issue or it's an issue with the missing methods for the two exmples cases in which a user might try to unknowingly end up with the same issue. Hopefully, maybe there is some merit to define the missing methods. Or maybe I am missing something and there are valid reasons that I don't know of why the methods were not defined in affectedqubits.jl and pauliframes.jl. Please find the MRE attached below:

Minimal Reproducible Example 👇

julia> using QuantumClifford
julia> using QuantumClifford.Experimental.NoisyCircuits
julia> using Quantikz
julia> good_bell_state =  ghz(2);
julia> canonicalize_rref!(good_bell_state);
julia> initial_state = MixedDestabilizer(good_bell_stategood_bell_state);
julia> g1 = sCNOT(1,3); g2 = sCNOT(2,4);
julia> m = BellMeasurement([sMX(3),sMX(4)]);
julia> v = VerifyOp(good_bell_state,[1,2]);
julia> n = NoiseOpAll(UnbiasedUncorrelatedNoise(0.01))
NoiseOpAll(UnbiasedUncorrelatedNoise{Float64}(0.01))
julia> noisy_circuit = [n,g1,g2,m,v]
5-element Vector{QuantumClifford.AbstractOperation}:
 NoiseOpAll(UnbiasedUncorrelatedNoise{Float64}(0.01))
 sCNOT(1,3)
 sCNOT(2,4)
 BellMeasurement(Union{sMX, sMY, sMZ}[sMX(3, 0), sMX(4, 0)], false)
 VerifyOp(Stabilizer 2×2, [1, 2])
julia> nccircuit = eltype(noisy_circuit) <: QuantumClifford.CompactifiedGate ? noisy_circuit : compactify_circuit(noisy_circuit)
5-element Vector{QuantumClifford.CompactifiedGate}:
 QuantumClifford.NoiseOpAll(UnbiasedUncorrelatedNoise{Float64}(0.01))::QuantumClifford.CompactifiedGate
 QuantumClifford.sCNOT(1, 3)::QuantumClifford.CompactifiedGate
 QuantumClifford.sCNOT(2, 4)::QuantumClifford.CompactifiedGate
 QuantumClifford.BellMeasurement(Union{sMX, sMY, sMZ}[sMX(3, 0), sMX(4, 0)], false)::QuantumClifford.CompactifiedGate
 QuantumClifford.VerifyOp(+ ZZ
+ XX, [1, 2])::QuantumClifford.CompactifiedGate
julia> result = pftrajectories(nccircuit)

Error & Stacktrace or other complete output produced by the MRE ⚠️

ERROR: MethodError: no method matching affectedqubits(::NoiseOpAll)

Closest candidates are:
  affectedqubits(::NoisyGate)
   @ QuantumClifford ~/Desktop/New/analysis/QuantumClifford.jl/src/affectedqubits.jl:5
  affectedqubits(::ConditionalGate)
   @ QuantumClifford ~/Desktop/New/analysis/QuantumClifford.jl/src/experimental/NoisyCircuits.jl:92
  affectedqubits(::BellMeasurement)
   @ QuantumClifford ~/Desktop/New/analysis/QuantumClifford.jl/src/affectedqubits.jl:7
  ...

Stacktrace:
  [1] macro expansion
    @ ~/Desktop/New/analysis/QuantumClifford.jl/src/sumtypes.jl:82 [inlined]
  [2] macro expansion
    @ ~/.julia/packages/SumTypes/aO6qd/src/cases.jl:120 [inlined]
  [3] affectedqubits(g::QuantumClifford.CompactifiedGate)
    @ QuantumClifford ~/Desktop/New/analysis/QuantumClifford.jl/src/sumtypes.jl:81
  [4] (::QuantumClifford.var"#195#197")(g::QuantumClifford.CompactifiedGate)
    @ QuantumClifford ./none:0
  [5] MappingRF
    @ ./reduce.jl:100 [inlined]
  [6] _foldl_impl(op::Base.MappingRF{…}, init::Base._InitialValue, itr::Vector{…})
    @ Base ./reduce.jl:58
  [7] foldl_impl
    @ ./reduce.jl:48 [inlined]
  [8] mapfoldl_impl
    @ ./reduce.jl:44 [inlined]
  [9] mapfoldl
    @ ./reduce.jl:175 [inlined]
 [10] mapreduce
    @ ./reduce.jl:307 [inlined]
 [11] maximum
    @ ./reduce.jl:764 [inlined]
 [12] _create_pauliframe(ccircuit::Vector{QuantumClifford.CompactifiedGate}; trajectories::Int64)
    @ QuantumClifford ~/Desktop/New/analysis/QuantumClifford.jl/src/pauli_frames.jl:191
 [13] _create_pauliframe
    @ ~/Desktop/New/analysis/QuantumClifford.jl/src/pauli_frames.jl:190 [inlined]
 [14] _pftrajectories(circuit::Vector{QuantumClifford.CompactifiedGate}; trajectories::Int64, threads::Bool)
    @ QuantumClifford ~/Desktop/New/analysis/QuantumClifford.jl/src/pauli_frames.jl:207
 [15] _pftrajectories
    @ ~/Desktop/New/analysis/QuantumClifford.jl/src/pauli_frames.jl:196 [inlined]
 [16] #pftrajectories#193
    @ ~/Desktop/New/analysis/QuantumClifford.jl/src/pauli_frames.jl:187 [inlined]
 [17] pftrajectories(circuit::Vector{QuantumClifford.CompactifiedGate})
    @ QuantumClifford ~/Desktop/New/analysis/QuantumClifford.jl/src/pauli_frames.jl:186
 [18] top-level scope
    @ REPL[26]:1
Some type information was truncated. Use `show(err)` to see complete types.

Continuing with no noise, we see a different error, this time with PauliFrame:

Error & Stacktrace or other complete output produced by the MRE ⚠️

julia> no_noise = [g1,g2,m,v];
julia> with_no_circuit = eltype(no_noise) <: QuantumClifford.CompactifiedGate ? no_noise : compactify_circuit(no_noise)
4-element Vector{QuantumClifford.CompactifiedGate}:
 QuantumClifford.sCNOT(1, 3)::QuantumClifford.CompactifiedGate
 QuantumClifford.sCNOT(2, 4)::QuantumClifford.CompactifiedGate
 QuantumClifford.BellMeasurement(Union{sMX, sMY, sMZ}[sMX(3, 0), sMX(4, 0)], false)::QuantumClifford.CompactifiedGate
 QuantumClifford.VerifyOp(+ ZZ
+ XX, [1, 2])::QuantumClifford.CompactifiedGate
julia> result = pftrajectories(with_no_circuit)

Error & Stacktrace or other complete output produced by the MRE ⚠️

ERROR: MethodError: no method matching apply!(::PauliFrame{Stabilizer{QuantumClifford.Tableau{Vector{}, LinearAlgebra.Adjoint{}}}, Matrix{Bool}}, ::BellMeasurement)

Closest candidates are:
  apply!(::Register, ::Any, Any...; kwargs...)
   @ QuantumClifford ~/Desktop/New/analysis/QuantumClifford.jl/src/classical_register.jl:36
  apply!(::QuantumClifford.AbstractQCState, ::NoisyGate)
   @ QuantumClifford ~/Desktop/New/analysis/QuantumClifford.jl/src/noise.jl:125
  apply!(::QuantumClifford.AbstractQCState, ::NoiseOpAll)
   @ QuantumClifford ~/Desktop/New/analysis/QuantumClifford.jl/src/noise.jl:133
  ...

Stacktrace:
 [1] macro expansion
   @ ~/Desktop/New/analysis/QuantumClifford.jl/src/sumtypes.jl:82 [inlined]
 [2] macro expansion
   @ ~/.julia/packages/SumTypes/aO6qd/src/cases.jl:120 [inlined]
 [3] apply!(s::PauliFrame{Stabilizer{QuantumClifford.Tableau{…}}, Matrix{Bool}}, g::QuantumClifford.CompactifiedGate)
   @ QuantumClifford ~/Desktop/New/analysis/QuantumClifford.jl/src/sumtypes.jl:81
 [4] pftrajectories
   @ ~/Desktop/New/analysis/QuantumClifford.jl/src/pauli_frames.jl:229 [inlined]
 [5] _pftrajectories(circuit::Vector{QuantumClifford.CompactifiedGate}; trajectories::Int64, threads::Bool)
   @ QuantumClifford ~/Desktop/New/analysis/QuantumClifford.jl/src/pauli_frames.jl:217
 [6] _pftrajectories
   @ ~/Desktop/New/analysis/QuantumClifford.jl/src/pauli_frames.jl:196 [inlined]
 [7] #pftrajectories#193
   @ ~/Desktop/New/analysis/QuantumClifford.jl/src/pauli_frames.jl:187 [inlined]
 [8] pftrajectories(circuit::Vector{QuantumClifford.CompactifiedGate})
   @ QuantumClifford ~/Desktop/New/analysis/QuantumClifford.jl/src/pauli_frames.jl:186
 [9] top-level scope
   @ REPL[19]:1
Some type information was truncated. Use `show(err)` to see complete types.

Environment (please complete the following information):

  • Output of using Pkg; Pkg.status()
QuantumClifford v0.9.9
  • Output of using Pkg; Pkg.status(; mode = PKGMODE_MANIFEST)
QuantumClifford v0.9.9
  • Output of versioninfo()
julia> versioninfo()
Julia Version 1.10.4
Commit 48d4fd48430 (2024-06-04 10:41 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
@Fe-r-oz Fe-r-oz added the bug Something isn't working label Aug 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant