Skip to content

Commit

Permalink
🔥 Remove ToffoliTable from DD Package (#380)
Browse files Browse the repository at this point in the history
## Description

Fixes #339 

## 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.

Signed-off-by: Lukas Burgholzer <lukas.burgholzer@jku.at>
  • Loading branch information
burgholzer authored Jul 12, 2023
1 parent a6cc11b commit b1c49b9
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 156 deletions.
9 changes: 0 additions & 9 deletions include/dd/Operations.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,6 @@ qc::MatrixDD getStandardOperationDD(const qc::StandardOperation* op,
gm = dd::Hmat;
break;
case qc::X: {
qc::MatrixDD e{};
if (controls.size() > 1U) { // Toffoli
e = dd->toffoliTable.lookup(nqubits, controls, target);
if (e.p == nullptr) {
e = dd->makeGateDD(dd::Xmat, nqubits, controls, target, startQubit);
dd->toffoliTable.insert(nqubits, controls, target, e);
}
return e;
}
gm = dd::Xmat;
break;
}
Expand Down
14 changes: 0 additions & 14 deletions include/dd/Package.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include "dd/GateMatrixDefinitions.hpp"
#include "dd/Package_fwd.hpp"
#include "dd/StochasticNoiseOperationTable.hpp"
#include "dd/ToffoliTable.hpp"
#include "dd/UnaryComputeTable.hpp"
#include "dd/UniqueTable.hpp"
#include "operations/Control.hpp"
Expand Down Expand Up @@ -270,7 +269,6 @@ template <class Config> class Package {
matrixKronecker.clear();
matrixVectorMultiplication.clear();
matrixMatrixMultiplication.clear();
toffoliTable.clear();
clearIdentityTable();
stochasticNoiseOperationCache.clear();
densityAdd.clear();
Expand Down Expand Up @@ -1293,8 +1291,6 @@ template <class Config> class Package {
vectorKronecker.clear();
matrixKronecker.clear();

toffoliTable.clear();

clearIdentityTable();

stochasticNoiseOperationCache.clear();
Expand Down Expand Up @@ -2445,12 +2441,7 @@ template <class Config> class Package {
return ident3;
}

///
/// Toffoli gates
///
public:
ToffoliTable<mEdge> toffoliTable{};

///
/// Identity matrices
///
Expand Down Expand Up @@ -3691,9 +3682,6 @@ template <class Config> class Package {
<< sizeof(typename decltype(matrixKronecker)::Entry)
<< " bytes (aligned "
<< alignof(typename decltype(matrixKronecker)::Entry) << " bytes)"
<< "\n ToffoliTable::Entry size: "
<< sizeof(ToffoliTable<mEdge>::Entry) << " bytes (aligned "
<< alignof(ToffoliTable<mEdge>::Entry) << " bytes)"
<< "\n Package size: " << sizeof(Package) << " bytes (aligned "
<< alignof(Package) << " bytes)"
<< "\n"
Expand Down Expand Up @@ -3725,8 +3713,6 @@ template <class Config> class Package {
vectorKronecker.printStatistics();
std::cout << "[CT Matrix Kronecker] ";
matrixKronecker.printStatistics();
std::cout << "[Toffoli Table] ";
toffoliTable.printStatistics();
std::cout << "[Stochastic Noise Table] ";
stochasticNoiseOperationCache.printStatistics();
std::cout << "[CT Density Add] ";
Expand Down
103 changes: 0 additions & 103 deletions include/dd/ToffoliTable.hpp

This file was deleted.

30 changes: 0 additions & 30 deletions test/dd/test_package.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -435,36 +435,6 @@ TEST(DDPackageTest, TestConsistency) {
dd->debugnode(bellState.p);
}

TEST(DDPackageTest, ToffoliTable) {
auto dd = std::make_unique<dd::Package<>>(4);

// try to search for a toffoli in an empty table
auto toffoli = dd->toffoliTable.lookup(3, {0_nc, 1_pc}, 2);
EXPECT_EQ(toffoli.p, nullptr);
if (toffoli.p == nullptr) {
toffoli = dd->makeGateDD(dd::Xmat, 3, {0_nc, 1_pc}, 2);
dd->toffoliTable.insert(3, {0_nc, 1_pc}, 2, toffoli);
}

// try again with same toffoli
auto toffoliTableEntry = dd->toffoliTable.lookup(3, {0_nc, 1_pc}, 2);
EXPECT_NE(toffoliTableEntry.p, nullptr);
EXPECT_EQ(toffoli, toffoliTableEntry);

// try again with different controlled toffoli
toffoliTableEntry = dd->toffoliTable.lookup(3, {0_pc, 1_pc}, 2);
EXPECT_EQ(toffoliTableEntry.p, nullptr);

// try again with different qubit toffoli
toffoliTableEntry = dd->toffoliTable.lookup(4, {0_pc, 1_pc, 2_pc}, 3);
EXPECT_EQ(toffoliTableEntry.p, nullptr);

// clear the table
dd->toffoliTable.clear();
toffoliTableEntry = dd->toffoliTable.lookup(3, {0_nc, 1_pc}, 2);
EXPECT_EQ(toffoliTableEntry.p, nullptr);
}

TEST(DDPackageTest, Extend) {
auto dd = std::make_unique<dd::Package<>>(4);

Expand Down

1 comment on commit b1c49b9

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

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

Cpp-Linter Report ✔️

No problems need attention.

Have any feedback or feature suggestions? Share it here.

Please sign in to comment.