Open beavenah opened 2 months ago
@beavenah It seems like your network is doing something strange when trying to download the model.
The good news is that you can indeed download the model yourself and load it from a path using torch
, it would be something like the following:
import torch
espaloma_model = torch.load("/path/to/espaloma-latest.pt")
espaloma_model.eval()
I hope this works!
Thanks, @ijpulidos ! The suggestion seems to have worked (output below):
>>> import torch
>>> import espaloma as esp
>>> from openff.toolkit.topology import Molecule
>>> molecule = Molecule.from_smiles("CN1C=NC2=C1C(=O)N(C(=O)N2C)C")
>>> molecule_graph = esp.Graph(molecule)
/opt/homebrew/Caskroom/mambaforge/base/envs/espaloma/lib/python3.10/site-packages/dgl/heterograph.py:92: DGLWarning: Recommend creating graphs by `dgl.graph(data)` instead of `dgl.DGLGraph(data)`.
dgl_warning(
>>> espaloma_model = torch.load("/Users/abeaven/Downloads/espaloma-latest.pt")
>>> espaloma_model.eval()
Sequential(
(0): Sequential(
(f_in): Sequential(
(0): Linear(in_features=114, out_features=128, bias=True)
(1): Tanh()
)
(_sequential): _Sequential(
(d0): GN(
(gn): SAGEConv(
(feat_drop): Dropout(p=0.1, inplace=False)
(fc_self): Linear(in_features=128, out_features=512, bias=False)
(fc_neigh): Linear(in_features=128, out_features=512, bias=False)
)
)
(o2): Dropout(p=0.1, inplace=False)
(d3): GN(
(gn): SAGEConv(
(feat_drop): Dropout(p=0.1, inplace=False)
(fc_self): Linear(in_features=512, out_features=512, bias=False)
(fc_neigh): Linear(in_features=512, out_features=512, bias=False)
)
)
(o5): Dropout(p=0.1, inplace=False)
(d6): GN(
(gn): SAGEConv(
(feat_drop): Dropout(p=0.1, inplace=False)
(fc_self): Linear(in_features=512, out_features=512, bias=False)
(fc_neigh): Linear(in_features=512, out_features=512, bias=False)
)
)
(o8): Dropout(p=0.1, inplace=False)
)
)
(1): JanossyPooling(
(sequential_2): _Sequential(
(d0): Linear(in_features=1024, out_features=512, bias=True)
(o2): Dropout(p=0.1, inplace=False)
(d3): Linear(in_features=512, out_features=512, bias=True)
(o5): Dropout(p=0.1, inplace=False)
(d6): Linear(in_features=512, out_features=512, bias=True)
(o8): Dropout(p=0.1, inplace=False)
(d9): Linear(in_features=512, out_features=512, bias=True)
(o11): Dropout(p=0.1, inplace=False)
)
(f_out_2_to_log_coefficients): Linear(in_features=512, out_features=2, bias=True)
(sequential_3): _Sequential(
(d0): Linear(in_features=1536, out_features=512, bias=True)
(o2): Dropout(p=0.1, inplace=False)
(d3): Linear(in_features=512, out_features=512, bias=True)
(o5): Dropout(p=0.1, inplace=False)
(d6): Linear(in_features=512, out_features=512, bias=True)
(o8): Dropout(p=0.1, inplace=False)
(d9): Linear(in_features=512, out_features=512, bias=True)
(o11): Dropout(p=0.1, inplace=False)
)
(f_out_3_to_log_coefficients): Linear(in_features=512, out_features=2, bias=True)
(sequential_4): _Sequential(
(d0): Linear(in_features=2048, out_features=512, bias=True)
(o2): Dropout(p=0.1, inplace=False)
(d3): Linear(in_features=512, out_features=512, bias=True)
(o5): Dropout(p=0.1, inplace=False)
(d6): Linear(in_features=512, out_features=512, bias=True)
(o8): Dropout(p=0.1, inplace=False)
(d9): Linear(in_features=512, out_features=512, bias=True)
(o11): Dropout(p=0.1, inplace=False)
)
(f_out_4_to_k): Linear(in_features=512, out_features=6, bias=True)
(sequential_1): _Sequential(
(d0): Linear(in_features=512, out_features=512, bias=True)
(o2): Dropout(p=0.1, inplace=False)
(d3): Linear(in_features=512, out_features=512, bias=True)
(o5): Dropout(p=0.1, inplace=False)
(d6): Linear(in_features=512, out_features=512, bias=True)
(o8): Dropout(p=0.1, inplace=False)
(d9): Linear(in_features=512, out_features=512, bias=True)
(o11): Dropout(p=0.1, inplace=False)
)
(f_out_1_to_s): Linear(in_features=512, out_features=1, bias=True)
(f_out_1_to_e): Linear(in_features=512, out_features=1, bias=True)
)
(2): JanossyPoolingWithSmirnoffImproper(
(sequential_n4_improper): _Sequential(
(d0): Linear(in_features=2048, out_features=512, bias=True)
(o2): Dropout(p=0.1, inplace=False)
(d3): Linear(in_features=512, out_features=512, bias=True)
(o5): Dropout(p=0.1, inplace=False)
(d6): Linear(in_features=512, out_features=512, bias=True)
(o8): Dropout(p=0.1, inplace=False)
(d9): Linear(in_features=512, out_features=512, bias=True)
(o11): Dropout(p=0.1, inplace=False)
)
(f_out_n4_improper_to_k): Linear(in_features=512, out_features=2, bias=True)
)
(3): ExpCoefficients()
(4): ChargeEquilibrium()
(5): LinearMixtureToOriginal()
)
>>> espaloma_model(molecule_graph.heterograph)
Graph(num_nodes={'g': 1, 'n1': 24, 'n2': 50, 'n3': 86, 'n4': 108, 'n4_improper': 48, 'nonbonded': 324, 'onefour': 92},
num_edges={('g', 'g_has_n1', 'n1'): 24, ('g', 'g_has_n2', 'n2'): 50, ('g', 'g_has_n3', 'n3'): 86, ('g', 'g_has_n4', 'n4'): 108, ('g', 'g_has_n4_improper', 'n4_improper'): 48, ('g', 'g_has_nonbonded', 'nonbonded'): 324, ('g', 'g_has_onefour', 'onefour'): 92, ('n1', 'n1_as_0_in_n2', 'n2'): 50, ('n1', 'n1_as_0_in_n3', 'n3'): 86, ('n1', 'n1_as_0_in_n4', 'n4'): 108, ('n1', 'n1_as_0_in_n4_improper', 'n4_improper'): 48, ('n1', 'n1_as_0_in_nonbonded', 'nonbonded'): 324, ('n1', 'n1_as_0_in_onefour', 'onefour'): 92, ('n1', 'n1_as_1_in_n2', 'n2'): 50, ('n1', 'n1_as_1_in_n3', 'n3'): 86, ('n1', 'n1_as_1_in_n4', 'n4'): 108, ('n1', 'n1_as_1_in_n4_improper', 'n4_improper'): 48, ('n1', 'n1_as_1_in_nonbonded', 'nonbonded'): 324, ('n1', 'n1_as_1_in_onefour', 'onefour'): 92, ('n1', 'n1_as_2_in_n3', 'n3'): 86, ('n1', 'n1_as_2_in_n4', 'n4'): 108, ('n1', 'n1_as_2_in_n4_improper', 'n4_improper'): 48, ('n1', 'n1_as_3_in_n4', 'n4'): 108, ('n1', 'n1_as_3_in_n4_improper', 'n4_improper'): 48, ('n1', 'n1_in_g', 'g'): 24, ('n1', 'n1_neighbors_n1', 'n1'): 50, ('n2', 'n2_as_0_in_n3', 'n3'): 86, ('n2', 'n2_as_0_in_n4', 'n4'): 108, ('n2', 'n2_as_1_in_n3', 'n3'): 86, ('n2', 'n2_as_1_in_n4', 'n4'): 108, ('n2', 'n2_as_2_in_n4', 'n4'): 108, ('n2', 'n2_has_0_n1', 'n1'): 50, ('n2', 'n2_has_1_n1', 'n1'): 50, ('n2', 'n2_in_g', 'g'): 50, ('n3', 'n3_as_0_in_n4', 'n4'): 108, ('n3', 'n3_as_1_in_n4', 'n4'): 108, ('n3', 'n3_has_0_n1', 'n1'): 86, ('n3', 'n3_has_0_n2', 'n2'): 86, ('n3', 'n3_has_1_n1', 'n1'): 86, ('n3', 'n3_has_1_n2', 'n2'): 86, ('n3', 'n3_has_2_n1', 'n1'): 86, ('n3', 'n3_in_g', 'g'): 86, ('n4', 'n4_has_0_n1', 'n1'): 108, ('n4', 'n4_has_0_n2', 'n2'): 108, ('n4', 'n4_has_0_n3', 'n3'): 108, ('n4', 'n4_has_1_n1', 'n1'): 108, ('n4', 'n4_has_1_n2', 'n2'): 108, ('n4', 'n4_has_1_n3', 'n3'): 108, ('n4', 'n4_has_2_n1', 'n1'): 108, ('n4', 'n4_has_2_n2', 'n2'): 108, ('n4', 'n4_has_3_n1', 'n1'): 108, ('n4', 'n4_in_g', 'g'): 108, ('n4_improper', 'n4_improper_has_0_n1', 'n1'): 48, ('n4_improper', 'n4_improper_has_1_n1', 'n1'): 48, ('n4_improper', 'n4_improper_has_2_n1', 'n1'): 48, ('n4_improper', 'n4_improper_has_3_n1', 'n1'): 48, ('n4_improper', 'n4_improper_in_g', 'g'): 48, ('nonbonded', 'nonbonded_has_0_n1', 'n1'): 324, ('nonbonded', 'nonbonded_has_1_n1', 'n1'): 324, ('nonbonded', 'nonbonded_in_g', 'g'): 324, ('onefour', 'onefour_has_0_n1', 'n1'): 92, ('onefour', 'onefour_has_1_n1', 'n1'): 92, ('onefour', 'onefour_in_g', 'g'): 92},
metagraph=[('g', 'n1', 'g_has_n1'), ('g', 'n2', 'g_has_n2'), ('g', 'n3', 'g_has_n3'), ('g', 'n4', 'g_has_n4'), ('g', 'n4_improper', 'g_has_n4_improper'), ('g', 'nonbonded', 'g_has_nonbonded'), ('g', 'onefour', 'g_has_onefour'), ('n1', 'n2', 'n1_as_0_in_n2'), ('n1', 'n2', 'n1_as_1_in_n2'), ('n1', 'n3', 'n1_as_0_in_n3'), ('n1', 'n3', 'n1_as_1_in_n3'), ('n1', 'n3', 'n1_as_2_in_n3'), ('n1', 'n4', 'n1_as_0_in_n4'), ('n1', 'n4', 'n1_as_1_in_n4'), ('n1', 'n4', 'n1_as_2_in_n4'), ('n1', 'n4', 'n1_as_3_in_n4'), ('n1', 'n4_improper', 'n1_as_0_in_n4_improper'), ('n1', 'n4_improper', 'n1_as_1_in_n4_improper'), ('n1', 'n4_improper', 'n1_as_2_in_n4_improper'), ('n1', 'n4_improper', 'n1_as_3_in_n4_improper'), ('n1', 'nonbonded', 'n1_as_0_in_nonbonded'), ('n1', 'nonbonded', 'n1_as_1_in_nonbonded'), ('n1', 'onefour', 'n1_as_0_in_onefour'), ('n1', 'onefour', 'n1_as_1_in_onefour'), ('n1', 'g', 'n1_in_g'), ('n1', 'n1', 'n1_neighbors_n1'), ('n2', 'n3', 'n2_as_0_in_n3'), ('n2', 'n3', 'n2_as_1_in_n3'), ('n2', 'n4', 'n2_as_0_in_n4'), ('n2', 'n4', 'n2_as_1_in_n4'), ('n2', 'n4', 'n2_as_2_in_n4'), ('n2', 'n1', 'n2_has_0_n1'), ('n2', 'n1', 'n2_has_1_n1'), ('n2', 'g', 'n2_in_g'), ('n3', 'n4', 'n3_as_0_in_n4'), ('n3', 'n4', 'n3_as_1_in_n4'), ('n3', 'n1', 'n3_has_0_n1'), ('n3', 'n1', 'n3_has_1_n1'), ('n3', 'n1', 'n3_has_2_n1'), ('n3', 'n2', 'n3_has_0_n2'), ('n3', 'n2', 'n3_has_1_n2'), ('n3', 'g', 'n3_in_g'), ('n4', 'n1', 'n4_has_0_n1'), ('n4', 'n1', 'n4_has_1_n1'), ('n4', 'n1', 'n4_has_2_n1'), ('n4', 'n1', 'n4_has_3_n1'), ('n4', 'n2', 'n4_has_0_n2'), ('n4', 'n2', 'n4_has_1_n2'), ('n4', 'n2', 'n4_has_2_n2'), ('n4', 'n3', 'n4_has_0_n3'), ('n4', 'n3', 'n4_has_1_n3'), ('n4', 'g', 'n4_in_g'), ('n4_improper', 'n1', 'n4_improper_has_0_n1'), ('n4_improper', 'n1', 'n4_improper_has_1_n1'), ('n4_improper', 'n1', 'n4_improper_has_2_n1'), ('n4_improper', 'n1', 'n4_improper_has_3_n1'), ('n4_improper', 'g', 'n4_improper_in_g'), ('nonbonded', 'n1', 'nonbonded_has_0_n1'), ('nonbonded', 'n1', 'nonbonded_has_1_n1'), ('nonbonded', 'g', 'nonbonded_in_g'), ('onefour', 'n1', 'onefour_has_0_n1'), ('onefour', 'n1', 'onefour_has_1_n1'), ('onefour', 'g', 'onefour_in_g')])
>>> openmm_system = esp.graphs.deploy.openmm_system_from_graph(molecule_graph)
>>> print(openmm_system)
<openmm.openmm.System; proxy of <Swig Object of type 'OpenMM::System *' at 0x1d7fbe160> >
I have one more question -- let me know if I should open a new issue... Seems basic, but I haven't been able to get it to work out. I want to write the force field information in GROMACS format, which I figure should be done via Interchange.
>>> import torch
>>> import espaloma as esp
>>> from openff.toolkit import Molecule, Topology, ForceField
>>> from openff.interchange import Interchange
>>> molecule = Molecule.from_smiles("CN1C=NC2=C1C(=O)N(C(=O)N2C)C")
>>> topology = Topology.from_molecules([molecule])
>>> molecule_graph = esp.Graph(molecule)
>>> espaloma_model = torch.load("/Users/abeaven/Downloads/espaloma-latest.pt")
>>> espaloma_model.eval()
>>> espaloma_model(molecule_graph.heterograph)
>>> openmm_system = esp.graphs.deploy.openmm_system_from_graph(molecule_graph)
**>>> Interchange.from_openmm()
>>> Interchange.to_gro(topology, ...)
>>> Interchange.to_top(topology, ...)**
I'm unsure of what I should do to correctly Interchange here. Thanks again for all of the help!
@mattwthompson might have the answer
Hey @beavenah,
It looks like you're on the right track, but
Interchange
object, once constructed, contains all of the information needed to write out GROMACS (or OpenMM, etc.) files, so all that's needed is pointing it to a file path. There's also .to_gromacs("filename")
which just calls out to the topology and coordinate file writers in one go.
Interchange.from_openmm
. I don't recall if or how recently people have tried to use Espaloma with it
Thank you, @mikemhenry and @mattwthompson! It appears that I have a functional script based on other GitHub discussions I've seen... But, I'll still plan to open a new discussion at the openFF GitHub. I'll just check a few more things on my end first.
Hi all,
I'm using a MacBook M3 and using mandatory Zscaler for security. I was able to install espaloma on my laptop, but when I get to the "esp.get_model("latest")" step, I get:
It was recommended that I try
pip3 install pip_system_certs --trusted-host pypi.python.org --trusted-host files.pythonhosted.org --trusted-host pypi.org --trusted-host github.com
in my conda base and espaloma conda, but I get the same SSL errors. Does anyone have a recommendation of what to do? Can I download theespaloma-latest.pt
myself and use it instead of trying to pull it from GitHub in the python script? If so, how would I change the script?Thanks again!