From 0a731cac975100601a1dba218256b8a5f8ca20b8 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Thu, 3 Nov 2022 18:27:50 +0000 Subject: [PATCH] Remove qiskit-toqm tests and requirements-dev.txt entry (backport #9057) (#9061) * Remove qiskit-toqm tests and requirements-dev.txt entry (#9057) * Remove qiskit-toqm tests and requirements-dev.txt entry Im #9042 we removed the special case code to enable using toqm as an optional routing method. This was needed prior to qiskit-terra 0.22.0 as we didn't have the transpiler stage plugin interface. However, now that we've added a dedicated interface for external transpiler passes to integrate into transpile() the toqm passes are using that interface. However, in #9042 the tests for verifying the previously hard-coded toqm routing method path worked as before were left intact. In general this would be a good approach to ensure we're maintaining backwards compatibilty with the new modular interface with earlier releases. However, in this specific case this is causing an issue with how tests are run. Since qiskit-toqm has a necessary dependency on qiskit-terra this means when we install our development requirements before running tests toqm is pulling in the latest stable release of qiskit-terra from pypi. Then we later upgrade that with the source build before running tests. This however this bi-directional test dependency introduces a tension in a number of places. For the most recent example, when we're trying to add support for new platforms (see #9028 for an example) where the stable version of qiskit-terra does not support the platform. We're unable to run CI with qiskit-toqm being installed first since installing stable qiskit-terra won't work/ This commit removes qiskit-toqm from the requirements-dev.txt list and also removes the test cases using it to fix this conflict. In general the testing for qiskit-toqm can now be self contained since it's exercising a stable interface in terra that's tested independently. When weighing the backwards compatibility coverage vs the CI and build complexities having the bidirectional test dependency has just removing the toqm tests and development requirement is the simplest path forward. * Remove unused imports Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> (cherry picked from commit 8999047a2dc8af55c47b60d8d7e9683ece0c05f3) # Conflicts: # requirements-dev.txt * Remove qiskit-toqm from requirements-dev.txt This fixes a merge conflict and removes the qiskit-toqm entry from the requirements-dev.txt file * Fix lint failure Co-authored-by: Matthew Treinish Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> --- .../transpiler/preset_passmanagers/level0.py | 7 ++- .../transpiler/preset_passmanagers/level1.py | 7 ++- .../transpiler/preset_passmanagers/level2.py | 7 ++- .../transpiler/preset_passmanagers/level3.py | 7 ++- requirements-dev.txt | 1 - .../transpiler/test_preset_passmanagers.py | 48 ------------------- 6 files changed, 24 insertions(+), 53 deletions(-) diff --git a/qiskit/transpiler/preset_passmanagers/level0.py b/qiskit/transpiler/preset_passmanagers/level0.py index 585c727d11c2..1774507185ec 100644 --- a/qiskit/transpiler/preset_passmanagers/level0.py +++ b/qiskit/transpiler/preset_passmanagers/level0.py @@ -96,7 +96,12 @@ def _choose_layout_condition(property_set): # TODO: Remove when qiskit-toqm has it's own plugin and we can rely on just the plugin interface if routing_method == "toqm" and "toqm" not in list_stage_plugins("routing"): HAS_TOQM.require_now("TOQM-based routing") - from qiskit_toqm import ToqmSwap, ToqmStrategyO0, latencies_from_target + # pylint: disable=import-error + from qiskit_toqm import ( + ToqmSwap, + ToqmStrategyO0, + latencies_from_target, + ) if initial_layout: raise TranspilerError("Initial layouts are not supported with TOQM-based routing.") diff --git a/qiskit/transpiler/preset_passmanagers/level1.py b/qiskit/transpiler/preset_passmanagers/level1.py index ac6360862bdc..6268b3dc69c7 100644 --- a/qiskit/transpiler/preset_passmanagers/level1.py +++ b/qiskit/transpiler/preset_passmanagers/level1.py @@ -154,7 +154,12 @@ def _vf2_match_not_found(property_set): # TODO: Remove when qiskit-toqm has it's own plugin and we can rely on just the plugin interface if routing_method == "toqm" and "toqm" not in list_stage_plugins("routing"): HAS_TOQM.require_now("TOQM-based routing") - from qiskit_toqm import ToqmSwap, ToqmStrategyO1, latencies_from_target + # pylint: disable=import-error + from qiskit_toqm import ( + ToqmSwap, + ToqmStrategyO1, + latencies_from_target, + ) if initial_layout: raise TranspilerError("Initial layouts are not supported with TOQM-based routing.") diff --git a/qiskit/transpiler/preset_passmanagers/level2.py b/qiskit/transpiler/preset_passmanagers/level2.py index 9597b484a3b7..240869d6082a 100644 --- a/qiskit/transpiler/preset_passmanagers/level2.py +++ b/qiskit/transpiler/preset_passmanagers/level2.py @@ -139,7 +139,12 @@ def _vf2_match_not_found(property_set): # TODO: Remove when qiskit-toqm has it's own plugin and we can rely on just the plugin interface if routing_method == "toqm" and "toqm" not in list_stage_plugins("routing"): HAS_TOQM.require_now("TOQM-based routing") - from qiskit_toqm import ToqmSwap, ToqmStrategyO2, latencies_from_target + # pylint: disable=import-error + from qiskit_toqm import ( + ToqmSwap, + ToqmStrategyO2, + latencies_from_target, + ) if initial_layout: raise TranspilerError("Initial layouts are not supported with TOQM-based routing.") diff --git a/qiskit/transpiler/preset_passmanagers/level3.py b/qiskit/transpiler/preset_passmanagers/level3.py index 61080636f357..5e1f5b979b64 100644 --- a/qiskit/transpiler/preset_passmanagers/level3.py +++ b/qiskit/transpiler/preset_passmanagers/level3.py @@ -144,7 +144,12 @@ def _vf2_match_not_found(property_set): # TODO: Remove when qiskit-toqm has it's own plugin and we can rely on just the plugin interface if routing_method == "toqm" and "toqm" not in list_stage_plugins("routing"): HAS_TOQM.require_now("TOQM-based routing") - from qiskit_toqm import ToqmSwap, ToqmStrategyO3, latencies_from_target + # pylint: disable=import-error + from qiskit_toqm import ( + ToqmSwap, + ToqmStrategyO3, + latencies_from_target, + ) if initial_layout: raise TranspilerError("Initial layouts are not supported with TOQM-based routing.") diff --git a/requirements-dev.txt b/requirements-dev.txt index 8d47d49e357e..5a97cfc37c39 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -18,7 +18,6 @@ seaborn>=0.9.0 reno>=3.4.0 Sphinx>=3.0.0 qiskit-sphinx-theme>=1.6 -qiskit-toqm>=0.0.4;platform_machine != 'aarch64' or platform_system != 'Linux' sphinx-autodoc-typehints~=1.18,!=1.19.3 jupyter-sphinx sphinx-design>=0.2.0 diff --git a/test/python/transpiler/test_preset_passmanagers.py b/test/python/transpiler/test_preset_passmanagers.py index 79b8f27297d7..148488edabf4 100644 --- a/test/python/transpiler/test_preset_passmanagers.py +++ b/test/python/transpiler/test_preset_passmanagers.py @@ -39,15 +39,12 @@ FakeTokyo, FakePoughkeepsie, FakeLagosV2, - FakeLima, - FakeWashington, ) from qiskit.converters import circuit_to_dag from qiskit.circuit.library import GraphState from qiskit.quantum_info import random_unitary from qiskit.transpiler.preset_passmanagers import generate_preset_pass_manager from qiskit.transpiler.preset_passmanagers import level0, level1, level2, level3 -from qiskit.utils.optionals import HAS_TOQM from qiskit.transpiler.passes import Collect2qBlocks, GatesInBasis @@ -267,51 +264,6 @@ def counting_callback_func(pass_, dag, time, property_set, count): self.assertEqual(gates_in_basis_true_count + 1, collect_2q_blocks_count) -@ddt -@unittest.skipUnless(HAS_TOQM, "qiskit-toqm needs to be installed") -class TestToqmIntegration(QiskitTestCase): - """Test transpiler with TOQM-based routing""" - - @combine( - level=[0, 1, 2, 3], - layout_method=[None, "trivial", "dense", "noise_adaptive", "sabre"], - backend_vbits_pair=[(FakeWashington(), 10), (FakeLima(), 5)], - dsc="TOQM-based routing with '{layout_method}' layout" - + "method on '{backend_vbits_pair[0]}' backend at level '{level}'", - name="TOQM_{layout_method}_{backend_vbits_pair[0]}_level{level}", - ) - def test_basic_circuit(self, level, layout_method, backend_vbits_pair): - """ - Basic circuits transpile across all opt levels and layout - methods when using TOQM-based routing. - """ - backend, circuit_size = backend_vbits_pair - qr = QuantumRegister(circuit_size, "q") - qc = QuantumCircuit(qr) - - # Generate a circuit that should need swaps. - for i in range(1, qr.size): - qc.cx(0, i) - - result = transpile( - qc, - layout_method=layout_method, - routing_method="toqm", - backend=backend, - optimization_level=level, - seed_transpiler=4222022, - ) - - self.assertIsInstance(result, QuantumCircuit) - - def test_initial_layout_is_rejected(self): - """Initial layout is rejected when using TOQM-based routing""" - with self.assertRaisesRegex( - TranspilerError, "Initial layouts are not supported with TOQM-based routing." - ): - transpile(QuantumCircuit(2), initial_layout=[1, 0], routing_method="toqm") - - @ddt class TestTranspileLevels(QiskitTestCase): """Test transpiler on fake backend"""