Skip to content

Fix mliap/pytorch.py and move model to the GPU device#4924

Merged
akohlmey merged 1 commit into
lammps:developfrom
canoalberto:develop
Mar 30, 2026
Merged

Fix mliap/pytorch.py and move model to the GPU device#4924
akohlmey merged 1 commit into
lammps:developfrom
canoalberto:develop

Conversation

@canoalberto

Copy link
Copy Markdown
Contributor

Summary

Fixes error of model living on the CPU side rather than GPU side, which triggered error:

RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cpu and cuda:0! (when checking argument for argument mat1 in method wrapper_CUDA_addmm)

reproducible using:

mpirun -np 1 lmp -k on g 1 -sf kk -pk kokkos newton on neigh half -in in.mliap.pytorch.Ta06A

Author(s)

Alberto Cano, Virginia Tech Advanced Research Computing

Licensing

By submitting this pull request, I agree, that my contribution will be included in LAMMPS and redistributed under either the GNU General Public License version 2 (GPL v2) or the GNU Lesser General Public License version 2.1 (LGPL v2.1).

Artificial Intelligence (AI) Tools Usage

By submitting this pull request, I confirm that I did NOT use any AI tools to generate
all or parts of the code and modifications in this pull request.

Backward Compatibility

No known issues.

Implementation Notes

Added an explicit instruction to move the model to the device when the GPU is in use.

Post Submission Checklist

  • The feature or features in this pull request is complete
  • Licensing information is complete
  • Corresponding author information is complete
  • The source code follows the LAMMPS formatting guidelines
  • Suitable new documentation files and/or updates to the existing docs are included
  • The added/updated documentation is integrated and tested with the documentation build system
  • The feature has been verified to work with the conventional build system
  • The feature has been verified to work with the CMake based build system

Fixing error of model living on the CPU side rather than GPU side, which triggered

RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cpu and cuda:0! (when checking argument for argument mat1 in method wrapper_CUDA_addmm)
@canoalberto
canoalberto requested a review from akohlmey as a code owner March 20, 2026 19:04
@akohlmey
akohlmey requested a review from athomps March 21, 2026 15:50
@akohlmey

Copy link
Copy Markdown
Member

@bathmatt I think you changed this chunk of code last. Can you please have a look and let us know if this is something we should merge?

@bathmatt

bathmatt commented Mar 21, 2026 via email

Copy link
Copy Markdown
Contributor

@akohlmey akohlmey removed this from the Feature Release 30 March 2026 milestone Mar 29, 2026
@stanmoore1
stanmoore1 self-requested a review March 30, 2026 14:30

@stanmoore1 stanmoore1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It looks OK to me, but would be good for @bathmatt to review.

@bathmatt

Copy link
Copy Markdown
Contributor

THis looks like a good fix to prevent things on CPU.

@akohlmey
akohlmey merged commit 8d4a4ba into lammps:develop Mar 30, 2026
14 checks passed
@github-project-automation github-project-automation Bot moved this from Ready for Review or Merge to Done in LAMMPS Pull Requests Mar 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Development

Successfully merging this pull request may close these issues.

4 participants