Skip to content

Commit

Permalink
Handle edge case where target doesn't have measurement defined
Browse files Browse the repository at this point in the history
This commit fixes an edge case in the heurstic scoring where if a target
is present but doesn't have measurement defined we always return a score
of 0. In the case measure ment doesn't have measurement defined this
will fall back to looking at the degree of the qubit instead of trying
to use the readout error rate.
  • Loading branch information
mtreinish committed Mar 30, 2022
1 parent 7ffec34 commit f7fb8a5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions qiskit/transpiler/passes/layout/vf2_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,10 @@ def _score_layout(self, layout):
on the chosen qubits. If BackendProperties are not available it uses the coupling map degree
to weight against higher connectivity qubits."""
bits = layout.get_physical_bits()
score = 0
score = None
if self.target is not None:
if "measure" in self.target:
score = 0
for bit in bits:
props = self.target["measure"].get((bit,))
if props is None or props.error is None:
Expand All @@ -223,7 +224,8 @@ def _score_layout(self, layout):
) / len(self.coupling_map.graph)
else:
score += props.error
else:
if score is None:
score = 0
if self.properties is None:
# Sum qubit degree for each qubit in chosen layout as really rough estimate of error
for bit in bits:
Expand Down

0 comments on commit f7fb8a5

Please sign in to comment.