Skip to content

Commit

Permalink
⬆️ update mqt-core and adapt to changes (#444)
Browse files Browse the repository at this point in the history
## Description

This PR updates MQT Core and adapts the code base to the changes from
cda-tum/mqt-core#668.

## Checklist:

<!---
This checklist serves as a reminder of a couple of things that ensure
your pull request will be merged swiftly.
-->

- [x] The pull request only contains commits that are related to it.
- [x] I have added appropriate tests and documentation.
- [x] I have made sure that all CI jobs on GitHub pass.
- [x] The pull request introduces no new warnings and follows the
project's style guidelines.
  • Loading branch information
burgholzer authored Aug 14, 2024
2 parents 119c781 + df98be9 commit 1ae653b
Show file tree
Hide file tree
Showing 31 changed files with 100 additions and 107 deletions.
4 changes: 2 additions & 2 deletions cmake/ExternalDependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ if(BUILD_MQT_QCEC_BINDINGS)
endif()

# cmake-format: off
set(MQT_CORE_VERSION 2.6.0
set(MQT_CORE_VERSION 2.6.1
CACHE STRING "MQT Core version")
set(MQT_CORE_REV "2a7a92951fb67d0c4e795afbd17449063aa42d20"
set(MQT_CORE_REV "89f18fb322ff2ce86e33558e3a2b42a08e655174"
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)")
Expand Down
16 changes: 8 additions & 8 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,14 @@

intersphinx_mapping = {
"python": ("https://docs.python.org/3", None),
"typing_extensions": ("https://typing-extensions.readthedocs.io/en/latest/", None),
"qiskit": ("https://qiskit.org/documentation/", None),
"mqt": ("https://mqt.readthedocs.io/en/latest/", None),
"core": ("https://mqt.readthedocs.io/projects/core/en/latest/", None),
"ddsim": ("https://mqt.readthedocs.io/projects/ddsim/en/latest/", None),
"qmap": ("https://mqt.readthedocs.io/projects/qmap/en/latest/", None),
"qecc": ("https://mqt.readthedocs.io/projects/qecc/en/latest/", None),
"syrec": ("https://mqt.readthedocs.io/projects/syrec/en/latest/", None),
"typing_extensions": ("https://typing-extensions.readthedocs.io/en/latest", None),
"qiskit": ("https://qiskit.org/documentation", None),
"mqt": ("https://mqt.readthedocs.io/en/latest", None),
"core": ("https://mqt.readthedocs.io/projects/core/en/latest", None),
"ddsim": ("https://mqt.readthedocs.io/projects/ddsim/en/latest", None),
"qmap": ("https://mqt.readthedocs.io/projects/qmap/en/latest", None),
"qecc": ("https://mqt.readthedocs.io/projects/qecc/en/latest", None),
"syrec": ("https://mqt.readthedocs.io/projects/syrec/en/latest", None),
}

nbsphinx_execute = "auto"
Expand Down
2 changes: 1 addition & 1 deletion include/EquivalenceCheckingManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

#include "Configuration.hpp"
#include "EquivalenceCriterion.hpp"
#include "QuantumComputation.hpp"
#include "ThreadSafeQueue.hpp"
#include "checker/EquivalenceChecker.hpp"
#include "checker/dd/DDSimulationChecker.hpp"
Expand All @@ -17,6 +16,7 @@
#include "checker/dd/simulation/StateType.hpp"
#include "dd/ComplexNumbers.hpp"
#include "dd/DDDefinitions.hpp"
#include "ir/QuantumComputation.hpp"

#include <condition_variable>
#include <cstddef>
Expand Down
2 changes: 1 addition & 1 deletion include/checker/EquivalenceChecker.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include "Configuration.hpp"
#include "EquivalenceCriterion.hpp"
#include "QuantumComputation.hpp"
#include "ir/QuantumComputation.hpp"

#include <algorithm>
#include <atomic>
Expand Down
2 changes: 1 addition & 1 deletion include/checker/dd/DDAlternatingChecker.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
#include "DDEquivalenceChecker.hpp"
#include "DDPackageConfigs.hpp"
#include "EquivalenceCriterion.hpp"
#include "QuantumComputation.hpp"
#include "applicationscheme/LookaheadApplicationScheme.hpp"
#include "dd/Package_fwd.hpp"
#include "ir/QuantumComputation.hpp"

#include <nlohmann/json_fwd.hpp>
#include <utility>
Expand Down
2 changes: 1 addition & 1 deletion include/checker/dd/DDConstructionChecker.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
#include "Configuration.hpp"
#include "DDEquivalenceChecker.hpp"
#include "DDPackageConfigs.hpp"
#include "QuantumComputation.hpp"
#include "checker/dd/TaskManager.hpp"
#include "checker/dd/applicationscheme/ApplicationScheme.hpp"
#include "dd/Package_fwd.hpp"
#include "ir/QuantumComputation.hpp"

#include <nlohmann/json_fwd.hpp>
#include <stdexcept>
Expand Down
2 changes: 1 addition & 1 deletion include/checker/dd/DDEquivalenceChecker.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

#include "Configuration.hpp"
#include "EquivalenceCriterion.hpp"
#include "QuantumComputation.hpp"
#include "TaskManager.hpp"
#include "applicationscheme/ApplicationScheme.hpp"
#include "checker/EquivalenceChecker.hpp"
#include "dd/Package.hpp"
#include "ir/QuantumComputation.hpp"

#include <cstddef>
#include <memory>
Expand Down
2 changes: 1 addition & 1 deletion include/checker/dd/DDSimulationChecker.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
#include "DDEquivalenceChecker.hpp"
#include "DDPackageConfigs.hpp"
#include "EquivalenceCriterion.hpp"
#include "QuantumComputation.hpp"
#include "checker/dd/TaskManager.hpp"
#include "dd/DDDefinitions.hpp"
#include "dd/Package_fwd.hpp"
#include "ir/QuantumComputation.hpp"

#include <nlohmann/json_fwd.hpp>

Expand Down
6 changes: 3 additions & 3 deletions include/checker/dd/TaskManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@

#pragma once

#include "QuantumComputation.hpp"
#include "dd/DDpackageConfig.hpp"
#include "dd/Operations.hpp"
#include "dd/Package.hpp"
#include "dd/Package_fwd.hpp"
#include "operations/OpType.hpp"
#include "operations/Operation.hpp"
#include "ir/QuantumComputation.hpp"
#include "ir/operations/OpType.hpp"
#include "ir/operations/Operation.hpp"

#include <cstddef>
#include <memory>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
#pragma once

#include "ApplicationScheme.hpp"
#include "QuantumComputation.hpp"
#include "checker/dd/TaskManager.hpp"
#include "operations/OpType.hpp"
#include "ir/QuantumComputation.hpp"
#include "ir/operations/OpType.hpp"

#include <cstddef>
#include <fstream>
Expand Down
4 changes: 2 additions & 2 deletions include/checker/zx/ZXChecker.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

#include "Configuration.hpp"
#include "EquivalenceCriterion.hpp"
#include "Permutation.hpp"
#include "QuantumComputation.hpp"
#include "checker/EquivalenceChecker.hpp"
#include "ir/Permutation.hpp"
#include "ir/QuantumComputation.hpp"
#include "zx/Rules.hpp"
#include "zx/ZXDefinitions.hpp"
#include "zx/ZXDiagram.hpp"
Expand Down
4 changes: 2 additions & 2 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def _run_tests(

session.install(*BUILD_REQUIREMENTS, *install_args, env=env)
install_arg = f"-ve.[{','.join(_extras)}]"
session.install("--no-build-isolation", install_arg, *install_args, env=env)
session.install("--no-build-isolation", "--reinstall-package", "mqt.qcec", install_arg, *install_args, env=env)
session.run("pytest", *run_args, *posargs, env=env)


Expand Down Expand Up @@ -106,7 +106,7 @@ def docs(session: nox.Session) -> None:
serve = args.builder == "html" and session.interactive
extra_installs = ["sphinx-autobuild"] if serve else []
session.install(*BUILD_REQUIREMENTS, *extra_installs)
session.install("--no-build-isolation", "-ve.[docs]")
session.install("--no-build-isolation", "-ve.[docs]", "--reinstall-package", "mqt.qcec")
session.chdir("docs")

if args.builder == "linkcheck":
Expand Down
6 changes: 4 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ target_include_directories(${PROJECT_NAME} PUBLIC ${PROJECT_SOURCE_DIR}/include
${PROJECT_BINARY_DIR}/include)

# link to the MQT::Core libraries
target_link_libraries(${PROJECT_NAME} PUBLIC MQT::CoreDD MQT::CoreZX)
target_link_libraries(${PROJECT_NAME} PRIVATE MQT::ProjectWarnings MQT::ProjectOptions)
target_link_libraries(
${PROJECT_NAME}
PUBLIC MQT::CoreDD MQT::CoreZX
PRIVATE MQT::CoreCircuitOptimizer MQT::ProjectWarnings MQT::ProjectOptions)

# add MQT alias
add_library(MQT::QCEC ALIAS ${PROJECT_NAME})
Expand Down
14 changes: 7 additions & 7 deletions src/EquivalenceCheckingManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@

#include "EquivalenceCheckingManager.hpp"

#include "CircuitOptimizer.hpp"
#include "Definitions.hpp"
#include "EquivalenceCriterion.hpp"
#include "Permutation.hpp"
#include "QuantumComputation.hpp"
#include "ThreadSafeQueue.hpp"
#include "checker/dd/DDAlternatingChecker.hpp"
#include "checker/dd/DDConstructionChecker.hpp"
#include "checker/dd/DDSimulationChecker.hpp"
#include "checker/dd/simulation/StateType.hpp"
#include "checker/zx/ZXChecker.hpp"
#include "circuit_optimizer/CircuitOptimizer.hpp"
#include "ir/Permutation.hpp"
#include "ir/QuantumComputation.hpp"
#include "zx/FunctionalityConstruction.hpp"

#include <algorithm>
Expand Down Expand Up @@ -284,8 +284,8 @@ void EquivalenceCheckingManager::runOptimizationPasses() {
}

if (configuration.optimizations.reorderOperations) {
qc::CircuitOptimizer::reorderOperations(qc1);
qc::CircuitOptimizer::reorderOperations(qc2);
qc1.reorderOperations();
qc2.reorderOperations();
}

// remove final measurements from both circuits so that the underlying
Expand Down Expand Up @@ -916,8 +916,8 @@ void EquivalenceCheckingManager::reconstructSWAPs() {

void EquivalenceCheckingManager::reorderOperations() {
if (!configuration.optimizations.reorderOperations) {
qc::CircuitOptimizer::reorderOperations(qc1);
qc::CircuitOptimizer::reorderOperations(qc2);
qc1.reorderOperations();
qc2.reorderOperations();
configuration.optimizations.reorderOperations = true;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/checker/dd/DDSimulationChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

#include "Configuration.hpp"
#include "EquivalenceCriterion.hpp"
#include "QuantumComputation.hpp"
#include "checker/dd/DDEquivalenceChecker.hpp"
#include "checker/dd/DDPackageConfigs.hpp"
#include "checker/dd/TaskManager.hpp"
#include "checker/dd/simulation/StateGenerator.hpp"
#include "ir/QuantumComputation.hpp"

#include <nlohmann/json.hpp>
#include <utility>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#include "checker/dd/applicationscheme/GateCostApplicationScheme.hpp"

#include "operations/OpType.hpp"
#include "ir/operations/OpType.hpp"

#include <cstddef>

Expand Down
2 changes: 1 addition & 1 deletion src/checker/zx/ZXChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
#include "Configuration.hpp"
#include "Definitions.hpp"
#include "EquivalenceCriterion.hpp"
#include "QuantumComputation.hpp"
#include "checker/EquivalenceChecker.hpp"
#include "ir/QuantumComputation.hpp"
#include "zx/FunctionalityConstruction.hpp"
#include "zx/Rules.hpp"
#include "zx/ZXDefinitions.hpp"
Expand Down
4 changes: 2 additions & 2 deletions src/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ pybind11_add_module(
OPT_SIZE
# Source code goes here
bindings.cpp)
target_link_libraries(pyqcec PRIVATE MQT::QCEC MQT::CorePython pybind11_json MQT::ProjectOptions
MQT::ProjectWarnings)
target_link_libraries(pyqcec PRIVATE MQT::QCEC MQT::CoreAlgorithms MQT::CorePython pybind11_json
MQT::ProjectOptions MQT::ProjectWarnings)

# Install directive for scikit-build-core
install(
Expand Down
23 changes: 8 additions & 15 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
package_add_test(
mqt-qcec-test
MQT::QCEC
legacy/test_functionality.cpp
legacy/test_journal.cpp
legacy/test_compilationflow.cpp
legacy/test_general.cpp
legacy/test_simulation.cpp
test_dynamic_circuits.cpp
test_simple_circuit_identities.cpp
test_gate_cost_application_scheme.cpp
test_equality.cpp
test_zx.cpp
test_symbolic.cpp
test_partial_equivalence.cpp)
# collect all test files
file(GLOB_RECURSE TEST_FILES "*.cpp")

# add test executable
package_add_test(mqt-qcec-test MQT::QCEC ${TEST_FILES})

# link to MQT::CoreAlgorithms library for dynamic circuit tests
target_link_libraries(mqt-qcec-test PRIVATE MQT::CoreAlgorithms)
2 changes: 1 addition & 1 deletion test/legacy/test_compilationflow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

#include "Configuration.hpp"
#include "EquivalenceCheckingManager.hpp"
#include "QuantumComputation.hpp"
#include "checker/dd/applicationscheme/ApplicationScheme.hpp"
#include "checker/dd/applicationscheme/GateCostApplicationScheme.hpp"
#include "ir/QuantumComputation.hpp"

#include <algorithm>
#include <gtest/gtest.h>
Expand Down
2 changes: 1 addition & 1 deletion test/legacy/test_functionality.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

#include "Configuration.hpp"
#include "EquivalenceCheckingManager.hpp"
#include "QuantumComputation.hpp"
#include "checker/dd/applicationscheme/ApplicationScheme.hpp"
#include "checker/dd/applicationscheme/GateCostApplicationScheme.hpp"
#include "checker/dd/simulation/StateType.hpp"
#include "ir/QuantumComputation.hpp"

#include <gtest/gtest.h>
#include <iostream>
Expand Down
34 changes: 1 addition & 33 deletions test/legacy/test_general.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,52 +4,20 @@
//

#include "Configuration.hpp"
#include "Definitions.hpp"
#include "EquivalenceCheckingManager.hpp"
#include "EquivalenceCriterion.hpp"
#include "QuantumComputation.hpp"
#include "algorithms/BernsteinVazirani.hpp"
#include "checker/dd/applicationscheme/ApplicationScheme.hpp"
#include "ir/QuantumComputation.hpp"

#include <gtest/gtest.h>
#include <iostream>
#include <stdexcept>

class GeneralTest : public ::testing::Test {
protected:
qc::QuantumComputation qc1;
qc::QuantumComputation qc2;
};

TEST_F(GeneralTest, DynamicCircuit) {
auto s = qc::BitString(15U);
auto bv = qc::BernsteinVazirani(s);
auto dbv = qc::BernsteinVazirani(s, true);

auto config = ec::Configuration{};
EXPECT_THROW(ec::EquivalenceCheckingManager(bv, dbv, config),
std::runtime_error);

config.optimizations.transformDynamicCircuit = true;
config.optimizations.backpropagateOutputPermutation = true;

auto ecm = ec::EquivalenceCheckingManager(bv, dbv, config);

ecm.run();

EXPECT_TRUE(ecm.getResults().consideredEquivalent());

std::cout << ecm.getResults() << "\n";

auto ecm2 = ec::EquivalenceCheckingManager(dbv, dbv, config);

ecm2.run();

EXPECT_TRUE(ecm2.getResults().consideredEquivalent());

std::cout << ecm2.getResults() << "\n";
}

TEST_F(GeneralTest, RemoveDiagonalGatesBeforeMeasure) {
qc1.addQubitRegister(1U);
qc1.addClassicalRegister(1U);
Expand Down
2 changes: 1 addition & 1 deletion test/legacy/test_journal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
#include "Configuration.hpp"
#include "EquivalenceCheckingManager.hpp"
#include "EquivalenceCriterion.hpp"
#include "QuantumComputation.hpp"
#include "checker/dd/applicationscheme/ApplicationScheme.hpp"
#include "ir/QuantumComputation.hpp"

#include <algorithm>
#include <array>
Expand Down
2 changes: 1 addition & 1 deletion test/legacy/test_simulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

#include "Configuration.hpp"
#include "EquivalenceCheckingManager.hpp"
#include "QuantumComputation.hpp"
#include "checker/dd/simulation/StateType.hpp"
#include "ir/QuantumComputation.hpp"

#include <gtest/gtest.h>
#include <iostream>
Expand Down
Loading

0 comments on commit 1ae653b

Please sign in to comment.