From 1fd8fe93b7e34f526d2c190e0a7a353c84ce7a50 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 12 Jun 2023 19:35:35 +0000 Subject: [PATCH 01/11] =?UTF-8?q?=E2=AC=86=EF=B8=8F=F0=9F=AA=9D=20update?= =?UTF-8?q?=20pre-commit=20hooks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/charliermarsh/ruff-pre-commit: v0.0.270 → v0.0.272](https://github.com/charliermarsh/ruff-pre-commit/compare/v0.0.270...v0.0.272) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a05185b5a..c76b402e8 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -51,7 +51,7 @@ repos: # Run ruff (subsumes pyupgrade, isort, flake8+plugins, and more) - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: v0.0.270 + rev: v0.0.272 hooks: - id: ruff args: ["--fix"] From 8a0d72a39fbfb4c23f9f2b6f9641a2db339b6d6e Mon Sep 17 00:00:00 2001 From: Lukas Burgholzer Date: Wed, 14 Jun 2023 15:52:05 +0200 Subject: [PATCH 02/11] =?UTF-8?q?=F0=9F=9A=A8=20fix=20new=20ruff=20warning?= =?UTF-8?q?s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 824e41daf..626a81559 100644 --- a/setup.py +++ b/setup.py @@ -58,9 +58,9 @@ def build_extension(self, ext: CMakeExtension) -> None: cmake_args += ["-GNinja"] else: # Single config generators are handled "normally" - single_config = any(x in cmake_generator for x in {"NMake", "Ninja"}) + single_config = any(x in cmake_generator for x in ("NMake", "Ninja")) # CMake allows an arch-in-generator style for backward compatibility - contains_arch = any(x in cmake_generator for x in {"ARM", "Win64"}) + contains_arch = any(x in cmake_generator for x in ("ARM", "Win64")) # Convert distutils Windows platform specifiers to CMake -A arguments plat_to_cmake = { "win32": "Win32", From 32ecfa4738c533916d25203faca70989a863f554 Mon Sep 17 00:00:00 2001 From: Lukas Burgholzer Date: Thu, 15 Jun 2023 10:06:46 +0200 Subject: [PATCH 03/11] =?UTF-8?q?=E2=AC=86=EF=B8=8F=20update=20rustworkx?= =?UTF-8?q?=20dependency?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Lukas Burgholzer --- pyproject.toml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index df39da357..7723fd64c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,7 +39,7 @@ classifiers=[ requires-python = ">=3.8" dependencies = [ "qiskit-terra>=0.20.2", - "rustworkx[all]>=0.12.0", + "rustworkx[all]>=0.13.0", "importlib_resources>=5.0; python_version < '3.10'", ] dynamic = ["version"] @@ -105,11 +105,8 @@ testpaths = ["test/python"] addopts = ["-ra", "--strict-markers", "--strict-config", "--showlocals"] log_cli_level = "INFO" xfail_strict = true -filterwarnings = [ - "error", - # See https://github.com/Qiskit/rustworkx/pull/728 - 'ignore:RetworkxLoader.exec_module\(\) not found; falling back to load_module\(\):ImportWarning', -] +filterwarnings = ["error"] + [tool.coverage.run] source = ["mqt.qmap"] From 5e04d0012ac1720e142776d4892fa116617f687e Mon Sep 17 00:00:00 2001 From: Lukas Burgholzer Date: Thu, 15 Jun 2023 10:08:53 +0200 Subject: [PATCH 04/11] =?UTF-8?q?=F0=9F=9A=A8=20address=20mypy=20warnings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Lukas Burgholzer --- mqt/qmap/subarchitectures.py | 36 +++++++------- pyproject.toml | 2 +- test/python/test_subarchitectures.py | 71 ++++++++++++++-------------- 3 files changed, 57 insertions(+), 52 deletions(-) diff --git a/mqt/qmap/subarchitectures.py b/mqt/qmap/subarchitectures.py index a731d3fef..6cbaf2aad 100644 --- a/mqt/qmap/subarchitectures.py +++ b/mqt/qmap/subarchitectures.py @@ -15,16 +15,20 @@ import pickle from itertools import combinations from pathlib import Path -from typing import TYPE_CHECKING, Dict, NewType, Set, Tuple +from typing import TYPE_CHECKING, Dict, NewType, Optional, Set, Tuple if TYPE_CHECKING: # pragma: no cover from matplotlib import figure from qiskit.providers import Backend + from typing_extensions import TypeAlias from mqt.qmap import Architecture import rustworkx as rx +import rustworkx.visualization as rxviz + +Graph: TypeAlias = rx.PyGraph[int, Optional[int]] PartialOrder = NewType("PartialOrder", Dict[Tuple[int, int], Set[Tuple[int, int]]]) @@ -40,7 +44,7 @@ class SubarchitectureOrder: def __init__(self) -> None: """Initialize a partial order.""" - self.arch: rx.PyGraph = rx.PyGraph() + self.arch: Graph = rx.PyGraph() self.subarch_order: PartialOrder = PartialOrder({}) self.desirable_subarchitectures: PartialOrder = PartialOrder({}) self.isomorphisms: dict[tuple[int, int], dict[tuple[int, int], dict[int, int]]] = {} @@ -50,7 +54,7 @@ def __init__(self) -> None: self.__compute_desirable_subarchitectures() @classmethod - def from_retworkx_graph(cls, graph: rx.PyGraph) -> SubarchitectureOrder: + def from_retworkx_graph(cls, graph: Graph) -> SubarchitectureOrder: """Construct the partial order from retworkx graph. Args: @@ -78,9 +82,9 @@ def from_coupling_map(cls, coupling_map: set[tuple[int, int]] | list[tuple[int, The resulting partial order. """ num_nodes = max(max(int(u), int(v)) for u, v in coupling_map) - graph = rx.PyGraph() + graph: Graph = rx.PyGraph() graph.add_nodes_from(list(range(num_nodes + 1))) - graph.add_edges_from_no_data([tuple(edge) for edge in coupling_map]) + graph.add_edges_from_no_data(list(coupling_map)) return cls.from_retworkx_graph(graph) @@ -144,7 +148,7 @@ def from_string(cls, name: str) -> SubarchitectureOrder: return cls.from_library(lib_path) return SubarchitectureOrder() - def optimal_candidates(self, nqubits: int) -> list[rx.PyGraph]: + def optimal_candidates(self, nqubits: int) -> list[Graph]: """Return optimal subarchitecture candidate. Args: @@ -176,7 +180,7 @@ def optimal_candidates(self, nqubits: int) -> list[rx.PyGraph]: return [self.sgs[n][i] for (n, i) in opt_cands] - def covering(self, nqubits: int, size: int) -> list[rx.PyGraph]: + def covering(self, nqubits: int, size: int) -> list[Graph]: """Return covering for nqubit circuits. Args: @@ -218,7 +222,7 @@ def store_library(self, lib_name: str | Path) -> None: with path.open("wb") as f: pickle.dump(self, f) - def draw_subarchitecture(self, subarchitecture: rx.PyGraph | tuple[int, int]) -> figure.Figure: + def draw_subarchitecture(self, subarchitecture: Graph | tuple[int, int]) -> figure.Figure: """Create a matplotlib figure showing subarchitecture within the entire architecture. Nodes that are part of the subarchitecture are drawn yellow. @@ -235,9 +239,9 @@ def draw_subarchitecture(self, subarchitecture: rx.PyGraph | tuple[int, int]) -> colors = [SubarchitectureOrder.inactive_color for _ in range(self.arch.num_nodes())] for node in subarchitecture.nodes(): colors[node] = SubarchitectureOrder.active_color - return rx.visualization.mpl_draw(subarchitecture, node_color=colors) + return rxviz.mpl_draw(self.arch, node_color=colors) # type: ignore[no-untyped-call] - def draw_subarchitectures(self, subarchitectures: list[rx.PyGraph] | list[tuple[int, int]]) -> list[figure.Figure]: + def draw_subarchitectures(self, subarchitectures: list[Graph] | list[tuple[int, int]]) -> list[figure.Figure]: """Create matplotlib figures showing subarchitectures within the entire architecture. For each subarchitecture one figure is drawn. @@ -254,15 +258,15 @@ def draw_subarchitectures(self, subarchitectures: list[rx.PyGraph] | list[tuple[ def __compute_subarchs(self) -> None: """Compute all subarchitectures of the architecture.""" - self.sgs: list[list[rx.PyGraph]] = [[] for i in range(self.arch.num_nodes() + 1)] + self.sgs: list[list[Graph]] = [[] for i in range(self.arch.num_nodes() + 1)] for i in range(1, self.arch.num_nodes() + 1): node_combinations = combinations(range(self.arch.num_nodes()), i) for sg in (self.arch.subgraph(selected_nodes) for selected_nodes in node_combinations): - if rx.is_connected(sg): + if rx.is_connected(sg): # type: ignore[attr-defined] new_class = True for g in self.sgs[i]: - if rx.is_isomorphic(g, sg): + if rx.is_isomorphic(g, sg): # type: ignore[attr-defined] new_class = False break if new_class: @@ -279,7 +283,7 @@ def __compute_subarch_order(self) -> None: for n, sgs_n in enumerate(self.sgs[:-1]): for i, sg in enumerate(sgs_n): for j, parent_sg in enumerate(self.sgs[n + 1]): - matcher = rx.graph_vf2_mapping(parent_sg, sg, subgraph=True) + matcher = rx.graph_vf2_mapping(parent_sg, sg, subgraph=True) # type: ignore[attr-defined] for iso in matcher: self.subarch_order[(n, i)].add((n + 1, j)) iso_rev = {} @@ -354,8 +358,8 @@ def __path_order_less(self, n: int, i: int, n_prime: int, i_prime: int) -> bool: if v is w: continue if ( - rx.dijkstra_shortest_path_lengths(lhs, v, lambda _x: 1, goal=w)[w] - > rx.dijkstra_shortest_path_lengths(rhs, iso[v], lambda _x: 1, goal=iso[w])[iso[w]] + rx.dijkstra_shortest_path_lengths(lhs, v, lambda _x: 1, goal=w)[w] # type: ignore[attr-defined] + > rx.dijkstra_shortest_path_lengths(rhs, iso[v], lambda _x: 1, goal=iso[w])[iso[w]] # type: ignore[attr-defined] ): return True return False diff --git a/pyproject.toml b/pyproject.toml index 7723fd64c..a84380806 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -128,7 +128,7 @@ warn_unreachable = true explicit_package_bases = true [[tool.mypy.overrides]] -module = ["qiskit.*", "rustworkx.*", "matplotlib.*"] +module = ["qiskit.*", "matplotlib.*"] ignore_missing_imports = true [tool.pylint] diff --git a/test/python/test_subarchitectures.py b/test/python/test_subarchitectures.py index f847bd9ec..4f2da0a35 100644 --- a/test/python/test_subarchitectures.py +++ b/test/python/test_subarchitectures.py @@ -8,6 +8,7 @@ from mqt.qmap import Architecture from mqt.qmap.subarchitectures import ( + Graph, SubarchitectureOrder, ibm_guadalupe_subarchitectures, rigetti_16_subarchitectures, @@ -67,60 +68,60 @@ def rigetti16() -> SubarchitectureOrder: @pytest.fixture() -def rigetti16_opt() -> rx.PyGraph: +def rigetti16_opt() -> Graph: """Return the optimal subarchitecture candidate for the Rigetti 16Q architecture.""" cm = [ - [0, 1], - [1, 2], - [2, 3], - [3, 4], - [4, 5], - [5, 6], - [6, 7], - [7, 8], - [8, 9], - [9, 10], - [10, 11], - [11, 12], - [12, 13], - [3, 12], - [4, 11], + (0, 1), + (1, 2), + (2, 3), + (3, 4), + (4, 5), + (5, 6), + (6, 7), + (7, 8), + (8, 9), + (9, 10), + (10, 11), + (11, 12), + (12, 13), + (3, 12), + (4, 11), ] num_nodes = max(max(int(u), int(v)) for u, v in cm) - graph = rx.PyGraph() + graph: Graph = rx.PyGraph() graph.add_nodes_from(list(range(num_nodes + 1))) - graph.add_edges_from_no_data([tuple(edge) for edge in cm]) + graph.add_edges_from_no_data(list(cm)) return graph @pytest.fixture() -def singleton_graph() -> rx.PyGraph: +def singleton_graph() -> Graph: """Return a graph with a single node.""" - g = rx.PyGraph() + g: Graph = rx.PyGraph() g.add_node(0) return g -def test_singleton_graph(singleton_graph: rx.PyGraph) -> None: +def test_singleton_graph(singleton_graph: Graph) -> None: """Verify that singleton graph has trivial ordering.""" order = SubarchitectureOrder.from_retworkx_graph(singleton_graph) assert len(order.sgs) == 2 assert len(order.sgs[0]) == 0 assert len(order.sgs[1]) == 1 - assert rx.is_isomorphic(order.optimal_candidates(1)[0], singleton_graph) + assert rx.is_isomorphic(order.optimal_candidates(1)[0], singleton_graph) # type: ignore[attr-defined] -def test_two_node_graph(singleton_graph: rx.PyGraph) -> None: +def test_two_node_graph(singleton_graph: Graph) -> None: """Verify ordering for graph with two nodes and one edge.""" order = SubarchitectureOrder.from_coupling_map([(0, 1)]) assert len(order.sgs) == 3 assert len(order.sgs[0]) == 0 assert len(order.sgs[1]) == 1 assert len(order.sgs[2]) == 1 - assert rx.is_isomorphic(order.optimal_candidates(2)[0], order.sgs[2][0]) - assert rx.is_isomorphic(order.optimal_candidates(1)[0], singleton_graph) + assert rx.is_isomorphic(order.optimal_candidates(2)[0], order.sgs[2][0]) # type: ignore[attr-defined] + assert rx.is_isomorphic(order.optimal_candidates(1)[0], singleton_graph) # type: ignore[attr-defined] def test_ibm_guadalupe_opt(ibm_guadalupe: SubarchitectureOrder) -> None: @@ -129,7 +130,7 @@ def test_ibm_guadalupe_opt(ibm_guadalupe: SubarchitectureOrder) -> None: assert len(opt_cand_9) == 2 assert opt_cand_9[0].num_nodes() == 15 assert opt_cand_9[1].num_nodes() == 15 - assert not rx.is_isomorphic(opt_cand_9[0], opt_cand_9[1]) + assert not rx.is_isomorphic(opt_cand_9[0], opt_cand_9[1]) # type: ignore[attr-defined] def test_ibm_guadalupe_cov(ibm_guadalupe: SubarchitectureOrder) -> None: @@ -140,37 +141,37 @@ def test_ibm_guadalupe_cov(ibm_guadalupe: SubarchitectureOrder) -> None: for sg in ibm_guadalupe.sgs[9]: covered = False for co in cov: - if rx.is_subgraph_isomorphic(co, sg): + if rx.is_subgraph_isomorphic(co, sg): # type: ignore[attr-defined] covered = True break assert covered -def test_rigetti16_opt(rigetti16: SubarchitectureOrder, rigetti16_opt: rx.PyGraph) -> None: +def test_rigetti16_opt(rigetti16: SubarchitectureOrder, rigetti16_opt: Graph) -> None: """Verify optimal candidates for Rigetti 16Q architecture.""" opt = rigetti16.optimal_candidates(10) assert len(opt) == 1 opt_cand = opt[0] - assert rx.is_isomorphic(opt_cand, rigetti16_opt) + assert rx.is_isomorphic(opt_cand, rigetti16_opt) # type: ignore[attr-defined] -def test_rigetti16_opt_library(rigetti16_opt: rx.PyGraph) -> None: +def test_rigetti16_opt_library(rigetti16_opt: Graph) -> None: """Verify optimal candidates for Rigetti 16Q architecture from library.""" opt = rigetti_16_subarchitectures().optimal_candidates(10) assert len(opt) == 1 opt_cand = opt[0] - assert rx.is_isomorphic(opt_cand, rigetti16_opt) + assert rx.is_isomorphic(opt_cand, rigetti16_opt) # type: ignore[attr-defined] -def test_rigetti16_opt_library_from_str(rigetti16_opt: rx.PyGraph) -> None: +def test_rigetti16_opt_library_from_str(rigetti16_opt: Graph) -> None: """Verify optimal candidates for Rigetti 16Q architecture from string.""" opt = SubarchitectureOrder.from_string("rigetti_16").optimal_candidates(10) assert len(opt) == 1 opt_cand = opt[0] - assert rx.is_isomorphic(opt_cand, rigetti16_opt) + assert rx.is_isomorphic(opt_cand, rigetti16_opt) # type: ignore[attr-defined] def test_ibm_guadalupe_library() -> None: @@ -179,7 +180,7 @@ def test_ibm_guadalupe_library() -> None: assert len(opt_cand_9) == 2 assert opt_cand_9[0].num_nodes() == 15 assert opt_cand_9[1].num_nodes() == 15 - assert not rx.is_isomorphic(opt_cand_9[0], opt_cand_9[1]) + assert not rx.is_isomorphic(opt_cand_9[0], opt_cand_9[1]) # type: ignore[attr-defined] def test_store_subarch(ibm_guadalupe: SubarchitectureOrder) -> None: @@ -198,7 +199,7 @@ def test_store_subarch(ibm_guadalupe: SubarchitectureOrder) -> None: assert len(opt_origin) == len(opt_loaded) for opt_cand_orig, opt_cand_load in zip(opt_origin, opt_loaded): - assert rx.is_isomorphic(opt_cand_load, opt_cand_orig) + assert rx.is_isomorphic(opt_cand_load, opt_cand_orig) # type: ignore[attr-defined] def test_subarchitecture_from_qmap_arch() -> None: From 05f381b315060004b9cd7a1873369eb2c979e9fd Mon Sep 17 00:00:00 2001 From: Lukas Burgholzer Date: Thu, 15 Jun 2023 11:24:25 +0200 Subject: [PATCH 05/11] =?UTF-8?q?=F0=9F=8D=B1=20update=20stored=20librarie?= =?UTF-8?q?s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Lukas Burgholzer --- mqt/qmap/libs/ibm_guadalupe_16.pickle | Bin 169150 -> 171627 bytes mqt/qmap/libs/rigetti_16.pickle | Bin 337696 -> 341613 bytes 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/mqt/qmap/libs/ibm_guadalupe_16.pickle b/mqt/qmap/libs/ibm_guadalupe_16.pickle index e39cda2109dad8545c7047551c7cb8ca10e583fc..914f50a29b30e3e80e742833af02bf840bc18d64 100644 GIT binary patch delta 11988 zcmcgyO>b0H819_T^v+CYrXXJti=n!((Aa_^5Nr(}wF%q?ZG%{>ZGd#-Lj?g@w15;; zM6C*T@LfrCW!#w%HU`DGW}!a-T^Luy$Uo5cc6I-Tjv+;hv~EPy%B`}w@jIrseh zefq(jbbLB~qv?A58>Ofp;hBs?5f@xVbs?pzRAYJ`8@t$(?#UVJGvEH8FreIkL`kto-_71e8kYP9H3 ztL;#CjSgYavprb8Jzm^zF&1ra%sJ^JwyR@OJ*Q2odo$x6+J`MzbTS7U22JYf*p@<% z?s3$pzgwuM^U(3B>VW(E)p9#_n`)1pAq=*#2gcr2S-sUjm;jQAo}{;9RQ0;plK9M% zU}9#rCOnhs1}!Duxq5J04kor{!fid1>o-70ayo4%rviU^Ja|^Oumwb%4?Ls*;a3N#3hS_?@5LCu#=|^mL-^127z2X>( zsyJ=NaYRt2EfETfniIss^znov$7~Xy1Tk3#F+?hGkfw47D|QIc537zDeHbcBHj=Om zF@eq!Bi(;p&#X{5HrG&lrkDx>9L+eZ!xZ?uqut;z4WO=UFgZ4#QH6PYhG+F)AWC#* zPjy%5_8`W$2a0bGn)&u1&bJ2%K3xQYm;%Sb&D2>y2kqd$X%0p}htEMLoF*3(MP{Rm z2v3jb@hJF>0@`XMfn0u|682jS5k&$^<=$%OXbAeIR77qH$69#Ew8QYilxm44tb#{v z)+!uG%nlbmP^m;@F(vPqajls8aBf1AhqDZlZ>%2;T5xM7ET16{saM<-kIj!Z*-J7p z#CYr(#o%6>HGCY()k=6)G7)dcVSCt!5?o28ATp^TVjp~bM71-iIrEQjN>dr2^#e{F z55|wWs2&+TH`Q}!_MGZ{q~qT&=`=6A<7t@HgM(plFDuc z65E3>kK>I3-6dB{UdV}rzHu`kB+sS3FlhBS$Y?oO` z(TziDj*OX3=8Hhm!$2Eqix8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HYQG(Vd+}MWdR#S ziCU1W87YEg;4?uUJPs{kRr9c*;H^az>Ni6P9oqp4}ZZJ1~cv$f`lNuvU)Zo2Nh@_`rXr4_V@n4J|?4vC$HjLQUD7v4X!y2e!eR`*li6Xissta4fat11Pw&= zIqp8j3QcTj8si?k69$hFo@y)n^BCkY&5&0l;KKy?^vf*Z6lDWRZsNKXuEYBgFjtB6 zTmaXdW+g_(Gf$STn=j@PXCty+Zi@AYdO67HoE98D37lo6{b(G~ze#ouS#Uj`JOzd6 zfRLq%&tFq~I9!=xsn!9gW1^du=h17et4~>gZU2Z(VQW%<0aOjb`t&r6tVqJsHsg&1 zxHF54?3)a*Op78-HUnjA*VN%~HJDE}={g2j6!sLMjx>)3$)f?@qmKAWd6I&!5SKTYt-I~QP}PoeBm(D9Zc)Qx#Q z4x5-0$DYZ<*(z9)ELw`s!!rrkksgoAI_U*z$66#8mn1n+e5IL}>;T;|`FQs{_wF<- zY2--tNeAbY1jXCP{|I9mZYEObtC0DGv$FBGcX%6-<-|*RPEr?hUFkS;#gKA$;M9BE x92K@`!0cwZjilXj@UQpTcp=lIcwMC;G{1jeEbUv8jnX5&f2s6sh`zY2_zxopZQB3< diff --git a/mqt/qmap/libs/rigetti_16.pickle b/mqt/qmap/libs/rigetti_16.pickle index 7529a9f48d63f80f8ef04ab3288f9ec91498257a..16866b3a45ff9d73c72d485635b19545a4e46c9f 100644 GIT binary patch delta 19492 zcmcg!ZH!!H72dn|-nlcgyVGrU7t+mYODl1u=}t{>O$ZHZ*bu|5M3#iGYDwGdSd~~z zOpSkxi$BmGB$hDC`6aZCB-BVtC95KV1cNB0w$wmsC{jrXO+%%P9}!|{J?Fgddq4Kh zotf@E@ABh@w4L`kAI~}GIrrX~eaDCYaemmF_ZHlTz5D03HOIrAu;;;M=!6bld&6G5 zx}l3#FZA&0hdy3QVF|B67~r)WmhoB%D|oGjRlN3veR%B;`|&yu4&b#G*6_M2T=ihH z0Vh}c+aI~bxdEJ)z42$h>8xAt^g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bBpjl-Mq< z?WLs6yLgxrPxcGer8&WxU>8zaYLOJ#@~dcQAbFOYXKjGE4wrLIPDx*su_7LGf^x_R zi=$jU1e&pft;yD7d@jM=9n!bD znxGOJQ`1oGTFe^UN{TFcbl?Fn2wS+uu&LREr~5U5#2X`+|5N~5Y7P`({vJr-F+}ML zHJm)4Cx&oq2r>)q3x{4H4zJB2<<~ch3waNkPF^*zvrFOJ99~BBn^a)DZ^Uv8Gt2m9 zxKc&V5^F!Eo^#FgR7TR&(6rJ@ZEFtm4W;viHz&5hx=?1GsO?uZ4@6BY<{kUQyHK5n zlmPV#GzqWPk{xvDaduls0sMES4!k;-Y*8UiNI-nk={-A=t6W=!I`?`Vxq=oN4o3%- z90%ew+`vmII{HRDXC*989DcHp7aOe}_%g#gY<7IlEaJ0F26+BQuH_g=TdAvd5_LlTr~XBLqlp&-zCSaWT0L6Fa|Oe2Xy&1m)HcnSGCs=#fw zPHm|PqFgL9{hrk$nVU(N&v2n5c#8A)EVG>NAu1~923rmXBP(EyYI6sM7m{6zrgF>j z$f`Tnfsq9~3TIbv>b56|H`2$%QP7Vv;NNhXs~5EXw+Om|VG^d`LNiGbK|=8bLuhpS zy#323$b``3b~tz>OentwS5|WBka?(|t${a>s4mjHt)I1LYfs+S2B1SSe^lY%*8}(o Hz>5C^Sy&GK From a5ea6141348be3933e79fb3df0a18633fd4abf66 Mon Sep 17 00:00:00 2001 From: Lukas Burgholzer Date: Thu, 15 Jun 2023 11:25:07 +0200 Subject: [PATCH 06/11] =?UTF-8?q?=F0=9F=A9=B9=20ensure=20proper=20Backend?= =?UTF-8?q?=20type?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Lukas Burgholzer --- mqt/qmap/subarchitectures.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mqt/qmap/subarchitectures.py b/mqt/qmap/subarchitectures.py index 6cbaf2aad..dad2fcc52 100644 --- a/mqt/qmap/subarchitectures.py +++ b/mqt/qmap/subarchitectures.py @@ -19,7 +19,7 @@ if TYPE_CHECKING: # pragma: no cover from matplotlib import figure - from qiskit.providers import Backend + from qiskit.providers import BackendV1 from typing_extensions import TypeAlias from mqt.qmap import Architecture @@ -89,7 +89,7 @@ def from_coupling_map(cls, coupling_map: set[tuple[int, int]] | list[tuple[int, return cls.from_retworkx_graph(graph) @classmethod - def from_backend(cls, backend: Backend) -> SubarchitectureOrder: + def from_backend(cls, backend: BackendV1) -> SubarchitectureOrder: """Construct the partial order from a coupling map defined as a Qiskit backend. Args: From a1ba0d9bccb05fb952bdd33514deb4858ba4531f Mon Sep 17 00:00:00 2001 From: Lukas Burgholzer Date: Thu, 15 Jun 2023 11:25:50 +0200 Subject: [PATCH 07/11] =?UTF-8?q?=F0=9F=9A=B8=20make=20import=20from=20cou?= =?UTF-8?q?pling=20map=20more=20generic?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Lukas Burgholzer --- mqt/qmap/subarchitectures.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mqt/qmap/subarchitectures.py b/mqt/qmap/subarchitectures.py index dad2fcc52..ad9b50f3b 100644 --- a/mqt/qmap/subarchitectures.py +++ b/mqt/qmap/subarchitectures.py @@ -18,6 +18,8 @@ from typing import TYPE_CHECKING, Dict, NewType, Optional, Set, Tuple if TYPE_CHECKING: # pragma: no cover + from collections.abc import Iterable + from matplotlib import figure from qiskit.providers import BackendV1 from typing_extensions import TypeAlias @@ -72,11 +74,11 @@ def from_retworkx_graph(cls, graph: Graph) -> SubarchitectureOrder: return so @classmethod - def from_coupling_map(cls, coupling_map: set[tuple[int, int]] | list[tuple[int, int]]) -> SubarchitectureOrder: + def from_coupling_map(cls, coupling_map: Iterable[tuple[int, int]]) -> SubarchitectureOrder: """Construct partial order from coupling map defined as set of tuples of connected qubits. Args: - coupling_map: Set or list of tuples of connected qubits. + coupling_map: Iterable of tuples of connected qubits. Returns: The resulting partial order. From 70a14b36674adbeaa58d3ec7384807b0d726a939 Mon Sep 17 00:00:00 2001 From: Lukas Burgholzer Date: Thu, 15 Jun 2023 11:26:36 +0200 Subject: [PATCH 08/11] =?UTF-8?q?=F0=9F=A9=B9=20protect=20type=20alias=20d?= =?UTF-8?q?efinition?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Lukas Burgholzer --- mqt/qmap/subarchitectures.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mqt/qmap/subarchitectures.py b/mqt/qmap/subarchitectures.py index ad9b50f3b..dee13a747 100644 --- a/mqt/qmap/subarchitectures.py +++ b/mqt/qmap/subarchitectures.py @@ -27,10 +27,14 @@ from mqt.qmap import Architecture +import contextlib + import rustworkx as rx import rustworkx.visualization as rxviz -Graph: TypeAlias = rx.PyGraph[int, Optional[int]] +with contextlib.suppress(TypeError): + Graph: TypeAlias = rx.PyGraph[int, Optional[int]] + PartialOrder = NewType("PartialOrder", Dict[Tuple[int, int], Set[Tuple[int, int]]]) From 1efa22dee04244daf83409358a4cd12fa1233ee6 Mon Sep 17 00:00:00 2001 From: Lukas Burgholzer Date: Thu, 15 Jun 2023 11:27:11 +0200 Subject: [PATCH 09/11] =?UTF-8?q?=F0=9F=A9=B9=20fix=20coupling=20map=20tes?= =?UTF-8?q?t?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Lukas Burgholzer --- test/python/test_subarchitectures.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/python/test_subarchitectures.py b/test/python/test_subarchitectures.py index 4f2da0a35..2b316ed7a 100644 --- a/test/python/test_subarchitectures.py +++ b/test/python/test_subarchitectures.py @@ -216,7 +216,8 @@ def test_subarchitecture_from_qiskit_backend() -> None: """Verify that subarchitecture order can be created from Qiskit backends.""" arch = FakeLondon() so_arch = SubarchitectureOrder.from_backend(arch) - so_cm = SubarchitectureOrder.from_coupling_map(arch.configuration().coupling_map) + cm = [(u, v) for u, v in arch.configuration().coupling_map] + so_cm = SubarchitectureOrder.from_coupling_map(cm) assert so_arch.subarch_order == so_cm.subarch_order From dcf7b846af3da67cc6d95100376d56ac83019dab Mon Sep 17 00:00:00 2001 From: Lukas Burgholzer Date: Thu, 15 Jun 2023 11:27:43 +0200 Subject: [PATCH 10/11] =?UTF-8?q?=F0=9F=9A=A8=20fix=20typing=20in=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Lukas Burgholzer --- test/python/test_subarchitectures.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/test/python/test_subarchitectures.py b/test/python/test_subarchitectures.py index 2b316ed7a..b401b2f31 100644 --- a/test/python/test_subarchitectures.py +++ b/test/python/test_subarchitectures.py @@ -1,6 +1,10 @@ """Test subarchitecture generation.""" +from __future__ import annotations + +import contextlib from pathlib import Path +from typing import TYPE_CHECKING, Optional import pytest import rustworkx as rx @@ -8,12 +12,17 @@ from mqt.qmap import Architecture from mqt.qmap.subarchitectures import ( - Graph, SubarchitectureOrder, ibm_guadalupe_subarchitectures, rigetti_16_subarchitectures, ) +if TYPE_CHECKING: + from typing_extensions import TypeAlias + +with contextlib.suppress(TypeError): + Graph: TypeAlias = rx.PyGraph[int, Optional[int]] + @pytest.fixture() def ibm_guadalupe() -> SubarchitectureOrder: From b540cc515485af7d7217ce8422fe296f200fb3fb Mon Sep 17 00:00:00 2001 From: Lukas Burgholzer Date: Thu, 15 Jun 2023 11:32:23 +0200 Subject: [PATCH 11/11] =?UTF-8?q?=E2=9E=95=20add=20`typing=5Fextensions`?= =?UTF-8?q?=20dependency?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Lukas Burgholzer --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index a84380806..499dbe864 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -41,6 +41,7 @@ dependencies = [ "qiskit-terra>=0.20.2", "rustworkx[all]>=0.13.0", "importlib_resources>=5.0; python_version < '3.10'", + "typing_extensions>=4.0", ] dynamic = ["version"]