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

Lookup dictionary for JW transformation of a FermionOperator #777

Merged
merged 1 commit into from
Jun 8, 2022

Conversation

alexfleury
Copy link
Contributor

Low-hanging fruit for a simple speedup when working on FermionOperator -> QubitOperator conversions. The problem has been raised in #587. This is not an optimal solution to this issue (neither parallelization nor cython), but there is a significant speed improvement when working with a FermionOperator with redundant terms.

Here is a simple script I used to test:

import time

import openfermion as of
from openfermionpyscf import run_pyscf

mol = of.chem.MolecularData(geometry=[["H", (0., 0., 0.)], ["H", (0., 0., 0.75)]], multiplicity=1, charge=0, basis="ccpvtz")
mol = run_pyscf(mol, verbose=True)
mol_op = mol.get_molecular_hamiltonian()

ferm_op = of.transforms.get_fermion_operator(mol_op)

start_time = time.time()
qubit_op = of.transforms.jordan_wigner(ferm_op)
final_time = time.time() - start_time

print(f"{final_time}s")

On my machine (Arch Linux 5.17.3-arch1-1, python 3.8.5):
Before = 10min27s
After = 5min14s

Other tests:
O2_6-31g_triplet | 81s | 42 s
NaCl_sto-3g_singlet | 2min34s | 1min20s

@ncrubin
Copy link
Collaborator

ncrubin commented Apr 26, 2022

@alexfleury , looks like we have a Cirq compatibility issue. I'll take a look and update what's going on here. I am fairly sure this a problem on our side and not yours.

@alexfleury
Copy link
Contributor Author

All good! I am following this thread to see if there are action items I would have to take care of.

@alexfleury alexfleury force-pushed the jw_simple_speedup branch from 1e26aaf to fbe4780 Compare May 6, 2022 02:23
@alexfleury alexfleury force-pushed the jw_simple_speedup branch from fbe4780 to faf221e Compare June 5, 2022 13:37
@ncrubin ncrubin requested a review from fdmalone June 7, 2022 20:49
Copy link
Collaborator

@fdmalone fdmalone left a comment

Choose a reason for hiding this comment

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

LGTM

@fdmalone fdmalone merged commit 8cb9f01 into quantumlib:master Jun 8, 2022
ncrubin pushed a commit to ncrubin/OpenFermion that referenced this pull request Jul 25, 2022
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