Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accept OpType.Phase in circuits passed to ZXGraphlikeOptimisation #1210

Merged
merged 4 commits into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pytket/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
4 changes: 4 additions & 0 deletions pytket/docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
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.2.84"
version = "1.2.85"
package_type = "library"
license = "Apache 2"
homepage = "https://github.com/CQCL/tket"
Expand Down
17 changes: 12 additions & 5 deletions tket/proptest/src/proptest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ using namespace tket;
DO(NormaliseTK2) \
DO(SquashRzPhasedX) \
DO(CnXPairwiseDecomposition) \
DO(RemoveImplicitQubitPermutation)
DO(RemoveImplicitQubitPermutation) \
DO(ZXGraphlikeOptimisation)

static const std::map<PassPtr, std::string> &pass_name() {
// Map from PassPtr to readable name
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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 &) {
}
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down
3 changes: 2 additions & 1 deletion tket/src/Converters/ZXConverters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
Loading