lanl / hippynn

python library for atomistic machine learning
https://lanl.github.io/hippynn/
Other
59 stars 22 forks source link

Using hippynn via mliap interface on CPU causes it to fail #54

Open wusatosi opened 5 months ago

wusatosi commented 5 months ago

Using hippynn via mliap causes script to fail:

Setting up Verlet run ...
  Unit style    : metal
  Current step  : 0
  Time step     : 0.001
Traceback (most recent call last):
  File "mliap_unified_couple_kokkos.pyx", line 412, in mliap_unified_couple_kokkos.compute_forces_python_kokkos
  File "mliap_unified_couple_kokkos.pyx", line 394, in mliap_unified_couple_kokkos.MLIAPUnifiedInterfaceKokkos.compute_forces
  File "/home/bradwu/hippynn/hippynn/interfaces/lammps_interface/mliap_interface.py", line 86, in compute_forces
    data.eatoms = atom_energy.numpy().astype(np.double)
AttributeError: attribute 'eatoms' of 'mliap_unified_couple_kokkos.MLIAPDataPy' objects is not writable
ERROR: Running mliappy unified compute_forces failure. (src/KOKKOS/mliap_unified_kokkos.cpp:82)
Last command: run             10000

Which points to this if-else branch: https://github.com/lanl/hippynn/blob/f8ed7390beb8261c8eec75580c683f5121226b30/hippynn/interfaces/lammps_interface/mliap_interface.py#L84-L89

Known fixes (which we are unsure if is correct) is:

  1. Update line 86 to eatoms = atom_energy.numpy().astype(np.double)
  2. Remove the if return_device=='cpu' branch.
lubbersnick commented 5 months ago

Yes, I think there is an issue with using kokkos version with the CPU device. Does it work if you do not use the kokkos suffixes?

I think your suggested fix 1 prevents LAMMPS from having local atomic energy assignments. I think your suggested fix 2 works on kokkos, but breaks non-kokkos. Can you confirm?

I believe the a better fix would be to uniformize how the local energy is written back to the MLIAPData, similar to the update_pair_forces which works the same in Kokkos and non-kokkos.

wusatosi commented 5 months ago

Hi lubbersnick, thanks for replying to this issue and pointing out the effects of both suggestions.

Sorry we are only using hippynn to run the MLMD benchmark, and I don't really have a lot of understanding into testing this without kokkos. If you can provide more instruction on how to attempt to debug this I might be able to help out.

lubbersnick commented 5 months ago

I believe that you can do this by removing the command -sf kk -k on -pk kokkos options from the command line call to lmp to run lammps without kokkos.

lubbersnick commented 5 months ago

Hi @wusatosi , were the directions above helpful at all?

wusatosi commented 5 months ago

I believe that you can do this by removing the command -sf kk -k on -pk kokkos options from the command line call to lmp to run lammps without kokkos.

will attempt, sorry I didn't have to look at this yet