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
Add tensordot
-based method to default.mixed
device
#3584
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3584 +/- ##
=======================================
Coverage 99.80% 99.80%
=======================================
Files 331 331
Lines 29078 29102 +24
=======================================
+ Hits 29021 29045 +24
Misses 57 57
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
Hey @dwierichs, I tested this with my original use case, and the results match. Also, this is much faster. For a 10 qubit circuit, Note that the results do not match exactly and differ in 15th or higher digit after the decimal for probability value. |
Hey @ankit27kh, that is great to hear! |
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.
It looks great, nice boost 💯 I have a couple of questions though
I performed some more comparisons, and the performance of |
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.
It looks all good, we just need one more test 👍
…ane into mixed-apply-tensordot
Some issues with pylint in the default mixed tests, after that it will be good to be merged 👍 @dwierichs |
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.
Thanks @dwierichs It looks good to me 💯
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.
Thanks!
* prototype and old tests extension * additional tests, comparing to matmul. cleanup * changelog * use tensordot for all ops with wires > 1 * autodiff compatibility * changelog: PR number * clean up * test readability * channel tests. skip stack for unitary channels * commented out tests before merge of #3612 * make matrix conjugation more readable * early_stack variant * blcak * lint tests, activate 3612-related tests * tests, black, cleanup * integration tests * black * torch stuff * lint stuff * solve import problem * lint --------- Co-authored-by: Romain Moyard <rmoyard@gmail.com>
Context:
The
_apply_channel
method ofdefault.mixed
devices usesqml.math.einsum
.For a device with
n
wires,einsum
does not support applying operations that act on alln
wires ifn>7
, see #3582.Description of the Change:
This PR adds an
_apply_channel_tensordot
method to the device, which does not have the above problem.In addition, preliminary benchmarks showed that the
tensordot
-based method is equally fast or faster for operations that act on more than a single qubit. Therefore, this PR not only switches the device to use the newtensordot
-based method if an operation acts on more than 7 qubits, but already for all multi-qubit operations.Benefits:
Support of many-qubit operations.
Performance upgrade for multi-qubit operations.
Possible Drawbacks:
A bit of code duplication/complexity. If this is a major drawback, it probably is best to even remove the old
einsum
-based method, as its performance gain compared to the new method is small even for single-qubit operations.Related GitHub Issues:
#3582