Skip to content

Commit 3f854c3

Browse files
committed
Add max_gate_error filter to partition selection (default 0.02)
Partitions with average 2q gate error above threshold are rejected with a warning. Prevents circuits from landing on high-error device regions (e.g. 7% error partition on ibm_fez that degraded hamlib results).
1 parent 6e12cf8 commit 3f854c3

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

qedclib/qiskit/execute_parallel.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ def _remove_measurements(circuit):
6767
return clean
6868

6969
def _find_topology_partitions(coupling_map, circuit_width, num_partitions, gap=2,
70-
backend_target=None, routing_buffer=0):
70+
backend_target=None, routing_buffer=0,
71+
max_gate_error=0.02):
7172
"""
7273
Find disjoint connected subgraphs on the device coupling map, separated
7374
by at least `gap` hops. Each partition has `circuit_width + routing_buffer`
@@ -213,6 +214,10 @@ def _grow(start, size):
213214
for _err, _diam, _neg_edges, qubits in candidates:
214215
if any(q in excluded for q in qubits):
215216
continue
217+
if edge_errors and max_gate_error and _err > max_gate_error:
218+
print(f"... WARNING: skipping {circuit_width}q partition {qubits}: "
219+
f"avg_gate_err={_err:.4f} exceeds threshold {max_gate_error}")
220+
break # candidates are sorted, all remaining are worse
216221
selected.append(qubits)
217222
if edge_errors:
218223
print(f"... selected {qubits}: avg_gate_err={_err:.4f}, "
@@ -228,7 +233,7 @@ def _grow(start, size):
228233

229234

230235
def _find_multi_width_partitions(coupling_map, width_requests, gap=2,
231-
backend_target=None):
236+
backend_target=None, max_gate_error=0.02):
232237
"""
233238
Find partitions for multiple circuit widths on the same device.
234239
@@ -354,6 +359,10 @@ def _try_select(width):
354359
pos[width] += 1
355360
if any(q in excluded for q in qubits):
356361
continue
362+
if edge_errors and max_gate_error and _err > max_gate_error:
363+
print(f"... WARNING: skipping {width}q partition: "
364+
f"avg_gate_err={_err:.4f} exceeds threshold {max_gate_error}")
365+
return False # candidates are sorted, all remaining are worse
357366
selected[width].append(qubits)
358367
quota[width] -= 1
359368
if edge_errors:

0 commit comments

Comments
 (0)