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

Update dependencies; fix code and tests for new qiskit-aer version #195

Merged
merged 6 commits into from
Oct 31, 2023
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: 2 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ unreleased
----------

* Add support for circuits with barriers in the Aer simulators.
* Update qiskit-ibm-runtime version to 0.13.0.
* Update qiskit-aer version to 0.13.0.

0.45.0 (October 2023)
---------------------
Expand Down
7 changes: 3 additions & 4 deletions pytket/extensions/qiskit/backends/aer.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,9 @@ def _tket_gate_set_from_qiskit_backend(
gate_set.add(OpType.Unitary2qBox)
gate_set.add(OpType.Unitary3qBox)

if qiskit_backend.name() != "aer_simulator_unitary":
gate_set.add(OpType.Reset)
gate_set.add(OpType.Measure)
gate_set.add(OpType.Conditional)
gate_set.add(OpType.Reset)
gate_set.add(OpType.Measure)
gate_set.add(OpType.Conditional)

# special case mapping TK1 to U
gate_set.add(OpType.TK1)
Expand Down
2 changes: 1 addition & 1 deletion pytket/extensions/qiskit/tket_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def __init__(
:type token: Optional[str]
"""
if isinstance(backend._provider, AerProvider):
tk_backend = self._aer_backend_map[backend.name()]()
tk_backend = self._aer_backend_map[backend.name]()
elif isinstance(backend._provider, IBMProvider):
tk_backend = IBMQBackend(backend.name, token=token)
else:
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
install_requires=[
"pytket ~= 1.21",
"qiskit ~= 0.44.0",
"qiskit-ibm-runtime ~= 0.12.0",
"qiskit-aer ~= 0.12.2",
"qiskit-ibm-runtime ~= 0.13.0",
"qiskit-aer ~= 0.13.0",
"qiskit-ibm-provider ~= 0.7.0",
"numpy",
],
Expand Down
27 changes: 10 additions & 17 deletions tests/backend_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -577,16 +577,16 @@ def test_ilo() -> None:
c.X(1)
res_s = bs.run_circuit(c)
res_u = bu.run_circuit(c)
assert (res_s.get_state() == np.asarray([0, 1, 0, 0])).all()
assert (res_s.get_state(basis=BasisOrder.dlo) == np.asarray([0, 0, 1, 0])).all()
assert (
res_u.get_unitary()
== np.asarray([[0, 1, 0, 0], [1, 0, 0, 0], [0, 0, 0, 1], [0, 0, 1, 0]])
).all()
assert (
res_u.get_unitary(basis=BasisOrder.dlo)
== np.asarray([[0, 0, 1, 0], [0, 0, 0, 1], [1, 0, 0, 0], [0, 1, 0, 0]])
).all()
assert np.allclose(res_s.get_state(), np.asarray([0, 1, 0, 0]))
assert np.allclose(res_s.get_state(basis=BasisOrder.dlo), np.asarray([0, 0, 1, 0]))
assert np.allclose(
res_u.get_unitary(),
np.asarray([[0, 1, 0, 0], [1, 0, 0, 0], [0, 0, 0, 1], [0, 0, 1, 0]]),
)
assert np.allclose(
res_u.get_unitary(basis=BasisOrder.dlo),
np.asarray([[0, 0, 1, 0], [0, 0, 0, 1], [1, 0, 0, 0], [0, 1, 0, 0]]),
)
c.measure_all()
res = b.run_circuit(c, n_shots=2)
assert (res.get_shots() == np.asarray([[0, 1], [0, 1]])).all()
Expand Down Expand Up @@ -1376,13 +1376,6 @@ def test_statevector_non_deterministic() -> None:
)


def test_unitary_sim_gateset() -> None:
backend = AerUnitaryBackend()
unitary_sim_gateset = backend.backend_info.gate_set
unsupported_ops = {OpType.Reset, OpType.Measure, OpType.Conditional}
assert unitary_sim_gateset.isdisjoint(unsupported_ops)


def test_unitary_backend_transpiles() -> None:
"""regression test for https://github.com/CQCL/pytket-qiskit/issues/142"""
backend = AerUnitaryBackend()
Expand Down