Skip to content

Commit

Permalink
Fix initialization of subcircuit in GuidedPauliSimp implementation (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
cqc-alec authored Oct 8, 2024
1 parent 37888db commit 0c3c72f
Show file tree
Hide file tree
Showing 5 changed files with 26 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.14")
self.requires("symengine/0.12.0")
self.requires("tkassert/0.3.4@tket/stable")
self.requires("tket/1.3.31@tket/stable")
self.requires("tket/1.3.32@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:

* Fix `GuidedPauliSimp` for circuits containing `CircBox` with classical wires.

1.33.0 (October 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.3.31"
version = "1.3.32"
package_type = "library"
license = "Apache 2"
homepage = "https://github.com/CQCL/tket"
Expand Down
9 changes: 8 additions & 1 deletion tket/src/Transformations/PauliOptimisation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include "tket/Circuit/CircUtils.hpp"
#include "tket/Converters/Converters.hpp"
#include "tket/OpType/EdgeType.hpp"
#include "tket/OpType/OpType.hpp"
#include "tket/OpType/OpTypeInfo.hpp"
#include "tket/PauliGraph/PauliGraph.hpp"
Expand Down Expand Up @@ -238,7 +239,13 @@ Transform special_UCC_synthesis(PauliSynthStrat strat, CXConfigType cx_config) {
Circuit inner_circ = *(box_ptr->to_circuit());
synther.apply(inner_circ);
decomp_boxes().apply(inner_circ);
Subcircuit sub = {circ.get_in_edges(v), circ.get_all_out_edges(v), {v}};
Subcircuit sub = {
circ.get_in_edges_of_type(v, EdgeType::Quantum),
circ.get_out_edges_of_type(v, EdgeType::Quantum),
circ.get_in_edges_of_type(v, EdgeType::Classical),
circ.get_out_edges_of_type(v, EdgeType::Classical),
circ.get_in_edges_of_type(v, EdgeType::Boolean),
{v}};
circ.substitute(inner_circ, sub);
}
return !circbox_verts
Expand Down
9 changes: 9 additions & 0 deletions tket/test/src/test_PauliGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "tket/PauliGraph/PauliGraph.hpp"
#include "tket/Transformations/PauliOptimisation.hpp"
#include "tket/Transformations/Rebase.hpp"
#include "tket/Utils/UnitID.hpp"

namespace tket {
namespace test_PauliGraph {
Expand Down Expand Up @@ -693,6 +694,14 @@ SCENARIO("Test mutual diagonalisation of fully commuting sets") {
test2.symbol_substitution(symbol_map);
REQUIRE(test_statevector_comparison(test1, test2));
}
GIVEN("A circuit with a classical bit") {
// https://github.com/CQCL/tket/issues/1578
Circuit c0(0, 1);
CircBox cbox(c0);
Circuit c(0, 1);
c.add_box<CircBox, Bit>(cbox, {Bit("c", 0)});
REQUIRE_NOTHROW(Transforms::special_UCC_synthesis().apply(c));
}
GIVEN(
"Clifford merges requires removing from start line without segfault "
"(Grover circuit)") {
Expand Down

0 comments on commit 0c3c72f

Please sign in to comment.