ACEsuit / mace

MACE - Fast and accurate machine learning interatomic potentials with higher order equivariant message passing.
Other
554 stars 205 forks source link

questions about mace documentation #347

Closed 1234zou closed 8 months ago

1234zou commented 8 months ago

Dear MACE developers,

Thank you for developing the wonderful MACE. I'm new to MACE and thus my questions may be naive. I've successfully installed MACE and running examples here. When I look into the OpenMM interface documentation, I encounter several problems:

(1) For mamba env create -f mace-openmm.yml, can you show an example about what is in the file mace-openmm.yml? Is it something like torch==2.0.1 torchvision==0.15.2 torchaudio==2.0.2?

(2) For pip install git+https://github.com/jharrymoore/openmm-ml.git@mace, I encounter the error

INFO: pip is looking at multiple versions of openmmml to determine which version is compatible with other requirements. This could take a while.
ERROR: Could not find a version that satisfies the requirement openmm>=7.5 (from openmmml) (from versions: 0.1, 0.2)
ERROR: No matching distribution found for openmm>=7.5

It seems this is a compatibility problem between openmm and opemm-ml.

(3) Can I install the master branch of openmm-ml and openmmtools? Or I have to install the branch in https://github.com/jharrymoore/?

Your kind help would be greatly appreciated.

jharrymoore commented 8 months ago

Could you try building the conda environment from this file? Then you should be able to run the pip install commands from the docs.

You need our forks of both openmmtools and openmm-torch to be compatible with MACE

1234zou commented 8 months ago

Thanks, @jharrymoore . It works with the file mace-openmm.yml. However, torchvision and torchaudio is not included in this .yml file. If I install them via pip install, pytorch-2.0.1 will be downloaded and installed. But pytorch-2.0.0 is already written in this .yml file. Would you please tell me how to install torchvision and torchaudio in such case?

By the way, there is a sklearn in the file openmmtools/openmm_torch/repex.py,

from sklearn.random_projection import sample_without_replacement

But I look into this file and find sample_without_replacement is not used at all. So this line is supposed to be deleted. Otherwise it will lead to errors when I run mace-md.

1234zou commented 8 months ago

There two ways of installing MACE from documentation or github README, the first is

mamba env create -f mace-openmm.yml
pip install git+https://github.com/ACEsuit/mace.git

which does not require torchvision or torchaudio.

The second is

pip install torch==2.0.1 torchvision==0.15.2 torchaudio==2.0.2 --index-url https://download.pytorch.org/whl/cu118
pip install mace-torch

which requires torchvision and torchaudio.

Currently I choose the 1st way to install MACE. It leads to python=3.10.12, pytorch=2.0.0.post304. But when I run the mace-md using

mace-md -f ejm_31.sdf --ml_mol ejm_31.sdf --model_path MACE-OFF23_small.model --output_dir md_test --nl torch --steps 1000 --minimiser ase --dtype float64 --remove_cmm --unwrap

The error is

Traceback (most recent call last):
  File "/public/home/jxzou/software/anaconda3/envs/mace-openmm/bin/mace-md", line 8, in <module>
    sys.exit(main())
  File "/public/home/jxzou/software/anaconda3/envs/mace-openmm/lib/python3.10/site-packages/openmmtools/scripts/mace_md.py", line 245, in main
    system = PureSystem(
  File "/public/home/jxzou/software/anaconda3/envs/mace-openmm/lib/python3.10/site-packages/openmmtools/openmm_torch/hybrid_md.py", line 953, in __init__
    self.create_system(ml_mol=ml_mol, model_path=model_path)
  File "/public/home/jxzou/software/anaconda3/envs/mace-openmm/lib/python3.10/site-packages/openmmtools/openmm_torch/hybrid_md.py", line 970, in create_system
    tmp_model = torch.load(model_path, map_location="cpu")
  File "/public/home/jxzou/software/anaconda3/envs/mace-openmm/lib/python3.10/site-packages/torch/serialization.py", line 815, in load
    return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)
  File "/public/home/jxzou/software/anaconda3/envs/mace-openmm/lib/python3.10/site-packages/torch/serialization.py", line 1033, in _legacy_load
    magic_number = pickle_module.load(f, **pickle_load_args)
_pickle.UnpicklingError: invalid load key, '{'.

@jharrymoore Would you please take a look at this? Thanks!

jharrymoore commented 8 months ago

I don't believe we depend on torchvision or torch audio packages in mace or through mace-md. Do you need these in your environment for some other reason?

If you are planning on running MD with mace via openmm, you must build the environment via the yaml file, since this ensures the torch binaries from conda forge are compatible with openmm - this is not guaranteed when installing via pip.

On the unpicking error, this normally indicates your model did not download properly, could you inspect the downloaded file and check this looks like a model file (should be several MB in size)

1234zou commented 8 months ago

Thank you for your quick response. Yes, the torchvision or torchaudio is not needed. I was reading here and it says about torchvision and torchaudio. Later I use the file mace-openmm.yml and the installation goes well.

And yes, the file MACE-OFF23_small.model is incomplete. It was my internet connection problem. This file should be about 7MB.

By the way, it seems that in the documentation --nl torch_nl should be modified into --nl torch now.

Best, Jingxiang

jharrymoore commented 8 months ago

Great, can I confirm your installation works as expected now? Thank you for the comment on the docs - this command has been updated now