Skip to content

Commit 631b16d

Browse files
authored
Use AutoRebase in tk_to_qiskit rather than RebaseCustom (#387)
* use AutoRebase instead of RebaseCustom * remove unused Union import
1 parent 6742322 commit 631b16d

File tree

1 file changed

+2
-16
lines changed

1 file changed

+2
-16
lines changed

pytket/extensions/qiskit/qiskit_convert.py

+2-16
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
from typing import (
2020
Callable,
2121
Optional,
22-
Union,
2322
Any,
2423
Iterable,
2524
cast,
@@ -82,7 +81,7 @@
8281
from pytket.pauli import Pauli, QubitPauliString
8382
from pytket.architecture import Architecture, FullyConnected
8483
from pytket.utils import QubitPauliOperator, gen_term_sequence_circuit
85-
from pytket.passes import RebaseCustom
84+
from pytket.passes import AutoRebase
8685

8786
if TYPE_CHECKING:
8887
from qiskit_ibm_runtime.ibm_backend import IBMBackend # type: ignore
@@ -762,9 +761,6 @@ def append_tk_command_to_qiskit(
762761
return qcirc.append(g, qargs=qargs)
763762

764763

765-
# Define varibles for RebaseCustom
766-
_cx_replacement = Circuit(2).CX(0, 1)
767-
768764
# The set of tket gates that can be converted directly to qiskit gates
769765
_supported_tket_gates = set(_known_gate_rev_phase.keys())
770766

@@ -779,18 +775,8 @@ def append_tk_command_to_qiskit(
779775
)
780776

781777

782-
Param = Union[float, "sympy.Expr"] # Type for TK1 and U3 parameters
783-
784-
785-
# Use the U3 gate for tk1_replacement as this is a member of _supported_tket_gates
786-
def _tk1_to_u3(a: Param, b: Param, c: Param) -> Circuit:
787-
tk1_circ = Circuit(1)
788-
tk1_circ.add_gate(OpType.U3, [b, a - 1 / 2, c + 1 / 2], [0]).add_phase(-(a + c) / 2)
789-
return tk1_circ
790-
791-
792778
# This is a rebase to the set of tket gates which have an exact substitution in qiskit
793-
supported_gate_rebase = RebaseCustom(_protected_tket_gates, _cx_replacement, _tk1_to_u3)
779+
supported_gate_rebase = AutoRebase(_protected_tket_gates)
794780

795781

796782
def tk_to_qiskit(

0 commit comments

Comments
 (0)