Implement PRODUCT decomposition#1542
Implement PRODUCT decomposition#1542christopherkang wants to merge 2 commits intoquantumlib:mainfrom
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
|
@NoureldinYosri can you take a look Ideally, we'd be adding new decompositions using the idiomatic qualtran style ( |
NoureldinYosri
left a comment
There was a problem hiding this comment.
@christopherkang thank you for your contribution. I see that you styled your code in the same way as the other bloqs in the file which is great ... however this file was written in the early days of Qualtran and now we have new ways for doing things. please use the examples I left to remodel your code
| num_toff = 2 * self.a_bitsize * self.b_bitsize - max(self.a_bitsize, self.b_bitsize) | ||
| return {Toffoli(): num_toff} | ||
|
|
||
| def decompose_from_registers( |
There was a problem hiding this comment.
please use the idiomatic way of defining the construction instead of the legacy way... the idiomatic way makes the construction more readable. you can use this as an example
Qualtran/qualtran/bloqs/arithmetic/comparison.py
Lines 988 to 1006 in 60037bc
| num_toff = 2 * bitsize * mbits - max(bitsize, mbits) | ||
| assert t_complexity(cbloq) == TComplexity(t=4 * num_toff) | ||
|
|
||
| def test_product_gates(): |
There was a problem hiding this comment.
we have methods that do most of the testing, you can use these as example
Qualtran/qualtran/bloqs/mod_arithmetic/mod_subtraction_test.py
Lines 209 to 248 in 60037bc
I have performed a quick implementation of the
PRODUCTfunction using the implementation suggested in https://arxiv.org/pdf/2007.07391 (page 69).This addresses issue #485.
Some notes:
ANDbloq. It is important to use theANDbloq because theAND.adjointnatively allows us to uncompute without additional Toffoli complexity (by using the strategies from Gidney)