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

Changes Required for DD Reordering to Minimize Runtime #407

Open
wants to merge 86 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
2990adb
setup of private repository with current status done
Jul 2, 2024
9e31e69
Merge branch 'cda-tum:main' into main
Claudiaaaaaaaaa Jul 2, 2024
082ccef
Control based reordering implemented
Jul 4, 2024
579f602
code cleanup and results printed to file
Jul 4, 2024
00a92a7
Merge branch 'cda-tum:main' into main
Claudiaaaaaaaaa Jul 5, 2024
cd8a2e4
wrote wrapper functions for parameter parsed testing.
Jul 6, 2024
105e3da
corrected time measurement, documented bug with u gate
Jul 8, 2024
fff70f2
added empty files to provide folder structure
Jul 8, 2024
9e2e8a4
collected test results
Jul 11, 2024
47e28dc
Merge branch 'cda-tum:main' into main
Claudiaaaaaaaaa Jul 11, 2024
3879de4
automized long time time measurements and results
Jul 15, 2024
79f9faa
Merge branch 'cda-tum:main' into main
Claudiaaaaaaaaa Jul 15, 2024
9b451a5
added short qasm for pattern recognition
Jul 19, 2024
17369f7
implemented structure for gate based reordering
Jul 22, 2024
cb874c8
Implemented final logic for gate/pattern based reordering
Jul 24, 2024
8aa5152
added test for executing gate/pattern based reordering
Jul 24, 2024
4ac11f4
Merge branch 'cda-tum:main' into main
Claudiaaaaaaaaa Jul 24, 2024
a6da074
removed all testing environment used for development, make it pull re…
Jul 24, 2024
ddf738e
Merge branch 'main' of https://github.com/Claudiaaaaaaaaa/mqt-ddsim
Jul 24, 2024
f4c6d99
🎨 pre-commit fixes
pre-commit-ci[bot] Jul 24, 2024
55ac1d1
Update src/DDMinimizer.cpp
Claudiaaaaaaaaa Jul 25, 2024
6f94a49
Update src/DDMinimizer.cpp
Claudiaaaaaaaaa Jul 25, 2024
d8b98af
Merge branch 'cda-tum:main' into main
Claudiaaaaaaaaa Aug 5, 2024
6f635a9
Final implementation
Claudiaaaaaaaaa Aug 13, 2024
2f4fba2
Merge branch 'main' into main
Claudiaaaaaaaaa Sep 7, 2024
246a957
🎨 pre-commit fixes
pre-commit-ci[bot] Sep 7, 2024
c3dd9c4
removed unneccesary include
Claudiaaaaaaaaa Sep 7, 2024
136007f
Update DDMinimizer.hpp
Claudiaaaaaaaaa Sep 7, 2024
62776b4
adjusted inclues for new folder structure in mqt-core
Claudiaaaaaaaaa Sep 7, 2024
a335cad
🎨 pre-commit fixes
pre-commit-ci[bot] Sep 7, 2024
6b2a77c
fix CodeQL suggestions
Claudiaaaaaaaaa Sep 7, 2024
2788f5b
Merge branch 'main' of https://github.com/Claudiaaaaaaaaa/mqt-ddsim
Claudiaaaaaaaaa Sep 16, 2024
00e9865
🎨 pre-commit fixes
pre-commit-ci[bot] Sep 16, 2024
e36dfaa
Merge branch 'cda-tum:main' into main
Claudiaaaaaaaaa Sep 16, 2024
f1f8535
Added all the comments
Claudiaaaaaaaaa Sep 16, 2024
e7ef6b4
🎨 pre-commit fixes
pre-commit-ci[bot] Sep 16, 2024
9e579e7
worked on issues from Lint
Sep 16, 2024
bc9fdad
Merge branch 'main' of https://github.com/Claudiaaaaaaaaa/mqt-ddsim
Sep 16, 2024
6afcacf
🎨 pre-commit fixes
pre-commit-ci[bot] Sep 16, 2024
81af6e4
resolved naming issues from Lint
Sep 16, 2024
0e503b4
🎨 pre-commit fixes
pre-commit-ci[bot] Sep 16, 2024
6f4a7b4
adjusted changes from .cpp
Sep 16, 2024
a56c4bf
Merge branch 'main' of https://github.com/Claudiaaaaaaaaa/mqt-ddsim
Sep 16, 2024
a4061cb
🎨 pre-commit fixes
pre-commit-ci[bot] Sep 16, 2024
2e3a23b
worked on lint
Sep 16, 2024
4ab0b1e
🎨 pre-commit fixes
pre-commit-ci[bot] Sep 16, 2024
e03373d
new try for linter
Sep 16, 2024
74d56c2
🎨 pre-commit fixes
pre-commit-ci[bot] Sep 16, 2024
1fe783a
corrected typo for lint
Sep 18, 2024
12bb49d
check test format
Sep 18, 2024
2eaa4c5
🎨 pre-commit fixes
pre-commit-ci[bot] Sep 18, 2024
e1a5b3e
check tests for current state
Sep 23, 2024
b46330d
🎨 pre-commit fixes
pre-commit-ci[bot] Sep 23, 2024
8bc9018
added cx test
Sep 23, 2024
53200c5
🎨 pre-commit fixes
pre-commit-ci[bot] Sep 23, 2024
4d13054
lint fixes
Sep 23, 2024
46aa58a
🎨 pre-commit fixes
pre-commit-ci[bot] Sep 23, 2024
dfc0c83
removed io include
Sep 23, 2024
775a70f
Merge branch 'main' of https://github.com/Claudiaaaaaaaaa/mqt-ddsim
Sep 23, 2024
e4a994f
🎨 pre-commit fixes
pre-commit-ci[bot] Sep 23, 2024
b74db3a
iostream
Sep 23, 2024
aabac4c
added more test cases
Sep 23, 2024
c31e7ec
🎨 pre-commit fixes
pre-commit-ci[bot] Sep 23, 2024
39f426c
changed test names for lint
Sep 23, 2024
3f8c523
added final test
Sep 23, 2024
08bbc4e
🎨 pre-commit fixes
pre-commit-ci[bot] Sep 23, 2024
6b74748
Merge branch 'cda-tum:main' into main
Claudiaaaaaaaaa Sep 23, 2024
08613ef
Merge branch 'cda-tum:main' into main
Claudiaaaaaaaaa Sep 26, 2024
39c22df
Update include/DDMinimizer.hpp
Claudiaaaaaaaaa Sep 26, 2024
1889992
🎨 pre-commit fixes
pre-commit-ci[bot] Sep 26, 2024
e396757
Included all review changes
Sep 26, 2024
17670d1
🎨 pre-commit fixes
pre-commit-ci[bot] Sep 26, 2024
77bc202
checked project guidelines -> ran clangd -> fixed issues
Sep 26, 2024
1bdbc4f
Merge branch 'cda-tum:main' into main
Claudiaaaaaaaaa Oct 14, 2024
3d79041
implemented changes of overseen comments
Oct 14, 2024
55364c4
🎨 pre-commit fixes
pre-commit-ci[bot] Oct 14, 2024
9d2c78b
added const for lint
Oct 14, 2024
e9db34f
small change in hopes to get token for coverage test
Oct 14, 2024
1551ada
Merge branch 'main' into main
burgholzer Oct 14, 2024
44f2ec0
✅ slightly more compact test circuit descriptions
burgholzer Oct 18, 2024
ee7eada
Merge branch 'main' into main
Claudiaaaaaaaaa Oct 28, 2024
9cab70f
implemented new suggested changes
Oct 28, 2024
375f8c4
🎨 pre-commit fixes
pre-commit-ci[bot] Oct 28, 2024
cf9bc98
ran clangd to pass pre commit check
Oct 28, 2024
893d3f9
Merge branch 'main' of https://github.com/Claudiaaaaaaaaa/mqt-ddsim
Oct 28, 2024
502d577
🎨 pre-commit fixes
pre-commit-ci[bot] Oct 28, 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
new try for linter
Claudiaaaaaaaaa committed Sep 16, 2024
commit e03373de9b3449c4e5c35a69dc4d327ba0681f43
87 changes: 41 additions & 46 deletions src/DDMinimizer.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "DDMinimizer.hpp"

#include "Definitions.hpp"
#include "circuit_optimizer/CircuitOptimizer.hpp"
#include "dd/DDDefinitions.hpp"
#include "ir/Permutation.hpp"
#include "ir/QuantumComputation.hpp"
#include "ir/operations/Control.hpp"
@@ -111,42 +111,42 @@ DDMinimizer::createGateBasedPermutation(qc::QuantumComputation& qc) {
auto cR = indices.find("cR");
auto xR = indices.find("xR");

const int PRIO_CR = DDMinimizer::getLadderPosition(cR->second, xC->second[0]);
const int PRIO_XL = DDMinimizer::getLadderPosition(xL->second, xC->second[0]);
const int STAIRS_CR = DDMinimizer::getStairCount(cR->second);
const int STAIRS_XL = DDMinimizer::getStairCount(xL->second);
const int PRIO_CL = DDMinimizer::getLadderPosition(cL->second, cX->second[0]);
const int PRIO_XR = DDMinimizer::getLadderPosition(xR->second, cX->second[0]);
const int STAIRS_CL = DDMinimizer::getStairCount(cL->second);
const int STAIRS_XR = DDMinimizer::getStairCount(xR->second);
const int prioCr = DDMinimizer::getLadderPosition(cR->second, xC->second[0]);
const int prioXl = DDMinimizer::getLadderPosition(xL->second, xC->second[0]);
const int stairsCr = DDMinimizer::getStairCount(cR->second);
const int stairsXl = DDMinimizer::getStairCount(xL->second);
const int prioCl = DDMinimizer::getLadderPosition(cL->second, cX->second[0]);
const int prioXr = DDMinimizer::getLadderPosition(xR->second, cX->second[0]);
const int stairsCl = DDMinimizer::getStairCount(cL->second);
const int stairsXr = DDMinimizer::getStairCount(xR->second);

// complete case checkins and adjust the layout
if ((cX->second[0] != -1) &&
(xC->second[0] == -1 || cX->second[0] < xC->second[0])) {

if ((PRIO_CR == 0 && DDMinimizer::isFull(cR->second)) ||
(PRIO_XL == 0 && DDMinimizer::isFull(xL->second))) {
} else if (PRIO_CR == 0 && STAIRS_CR > 0) {
if ((prioCr == 0 && DDMinimizer::isFull(cR->second)) ||
(prioXl == 0 && DDMinimizer::isFull(xL->second))) {
} else if (prioCr == 0 && stairsCr > 0) {
layout = DDMinimizer::reverseLayout(layout);
layout = DDMinimizer::rotateRight(layout, STAIRS_CR);
} else if (PRIO_XL == 0 && STAIRS_XL > 0) {
layout = DDMinimizer::rotateRight(layout, stairsCr);
} else if (prioXl == 0 && stairsXl > 0) {
layout = DDMinimizer::reverseLayout(layout);
layout = DDMinimizer::rotateLeft(layout, STAIRS_XL);
} else if (PRIO_CR > 0 || PRIO_XL > 0 || (PRIO_CR == 0 && PRIO_XL == 0)) {
layout = DDMinimizer::rotateLeft(layout, stairsXl);
} else if (prioCr > 0 || prioXl > 0 || (prioCr == 0 && prioXl == 0)) {
layout = DDMinimizer::reverseLayout(layout);
}
} else if ((xC->second[0] != -1) &&
(cX->second[0] == -1 || cX->second[0] > xC->second[0])) {

if ((PRIO_CL == 0 && DDMinimizer::isFull(cL->second)) ||
(PRIO_XR == 0 && DDMinimizer::isFull(xR->second))) {
if ((prioCl == 0 && DDMinimizer::isFull(cL->second)) ||
(prioXr == 0 && DDMinimizer::isFull(xR->second))) {
layout = DDMinimizer::reverseLayout(layout);
}

else if (PRIO_CL == 0 && STAIRS_CL > 0) {
layout = DDMinimizer::rotateLeft(layout, STAIRS_CL);
} else if (PRIO_XR == 0 && STAIRS_XR > 0) {
layout = DDMinimizer::rotateRight(layout, STAIRS_XR);
else if (prioCl == 0 && stairsCl > 0) {
layout = DDMinimizer::rotateLeft(layout, stairsCl);
} else if (prioXr == 0 && stairsXr > 0) {
layout = DDMinimizer::rotateRight(layout, stairsXr);
}
} else if ((DDMinimizer::isFull(xR->second) ||
DDMinimizer::isFull(cL->second))) {
@@ -189,51 +189,51 @@ DDMinimizer::makeDataStructure(qc::QuantumComputation& qc) {

// maps for the x-c and c-x ladder with pair of control qubit and target qubit
// to index
std::map<pair<Qubit, Qubit>, int> x_c_map;
std::map<pair<Qubit, Qubit>, int> cX_map;
std::map<pair<Qubit, Qubit>, int> xCMap;
std::map<pair<Qubit, Qubit>, int> cXMap;
for (size_t i = 0; i < max; i++) {
x_c_map.insert({{i + 1, i}, -1});
cX_map.insert({{i, i + 1}, -1});
xCMap.insert({{i + 1, i}, -1});
cXMap.insert({{i, i + 1}, -1});
}
// save complete maps of ladder and for max index evaluation
maps.insert({"xC", x_c_map});
maps.insert({"xC", xCMap});
indices.insert({"xC", std::vector<int>(1, 0)});
maps.insert({"cX", cX_map});
maps.insert({"cX", cXMap});
indices.insert({"cX", std::vector<int>(1, 0)});

// create c-l and x-l ladder
for (size_t i = 0; i < max; i++) {
std::map<pair<Qubit, Qubit>, int> xL_map;
std::map<pair<Qubit, Qubit>, int> cL_map;
std::map<pair<Qubit, Qubit>, int> xLMap;
std::map<pair<Qubit, Qubit>, int> cLMap;
// create the steps of the ladder
for (size_t j = 0; j < bits; j++) {
if (i < j) {
xL_map.insert({{j, i}, -1});
cL_map.insert({{i, j}, -1});
xLMap.insert({{j, i}, -1});
cLMap.insert({{i, j}, -1});
}
}
// save the steps in the maps
maps.insert({"xL_" + std::to_string(i), xL_map});
maps.insert({"cL_" + std::to_string(i), cL_map});
maps.insert({"xL_" + std::to_string(i), xLMap});
maps.insert({"cL_" + std::to_string(i), cLMap});
}
// save the complete ladder for max index evaluation
indices.insert({"xL", std::vector<int>(bits - 1, 0)});
indices.insert({"cL", std::vector<int>(bits - 1, 0)});

// create c-r and x-r ladder
for (size_t i = max; i > 0; i--) {
std::map<pair<Qubit, Qubit>, int> xR_map;
std::map<pair<Qubit, Qubit>, int> cR_map;
std::map<pair<Qubit, Qubit>, int> xRMap;
std::map<pair<Qubit, Qubit>, int> cRMap;
// create the steps of the ladder
for (size_t j = 0; j < bits; j++) {
if (i > j) {
xR_map.insert({{j, i}, -1});
cR_map.insert({{i, j}, -1});
xRMap.insert({{j, i}, -1});
cRMap.insert({{i, j}, -1});
}
}
// save the steps in the maps
maps.insert({"xR_" + std::to_string(i), xR_map});
maps.insert({"cR_" + std::to_string(i), cR_map});
maps.insert({"xR_" + std::to_string(i), xRMap});
maps.insert({"cR_" + std::to_string(i), cRMap});
}
// save the complete ladder for max index evaluation
indices.insert({"xR", std::vector<int>(bits - 1, 0)});
@@ -245,12 +245,7 @@ DDMinimizer::makeDataStructure(qc::QuantumComputation& qc) {
// Helper function to check if the vector of a ladder step is full, meaning each
// gate appeared in the circuit
bool DDMinimizer::isFull(const std::vector<int>& vec) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you give this function a more expressive name? Maybe something like isFullLadder?

for (const int value : vec) {
if (value == -1) {
return false;
}
}
return true;
return std::all_of(vec.begin(), vec.end(), [](int value) { return value != -1; });
}

// Helper function to get the number of complete stairs in a ladder
12 changes: 6 additions & 6 deletions test/test_reorder_without_reordering.cpp
Original file line number Diff line number Diff line change
@@ -14,26 +14,26 @@ TEST(ReorderWithoutReorderingTest, x_c) {
// TODO
}

TEST(ReorderWithoutReorderingTest, c_x) {
TEST(ReorderWithoutReorderingTest, cx) {
// TODO
}

TEST(ReorderWithoutReorderingTest, x_c_cl3) {
TEST(ReorderWithoutReorderingTest, xccl3) {
// TODO
}

TEST(ReorderWithoutReorderingTest, x_c_xr3) {
TEST(ReorderWithoutReorderingTest, xcxr3) {
// TODO
}

TEST(ReorderWithoutReorderingTest, c_x_cr3) {
TEST(ReorderWithoutReorderingTest, cxcr3) {
// TODO
}

TEST(ReorderWithoutReorderingTest, c_x_xl3) {
TEST(ReorderWithoutReorderingTest, cxxl3) {
// TODO
}

TEST(ReorderWithoutReorderingTest, no_pattern) {
TEST(ReorderWithoutReorderingTest, noPattern) {
// TODO
}