-
Notifications
You must be signed in to change notification settings - Fork 34
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
⚡ Added native construction of two-target controlled-gate DDs #534
⚡ Added native construction of two-target controlled-gate DDs #534
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #534 +/- ##
=======================================
- Coverage 91.3% 91.2% -0.2%
=======================================
Files 130 130
Lines 13857 13711 -146
Branches 2153 2155 +2
=======================================
- Hits 12665 12512 -153
- Misses 1192 1199 +7
*This pull request uses carry forward flags. Click here to find out more.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall the changes here are looking good and it seems like this should be working.
The biggest thing that is missing is tests of the new functionality. That's also why the code coverage check is failing. Almost none of the new lines (part of the patch) are covered by tests.
This should be quickly resolved though once the existing workaround methods are removed.
I would propose to turn the existing workarounds for constructing controlled two-target DDs into tests for the new functionality. That way, the existing code is not lost and is useful for testing.
Co-authored-by: Lukas Burgholzer <burgholzer@me.com>
Co-authored-by: Lukas Burgholzer <burgholzer@me.com>
…ontrolled-gate-DDs
✅ improved code coverage by adding new edge cases and updated old ones
At the moment, the following progress has been made:
Apart from point 4 (which is on my TODO list), the only question left from my side is if we still intend to unify |
…ontrolled-gate-DDs' into native-two-target-controlled-gate-DDs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall this is looking really good already. Many Thanks 🎉
The Python failures should be fixed after #536 is in. Then you can just merge the main branch in or rebase your branch on main.
There still are some warnings left to be fixed and I also added some comments that would be good to address before this gets merged.
Most importantly, the main library code in Package.hpp
can be significantly reduced by moving the respective special purpose construction methods to the tests. This should slim down the library quite a bit.
As for your question on combining the two gate DD creation methods: I do not think that is necessary as part of this PR. Content-wise, this PR is great as it is and definitly enough to close the respective issue 👍🏼
test/dd/test_dd_functionality.cpp
Outdated
// TEST_F(DDFunctionality, twoTargetControlledGateDDEdgeCases) { | ||
// using namespace qc::literals; | ||
// auto newNQubits = 12U; | ||
// auto newDD = std::make_unique<dd::Package<>>(newNQubits); | ||
// auto gate = SWAP; | ||
// | ||
// qc::StandardOperation op, op_neg; | ||
// op = qc::StandardOperation(newNQubits, Controls{1, 5, 7, 11}, 3, 9, gate); | ||
// op_neg = qc::StandardOperation(newNQubits, Controls{1_nc, 5_nc, 7_nc, | ||
// 11_nc}, | ||
// 3, 9, gate); | ||
// | ||
// ASSERT_NO_THROW( | ||
// { e = newDD->multiply(getDD(&op, *newDD), getInverseDD(&op, *newDD)); | ||
// }); | ||
// newDD->incRef(e); | ||
// | ||
// ASSERT_NO_THROW({ | ||
// d = newDD->multiply(getDD(&op_neg, *newDD), getInverseDD(&op_neg, | ||
// *newDD)); | ||
// }); | ||
// newDD->incRef(d); | ||
// | ||
// // the DD of the identity needs to be reconstructed as well | ||
// ident = newDD->makeIdent(newNQubits); | ||
// | ||
// EXPECT_EQ(ident, e); | ||
// EXPECT_EQ(ident, d); | ||
// } |
Check notice
Code scanning / CodeQL
Commented-out code
I have just added all the requested changes. The code coverage failed but according to the error message, it seems that it might be a connection problem (I might be wrong still). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great. Many thanks for another nice contribution! 🎉
I'll just apply some finishing touches and then proceed to merge 🔀
Description
The purpose of this PR is to add the extra logic for two-target controlled-gate DDs mentioned in #334 (comment). The problem was that the current implementation of the
makeTwoQubitGateDD
only worked for non-controlled two-target gates. Additionally, what we also want to achieve with this PR is to get rid of all the extra methods using the previous workaround (i.e.https://github.com/cda-tum/dd_package/blob/7c9644a2a65742bb580e3e5fefeac075c9534351/include/dd/Package.hpp#L629-L810).At the moment the updated version of
makeTwoQubitGateDD
is passing the CI, but there are still some TODOs left:makeTwoQubitGateDD
Fixes #334
Checklist: