From 18faba4b3063adb443b8fdb1531be82a771115dd Mon Sep 17 00:00:00 2001 From: burgholzer Date: Tue, 7 Jan 2025 22:09:21 +0100 Subject: [PATCH 1/3] =?UTF-8?q?=E2=AC=86=EF=B8=8F=20update=20mqt-core=20ve?= =?UTF-8?q?rsion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: burgholzer --- cmake/ExternalDependencies.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/ExternalDependencies.cmake b/cmake/ExternalDependencies.cmake index cb960a7a..b750934e 100644 --- a/cmake/ExternalDependencies.cmake +++ b/cmake/ExternalDependencies.cmake @@ -22,7 +22,7 @@ endif() # cmake-format: off set(MQT_CORE_VERSION 2.7.1 CACHE STRING "MQT Core version") -set(MQT_CORE_REV "ee7482834c75c6ba7b5ce5fbd74829cb513e3c01" +set(MQT_CORE_REV "a7032324072fef82cc5edc8798ca8b72870fb8d2" CACHE STRING "MQT Core identifier (tag, branch or commit hash)") set(MQT_CORE_REPO_OWNER "cda-tum" CACHE STRING "MQT Core repository owner (change when using a fork)") From 540ef4ad693e5b4e509e5d734e2604e47ea908f5 Mon Sep 17 00:00:00 2001 From: burgholzer Date: Tue, 7 Jan 2025 22:17:22 +0100 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=91=BD=20adjust=20SWAP=20handling=20a?= =?UTF-8?q?nd=20reference=20counting?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: burgholzer --- include/checker/dd/TaskManager.hpp | 21 +++++++++++++------- src/checker/dd/DDAlternatingChecker.cpp | 4 ++-- src/checker/dd/DDSimulationChecker.cpp | 1 + src/checker/dd/simulation/StateGenerator.cpp | 6 +++--- 4 files changed, 20 insertions(+), 12 deletions(-) diff --git a/include/checker/dd/TaskManager.hpp b/include/checker/dd/TaskManager.hpp index 170a5270..83118115 100644 --- a/include/checker/dd/TaskManager.hpp +++ b/include/checker/dd/TaskManager.hpp @@ -13,8 +13,10 @@ #include "ir/operations/OpType.hpp" #include "ir/operations/Operation.hpp" +#include #include #include +#include namespace ec { enum class Direction : bool { Left = true, Right = false }; @@ -53,10 +55,10 @@ template class TaskManager { } [[nodiscard]] qc::MatrixDD getDD() { - return dd::getDD((*iterator).get(), *package, permutation); + return dd::getDD(iterator->get(), *package, permutation); } [[nodiscard]] qc::MatrixDD getInverseDD() { - return dd::getInverseDD((*iterator).get(), *package, permutation); + return dd::getInverseDD(iterator->get(), *package, permutation); } [[nodiscard]] const qc::QuantumComputation* getCircuit() const noexcept { @@ -85,17 +87,22 @@ template class TaskManager { ++iterator; } - void applySwapOperations(DDType& state) { - while (!finished() && (*iterator)->getType() == qc::SWAP) { - applyGate(state); + void applySwapOperations() { + while (!finished() && (*iterator)->getType() == qc::SWAP && + !(*iterator)->isControlled()) { + const auto& targets = (*iterator)->getTargets(); + assert(targets.size() == 2); + const auto t1 = targets[0]; + const auto t2 = targets[1]; + std::swap(permutation.at(t1), permutation.at(t2)); + ++iterator; } } - void applySwapOperations() { applySwapOperations(internalState); } void advance(DDType& state, const std::size_t steps) { for (std::size_t i = 0U; i < steps && !finished(); ++i) { applyGate(state); - applySwapOperations(state); + applySwapOperations(); } } void advance(DDType& state) { advance(state, 1U); } diff --git a/src/checker/dd/DDAlternatingChecker.cpp b/src/checker/dd/DDAlternatingChecker.cpp index 6ee0c313..32a700c1 100644 --- a/src/checker/dd/DDAlternatingChecker.cpp +++ b/src/checker/dd/DDAlternatingChecker.cpp @@ -52,8 +52,8 @@ void DDAlternatingChecker::initialize() { void DDAlternatingChecker::execute() { while (!taskManager1.finished() && !taskManager2.finished() && !isDone()) { // skip over any SWAP operations - taskManager1.applySwapOperations(functionality); - taskManager2.applySwapOperations(functionality); + taskManager1.applySwapOperations(); + taskManager2.applySwapOperations(); if (!taskManager1.finished() && !taskManager2.finished() && !isDone()) { // whenever the current functionality resembles the identity, identical diff --git a/src/checker/dd/DDSimulationChecker.cpp b/src/checker/dd/DDSimulationChecker.cpp index b2957768..2cf9af15 100644 --- a/src/checker/dd/DDSimulationChecker.cpp +++ b/src/checker/dd/DDSimulationChecker.cpp @@ -38,6 +38,7 @@ EquivalenceCriterion DDSimulationChecker::checkEquivalence() { // adjust reference counts to facilitate reuse of the simulation checker taskManager1.decRef(); taskManager2.decRef(); + dd->decRef(initialState); return equivalence; } diff --git a/src/checker/dd/simulation/StateGenerator.cpp b/src/checker/dd/simulation/StateGenerator.cpp index 0a326f1b..3ddc80eb 100644 --- a/src/checker/dd/simulation/StateGenerator.cpp +++ b/src/checker/dd/simulation/StateGenerator.cpp @@ -143,15 +143,15 @@ qc::VectorDD StateGenerator::generateRandomStabilizerState( // circuit auto stabilizer = simulate(&rcs, dd.makeZeroState(randomQubits), dd); - // decrease the ref count right after so that it stays correct later on - dd.decRef(stabilizer); - // add |0> edges for all the ancillary qubits auto initial = stabilizer; for (std::size_t p = randomQubits; p < totalQubits; ++p) { initial = dd.makeDDNode(static_cast(p), std::array{initial, qc::VectorDD::zero()}); } + // properly set the reference count for the state + dd.incRef(initial); + dd.decRef(stabilizer); // return the resulting decision diagram return initial; From 4c57cfd7caab95e18cb47cb0114937bb0bf702cc Mon Sep 17 00:00:00 2001 From: burgholzer Date: Tue, 7 Jan 2025 23:25:02 +0100 Subject: [PATCH 3/3] =?UTF-8?q?=E2=9A=97=EF=B8=8F=20run=20Python=20tests?= =?UTF-8?q?=20individually?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: burgholzer --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 94e304d2..62da4cb8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,6 +38,9 @@ jobs: needs: change-detection if: fromJSON(needs.change-detection.outputs.run-python-tests) uses: cda-tum/mqt-workflows/.github/workflows/reusable-python-ci.yml@v1.5 + with: + # Runs all Python tests in separate jobs to maximize parallelism + run-tests-individually: true code-ql: name: 📝 CodeQL