Skip to content

Commit a7991d3

Browse files
Avoid using rustworkx 0.16.0 methods in vf2_utils (backport Qiskit#14513) (Qiskit#14533)
* Avoid using rustworkx 0.16.0 methods in vf2_utils (Qiskit#14513) * Avoid using rustworkx 0.16.0 methods in vf2_utils In Qiskit#14218 the vf2_utils module was updated to use the `PyDiGraph.neighbors_undirected()` method which was added in 0.16.0. However that PR neglected to bump the minimum required version of rustworkx to 0.16.0 from 0.15.0 which is the current minim version listed. While we could bump the minimum version (see Qiskit#14507) to rustworkx 0.16.0 using this method isn't strictly necessary and Qiskit#14218 was backported to stable branches and backporting a version bump is not desireable. This commit instead just updates the rustworkx usage to use APIs in 0.15.0. This PR will need to be backported to stable/1.4 and stable/2.0 to fix compatibility with the listed rustworkx requirement. However, in the backport a fix note will be needed to document that the release fixes compatibility with the listed requirement. * Correctly handle duplicates across successors and predecessors (cherry picked from commit 9aa1a29) * Add release note --------- Co-authored-by: Matthew Treinish <[email protected]>
1 parent c100656 commit a7991d3

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

qiskit/transpiler/passes/layout/vf2_utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,9 @@ def build_average_error_map(target, properties, coupling_map):
203203
coupling_map = target.build_coupling_map()
204204
if not built and coupling_map is not None:
205205
for qubit in range(num_qubits):
206-
degree = len(set(coupling_map.graph.neighbors_undirected(qubit)))
206+
neighbor_set = set(coupling_map.graph.successor_indices(qubit))
207+
neighbor_set.update(coupling_map.graph.predecessor_indices(qubit))
208+
degree = len(neighbor_set)
207209
avg_map.add_error((qubit, qubit), degree / num_qubits)
208210
for edge in coupling_map.graph.edge_list():
209211
avg_map.add_error(edge, (avg_map[edge[0], edge[0]] + avg_map[edge[1], edge[1]]) / 2)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
fixes:
3+
- |
4+
Fixed a compatibility issue with the minimum supported version of rustworkx,
5+
0.15. With certain inputs the :class:`.VF2Layout` and
6+
:class:`.VF2PostLayout` were previously using a rustworkx method that was
7+
added in rustworkx 0.16.0 which would cause an error when using an older
8+
rustworkx release which is listed as supported.

0 commit comments

Comments
 (0)