Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update autode to 1.3.3 #121

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

juraskov
Copy link
Member

@juraskov juraskov commented Dec 6, 2024

Preliminary update to autode v1.3.3. Update to the latest version will continue once I figure out the source of npz loading issue which started to occur in v1.3.4

@codecov-commenter
Copy link

codecov-commenter commented Dec 6, 2024

Codecov Report

Attention: Patch coverage is 45.45455% with 12 lines in your changes missing coverage. Please review.

Project coverage is 64.69%. Comparing base (b99faae) to head (7dcd999).

Files with missing lines Patch % Lines
mlptrain/configurations/configuration_set.py 44.44% 10 Missing ⚠️
mlptrain/configurations/calculate.py 50.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #121      +/-   ##
==========================================
- Coverage   64.99%   64.69%   -0.30%     
==========================================
  Files          37       37              
  Lines        4268     4280      +12     
==========================================
- Hits         2774     2769       -5     
- Misses       1494     1511      +17     
Flag Coverage Δ
python-3.9 60.74% <45.45%> (-0.29%) ⬇️
python-3.9-ace 60.74% <45.45%> (-0.29%) ⬇️
python-3.9-mace 64.50% <45.45%> (-0.30%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@juraskov
Copy link
Member Author

juraskov commented Jan 24, 2025

Error observed when loading mg_aqua_mace_al.npz file (prepared with autode1.1.3) using autode1.4.4

>>> data = mlt.ConfigurationSet()
>>> data.load('mg_aqua_mace_al.npz')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/veronikajuraskova/SOFTWARE/mlp-train/mlptrain/configurations/configuration_set.py", line 493, in load
    self._load_npz(filename)
  File "/Users/veronikajuraskova/SOFTWARE/mlp-train/mlptrain/configurations/configuration_set.py", line 685, in _load_npz
    if data['F_true'].ndim > 0:
  File "/Users/veronikajuraskova/miniconda3/envs/mlptrain-gap/lib/python3.9/site-packages/numpy/lib/npyio.py", line 256, in __getitem__
    return format.read_array(bytes,
  File "/Users/veronikajuraskova/miniconda3/envs/mlptrain-gap/lib/python3.9/site-packages/numpy/lib/format.py", line 800, in read_array
    array = pickle.load(fp, **pickle_kwargs)
  File "/Users/veronikajuraskova/miniconda3/envs/mlptrain-gap/lib/python3.9/site-packages/autode/values.py", line 667, in __setstate__
    self.__dict__.update(state[-1])
TypeError: cannot convert dictionary update sequence element #0 to a sequence

@Hanwen1018
Copy link
Member

  1. allow training MACE with dipole
  2. update mace
  3. allow multi-head fine-tuning
  4. allow mace training on multi-GPU cores

@juraskov
Copy link
Member Author

Error observed with using autode v1.1.3 to 1.3.3, most probably data set specific:

import numpy as np
data_np = np.load('mg_aqua_mace_al.npz',allow_pickle=True)
data_np['F_true']
Traceback (most recent call last):
File "", line 1, in
File "/Users/veronikajuraskova/miniconda3/envs/mlptrain-gap-old/lib/python3.9/site-packages/numpy/core/arrayprint.py", line 1612, in _array_str_implementation
return array2string(a, max_line_width, precision, suppress_small, ' ', "")
File "/Users/veronikajuraskova/miniconda3/envs/mlptrain-gap-old/lib/python3.9/site-packages/numpy/core/arrayprint.py", line 736, in array2string
return _array2string(a, options, separator, prefix)
File "/Users/veronikajuraskova/miniconda3/envs/mlptrain-gap-old/lib/python3.9/site-packages/numpy/core/arrayprint.py", line 513, in wrapper
return f(self, *args, **kwargs)
File "/Users/veronikajuraskova/miniconda3/envs/mlptrain-gap-old/lib/python3.9/site-packages/numpy/core/arrayprint.py", line 546, in _array2string
lst = _formatArray(a, format_function, options['linewidth'],
File "/Users/veronikajuraskova/miniconda3/envs/mlptrain-gap-old/lib/python3.9/site-packages/numpy/core/arrayprint.py", line 889, in _formatArray
return recurser(index=(),
File "/Users/veronikajuraskova/miniconda3/envs/mlptrain-gap-old/lib/python3.9/site-packages/numpy/core/arrayprint.py", line 845, in recurser
word = recurser(index + (-i,), next_hanging_indent, next_width)
File "/Users/veronikajuraskova/miniconda3/envs/mlptrain-gap-old/lib/python3.9/site-packages/numpy/core/arrayprint.py", line 799, in recurser
return format_function(a[index])
File "/Users/veronikajuraskova/miniconda3/envs/mlptrain-gap-old/lib/python3.9/site-packages/numpy/core/arrayprint.py", line 395, in _object_format
return fmt.format(o)
File "/Users/veronikajuraskova/miniconda3/envs/mlptrain-gap-old/lib/python3.9/site-packages/autode/values.py", line 592, in repr
return f'Gradients({np.ndarray.str(self)} {self.units.name})'
AttributeError: 'Gradient' object has no attribute 'units'

@juraskov juraskov changed the title WIP: Update autode to 1.4.4 WIP: Update autode to 1.3.3 Jan 27, 2025
@juraskov juraskov marked this pull request as ready for review January 28, 2025 00:19
@juraskov juraskov requested review from danielhollas and Hanwen1018 and removed request for danielhollas January 28, 2025 00:20
Copy link
Contributor

@danielhollas danielhollas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, just some minor comments.

@@ -11,7 +11,7 @@ repos:
exclude: examples/WTMetaD_paper/r2/free_energy/wtmetad_ib/accumulated_bias/bias_after_iter_15.dat
- id: check-added-large-files
args: ['--maxkb=500', '--enforce-all']
exclude: tests/data/data.zip
exclude: (?x)^(tests/data/data.zip | tests/data/water_al.npz)$
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could still try to make this file smaller, i.e. by reading it and saving using the old mlptrain version and making sure we use old numpy as well? Worth a try.

if data['R_plumed'].ndim > 0:
config.plumed_coordinates = np.array(
data['R_plumed'][i], dtype=float
try:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a note that this is fixing an issue unrelated to autoDE, where the code could not load npz files that were created before the Plumed integration was merged. Might be nice to document this problem in an issue and link it to this PR.

@@ -137,6 +139,41 @@ def test_configurations_load_with_energies_forces():
)


@work_in_tmp_dir()
def test_configurations_load_with_energies_forces_diff_sizes(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great to have this test! Would be good to add a docstring to explain what we're testing here (loading configurations with different molecules)

for attr in ('energy', 'forces'):
for kind in ('predicted', 'true'):
assert np.allclose(
getattr(getattr(loaded_configs[0], attr), kind),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is clever but hard to read. I would trade the for loops for a bit of (straightforward) code repetition.

@@ -161,6 +198,19 @@ def test_configurations_load_xyz():
assert config.mult == 2


def test_configurations_load_numpy_compatibility():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here again having a docstring explaining why this test is here would be good.

@juraskov juraskov changed the title WIP: Update autode to 1.3.3 Update autode to 1.3.3 Jan 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants