Skip to content

Commit

Permalink
Make CliffordCircuitPredicate accept measurements (#1743)
Browse files Browse the repository at this point in the history
  • Loading branch information
cqc-alec authored Jan 22, 2025
1 parent 3dbdd4a commit 03d7a2e
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 4 deletions.
3 changes: 2 additions & 1 deletion pytket/binders/predicates.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@ PYBIND11_MODULE(predicates, m) {
CliffordCircuitPredicate, std::shared_ptr<CliffordCircuitPredicate>,
Predicate>(
m, "CliffordCircuitPredicate",
"Predicate asserting that a circuit has only Clifford gates.")
"Predicate asserting that a circuit has only Clifford gates and "
"measurements.")
.def(py::init<>(), "Constructor.");
py::class_<
UserDefinedPredicate, std::shared_ptr<UserDefinedPredicate>, Predicate>(
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.15")
self.requires("symengine/0.13.0")
self.requires("tkassert/0.3.4@tket/stable")
self.requires("tket/1.3.62@tket/stable")
self.requires("tket/1.3.63@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
7 changes: 7 additions & 0 deletions pytket/docs/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
Changelog
=========

Unreleased
----------

Fixes:

* Make `CliffordCircuitPredicate` accept circuits containing measurements.

1.39.0 (January 2025)
---------------------

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.62"
version = "1.3.63"
package_type = "library"
license = "Apache 2"
homepage = "https://github.com/CQCL/tket"
Expand Down
1 change: 1 addition & 0 deletions tket/src/Predicates/Predicates.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,7 @@ bool CliffordCircuitPredicate::verify(const Circuit& circ) const {
BGL_FORALL_VERTICES(v, circ.dag, DAG) {
Op_ptr op = circ.get_Op_ptr_from_Vertex(v);
if (op->get_desc().is_meta()) continue;
if (op->get_type() == OpType::Measure) continue;
if (!op->is_clifford()) return false;
}
return true;
Expand Down
3 changes: 2 additions & 1 deletion tket/test/src/test_CompilerPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2164,12 +2164,13 @@ SCENARIO("GPI, GPI2 and AAMS operations") {
REQUIRE(test_unitary_comparison(circ1, circ2));
}
GIVEN("A circuit made of Clifford gates") {
Circuit c(3);
Circuit c(3, 1);
c.add_op<unsigned>(OpType::GPI, 0.25, {0});
c.add_op<unsigned>(OpType::GPI2, 0.5, {1});
c.add_op<unsigned>(OpType::AAMS, {0, 0.1, 0.2}, {0, 1});
c.add_op<unsigned>(OpType::AAMS, {1., 0.25, 0.75}, {1, 2});
c.add_op<unsigned>(OpType::AAMS, {0.5, 0.5, 1.5}, {0, 1});
c.add_measure(0, 0);
REQUIRE(CliffordCircuitPredicate().verify(c));
}
GIVEN("A circuit with a non-Clifford AAMS gate") {
Expand Down

0 comments on commit 03d7a2e

Please sign in to comment.