Skip to content

Commit

Permalink
Merge pull request #202 from BQSKit/pam-barrier-fix
Browse files Browse the repository at this point in the history
Pam barrier fix
  • Loading branch information
edyounis authored Nov 13, 2023
2 parents 8539d75 + e96a69f commit e0632da
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
8 changes: 8 additions & 0 deletions bqskit/passes/mapping/pam.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import numpy as np

from bqskit.ir.circuit import Circuit
from bqskit.ir.gates.barrier import BarrierPlaceholder
from bqskit.ir.gates.constant.swap import SwapGate
from bqskit.ir.point import CircuitPoint
from bqskit.passes.mapping.sabre import GeneralizedSabreAlgorithm
Expand Down Expand Up @@ -175,6 +176,13 @@ def forward_pass( # type: ignore
E = self._calc_extended_set(circuit, F)
for n in execute_list:
op = circuit[n]

if isinstance(op.gate, BarrierPlaceholder):
if modify_circuit:
physical_location = [pi[q] for q in op.location]
mapped_circuit.append_gate(op.gate, op.location)
continue

p1, circ, p2 = self._get_best_perm(
circuit,
perm_data[n],
Expand Down
4 changes: 4 additions & 0 deletions bqskit/passes/mapping/sabre.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import numpy as np

from bqskit.ir.circuit import Circuit
from bqskit.ir.gates.barrier import BarrierPlaceholder
from bqskit.ir.gates.circuitgate import CircuitGate
from bqskit.ir.gates.constant.swap import SwapGate
from bqskit.ir.operation import Operation
Expand Down Expand Up @@ -330,6 +331,9 @@ def backward_pass(

def _can_exe(self, op: Operation, pi: list[int], cg: CouplingGraph) -> bool:
"""Return true if `op` is executable given the current mapping `pi`."""
if isinstance(op.gate, BarrierPlaceholder):
return True

if isinstance(op.gate, CircuitGate):
if all(g.num_qudits == 1 for g in op.gate._circuit.gate_set):
return True
Expand Down

0 comments on commit e0632da

Please sign in to comment.