From 01643fe834f7f9a8388d5639ae82a9f85288cd3a Mon Sep 17 00:00:00 2001 From: Alec Edgington <54802828+cqc-alec@users.noreply.github.com> Date: Wed, 27 Nov 2024 16:09:01 +0000 Subject: [PATCH] Only update index map when needed (#1697) --- pytket/conanfile.py | 2 +- tket/conanfile.py | 2 +- tket/include/tket/Transformations/CliffordReductionPass.hpp | 3 +++ tket/src/Transformations/CliffordReductionPass.cpp | 3 ++- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/pytket/conanfile.py b/pytket/conanfile.py index 9bdd4157ce..cc9ab6c313 100644 --- a/pytket/conanfile.py +++ b/pytket/conanfile.py @@ -38,7 +38,7 @@ def requirements(self): self.requires("pybind11_json/0.2.14") self.requires("symengine/0.13.0") self.requires("tkassert/0.3.4@tket/stable") - self.requires("tket/1.3.50@tket/stable") + self.requires("tket/1.3.51@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") diff --git a/tket/conanfile.py b/tket/conanfile.py index da3643e863..8e330a0a69 100644 --- a/tket/conanfile.py +++ b/tket/conanfile.py @@ -23,7 +23,7 @@ class TketConan(ConanFile): name = "tket" - version = "1.3.50" + version = "1.3.51" package_type = "library" license = "Apache 2" homepage = "https://github.com/CQCL/tket" diff --git a/tket/include/tket/Transformations/CliffordReductionPass.hpp b/tket/include/tket/Transformations/CliffordReductionPass.hpp index 71fc6c3dd5..eeb27545f6 100644 --- a/tket/include/tket/Transformations/CliffordReductionPass.hpp +++ b/tket/include/tket/Transformations/CliffordReductionPass.hpp @@ -112,6 +112,9 @@ class CliffordReductionPass { /** The circuit under transformation */ Circuit ˆ + /** Topological-order-respecting map from circuit vertices to integers */ + IndexMap im; + /** Table of potential transports of 2qb interactions through the circuit */ interaction_table_t itable; diff --git a/tket/src/Transformations/CliffordReductionPass.cpp b/tket/src/Transformations/CliffordReductionPass.cpp index 8efd3b2ec9..65934205b9 100644 --- a/tket/src/Transformations/CliffordReductionPass.cpp +++ b/tket/src/Transformations/CliffordReductionPass.cpp @@ -234,7 +234,6 @@ std::optional CliffordReductionPass::search_back_for_match( point[0] = rip0; point[1] = rip1; std::map point_lookup; - IndexMap im = circ.index_map(); // interactions met when commuting back; point lists are in causal order of // circuit: @@ -350,6 +349,7 @@ void CliffordReductionPass::process_new_interaction(const Vertex &inter) { break; } } + im = circ.index_map(); success = true; } else { std::vector> outs = circ.get_linear_out_edges(v); @@ -645,6 +645,7 @@ CliffordReductionPass::valid_insertion_point( CliffordReductionPass::CliffordReductionPass(Circuit &c, bool swaps) : circ(c), + im(c.index_map()), itable(), v_to_depth(), success(false),