Skip to content

Commit

Permalink
Ignore boxes when applying KAK decomposition to a circuit (#1740)
Browse files Browse the repository at this point in the history
  • Loading branch information
cqc-alec authored Jan 17, 2025
1 parent cde5f28 commit 6c9847f
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 3 deletions.
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.15")
self.requires("symengine/0.13.0")
self.requires("tkassert/0.3.4@tket/stable")
self.requires("tket/1.3.61@tket/stable")
self.requires("tket/1.3.62@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 @@ -11,6 +11,7 @@ Features:
Fixes:

* Fix issue with custom gates in qasm to circuit conversion.
* Ignore boxes when applying `KAKDecomposition`.

1.38.0 (January 2025)
---------------------
Expand Down
7 changes: 7 additions & 0 deletions pytket/tests/transform_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1237,6 +1237,13 @@ def test_KAK_with_ClassicalExpBox() -> None:
assert not kak.apply(circ)


def test_KAK_with_CircBox() -> None:
# https://github.com/CQCL/tket/issues/1553
cbox = CircBox(Circuit(2))
c = Circuit(2).add_circbox(cbox, [0, 1]).add_circbox(cbox, [0, 1])
assert not Transform.KAKDecomposition().apply(c)


def test_round_angles() -> None:
circ0 = Circuit(3).H(0).CRz(0.001, 0, 1).TK2(0.5, 0.499, 0.501, 1, 2)
circ1 = Circuit(3).H(0).TK2(0.5, 0.5, 0.5, 1, 2)
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.61"
version = "1.3.62"
package_type = "library"
license = "Apache 2"
homepage = "https://github.com/CQCL/tket"
Expand Down
4 changes: 3 additions & 1 deletion tket/src/Transformations/BasicOptimisation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,9 @@ Transform two_qubit_squash(
circ.get_next_edge(*v, current_edge_on_qb[q]);
}
}
} else if (circ.n_in_edges_of_type(*v, EdgeType::Quantum) == 2) {
} else if (
is_gate_type(type) &&
circ.n_in_edges_of_type(*v, EdgeType::Quantum) == 2) {
// Check for 2qb gate
Qubit q0 = v_to_qb.at({*v, 0});
Qubit q1 = v_to_qb.at({*v, 1});
Expand Down

0 comments on commit 6c9847f

Please sign in to comment.