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

Replaced custom ApplyAndAssuming0Target with AND from std #2123

Merged
merged 1 commit into from
Jan 24, 2025

Conversation

DmitryVasilevsky
Copy link
Contributor

We used to have custom implementation for AND before we added it to the standard library. Now that we have it in std, this PR removes custom ApplyAndAssuming0Target and replaces it with AND. This standard implementation is via PhaseCCX, and has the same T-count of 4, T-depth of 2, but uses fewer gates overall.

Previous custom implementation:
Screenshot 2025-01-23 124923

Implementation from the standard library:
Screenshot 2025-01-23 124952

This new implementation results in different sequence of gates in Shor's sample, which, in turn, changes its behavior on the specific test we have for it. As randomness is removed from tests, that scenario results in guessing factorization, which isn't great. So this PR changes the default sample for Shor.

Copy link

Change in memory usage detected by benchmark.

Memory Report for 50b0e01

Test This Branch On Main Difference
compile core + standard lib 19562389 bytes 19587953 bytes -25564 bytes

@DmitryVasilevsky DmitryVasilevsky added this pull request to the merge queue Jan 24, 2025
Merged via the queue into main with commit 3ff4980 Jan 24, 2025
18 checks passed
@DmitryVasilevsky DmitryVasilevsky deleted the dmitryv/and branch January 24, 2025 09:56
idavis pushed a commit that referenced this pull request Feb 2, 2025
We used to have custom implementation for AND before we added it to the
standard library. Now that we have it in std, this PR removes custom
ApplyAndAssuming0Target and replaces it with AND. This standard
implementation is via PhaseCCX, and has the same T-count of 4, T-depth
of 2, but uses fewer gates overall.

Previous custom implementation:
![Screenshot 2025-01-23
124923](https://github.com/user-attachments/assets/4e480670-40f2-4d50-af4e-0d6ec2fb4797)

Implementation from the standard library:
![Screenshot 2025-01-23
124952](https://github.com/user-attachments/assets/d4c6a90d-95f1-4d17-a7ea-fb08d3dbacef)

This new implementation results in different sequence of gates in Shor's
sample, which, in turn, changes its behavior on the specific test we
have for it. As randomness is removed from tests, that scenario results
in guessing factorization, which isn't great. So this PR changes the
default sample for Shor.

Co-authored-by: Dmitry Vasilevsky <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants