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

Implement Bravyi-Kitaev for InteractionOperator #752 #753

Merged
merged 4 commits into from
Nov 1, 2021
Merged

Implement Bravyi-Kitaev for InteractionOperator #752 #753

merged 4 commits into from
Nov 1, 2021

Conversation

jamesquantum
Copy link
Contributor

@jamesquantum jamesquantum commented Oct 26, 2021

Fixes #752

Extends the implementation of the Bravyi-Kitaev method as described by Seeley, Richard, Love. 2012 (https://arxiv.org/pdf/1208.5986.pdf) to InteractionOperators. Table II of arXiv:1208.5986 [quant-ph] is implemented by introducing the seeley_richard_love (SRL) method which can also accept complex operators. This method is believed to reduce the overheads in simplification required when evaluating products of creation/annihilation operators as Pauli strings in the Bravyi-Kitaev qubit basis.

image

The previous approach to converting InteractionOperator to QubitOperator would be to:

  1. Convert to a FermionOperator (negligible)
  2. Use the bravyi_kitaev method
    In total this is between 1.2 - 2.2 times slower than using SRL.

image

For large molecules 20% is considerable runtime. When running on an HPC node, transforming trifluoroacetic acid (TFA, 70 qubits) using SRL saved 3.7 minutes.

The SRL approach will not work for general FermionOperator objects. To speedup these, convert to an InteractionOperator before running the transformation.

Here is simplified explanation of the speedup:

  • Consider the simpler case of a Jordan-Wigner transformation. Transforming an arbitrary one-body interaction term (eg. i = N, j = 3) requires taking the product of two fermion operators and writing it as a Pauli string:
    image
    Between any two operators, many trailing Z gates will lead to cancellations that are trivial when written in this form but must still be computed and evaluated by a general approach.

  • By applying each of the 5 cases arising from second-quantisation the Jordan-Wigner transformation can be written as a set of general Pauli string:
    image Reference: https://docs.microsoft.com/en-us/quantum/user-guide/libraries/chemistry/concepts/jordan-wigner

  • The simplification for Bravyi-Kitaev follows a similar logic, albeit more involved. For each of the 5 equations above, the RHS now evaluates to an expression that is determined by each of the 10 cases illustrated in Table II (p,q -> i, j) above and given here in Python as the SRL method.

This pull request also:

  • Applies consistency between _parity_set and _update_set definitions in arXiv:1208.5986 [quant-ph] (Note: needed to update fenwick_tree_test.py to handle minor change in parity set function imported from bravyi_kitaev.py):
    image image

  • Adds additional class to bravyi_kitaev_test.py to maintain full coverage over new code:
    Screenshot 2021-10-26 at 17 35 36

@google-cla google-cla bot added the cla: yes label Oct 26, 2021
@jamesquantum jamesquantum marked this pull request as ready for review October 26, 2021 20:49
@jamesquantum jamesquantum marked this pull request as draft October 27, 2021 08:12
@jamesquantum jamesquantum marked this pull request as ready for review October 27, 2021 15:42
@ncrubin
Copy link
Collaborator

ncrubin commented Oct 28, 2021

@jamesphysics this is an excellent optimization. Thank you! I'll ask @jjgoings or @obriente to take a look since I am currently OOO.

@ncrubin ncrubin requested a review from jjgoings October 28, 2021 16:49
@ncrubin
Copy link
Collaborator

ncrubin commented Oct 28, 2021

To be clear this is implementing the transform directly and leveraging hermiticity to avoid avoid having to do simplification steps that are built into the current code path...is that correct?

@jamesquantum
Copy link
Contributor Author

@ncrubin thanks for the feedback and yes that is brilliant way to explain it!

@jjgoings please reach out if I can help in any way

jjgoings
jjgoings previously approved these changes Oct 29, 2021
Copy link
Contributor

@jjgoings jjgoings left a comment

Choose a reason for hiding this comment

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

LGTM!

@google-cla
Copy link

google-cla bot commented Nov 1, 2021

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and then comment @googlebot I fixed it.. If the bot doesn't comment, it means it doesn't think anything has changed.

ℹ️ Googlers: Go here for more info.

@google-cla google-cla bot added cla: no and removed cla: yes labels Nov 1, 2021
@jjgoings
Copy link
Contributor

jjgoings commented Nov 1, 2021

@googlebot I fixed it.

@google-cla
Copy link

google-cla bot commented Nov 1, 2021

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@google-cla
Copy link

google-cla bot commented Nov 1, 2021

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

3 similar comments
@google-cla
Copy link

google-cla bot commented Nov 1, 2021

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@google-cla
Copy link

google-cla bot commented Nov 1, 2021

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@google-cla
Copy link

google-cla bot commented Nov 1, 2021

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@jamesquantum
Copy link
Contributor Author

@googlebot I consent.

@google-cla
Copy link

google-cla bot commented Nov 1, 2021

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@jjgoings
Copy link
Contributor

jjgoings commented Nov 1, 2021

@googlebot I consent.

@google-cla google-cla bot added cla: yes and removed cla: no labels Nov 1, 2021
Copy link
Contributor

@jjgoings jjgoings left a comment

Choose a reason for hiding this comment

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

LGTM

@jjgoings jjgoings merged commit c4173bd into quantumlib:master Nov 1, 2021
@jamesquantum jamesquantum deleted the bravyi-kitaev-interaction-operator branch November 2, 2021 10:04
@jamesquantum jamesquantum restored the bravyi-kitaev-interaction-operator branch November 2, 2021 10:04
@mpharrigan mpharrigan mentioned this pull request Dec 6, 2021
ncrubin pushed a commit to ncrubin/OpenFermion that referenced this pull request Jul 25, 2022
…umlib#753)

* Implement Bravyi-Kitaev for InteractionOperator quantumlib#752

* cleaning up test imports and improving readability of comments

* fixup for formatting and linting

* formatting and linting

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

Successfully merging this pull request may close these issues.

Implement Bravyi-Kitaev Transform for InteractionOperator
3 participants