facebookresearch / esm

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

Keys 'trunk.structure_module.ipa.linear_q_points.linear.weight, trunk.structure_module.ipa.linear_q_points.linear.bias, trunk.structure_module.ipa.linear_kv_points.linear.weight, trunk.structure_module.ipa.linear_kv_points.linear.bias' are missing. #435

Closed nibtehaz closed 1 year ago

nibtehaz commented 1 year ago

Hi, thank you for making the ESMFold codes and weights publicly available.

Unfortunately, I can't load the model as it says some layer weights are missing

Bug description

When I load the pretrained model, some layer weights in trunk.structure_module.ipa are missing

Reproduction steps

import esm

model = esm.pretrained.esmfold_v1()

Expected behavior

The model should have been loaded without any errors

Logs Please paste the command line output:

RuntimeError: Keys 'trunk.structure_module.ipa.linear_q_points.linear.weight, trunk.structure_module.ipa.linear_q_points.linear.bias, 
trunk.structure_module.ipa.linear_kv_points.linear.weight, trunk.structure_module.ipa.linear_kv_points.linear.bias' are missing.
tomsercu commented 1 year ago

This is strange and indicates that something went wrong in installation. Could you have a conflicting or wrong version of OpenFold installed? Since the structure modules internal import directly from openfold, see https://github.com/facebookresearch/esm/blob/main/esm/esmfold/v1/trunk.py#L11

nibtehaz commented 1 year ago

Hi, actually I've found out the issue. I did have the right version of openfold, but for some weird network reasons the model download was somewhat faulty. I downloaded the model from a different network and everything works perfectly.

Apologies for the delay, and thank you so much for open-sourcing such inspiring works :)

tomsercu commented 1 year ago

Thank you and thanks for reporting back!

awer-A commented 6 months ago

@nibtehaz Hi,Could you please provide specific instructions on how to download this model?

martino27 commented 6 months ago

@nibtehaz Hi, I couldn't load the model. Following your words, I've tried to download openfold again.

First, I tried command pip install 'openfold @ git+https://github.com/aqlaboratory/openfold.git' But still has the runtime error.

Then, I uninstall it, and tried command pip install 'openfold @ git+https://github.com/aqlaboratory/openfold.git@4b41059694619831a7db195b7e0988' But still the same error.

Could you please provide the specific instructions on how to download the model from a different network?

nibtehaz commented 6 months ago

Hi @awer-A and @martino27 , apologies for the delay.

For my case the downloaded model file had some issues. It got resolved when I deleted the model file from the torch hub directory and downloaded it again.

I would suggest you to just load the state_dict file and manually check whether the layers raising the errors are there or not.

Regarding openfold version, I followed the version mentioned in the readme file of this repo

pip install "fair-esm[esmfold]"
# OpenFold and its remaining dependency
pip install 'dllogger @ git+https://github.com/NVIDIA/dllogger.git'
pip install 'openfold @ git+https://github.com/aqlaboratory/openfold.git@4b41059694619831a7db195b7e0988fc4ff3a307'

I hope this helps.

awer-A commented 6 months ago

@nibtehaz Now I have solved this problem. Thank you very much for your response

awer-A commented 6 months ago

@nibtehaz Hi, I couldn't load the model. Following your words, I've tried to download openfold again.

First, I tried command pip install 'openfold @ git+https://github.com/aqlaboratory/openfold.git' But still has the runtime error.

Then, I uninstall it, and tried command pip install 'openfold @ git+https://github.com/aqlaboratory/openfold.git@4b41059694619831a7db195b7e0988' But still the same error.

Could you please provide the specific instructions on how to download the model from a different network?

I used version 1.0.1 of OpenFold and it worked.

martino27 commented 6 months ago

@nibtehaz Sorry for the delay. I've solved the problem. Thank you for your help.

Tom0515Lt commented 6 months ago

I also have this issue, but pip install 'openfold @ git+https://github.com/aqlaboratory/openfold.git always fails. I downloaded it locally and then uploaded it.

× git clone --quiet https://github.com/aqlaboratory/openfold.git /tmp/pip-install-tg5fh56v/openfold_8895216bd78c449ba1df7efd9e46aecc did not run successfully. │ exit code: 128 ╰─> See above for output.

realfenston commented 3 months ago

Same issue and solved, thank you all, you saved my day.

lanna0504 commented 3 months ago

I also had the same issue and found that I had the wrong version of OpenFold installed. Because I installed OpenFold manually and the version was 2.0.0. But is seemed that the version should be 1.0.0. Thank you all!!