From 521fbf92f5fa8c7e7a48319ac397581949b6d324 Mon Sep 17 00:00:00 2001 From: Alec Edgington Date: Thu, 11 Jan 2024 14:44:37 +0000 Subject: [PATCH 1/4] Handle (i.e. ignore) OpType::Phase in ZXGraphlikeOptimisation. --- tket/src/Converters/ZXConverters.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tket/src/Converters/ZXConverters.cpp b/tket/src/Converters/ZXConverters.cpp index 3a33eb6c51..b5f60b2b1e 100644 --- a/tket/src/Converters/ZXConverters.cpp +++ b/tket/src/Converters/ZXConverters.cpp @@ -159,7 +159,8 @@ BoundaryVertMap circuit_to_zx_recursive( // Spiderless ops are handled during vertex wiring case OpType::Barrier: case OpType::noop: - case OpType::SWAP: { + case OpType::SWAP: + case OpType::Phase: { continue; } case OpType::H: { From cab72ba2279595ae06c28f7fa3182d619121a4de Mon Sep 17 00:00:00 2001 From: Alec Edgington Date: Thu, 11 Jan 2024 15:11:33 +0000 Subject: [PATCH 2/4] Add ZXGraphlikeOptimisation pass to proptest. This pass ignores global phase, so the correctness check needs to be modified accordingly. --- tket/proptest/src/proptest.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/tket/proptest/src/proptest.cpp b/tket/proptest/src/proptest.cpp index 11884b15fa..6883559c5c 100644 --- a/tket/proptest/src/proptest.cpp +++ b/tket/proptest/src/proptest.cpp @@ -54,7 +54,8 @@ using namespace tket; DO(NormaliseTK2) \ DO(SquashRzPhasedX) \ DO(CnXPairwiseDecomposition) \ - DO(RemoveImplicitQubitPermutation) + DO(RemoveImplicitQubitPermutation) \ + DO(ZXGraphlikeOptimisation) static const std::map &pass_name() { // Map from PassPtr to readable name @@ -201,7 +202,9 @@ static Architecture random_architecture() { * @param[in] c0 original circuit * @param[in] cu compliation pass having been applied to \p c0 */ -static void check_correctness(const Circuit &c0, const CompilationUnit &cu) { +static void check_correctness( + const Circuit &c0, const CompilationUnit &cu, + tket_sim::MatrixEquivalence equivalence) { RC_LOG() << "In Check Correctness" << std::endl; const Circuit &c1 = cu.get_circ_ref(); @@ -247,7 +250,7 @@ static void check_correctness(const Circuit &c0, const CompilationUnit &cu) { const auto u1 = tket_sim::get_unitary(c1); const auto u0 = tket_sim::get_unitary(c0_copy); RC_ASSERT(tket_sim::compare_statevectors_or_unitaries( - u0, m_inv_fin * u1 * m_ini)); + u0, m_inv_fin * u1 * m_ini, equivalence)); } catch (const Unsupported &) { } catch (const BadOpType &) { } @@ -317,7 +320,11 @@ bool check_passes() { for (auto postcon : postcons) { RC_ASSERT(postcon.second->verify(c1)); } - check_correctness(c, cu); + check_correctness( + c, cu, + (pass_name().at(p) == "ZXGraphlikeOptimisation") + ? tket_sim::MatrixEquivalence::EQUAL_UP_TO_GLOBAL_PHASE + : tket_sim::MatrixEquivalence::EQUAL); } else { RC_ASSERT(c == c1); } @@ -368,7 +375,7 @@ bool check_mapping() { RC_LOG() << x.first.repr() << " " << x.second.repr() << std::endl; } if (applied) { - check_correctness(c, cu); + check_correctness(c, cu, tket_sim::MatrixEquivalence::EQUAL); } else { RC_ASSERT(c == c1); } From 6bd3240b2436ffd61fa75bb9b4686a4d83a2c454 Mon Sep 17 00:00:00 2001 From: Alec Edgington Date: Thu, 11 Jan 2024 15:12:51 +0000 Subject: [PATCH 3/4] Update changelog. --- pytket/docs/changelog.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pytket/docs/changelog.rst b/pytket/docs/changelog.rst index b17bdd873f..f6d4cf8895 100644 --- a/pytket/docs/changelog.rst +++ b/pytket/docs/changelog.rst @@ -4,6 +4,10 @@ Changelog Unreleased ---------- +Features: + +* Accept ``OpType.Phase`` in circuits passed to ``ZXGraphlikeOptimisation``. + Fixes: * Handle a missing edge case in decomposition of single-qubit rotations. From bc22a3345700bfbe63bfe561af8a617041bce022 Mon Sep 17 00:00:00 2001 From: Alec Edgington Date: Thu, 11 Jan 2024 15:14:13 +0000 Subject: [PATCH 4/4] Bump tket version. --- pytket/conanfile.py | 2 +- tket/conanfile.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pytket/conanfile.py b/pytket/conanfile.py index f58176a657..a361ece52f 100644 --- a/pytket/conanfile.py +++ b/pytket/conanfile.py @@ -32,7 +32,7 @@ def package(self): cmake.install() def requirements(self): - self.requires("tket/1.2.84@tket/stable") + self.requires("tket/1.2.85@tket/stable") self.requires("tklog/0.3.3@tket/stable") self.requires("tkrng/0.3.3@tket/stable") self.requires("tkassert/0.3.4@tket/stable") diff --git a/tket/conanfile.py b/tket/conanfile.py index 138831949c..d389871a46 100644 --- a/tket/conanfile.py +++ b/tket/conanfile.py @@ -23,7 +23,7 @@ class TketConan(ConanFile): name = "tket" - version = "1.2.84" + version = "1.2.85" package_type = "library" license = "Apache 2" homepage = "https://github.com/CQCL/tket"