Skip to content

Commit

Permalink
🚨 fix Qiskit 0.46.0 deprecation warnings (#360)
Browse files Browse the repository at this point in the history
## Description

This PR works around some newly introduced deprecation warnings in the
latest Qiskit version.

## Checklist:

<!---
This checklist serves as a reminder of a couple of things that ensure
your pull request will be merged swiftly.
-->

- [x] The pull request only contains commits that are related to it.
- [x] I have added appropriate tests and documentation.
- [x] I have made sure that all CI jobs on GitHub pass.
- [x] The pull request introduces no new warnings and follows the
project's style guidelines.

Signed-off-by: burgholzer <[email protected]>
  • Loading branch information
burgholzer authored Feb 5, 2024
1 parent 79fae0d commit 00ce22d
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 12 deletions.
7 changes: 5 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ requires-python = ">=3.8"
dependencies = [
"importlib_resources>=5.0; python_version < '3.10'",
"typing_extensions>=4.2",
"qiskit-terra>=0.22.1",
"qiskit[qasm3-import]>=0.45.0",
]
dynamic = ["version"]

Expand All @@ -57,7 +57,7 @@ docs = [
"nbsphinx",
"sphinxext-opengraph",
"sphinx-autodoc-typehints",
"qiskit-terra[visualization]",
"qiskit[visualization]",
]
dev = ["mqt.qcec[coverage, docs]"]

Expand Down Expand Up @@ -130,6 +130,9 @@ filterwarnings = [
'ignore:.*Building a flow controller with keyword arguments is going to be deprecated*:PendingDeprecationWarning:qiskit',
'ignore:.*encountered in det.*:RuntimeWarning:numpy.linalg:',
'ignore:.*datetime\.datetime\.utcfromtimestamp.*:DeprecationWarning:',
'ignore:.*qiskit.utils.parallel*:DeprecationWarning:qiskit',
'ignore:.*qiskit.tools.events*:DeprecationWarning:qiskit',
'ignore:.*qiskit.qasm*:DeprecationWarning:qiskit',
]

[tool.coverage]
Expand Down
2 changes: 1 addition & 1 deletion test/python/constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ pybind11==2.11.0
pytest==7.0.0
importlib_resources==5.0.0
typing_extensions==4.2.0
qiskit-terra==0.22.1
qiskit==0.45.0
4 changes: 2 additions & 2 deletions test/python/test_construction.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from pathlib import Path

import pytest
from qiskit import QuantumCircuit
from qiskit import QuantumCircuit, qasm2

from mqt import qcec

Expand All @@ -32,6 +32,6 @@ def test_constructor_with_configuration(example_circuit: QuantumCircuit) -> None
def test_default_constructor_with_file(example_circuit: QuantumCircuit) -> None:
"""Test constructing an instance from two circuit files with all default arguments."""
filename = "test.qasm"
example_circuit.qasm(filename=filename)
qasm2.dump(example_circuit, Path(filename))
qcec.EquivalenceCheckingManager(circ1=filename, circ2=filename)
Path(filename).unlink()
15 changes: 12 additions & 3 deletions test/python/test_symbolic.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import pytest
from qiskit import QuantumCircuit, transpile
from qiskit.circuit import Parameter
from qiskit.providers.fake_provider import FakeAthens

from mqt import qcec
from mqt.qcec.compilation_flow_profiles import AncillaMode
Expand Down Expand Up @@ -186,7 +185,12 @@ def test_cnot_rx_non_equ_approx(cnot_rx: QuantumCircuit, cnot_rx_flipped_approx:
@pytest.mark.parametrize("optimization_level", [0, 1, 2, 3])
def test_verify_compilation_on_optimization_levels(original_circuit: QuantumCircuit, optimization_level: int) -> None:
"""Test the verification of the compilation of a circuit to the 5-qubit IBMQ Athens architecture with various optimization levels."""
compiled_circuit = transpile(original_circuit, backend=FakeAthens(), optimization_level=optimization_level)
compiled_circuit = transpile(
original_circuit,
coupling_map=[[0, 1], [1, 0], [1, 2], [2, 1], [2, 3], [3, 2], [3, 4], [4, 3]],
basis_gates=["cx", "x", "id", "u3", "measure", "u2", "rz", "u1", "reset", "sx"],
optimization_level=optimization_level,
)
result = qcec.verify_compilation(original_circuit, compiled_circuit, optimization_level, timeout=3600)
assert result.equivalence in {
qcec.EquivalenceCriterion.equivalent,
Expand All @@ -201,7 +205,12 @@ def test_verify_compilation_on_optimization_levels_config(
"""Test the verification of the compilation of a circuit to the 5-qubit IBMQ Athens architecture with various optimization levels."""
config = qcec.Configuration()
config.execution.run_zx_checker = False
compiled_circuit = transpile(original_circuit, backend=FakeAthens(), optimization_level=optimization_level)
compiled_circuit = transpile(
original_circuit,
coupling_map=[[0, 1], [1, 0], [1, 2], [2, 1], [2, 3], [3, 2], [3, 4], [4, 3]],
basis_gates=["cx", "x", "id", "u3", "measure", "u2", "rz", "u1", "reset", "sx"],
optimization_level=optimization_level,
)
result = qcec.verify_compilation(
original_circuit, compiled_circuit, optimization_level, AncillaMode.NO_ANCILLA, config
)
Expand Down
7 changes: 5 additions & 2 deletions test/python/test_verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import pytest
from qiskit import QuantumCircuit, transpile
from qiskit.providers.fake_provider import FakeAthens

from mqt import qcec

Expand Down Expand Up @@ -70,7 +69,11 @@ def test_compiled_circuit_without_measurements() -> None:
"""
qc = QuantumCircuit(1)
qc.x(0)
qc_compiled = transpile(qc, backend=FakeAthens())
qc_compiled = transpile(
qc,
coupling_map=[[0, 1], [1, 0], [1, 2], [2, 1], [2, 3], [3, 2], [3, 4], [4, 3]],
basis_gates=["cx", "x", "id", "u3", "measure", "u2", "rz", "u1", "reset", "sx"],
)

result = qcec.verify(qc, qc_compiled)
assert result.equivalence == qcec.EquivalenceCriterion.equivalent
Expand Down
8 changes: 6 additions & 2 deletions test/python/test_verify_compilation.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import pytest
from qiskit import QuantumCircuit, transpile
from qiskit.providers.fake_provider import FakeAthens

from mqt import qcec

Expand All @@ -23,7 +22,12 @@ def original_circuit() -> QuantumCircuit:
@pytest.mark.parametrize("optimization_level", [0, 1, 2, 3])
def test_verify_compilation_on_optimization_levels(original_circuit: QuantumCircuit, optimization_level: int) -> None:
"""Test the verification of the compilation of a circuit to the 5-qubit IBMQ Athens architecture with various optimization levels."""
compiled_circuit = transpile(original_circuit, backend=FakeAthens(), optimization_level=optimization_level)
compiled_circuit = transpile(
original_circuit,
coupling_map=[[0, 1], [1, 0], [1, 2], [2, 1], [2, 3], [3, 2], [3, 4], [4, 3]],
basis_gates=["cx", "x", "id", "u3", "measure", "u2", "rz", "u1", "reset", "sx"],
optimization_level=optimization_level,
)
result = qcec.verify_compilation(original_circuit, compiled_circuit, optimization_level=optimization_level)
assert result.equivalence in {
qcec.EquivalenceCriterion.equivalent,
Expand Down

0 comments on commit 00ce22d

Please sign in to comment.