Skip to content

Commit

Permalink
make the choice of kak_gate deterministic
Browse files Browse the repository at this point in the history
  • Loading branch information
ShellyGarion committed Dec 22, 2024
1 parent 14c7aac commit eeff4cd
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions qiskit/transpiler/passes/synthesis/unitary_synthesis.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,14 @@
def _choose_kak_gate(basis_gates):
"""Choose the first available 2q gate to use in the KAK decomposition."""
kak_gate = None
kak_gates = set(basis_gates or []).intersection(KAK_GATE_NAMES.keys())
kak_gates_params = set(basis_gates or []).intersection(KAK_GATE_PARAM_NAMES.keys())
kak_gates = sorted(set(basis_gates or []).intersection(KAK_GATE_NAMES.keys()))
kak_gates_params = sorted(set(basis_gates or []).intersection(KAK_GATE_PARAM_NAMES.keys()))

if kak_gates_params:
kak_gate = KAK_GATE_PARAM_NAMES[kak_gates_params.pop()]
kak_gate = KAK_GATE_PARAM_NAMES[kak_gates_params[0]]

elif kak_gates:
kak_gate = KAK_GATE_NAMES[kak_gates.pop()]
kak_gate = KAK_GATE_NAMES[kak_gates[0]]

return kak_gate

Expand Down

0 comments on commit eeff4cd

Please sign in to comment.