diff --git a/qiskit/transpiler/passes/layout/vf2_post_layout.py b/qiskit/transpiler/passes/layout/vf2_post_layout.py index 17fc04a567..fb346d6e56 100644 --- a/qiskit/transpiler/passes/layout/vf2_post_layout.py +++ b/qiskit/transpiler/passes/layout/vf2_post_layout.py @@ -169,16 +169,14 @@ class VF2PostLayout(AnalysisPass): global_ops[num_qubits].append(op) op_names = [] for i in range(self.target.num_qubits): - entry = set() try: entry = set(self.target.operation_names_for_qargs((i,))) except KeyError: - pass + entry = set() if global_ops is not None: entry.update(global_ops[1]) op_names.append(entry) - - cm_graph.add_nodes_from(op_names) + cm_graph.add_nodes_from(op_names) for qargs in self.target.qargs: len_args = len(qargs) # If qargs == 1 we already populated it and if qargs > 2 there are no instructions diff --git a/releasenotes/notes/fix-vf2post-regression-d4b057ea02ce00d3.yaml b/releasenotes/notes/fix-vf2post-regression-d4b057ea02ce00d3.yaml new file mode 100644 index 0000000000..070ca9d3b6 --- /dev/null +++ b/releasenotes/notes/fix-vf2post-regression-d4b057ea02ce00d3.yaml @@ -0,0 +1,7 @@ +--- +fixes: + - | + Fixed a bug in the :class:`.VF2PostLayout` pass when transpiling for backends + with a defined :class:`.Target`, where the interaction graph would be built + incorrectly. This could result in excessive runtimes due to the graph being + far more complex than necessary.