Fix mliap/pytorch.py and move model to the GPU device#4924
Merged
Conversation
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)
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? |
Contributor
|
I'm on vacation but will look end of the month. Sorry for the delay
…On Sat, Mar 21, 2026, 9:52 AM Axel Kohlmeyer ***@***.***> wrote:
*akohlmey* left a comment (lammps/lammps#4924)
<#4924 (comment)>
@bathmatt <https://github.com/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?
—
Reply to this email directly, view it on GitHub
<#4924?email_source=notifications&email_token=ADR4GIBVY4DJAQPCZSOL7WD4R23FNA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTIMJQGM3DAOBVG4YKM4TFMFZW63VHNVSW45DJN5XKKZLWMVXHJLDGN5XXIZLSL5RWY2LDNM#issuecomment-4103608570>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADR4GIBM7VTBEPMCN7WAFJ34R23FNAVCNFSM6AAAAACWZPTMAKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHM2DCMBTGYYDQNJXGA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
stanmoore1
self-requested a review
March 30, 2026 14:30
stanmoore1
approved these changes
Mar 30, 2026
stanmoore1
left a comment
Contributor
There was a problem hiding this comment.
It looks OK to me, but would be good for @bathmatt to review.
Contributor
|
THis looks like a good fix to prevent things on CPU. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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