facebookresearch / esm

Evolutionary Scale Modeling (esm): Pretrained language models for proteins
MIT License
2.97k stars 586 forks source link

Einops 0.7.0 syntax error #626

Open ivanpmartell opened 8 months ago

ivanpmartell commented 8 months ago

Bug description When running esm-fold command from a new install, you will now get an error:

def einsum(tensor: Tensor, pattern: str, /) -> Tensor:
                                             ^
SyntaxError: invalid syntax

This is because einops has been updated to version 0.7.0 on conda-forge. We need to set einops to use 0.6.1 version to solve this issue.

Reproduction steps Install from scratch following the steps in the README. Run esm-fold command with any input. You will get the invalid syntax error.

Expected behavior No syntax error should happen during the loading model phase.

Logs

23/10/11 02:18:01 | INFO | root | Reading sequences from ...
23/10/11 02:18:01 | INFO | root | Loaded 1 sequences from ...
23/10/11 02:18:01 | INFO | root | Loading model
Traceback (most recent call last):
  File "/mnt/miniconda3/envs/esmfold/bin/esm-fold", line 8, in <module>
    sys.exit(main())
  File "/mnt/miniconda3/envs/esmfold/lib/python3.7/site-packages/esm/scripts/fold.py", line 202, in main
    run(args)
  File "/mnt/miniconda3/envs/esmfold/lib/python3.7/site-packages/esm/scripts/fold.py", line 143, in run
    model = esm.pretrained.esmfold_v1()
  File "/mnt/miniconda3/envs/esmfold/lib/python3.7/site-packages/esm/pretrained.py", line 419, in esmfold_v1
    import esm.esmfold.v1.pretrained
  File "/mnt/miniconda3/envs/esmfold/lib/python3.7/site-packages/esm/esmfold/v1/pretrained.py", line 10, in <module>
    from esm.esmfold.v1.esmfold import ESMFold
  File "/mnt/miniconda3/envs/esmfold/lib/python3.7/site-packages/esm/esmfold/v1/esmfold.py", line 17, in <module>
    from esm.esmfold.v1.misc import (
  File "/mnt/miniconda3/envs/esmfold/lib/python3.7/site-packages/esm/esmfold/v1/misc.py", line 10, in <module>
    from einops import rearrange, repeat
  File "/mnt/miniconda3/envs/esmfold/lib/python3.7/site-packages/einops/__init__.py", line 14, in <module>
    from .einops import rearrange, reduce, repeat, einsum, parse_shape, asnumpy
  File "/mnt/miniconda3/envs/esmfold/lib/python3.7/site-packages/einops/einops.py", line 807
    def einsum(tensor: Tensor, pattern: str, /) -> Tensor:
                                             ^
SyntaxError: invalid syntax

Additional context To fix, change the following in the environment.yml (if installing the conda environment through the file)

conda-forge::einops 

into the following

 conda-forge::einops=0.6.1

Or if you are not using the conda environment installation, revert to einops 0.6.1 after installation:

conda install -c conda-forge einops=0.6.1