mirror of https://github.com/Qiskit/qiskit.git
Fix incorrect graph construction in VF2PostLayout (#9058)
The `add_nodes` call should be outside the loop; inside, it adds nodes quadratically. This commit also squashes a minor inefficiency in set allocation.
This commit is contained in:
parent
a2ea9288a2
commit
61ca9ca6b2
|
@ -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
|
||||
|
|
|
@ -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.
|
Loading…
Reference in New Issue