quantumlib / OpenFermion

The electronic structure package for quantum computers.
Apache License 2.0
1.51k stars 372 forks source link

OpenFermion is not compatible with cirq 0.13 (currect version) #765

Closed cvmxn1 closed 2 years ago

cvmxn1 commented 2 years ago

The current version of OpenFermion is not compatible with cirq v0.13. When attempting to run the necessary checks prior to pushing , this error notified me that certain features of cirq had been completely deprecated, which forces tests to be interrupted during collection. Prior to this, the version of cirq that was used, was v0.10. This issue was fixed by downgrading to an older version, v0.12.

______________________________________________________________ ERROR collecting test session _______________________________________________________________
../../../miniforge3/envs/testenv_google/lib/python3.8/importlib/__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
<frozen importlib._bootstrap>:1014: in _gcd_import
    ???
<frozen importlib._bootstrap>:991: in _find_and_load
    ???
<frozen importlib._bootstrap>:961: in _find_and_load_unlocked
    ???
<frozen importlib._bootstrap>:219: in _call_with_frames_removed
    ???
<frozen importlib._bootstrap>:1014: in _gcd_import
    ???
<frozen importlib._bootstrap>:991: in _find_and_load
    ???
<frozen importlib._bootstrap>:975: in _find_and_load_unlocked
    ???
<frozen importlib._bootstrap>:671: in _load_unlocked
    ???
<frozen importlib._bootstrap_external>:848: in exec_module
    ???
<frozen importlib._bootstrap>:219: in _call_with_frames_removed
    ???
src/openfermion/__init__.py:41: in <module>
    from openfermion.hamiltonians import (
src/openfermion/hamiltonians/__init__.py:13: in <module>
    from .general_hubbard import (
src/openfermion/hamiltonians/general_hubbard.py:18: in <module>
    from openfermion.utils import (SpinPairs, Spin)
src/openfermion/utils/__init__.py:29: in <module>
    from .commutators import (
src/openfermion/utils/commutators.py:17: in <module>
    from openfermion.transforms.opconversions.term_reordering\
src/openfermion/transforms/__init__.py:13: in <module>
    from .opconversions import (
src/openfermion/transforms/opconversions/__init__.py:70: in <module>
    from .qubitoperator_to_paulisum import qubit_operator_to_pauli_sum
src/openfermion/transforms/opconversions/qubitoperator_to_paulisum.py:18: in <module>
    def _qubit_operator_term_to_pauli_string(term: dict, qubits: Sequence[cirq.Qid]
E   AttributeError: module 'cirq' has no attribute 'Qid'
================================================================= short test summary info ==================================================================
ERROR  - AttributeError: module 'cirq' has no attribute 'Qid'
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
===================================================================== 1 error in 3.57s =====================================================================
mpharrigan commented 2 years ago

hmm we test against cirq 0.13 and cirq.Qid was introduced a really long time ago.

I'll investigate

mpharrigan commented 2 years ago

I couldn't reproduce naively.

Can you paste your exact openfermion and cirq version

cvmxn1 commented 2 years ago

The version used when I ran into this incompatibility for openfermion and cirq version was 1.0.0 and 0.13.0 respectively. The reason for using such an outdated version of OF is because it is installed in editable mode, for method development.

mpharrigan commented 2 years ago

Ok, you need a more recent version of openfermion to use a recent version of Cirq. Since you've installed in editable mode it should just be a matter of git pull origin master in your openfermion directory. I recommend doing all development vs the master branch rather than vs the 1.0 release. You can always merge in the latest changes to your feature branch using git pull or git merge