Skip to content

Commit

Permalink
[bugfix] Don't reuse "stale" Pauli stabilizers when generating Pauli …
Browse files Browse the repository at this point in the history
…graphs (#1245)
  • Loading branch information
cqc-alec authored Feb 9, 2024
1 parent c5a7106 commit fc89c70
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 4 deletions.
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.89@tket/stable")
self.requires("tket/1.2.90@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
5 changes: 5 additions & 0 deletions pytket/docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ Features:

* Add ``WasmFileHandler.bytecode()`` method to retrieve the WASM as bytecode.

Fixes:

* Fix bug in ``PauliExponentials()`` pass affecting circuits containing
``PhasedX`` gates containing Clifford angles.

1.24.0 (January 2024)
---------------------

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.89"
version = "1.2.90"
package_type = "library"
license = "Apache 2"
homepage = "https://github.com/CQCL/tket"
Expand Down
5 changes: 3 additions & 2 deletions tket/src/PauliGraph/PauliGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,6 @@ void PauliGraph::apply_gate_at_end(
case OpType::PhasedX: {
Expr alpha = gate.get_params().at(0);
Expr beta = gate.get_params().at(1);
SpPauliStabiliser zpauli = cliff_.get_zrow(qbs.at(0));
SpPauliStabiliser xpauli = cliff_.get_xrow(qbs.at(0));
std::optional<unsigned> cliff_alpha = equiv_Clifford(alpha);
std::optional<unsigned> cliff_beta = equiv_Clifford(beta);
// Rz(-b)
Expand All @@ -173,6 +171,7 @@ void PauliGraph::apply_gate_at_end(
cliff_.apply_gate_at_end(OpType::Sdg, qbs);
}
} else {
SpPauliStabiliser zpauli = cliff_.get_zrow(qbs.at(0));
apply_pauli_gadget_at_end(zpauli, -beta);
}
// Rx(a)
Expand All @@ -181,6 +180,7 @@ void PauliGraph::apply_gate_at_end(
cliff_.apply_gate_at_end(OpType::V, qbs);
}
} else {
SpPauliStabiliser xpauli = cliff_.get_xrow(qbs.at(0));
apply_pauli_gadget_at_end(xpauli, alpha);
}
// Rz(b)
Expand All @@ -189,6 +189,7 @@ void PauliGraph::apply_gate_at_end(
cliff_.apply_gate_at_end(OpType::S, qbs);
}
} else {
SpPauliStabiliser zpauli = cliff_.get_zrow(qbs.at(0));
apply_pauli_gadget_at_end(zpauli, beta);
}
break;
Expand Down
13 changes: 13 additions & 0 deletions tket/test/src/test_CompilerPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2026,5 +2026,18 @@ SCENARIO(
REQUIRE(cu.get_circ_ref().n_gates() == 1);
}
}

SCENARIO("PauliExponentials") {
GIVEN("A PhasedX gate") {
// https://github.com/CQCL/tket/issues/1244
Circuit c(1);
c.add_op<unsigned>(OpType::PhasedX, {0.5, 0.6}, {0});
c.add_op<unsigned>(OpType::PhasedX, {0.6, 0.5}, {0});
CompilationUnit cu(c);
CHECK(gen_pauli_exponentials(Transforms::PauliSynthStrat::Individual)
->apply(cu));
REQUIRE(test_unitary_comparison(c, cu.get_circ_ref(), true));
}
}
} // namespace test_CompilerPass
} // namespace tket

0 comments on commit fc89c70

Please sign in to comment.