MLAIP - AttributeError: 'mliap_unified_couple_kokkos.MLIAPDataPy' object has no attribute 'forward_exchange'

Hi, I am trying to run MACE neural-network potential via the MLIAP library. My system is a simple box of Al atoms at 300K, here’s my code:

units         metal
atom_style    atomic
atom_modify   map yes
boundary      p p p
newton        on
variable inputfile string "uob/Al_wide_box.lmp"
variable outputfile1 string "lammps-output/Al_wide_minimize.data"
variable outputfile2 string "lammps-output/Al_wide_final.data"
variable modelfile string "models-uob/GPU_Models/BCC/mace01_64channel_stagetwo.model-mliap_lammps.pt"
read_data ${inputfile}
pair_style mliap unified ${modelfile} 0
pair_coeff * * Al
neighbor        1.0 bin
neigh_modify    every 1 delay 5 check yes
fix             nvt1 all nvt temp 300.0 300.0 1.0
timestep        0.001
thermo          1
run             1000
write_data      ${outputfile2}

At run 1000 I get the following error:

Traceback (most recent call last):
  File "mliap_unified_couple_kokkos.pyx", line 418, in mliap_unified_couple_kokkos.compute_forces_python_kokkos
  File "mliap_unified_couple_kokkos.pyx", line 400, in mliap_unified_couple_kokkos.MLIAPUnifiedInterfaceKokkos.compute_forces
  File "/home/michele/mambaforge/envs/benchmark-mace/lib/python3.12/site-packages/mace/calculators/lammps_mliap_mace.py", line 160, in compute_forces
    _, atom_energies, pair_forces = self.model(batch)
                                    ^^^^^^^^^^^^^^^^^
  File "/home/michele/mambaforge/envs/benchmark-mace/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/michele/mambaforge/envs/benchmark-mace/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl
    return forward_call(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/michele/mambaforge/envs/benchmark-mace/lib/python3.12/site-packages/mace/calculators/lammps_mliap_mace.py", line 84, in forward
    out = self.model(
          ^^^^^^^^^^^
  File "/home/michele/mambaforge/envs/benchmark-mace/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/michele/mambaforge/envs/benchmark-mace/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl
    return forward_call(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/michele/mambaforge/envs/benchmark-mace/lib/python3.12/site-packages/mace/modules/models.py", line 418, in forward
    node_feats, sc = interaction(
                     ^^^^^^^^^^^^
  File "/home/michele/mambaforge/envs/benchmark-mace/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/michele/mambaforge/envs/benchmark-mace/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl
    return forward_call(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/michele/mambaforge/envs/benchmark-mace/lib/python3.12/site-packages/mace/modules/blocks.py", line 545, in forward
    node_feats = self.handle_lammps(
                 ^^^^^^^^^^^^^^^^^^^
  File "/home/michele/mambaforge/envs/benchmark-mace/lib/python3.12/site-packages/mace/modules/blocks.py", line 355, in handle_lammps
    node_feats = LAMMPS_MP.apply(node_feats, lammps_class)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/michele/mambaforge/envs/benchmark-mace/lib/python3.12/site-packages/torch/autograd/function.py", line 575, in apply
    return super().apply(*args, **kwargs)  # type: ignore[misc]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/michele/mambaforge/envs/benchmark-mace/lib/python3.12/site-packages/mace/tools/utils.py", line 158, in forward
    data.forward_exchange(feats, out, ctx.vec_len)
    ^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'mliap_unified_couple_kokkos.MLIAPDataPy' object has no attribute 'forward_exchange'
ERROR: Running mliappy unified compute_forces failure. (src/KOKKOS/mliap_unified_kokkos.cpp:82)

And I really have no clue what’s going on. I could not find anyone else having the same problem and I cannot really determine if it’s a MLAIP issue or a MACE issue (in the latter case I am preventively sorry for spamming on this forum).

What is your LAMMPS version?

It’s not official release, I am building from GitHub - ACEsuit/lammps: Public development project of the LAMMPS MD software package, develop branch.

I asked the maintainers of that repo for help: they could help me for some things, but not this error in particular.

I cannot help you either. I am not involved in the development done in this repo and when the people maintaining it don’t know, then there is not much hope.

I can only note that that repository is substantially behind the develop branch in the upstream repository and that the mliap_unified_couple_kokkos.pyx has had some changes since. Just compare:

with

I am also wondering, why you are using the “develop” branch, which is just tracking upstream (you could just follow the official repo and develop) and not one of the “mace” specific branches.

I am also wondering, why you are using the “develop” branch, which is just tracking upstream (you could just follow the official repo and develop) and not one of the “mace” specific branches.

That’s a great question, and probably the reason why I am getting this error. I was 100% sure MACE documentation indicated to clone their develop branch, it turns out I had to clone LAMMPS official repo instead! The fact that MACE develop branch is so much behind is most probably the reason why I am getting the error. Thanks!

Please let me remind you that the MACE development is done outside of LAMMPS and it is not part of LAMMPS, so you are really looking for help in the wrong place.

Please let me remind you that the MACE development is done outside of LAMMPS and it is not part of LAMMPS, so you are really looking for help in the wrong place.

Might be, but at the end of the day here is where I found the missing piece of solution to my problem (now the ML-IAP interface works like a charm). I understand that it can get frustrating having to skim through dozen of off-topic posts (and I wouldn’t have posted, if I hadn’t spent an entire afternoon debugging, to no avail), but please try not to be too patronizing when people just thank you for you help.