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

reduce JET errors #364

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/fastmemlayout.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ See also: [`fastrow`](@ref)"""
function fastcolumn end

fastrow(t::Tableau{Tₚᵥ,Tₘ}) where {Tₚᵥ, Tₘ} = t
fastrow(t::Tableau{Tₚᵥ,Tₘ}) where {Tₚᵥ, Tₘ<:Adjoint} = Tableau(t.phases, t.nqubits, collect(t.xzs))
fastcolumn(t::Tableau{Tₚᵥ,Tₘ}) where {Tₚᵥ, Tₘ} = Tableau(t.phases, t.nqubits, collect(t.xzs')')
fastrow(t::Tableau{Tₚᵥ,Tₘ}) where {Tₚᵥ, Tₘ<:Adjoint} = Tableau(t.phases, t.nqubits, Matrix(collect(t.xzs)))
fastcolumn(t::Tableau{Tₚᵥ,Tₘ}) where {Tₚᵥ, Tₘ} = Tableau(t.phases, t.nqubits, Matrix(collect(t.xzs')'))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this introduces a bug:

julia> typeof(a)
Matrix{Float64} (alias for Array{Float64, 2})

julia> typeof(a')
LinearAlgebra.Adjoint{Float64, Matrix{Float64}}

julia> typeof(Matrix(a'))
Matrix{Float64} # we want it to be an Adjoint view

It undoes the purposeful change to the memory layout. Sure, the results you get by indexing into it are the same, but we specifically want to preserve the column-major or row-major order

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for all these insightful comments.

fastcolumn(t::Tableau{Tₚᵥ,Tₘ}) where {Tₚᵥ, Tₘ<:Adjoint} = t

fastrow(s::Stabilizer) = Stabilizer(fastrow(s.tab))
Expand Down
2 changes: 1 addition & 1 deletion src/petrajectory.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function petrajectory(state, circuit; branch_weight=1.0, current_order=0, max_or
if status==continue_stat # TODO is the copy below necessary?
out_probs = petrajectory(copy(newstate), rest_of_circuit,
branch_weight=branch_weight*prob, current_order=current_order+order, max_order=max_order)
status_probs .+= out_probs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not a big fan of this change -- it is great that it fixes a JET issue, but it makes the code much harder to read. Without a better understanding of why this is an issue, I prefer to keep this as it is.

map!((x,y)-> x+y, status_probs, status_probs, out_probs)
else
status_probs[status.status] += prob*branch_weight
end
Expand Down
2 changes: 1 addition & 1 deletion test/test_jet.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@

@show rep
@test_broken length(JET.get_reports(rep)) == 0
@test length(JET.get_reports(rep)) <= 11
@test length(JET.get_reports(rep)) <= 9
end
Loading