diff --git a/ext/QuantumCliffordGPUExt/fastmemlayout.jl b/ext/QuantumCliffordGPUExt/fastmemlayout.jl index f5706b641..490903ef9 100644 --- a/ext/QuantumCliffordGPUExt/fastmemlayout.jl +++ b/ext/QuantumCliffordGPUExt/fastmemlayout.jl @@ -8,7 +8,7 @@ TableauAdj is the type of Tableau with its data stored in an adjoint of a CUDA a rest of the fastrow, fastcolumn functions are implemented in QuantumClifford.jl """ -# todo when we use to_gpu, to_cpu the efffect of fastrow, fastcolumn disappears +# todo when we use to_gpu, to_cpu the effect of fastrow, fastcolumn disappears fastrow(t::TableauCUDA) = t fastrow(t::TableauAdj) = Tableau(t.phases, t.nqubits, CuArray(t.xzs)) fastcolumn(t::TableauCUDA) = Tableau(t.phases, t.nqubits, CuArray(t.xzs')') diff --git a/src/ecc/codes/concat.jl b/src/ecc/codes/concat.jl index 0bd8f627b..1304f36ea 100644 --- a/src/ecc/codes/concat.jl +++ b/src/ecc/codes/concat.jl @@ -25,7 +25,7 @@ function parity_checks(c::Concat) phases_logx₁ = phases(logx_ops(c₁)) h_logz₁ = stab_to_gf2(logz_ops(c₁)) phases_logz₁ = phases(logz_ops(c₁)) - # parity checks of c₂ with qubits repalced with logical qubits of c₁ + # parity checks of c₂ with qubits replaced with logical qubits of c₁ outer_check_h = transpose(hcat([vcat( kron(h₂[i, 1:end÷2], h_logx₁[j, 1:end÷2]) .⊻ kron(h₂[i, end÷2+1:end], h_logz₁[j, 1:end÷2]), # X part kron(h₂[i, 1:end÷2], h_logx₁[j, end÷2+1:end]) .⊻ kron(h₂[i, end÷2+1:end], h_logz₁[j, end÷2+1:end]) # Z part diff --git a/src/noise.jl b/src/noise.jl index 226a77780..7283afa90 100644 --- a/src/noise.jl +++ b/src/noise.jl @@ -208,3 +208,11 @@ function applybranches(s::AbstractQCState, g::NoisyGate; max_order=1) news, _,_,_ = applybranches(s,g.gate,max_order=max_order)[1] # TODO this assumes only one always successful branch for the gate return [(state, continue_stat, prob, order) for (state, prob, order) in applynoise_branches(news, g.noise, affectedqubits(g), max_order=max_order)] end + +function _sentinel_affectedqubits end +QuantumClifford._sentinel_affectedqubits(x::Any) = QuantumClifford.affectedqubits(x) +QuantumClifford._sentinel_affectedqubits(::QuantumClifford.NoiseOpAll) = missing + +function _sentinel_maximum end +QuantumClifford._sentinel_maximum(x::Any) = maximum(x) +QuantumClifford._sentinel_maximum(::Missing) = 0 \ No newline at end of file diff --git a/src/petrajectory.jl b/src/petrajectory.jl index 125ecc30e..fb58b949d 100644 --- a/src/petrajectory.jl +++ b/src/petrajectory.jl @@ -70,6 +70,11 @@ end See also: [`pftrajectories`](@ref), [`mctrajectories`](@ref)""" function petrajectories(initialstate, circuit; branch_weight=1.0, max_order=1, keepstates::Bool=false) + for circuit_op in circuit + if(_sentinel_maximum(_sentinel_affectedqubits(circuit_op)) > nqubits(initialstate)) + throw(ArgumentError(lazy"""Qubit out of bounds for $circuit_op. Attempting to access a $(nqubits(initialstate)) qubit state at index $(_sentinel_maximum(_sentinel_affectedqubits(circuit_op)))""")) + end + end if keepstates return petrajectory_keep(initialstate, circuit; branch_weight=branch_weight, current_order=0, max_order=max_order) else diff --git a/src/randoms.jl b/src/randoms.jl index b1150a0a4..b45c28018 100644 --- a/src/randoms.jl +++ b/src/randoms.jl @@ -287,7 +287,7 @@ function _reset!(memory::RandDestabMemory) end end -# Allocation free inverse of upper trinagular int matrix with 1 on diagonal. +# Allocation free inverse of upper triangular int matrix with 1 on diagonal. function _inv!(inverse, A) for i in 2:size(A, 2) for j in 1:i-1 diff --git a/src/sumtypes.jl b/src/sumtypes.jl index f496532b0..d06ac4a3f 100644 --- a/src/sumtypes.jl +++ b/src/sumtypes.jl @@ -209,7 +209,7 @@ end ## -# `concrete_typeparams` annotations for the parameteric types we care about +# `concrete_typeparams` annotations for the parametric types we care about ## function concrete_typeparams(t::Type{ClassicalXOR}) diff --git a/test/test_noisycircuits.jl b/test/test_noisycircuits.jl index b1eb33c3f..83e31dc8f 100644 --- a/test/test_noisycircuits.jl +++ b/test/test_noisycircuits.jl @@ -272,7 +272,7 @@ @test pet_y[true_success_stat] == 1 @test pet_y[failure_stat] == 0 - #checks probabilstic case to see if the phase of measurement anticommuting stabilizer is the same in both branches + #checks probabilistic case to see if the phase of measurement anticommuting stabilizer is the same in both branches ghz_state = S"XXX ZZI IZZ" reg = Register(ghz_state, [0]) branches = applybranches(reg, sMRZ(1,1))