Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Approximate equivalence checking #443

Open
wants to merge 44 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
0a5651a
Added mqt-core as submodule
TeWas Aug 8, 2024
dde15d3
Update submodule to latest version
TeWas Aug 8, 2024
3541a8e
:sparkles: Approximate equivalence checking for construction checker
TeWas Aug 8, 2024
b3e5bf2
:sparkles: Approximate equivalence checking for alternating checker
TeWas Aug 8, 2024
b2d44a5
:art: Change threshold
TeWas Aug 12, 2024
797af78
:white_check_mark: Add test files
TeWas Aug 12, 2024
6e5e33d
:white_check_mark: Test circuits synthesized with BQSKit
TeWas Aug 12, 2024
b0731f7
:white_check_mark: Add tests
TeWas Aug 13, 2024
3179789
Merge remote-tracking branch 'upstream/main'
TeWas Aug 13, 2024
8e92156
Merge remote-tracking branch 'origin/main' into approximate-equivalen…
TeWas Aug 13, 2024
5e46334
:memo: Add comments
TeWas Aug 13, 2024
3c9f84f
:rotating_light: Fix warnings
TeWas Aug 14, 2024
824e439
:rotating_light: Fix warnings
TeWas Aug 14, 2024
313053a
:sparkles: Introduce HSF checker
TeWas Oct 4, 2024
847559f
Merge remote-tracking branch 'upstream/main'
TeWas Oct 4, 2024
46741c1
:twisted_rightwards_arrows: Merge CMakeLists changes
TeWas Oct 4, 2024
7ea9ff5
:rotating_light: Fix linking issues
TeWas Oct 4, 2024
e1ca1e2
:rotating_light: Fix warnings
TeWas Oct 4, 2024
30b4756
:rotating_light: Fix linter warnings: Include header directly
TeWas Oct 5, 2024
aa7fd5b
:art: Make input circuits const, keep measurements as they are skippe…
TeWas Oct 5, 2024
da1674a
:white_check_mark: Fix test
TeWas Oct 5, 2024
9052e16
:rotating_light: Remove inline keyword and move header
TeWas Oct 5, 2024
4596e86
:art: :test_tube: Add threshold check; make splitQubit class attribut…
TeWas Oct 7, 2024
4265cce
:rotating_light: Include header
TeWas Oct 7, 2024
2918b60
:children_crossing: Incorporate improved error messaging from ddsim
TeWas Oct 9, 2024
4d27272
:bug: Fix: Throw overflow error when circuit exceeds maximum number o…
TeWas Oct 9, 2024
7d2386a
:rotating_light: Fix linter warning
TeWas Oct 9, 2024
1e80d63
:memo: Add comments
TeWas Oct 9, 2024
5670559
:zap: :art: Move inversion of qc2 to constructor and flatten operations
TeWas Oct 11, 2024
6b9a709
:bug: Fix: Skip measure and barrier ops for inversion.
TeWas Oct 11, 2024
a95acb4
Merge remote-tracking branch 'upstream/main' into approximate-equival…
TeWas Oct 12, 2024
2dc38c4
Merge remote-tracking branch 'upstream/main' into approximate-equival…
TeWas Oct 23, 2024
afa1cbc
:sparkles: Expose approximate equivalence checking to Python
TeWas Oct 25, 2024
1cc7249
:art: Integrate HSF checker into equivalence checking flow
TeWas Oct 26, 2024
1c57b66
:rotating_light: Fix warnings
TeWas Oct 26, 2024
bfc2ba6
:rotating_light: :white_check_mark: Fix warnings & add HSF test in Py…
TeWas Oct 26, 2024
668589e
:bug: :white_check_mark: Fix integration of HSF into equivalence chec…
TeWas Oct 27, 2024
380d0aa
:memo: Update documentation
TeWas Oct 27, 2024
ccd62d8
:truck: Rename checker
TeWas Oct 27, 2024
9983e3e
:test_tube: Comment out failing test due to timeout issue with std::f…
TeWas Oct 27, 2024
b206f62
:white_check_mark: Restructure tests
TeWas Oct 27, 2024
abfa52c
:art: :recycle: :goal_net: Refactor HSF Checker Integration and Error…
TeWas Nov 10, 2024
1c1baf0
:rotating_light: Fix linter warnings
TeWas Nov 10, 2024
b92d53e
:memo: Update documentation for HSF checker in the approximate equiva…
TeWas Nov 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
🚨 Fix linking issues
  • Loading branch information
TeWas committed Oct 4, 2024
commit 7ea9ff5b7ad5fa6b64fb7a770c4b8ddd03abaa89
7 changes: 1 addition & 6 deletions include/checker/dd/HybridSchrodingerFeynmanChecker.hpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
#pragma once

#include "CircuitOptimizer.hpp"
#include "Definitions.hpp"
#include "QuantumComputation.hpp"
#include "dd/ComplexValue.hpp"
#include "dd/Package.hpp"
#include "dd/Package_fwd.hpp"
#include "ir/QuantumComputation.hpp"

#include <cstddef>
#include <map>
#include <memory>
#include <string>

namespace ec {
@@ -21,12 +19,9 @@
: qc1(&circ1), qc2(&circ2), nthreads(nThreads) {
// remove final measurements
if (qc1->getNqubits() != qc2->getNqubits()) {
throw std::invalid_argument(

Check warning on line 22 in include/checker/dd/HybridSchrodingerFeynmanChecker.hpp

GitHub Actions / 🇨‌ Lint / 🚨 Lint

include/checker/dd/HybridSchrodingerFeynmanChecker.hpp:22:18 [misc-include-cleaner]

no header providing "std::invalid_argument" is directly included
"The two circuits have a different number of qubits.");
}
qc::CircuitOptimizer::removeFinalMeasurements(*qc1);
qc::CircuitOptimizer::removeFinalMeasurements(*qc2);
qc2->invert();
}
std::map<std::string, std::size_t> check();

@@ -44,7 +39,7 @@

void approximateVerification(qc::Qubit splitQubit);

dd::ComplexValue simulateSlicing(std::unique_ptr<DDPackage>& sliceDD1,

Check warning on line 42 in include/checker/dd/HybridSchrodingerFeynmanChecker.hpp

GitHub Actions / 🇨‌ Lint / 🚨 Lint

include/checker/dd/HybridSchrodingerFeynmanChecker.hpp:42:41 [misc-include-cleaner]

no header providing "std::unique_ptr" is directly included
std::unique_ptr<DDPackage>& sliceDD2,
qc::Qubit splitQubit, std::size_t controls);

@@ -74,7 +69,7 @@
}

bool apply(std::unique_ptr<DDPackage>& sliceDD,
const std::unique_ptr<qc::Operation>& op);

Check warning on line 72 in include/checker/dd/HybridSchrodingerFeynmanChecker.hpp

GitHub Actions / 🇨‌ Lint / 🚨 Lint

include/checker/dd/HybridSchrodingerFeynmanChecker.hpp:72:27 [misc-include-cleaner]

no header providing "std::unique_ptr" is directly included
};
};

7 changes: 4 additions & 3 deletions src/checker/dd/HybridSchrodingerFeynmanChecker.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "checker/dd/HybridSchrodingerFeynmanChecker.hpp"

#include "Definitions.hpp"
#include "circuit_optimizer/CircuitOptimizer.hpp"
#include "dd/ComplexValue.hpp"
#include "dd/DDpackageConfig.hpp"
#include "dd/Operations.hpp"
@@ -11,21 +12,18 @@
#include <cmath>
#include <cstddef>
#include <cstdio>
#include <map>
#include <memory>
#include <mutex>
#include <stdexcept>
#include <string>
#include <taskflow/core/async.hpp>
#include <taskflow/core/executor.hpp>

template <class Config>
std::size_t ec::HybridSchrodingerFeynmanChecker<Config>::getNDecisions(
qc::Qubit splitQubit, qc::QuantumComputation& qc) {

Check warning on line 22 in src/checker/dd/HybridSchrodingerFeynmanChecker.cpp

GitHub Actions / 🇨‌ Lint / 🚨 Lint

src/checker/dd/HybridSchrodingerFeynmanChecker.cpp:22:31 [misc-include-cleaner]

no header providing "qc::QuantumComputation" is directly included
std::size_t ndecisions = 0;
// calculate number of decisions
for (const auto& op : qc) {
if (op->getType() == qc::Barrier) {

Check warning on line 26 in src/checker/dd/HybridSchrodingerFeynmanChecker.cpp

GitHub Actions / 🇨‌ Lint / 🚨 Lint

src/checker/dd/HybridSchrodingerFeynmanChecker.cpp:26:30 [misc-include-cleaner]

no header providing "qc::Barrier" is directly included
continue;
}
if (op->isStandardOperation()) {
@@ -56,7 +54,7 @@

template <class Config>
dd::ComplexValue ec::HybridSchrodingerFeynmanChecker<Config>::simulateSlicing(
std::unique_ptr<dd::Package<Config>>& sliceDD1,

Check warning on line 57 in src/checker/dd/HybridSchrodingerFeynmanChecker.cpp

GitHub Actions / 🇨‌ Lint / 🚨 Lint

src/checker/dd/HybridSchrodingerFeynmanChecker.cpp:57:10 [misc-include-cleaner]

no header providing "std::unique_ptr" is directly included
std::unique_ptr<dd::Package<Config>>& sliceDD2, unsigned int splitQubit,
size_t controls) {
Slice lower(sliceDD1, 0, splitQubit - 1, controls);
@@ -89,12 +87,12 @@
template <class Config>
bool ec::HybridSchrodingerFeynmanChecker<Config>::Slice::apply(
std::unique_ptr<dd::Package<Config>>& sliceDD,
const std::unique_ptr<qc::Operation>& op) {

Check warning on line 90 in src/checker/dd/HybridSchrodingerFeynmanChecker.cpp

GitHub Actions / 🇨‌ Lint / 🚨 Lint

src/checker/dd/HybridSchrodingerFeynmanChecker.cpp:90:16 [misc-include-cleaner]

no header providing "std::unique_ptr" is directly included
bool isSplitOp = false;
if (dynamic_cast<qc::StandardOperation*>(op.get()) !=

Check warning on line 92 in src/checker/dd/HybridSchrodingerFeynmanChecker.cpp

GitHub Actions / 🇨‌ Lint / 🚨 Lint

src/checker/dd/HybridSchrodingerFeynmanChecker.cpp:92:24 [misc-include-cleaner]

no header providing "qc::StandardOperation" is directly included
nullptr) { // TODO change control and target if wrong direction
qc::Targets opTargets{};
qc::Controls opControls{};

Check warning on line 95 in src/checker/dd/HybridSchrodingerFeynmanChecker.cpp

GitHub Actions / 🇨‌ Lint / 🚨 Lint

src/checker/dd/HybridSchrodingerFeynmanChecker.cpp:95:9 [misc-include-cleaner]

no header providing "qc::Controls" is directly included

// check targets
bool targetInSplit = false;
@@ -144,7 +142,7 @@
auto tmp = matrix;
auto project = control != (c.type == qc::Control::Type::Neg) ? 0 : 1;
auto projMatrix = project == 1
? sliceDD->makeGateDD(dd::MEAS_ZERO_MAT, c.qubit)

Check warning on line 145 in src/checker/dd/HybridSchrodingerFeynmanChecker.cpp

GitHub Actions / 🇨‌ Lint / 🚨 Lint

src/checker/dd/HybridSchrodingerFeynmanChecker.cpp:145:57 [misc-include-cleaner]

no header providing "dd::MEAS_ZERO_MAT" is directly included
: sliceDD->makeGateDD(dd::MEAS_ONE_MAT, c.qubit);
matrix = sliceDD->multiply(projMatrix, matrix);
sliceDD->incRef(matrix);
@@ -171,6 +169,9 @@
template <class Config>
std::map<std::string, std::size_t>
ec::HybridSchrodingerFeynmanChecker<Config>::check() {
qc::CircuitOptimizer::removeFinalMeasurements(*qc1);
qc::CircuitOptimizer::removeFinalMeasurements(*qc2);
this->qc2->invert();
auto nqubits = this->qc1->getNqubits();
auto splitQubit = static_cast<qc::Qubit>(nqubits / 2);
approximateVerification(splitQubit);
3 changes: 1 addition & 2 deletions test/test_equality.cpp
Original file line number Diff line number Diff line change
@@ -5,15 +5,14 @@

#include "EquivalenceCheckingManager.hpp"
#include "EquivalenceCriterion.hpp"
#include "QuantumComputation.hpp"
#include "checker/dd/applicationscheme/ApplicationScheme.hpp"
#include "dd/DDDefinitions.hpp"
#include "ir/QuantumComputation.hpp"
#include "ir/operations/Control.hpp"

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

class EqualityTest : public testing::Test {
Loading
Oops, something went wrong.