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

Remove qiskit-toqm tests and requirements-dev.txt entry (backport #9057) #9061

Merged
merged 4 commits into from
Nov 3, 2022
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
7 changes: 6 additions & 1 deletion qiskit/transpiler/preset_passmanagers/level0.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down
7 changes: 6 additions & 1 deletion qiskit/transpiler/preset_passmanagers/level1.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down
7 changes: 6 additions & 1 deletion qiskit/transpiler/preset_passmanagers/level2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down
7 changes: 6 additions & 1 deletion qiskit/transpiler/preset_passmanagers/level3.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down
1 change: 0 additions & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
48 changes: 0 additions & 48 deletions test/python/transpiler/test_preset_passmanagers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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"""
Expand Down