Skip to content

Commit

Permalink
Merge branch 'main' into single-thread-GPO
Browse files Browse the repository at this point in the history
  • Loading branch information
sjdilkes committed Nov 19, 2024
2 parents ac9c319 + eb7d846 commit ed778d0
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 18 deletions.
13 changes: 6 additions & 7 deletions pytket/binders/passes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ PYBIND11_MODULE(passes, m) {
m.def(
"RebaseTket", &RebaseTket,
"Converts all gates to CX, TK1 and Phase. "
"(Any Measure, Reset and Collapse operations are left untouched; "
"(Any Measure and Reset operations are left untouched; "
"Conditional gates are also allowed.)");
m.def(
"RemoveRedundancies", &RemoveRedundancies,
Expand Down Expand Up @@ -650,7 +650,7 @@ PYBIND11_MODULE(passes, m) {
":math:`(a,b,c)` to generate replacement circuits."
"\n\n"
":param gateset: the allowed operations in the rebased circuit "
"(in addition, Measure, Reset and Collapse operations are always allowed "
"(in addition, Measure and Reset operations are always allowed "
"and are left alone; conditional operations may be present; and Phase "
"gates may also be introduced by the rebase)"
"\n:param cx_replacement: the equivalent circuit to replace a CX gate "
Expand All @@ -660,8 +660,7 @@ PYBIND11_MODULE(passes, m) {
"Rz(a)Rx(b)Rz(c) triple, returns an equivalent circuit in the desired "
"basis"
"\n:return: a pass that rebases to the given gate set (possibly "
"including conditional and phase operations, and Measure, Reset and "
"Collapse)",
"including conditional and phase operations, and Measure and Reset",
py::arg("gateset"), py::arg("cx_replacement"),
py::arg("tk1_replacement"));

Expand All @@ -679,7 +678,7 @@ PYBIND11_MODULE(passes, m) {
"to each TK1(a,b,c)."
"\n\n"
":param gateset: the allowed operations in the rebased circuit "
"(in addition, Measure, Reset and Collapse operations are always allowed "
"(in addition, Measure and Reset always allowed "
"and are left alone; conditional operations may be present; and Phase "
"gates may also be introduced by the rebase)\n"
":param tk2_replacement: a function which, given the parameters (a,b,c) "
Expand All @@ -689,7 +688,7 @@ PYBIND11_MODULE(passes, m) {
"of an Rz(a)Rx(b)Rz(c) triple, returns an equivalent circuit in the "
"desired basis\n"
":return: a pass that rebases to the given gate set (possibly including "
"conditional and phase operations, and Measure, Reset and Collapse)",
"conditional and phase operations, and Measure and Reset)",
py::arg("gateset"), py::arg("tk2_replacement"),
py::arg("tk1_replacement"));
m.def(
Expand All @@ -701,7 +700,7 @@ PYBIND11_MODULE(passes, m) {
"Raises an error if no known decompositions can be found, in which case "
"try using :py:class:`RebaseCustom` with your own decompositions.\n\n"
":param gateset: Set of supported OpTypes, target gate set. "
"(in addition, Measure, Reset and Collapse operations are always allowed "
"(in addition, Measure and Reset operations are always allowed "
"and are left alone; conditional operations may be present; and Phase "
"gates may also be introduced by the rebase)\n"
":param allow_swaps: Whether to allow implicit wire swaps. Default to "
Expand Down
2 changes: 1 addition & 1 deletion pytket/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def requirements(self):
self.requires("pybind11_json/0.2.14")
self.requires("symengine/0.13.0")
self.requires("tkassert/0.3.4@tket/stable")
self.requires("tket/1.3.49@tket/stable")
self.requires("tket/1.3.47@tket/stable")
self.requires("tklog/0.3.3@tket/stable")
self.requires("tkrng/0.3.3@tket/stable")
self.requires("tktokenswap/0.3.9@tket/stable")
Expand Down
1 change: 1 addition & 0 deletions pytket/docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Features:
* Extend `DecomposeClassicalExp` to handle `ClExprOp` as well as
`ClassicalExpBox`.
* Add convenience method `Circuit.add_clecpr_from_logicexp()`.
* Remove `OpType::Collapse` from the `GateSetPredicate` of `gen_auto_rebase_pass`.

Deprecations:

Expand Down
12 changes: 6 additions & 6 deletions pytket/pytket/_tket/passes.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ def AutoRebase(gateset: set[pytket._tket.circuit.OpType], allow_swaps: bool = Fa
Attempt to generate a rebase pass automatically for the given target gateset. Checks if there are known existing decompositions to target gateset and TK1 to target gateset and uses those to construct a custom rebase.
Raises an error if no known decompositions can be found, in which case try using :py:class:`RebaseCustom` with your own decompositions.
:param gateset: Set of supported OpTypes, target gate set. (in addition, Measure, Reset and Collapse operations are always allowed and are left alone; conditional operations may be present; and Phase gates may also be introduced by the rebase)
:param gateset: Set of supported OpTypes, target gate set. (in addition, Measure and Reset operations are always allowed and are left alone; conditional operations may be present; and Phase gates may also be introduced by the rebase)
:param allow_swaps: Whether to allow implicit wire swaps. Default to False.
"""
def AutoSquash(singleqs: set[pytket._tket.circuit.OpType]) -> BasePass:
Expand Down Expand Up @@ -565,10 +565,10 @@ def RebaseCustom(gateset: set[pytket._tket.circuit.OpType], cx_replacement: pytk
3. converts any single-qubit gates not in the gate type set to the form :math:`\\mathrm{Rz}(a)\\mathrm{Rx}(b)\\mathrm{Rz}(c)` (in matrix-multiplication order, i.e. reverse order in the circuit);
4. applies the `tk1_replacement` function to each of these triples :math:`(a,b,c)` to generate replacement circuits.
:param gateset: the allowed operations in the rebased circuit (in addition, Measure, Reset and Collapse operations are always allowed and are left alone; conditional operations may be present; and Phase gates may also be introduced by the rebase)
:param gateset: the allowed operations in the rebased circuit (in addition, Measure and Reset operations are always allowed and are left alone; conditional operations may be present; and Phase gates may also be introduced by the rebase)
:param cx_replacement: the equivalent circuit to replace a CX gate using two qubit gates from the desired basis (can use any single qubit OpTypes)
:param tk1_replacement: a function which, given the parameters of an Rz(a)Rx(b)Rz(c) triple, returns an equivalent circuit in the desired basis
:return: a pass that rebases to the given gate set (possibly including conditional and phase operations, and Measure, Reset and Collapse)
:return: a pass that rebases to the given gate set (possibly including conditional and phase operations, and Measure and Reset
"""
@typing.overload
def RebaseCustom(gateset: set[pytket._tket.circuit.OpType], tk2_replacement: typing.Callable[[sympy.Expr | float, sympy.Expr | float, sympy.Expr | float], pytket._tket.circuit.Circuit], tk1_replacement: typing.Callable[[sympy.Expr | float, sympy.Expr | float, sympy.Expr | float], pytket._tket.circuit.Circuit]) -> BasePass:
Expand All @@ -580,14 +580,14 @@ def RebaseCustom(gateset: set[pytket._tket.circuit.OpType], tk2_replacement: typ
3. converts any single-qubit gates not in the gate type set to TK1;
4. if TK2 is not in `gateset`. applies the `tk1_replacement` function to each TK1(a,b,c).
:param gateset: the allowed operations in the rebased circuit (in addition, Measure, Reset and Collapse operations are always allowed and are left alone; conditional operations may be present; and Phase gates may also be introduced by the rebase)
:param gateset: the allowed operations in the rebased circuit (in addition, Measure and Reset always allowed and are left alone; conditional operations may be present; and Phase gates may also be introduced by the rebase)
:param tk2_replacement: a function which, given the parameters (a,b,c) of an XXPhase(a)YYPhase(b)ZZPhase(c) triple, returns an equivalent circuit in the desired basis
:param tk1_replacement: a function which, given the parameters (a,b,c) of an Rz(a)Rx(b)Rz(c) triple, returns an equivalent circuit in the desired basis
:return: a pass that rebases to the given gate set (possibly including conditional and phase operations, and Measure, Reset and Collapse)
:return: a pass that rebases to the given gate set (possibly including conditional and phase operations, and Measure and Reset)
"""
def RebaseTket() -> BasePass:
"""
Converts all gates to CX, TK1 and Phase. (Any Measure, Reset and Collapse operations are left untouched; Conditional gates are also allowed.)
Converts all gates to CX, TK1 and Phase. (Any Measure and Reset operations are left untouched; Conditional gates are also allowed.)
"""
def RemoveBarriers() -> BasePass:
"""
Expand Down
4 changes: 2 additions & 2 deletions pytket/pytket/passes/auto_rebase.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ def auto_rebase_pass(gateset: set[OpType], allow_swaps: bool = False) -> BasePas
Raises an error if no known decompositions can be found, in which case try
using RebaseCustom with your own decompositions.
In addition to the gate types in ``gateset``, any ``Measure``, ``Reset`` and
``Collapse`` operations in the original circuit are retained. Conditional
In addition to the gate types in ``gateset``, any ``Measure`` and ``Reset``
operations in the original circuit are retained. Conditional
operations are also allowed. ``Phase`` gates may also be introduced.
:param gateset: Set of supported OpTypes, target gate set.
Expand Down
2 changes: 1 addition & 1 deletion tket/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

class TketConan(ConanFile):
name = "tket"
version = "1.3.49"
version = "1.3.47"
package_type = "library"
license = "Apache 2"
homepage = "https://github.com/CQCL/tket"
Expand Down
1 change: 0 additions & 1 deletion tket/src/Predicates/PassGenerators.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,6 @@ PassPtr gen_auto_rebase_pass(const OpTypeSet& allowed_gates, bool allow_swaps) {
PredicatePtrMap precons;
OpTypeSet all_types(allowed_gates);
all_types.insert(OpType::Measure);
all_types.insert(OpType::Collapse);
all_types.insert(OpType::Reset);
PredicatePtr postcon1 = std::make_shared<GateSetPredicate>(all_types);
PredicatePtr postcon2 = std::make_shared<MaxTwoQubitGatesPredicate>();
Expand Down

0 comments on commit ed778d0

Please sign in to comment.