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

Merged
merged 23 commits into from
Feb 3, 2025
Merged

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

Also closes #127

@codecov-commenter
Copy link

codecov-commenter commented Dec 6, 2024

Codecov Report

Attention: Patch coverage is 86.36364% with 3 lines in your changes missing coverage. Please review.

Project coverage is 64.90%. Comparing base (339c5af) to head (4e0226b).

Files with missing lines Patch % Lines
mlptrain/configurations/calculate.py 50.00% 2 Missing ⚠️
mlptrain/configurations/configuration_set.py 94.44% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #121      +/-   ##
==========================================
- Coverage   64.99%   64.90%   -0.09%     
==========================================
  Files          37       37              
  Lines        4268     4280      +12     
==========================================
+ Hits         2774     2778       +4     
- Misses       1494     1502       +8     
Flag Coverage Δ
python-3.9 60.95% <86.36%> (-0.08%) ⬇️
python-3.9-ace 60.95% <86.36%> (-0.08%) ⬇️
python-3.9-mace 64.71% <86.36%> (-0.09%) ⬇️

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)$

This comment was marked as resolved.

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

This comment was marked as resolved.

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


@work_in_tmp_dir()
def test_configurations_load_with_energies_forces_diff_sizes(

This comment was marked as resolved.

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():

This comment was marked as resolved.

@juraskov juraskov changed the title WIP: Update autode to 1.3.3 Update autode to 1.3.3 Jan 28, 2025
@danielhollas
Copy link
Contributor

The next investigation step here, ideally before merging, would be to try to minimize the water_al.npz test file, i.e. using an older mlptrain version, with autode==1.1 and older numpy < 1.26, hopefully taking only a few configurations (or only one? We saw the error got triggered for the first config) should suffice to trigger the problem.

juraskov and others added 2 commits February 3, 2025 16:05
Co-authored-by: Daniel Hollas <danekhollas@gmail.com>
juraskov and others added 2 commits February 3, 2025 17:14
Co-authored-by: Daniel Hollas <danekhollas@gmail.com>
juraskov and others added 2 commits February 3, 2025 16:28
Co-authored-by: Daniel Hollas <danekhollas@gmail.com>
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.

Nice, what an epic debugging. I'll open an issue related to autode=1.3.4 and loading of old npz files.

@juraskov juraskov merged commit 5582e8e into duartegroup:main Feb 3, 2025
4 checks passed
@juraskov juraskov deleted the autode-update-latest branch February 3, 2025 16:52
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.

Error when reading npz files created before plumed implementation
4 participants