Skip to content

Commit

Permalink
Set all custom passes in UCCDefault1 initializer
Browse files Browse the repository at this point in the history
  • Loading branch information
bachase committed Feb 27, 2025
1 parent 830249f commit 4001335
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
5 changes: 3 additions & 2 deletions ucc/compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,10 @@ def compile(

# Translate to Qiskit Circuit object
qiskit_circuit = transpile(circuit, "qiskit")
compiled_circuit = UCCDefault1().run(
compiled_circuit = UCCDefault1(
coupling_list=get_backend_connectivity(target_device)
).run(
qiskit_circuit,
coupling_list=get_backend_connectivity(target_device),
)

# Translate the compiled circuit to the desired format
Expand Down
15 changes: 7 additions & 8 deletions ucc/transpilers/ucc_defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@


class UCCDefault1:
def __init__(self, local_iterations=1):
def __init__(self, local_iterations=1, coupling_list=None):
self.pass_manager = PassManager()
self._1q_basis = ["rz", "rx", "ry", "h"]
self._2q_basis = ["cx"]
Expand All @@ -43,6 +43,10 @@ def __init__(self, local_iterations=1):
},
}
self.add_local_passes(local_iterations)
self.add_map_passes(coupling_list)
self.pass_manager.append(
BasisTranslator(sel, target_basis=self.target_basis)
)

@property
def default_passes(self):
Expand Down Expand Up @@ -103,13 +107,8 @@ def add_map_passes(self, coupling_list=None):
self.pass_manager.append(VF2PostLayout(coupling_map=coupling_map))
self.pass_manager.append(ApplyLayout())

def run(self, circuits, coupling_list=None):
self.add_map_passes(coupling_list)
self.pass_manager.append(
BasisTranslator(sel, target_basis=self.target_basis)
)
out_circuits = self.pass_manager.run(circuits)
return out_circuits
def run(self, circuits):
return self.pass_manager.run(circuits)


def _get_trial_count(default_trials=5):
Expand Down

0 comments on commit 4001335

Please sign in to comment.