lanl / hippynn

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

Possible fix to hippynn via mliap interface CPU failure #60

Open Montana opened 5 months ago

Montana commented 5 months ago

For reference:

# Assuming fij and atom_energy are tensors and data is an object with an eatoms attribute
if return_device == "cpu":
    # Convert tensors to numpy arrays if we're moving them to CPU
    fij = fij.cpu().numpy()  # Ensure fij is moved to CPU before converting to numpy array
    data.eatoms = atom_energy.cpu().numpy().astype(np.double)  # Move atom_energy to CPU, then convert
else:
    # Ensure eatoms is a tensor on the target device, and copy atom_energy to it
    # The .to() method ensures the tensor is moved to the specified device and converted to the desired dtype
    eatoms = atom_energy.to(device=return_device, dtype=torch.double)
    data.eatoms = eatoms  # Update data.eatoms with the new tensor

    # If you need to preserve the original eatoms tensor and only copy values from atom_energy, use the following:
    data.eatoms = torch.empty_like(atom_energy, device=return_device, dtype=torch.double)
    data.eatoms.copy_(atom_energy.to(device=return_device, dtype=torch.double))

I've also tried to run it without the kokkos package, you can adjust the command by simply omitting the options related to kokkos. Some of the options offered like -sf kk, -k on, and -pk kokkos are specific to enabling and configuring the kokkos package for parallel execution on various architectures.

If your original command line call to LAMMPS includes these options, such as:

lmp -sf kk -k on -pk kokkos

To run LAMMPS without Kokkos, you would remove -sf kk, -k on, and -pk kokkos options, leaving you with:

lmp