In the code for jordan_wigner, InteractionOperators are handled with the helper function jordan_wigner_interaction_op, rather than simply mapping to a FermionOperator first and then transforming with the existing code. This is supposedly for the sake of speed. However, I found that doing it this way on a Hubbard Hamiltonian is apparently around 10 times slower. Does anyone have an idea why? Was this actually tested for speed? Should we just ditch the helper function?
In [1]: from openfermion.hamiltonians import fermi_hubbard
In [2]: from openfermion.transforms import jordan_wigner, get_fermion_operator, get_interaction_operator
In [3]: hubbard_model = fermi_hubbard(4, 4, 1., 4., 2., 2.)
In [4]: iop = get_interaction_operator(hubbard_model)
In [5]: def jordan_wigner_iop(iop):
...: ferm_op = get_fermion_operator(iop)
...: qubit_op = jordan_wigner(ferm_op)
...: return qubit_op
...:
In [6]: %timeit -n 3 -r 7 qubit_op_1 = jordan_wigner_iop(iop)
250 ms ± 5.32 ms per loop (mean ± std. dev. of 7 runs, 3 loops each)
In [7]: %timeit -n 3 -r 7 qubit_op_2 = jordan_wigner(iop)
2.33 s ± 96.4 ms per loop (mean ± std. dev. of 7 runs, 3 loops each)
In the code for
jordan_wigner, InteractionOperators are handled with the helper functionjordan_wigner_interaction_op, rather than simply mapping to a FermionOperator first and then transforming with the existing code. This is supposedly for the sake of speed. However, I found that doing it this way on a Hubbard Hamiltonian is apparently around 10 times slower. Does anyone have an idea why? Was this actually tested for speed? Should we just ditch the helper function?