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

Fix Qiskit circuit conversion to Tenet #291

Merged
merged 7 commits into from
Jan 23, 2025
Merged
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
2 changes: 1 addition & 1 deletion ext/TenetPythonCallExt/Qiskit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function Base.convert(::Type{Circuit}, ::Val{:qiskit}, pyobj::Py)
circuit = Circuit()

for instr in pyobj
gatelanes = map(x -> Lane(pyconvert(Int, x._index)), instr.qubits)
gatelanes = map(x -> Lane(pyconvert(Int, x._index) + 1), instr.qubits)
Copy link
Member

@mofeing mofeing Jan 23, 2025

Choose a reason for hiding this comment

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

I just have one question: are we sure that Qiskit only uses 1-dimensional coordinates for qubits? Do you mind checking it in the docs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If your question is whether the qubits field is always a 1D array, then yes, I think so.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

gatesites = [Site.(gatelanes; dual=true)..., Site.(gatelanes)...]

# if unassigned parameters, throw
Expand Down
6 changes: 3 additions & 3 deletions test/integration/python/test_qiskit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@

tn = convert(Circuit, circuit)
@test tn isa Circuit
@test issetequal(sites(tn; set=:inputs), Site.([0, 1, 2]; dual=true))
@test issetequal(sites(tn; set=:outputs), Site.([0, 1, 2]))
@test issetequal(sites(tn; set=:inputs), Site.([1, 2, 3]; dual=true))
@test issetequal(sites(tn; set=:outputs), Site.([1, 2, 3]))
@test Tenet.ntensors(tn) == 7
@test issetequal(
moments(tn),
[Tenet.Moment.(Ref(Lane(0)), 1:4)..., Tenet.Moment.(Ref(Lane(1)), 1:4)..., Tenet.Moment.(Ref(Lane(2)), 1:4)...],
[Tenet.Moment.(Ref(Lane(1)), 1:4)..., Tenet.Moment.(Ref(Lane(2)), 1:4)..., Tenet.Moment.(Ref(Lane(3)), 1:4)...],
)
end
Loading