Hi — I ran into this while getting MACE running inside LAMMPS on a single-GPU workstation (RTX 5080, CUDA 13.2), and I think it's a quick one.
If you configure without MPI (-D BUILD_MPI=off), pair_mace.cpp fails to compile:
src/ML-MACE/pair_mace.cpp:301: error: 'MPI_COMM_TYPE_SHARED' was not declared in this scope
src/ML-MACE/pair_mace.cpp:301: error: 'MPI_INFO_NULL' was not declared in this scope
src/ML-MACE/pair_mace.cpp:301: error: 'MPI_Comm_split_type' was not declared in this scope
The cause is in PairMACE::coeff(): when CUDA is available it calls
MPI_Comm_split_type(world, MPI_COMM_TYPE_SHARED, 0, MPI_INFO_NULL, &local) to find the node-local rank and pick a GPU from it. Those symbols only exist in a real MPI build — LAMMPS's bundled MPI stubs (what BUILD_MPI=off gives you) don't define them, so the file won't compile and you can't build at all.
Why it matters: a lot of people run MACE on one workstation GPU rather than a cluster, and the natural way to build that is serial (no MPI). Right now that path is simply broken — you can't get a pair_style mace binary without dragging in MPI, even though on a single GPU there's nothing to split. It's a small papercut, but it blocks the most common "let me just try it on my GPU" setup.
I have a fix, and it's tiny: guard the rank-splitting block with #ifdef MPI_COMM_TYPE_SHARED and default the local rank to 0. With real MPI nothing changes (same node-local-rank logic); without MPI there's a single rank, so rank 0 / GPU 0 is the right answer anyway.
I tested it both ways: an only-the-source-differs compile (same flags) goes from failing to passing, and the resulting lmp runs a 1536-atom water NVE with conserved total energy on the GPU.
+ int localrank = 0;
+#ifdef MPI_COMM_TYPE_SHARED
MPI_Comm local;
MPI_Comm_split_type(world, MPI_COMM_TYPE_SHARED, 0, MPI_INFO_NULL, &local);
- int localrank;
MPI_Comm_rank(local, &localrank);
+#endif
device = c10::Device(torch::kCUDA, localrank);
Happy to send a PR (the change is on a branch already). Opening this first in case you'd rather approach it differently.
(Separate, smaller thing: building cleanly on CUDA 13 with a recent toolchain also needed a few build-flag workarounds — MKL_INCLUDE_DIR, FFT=KISS, and disabling the JPEG/PNG image deps. Glad to write those up as their own issue if useful.)
Hi — I ran into this while getting MACE running inside LAMMPS on a single-GPU workstation (RTX 5080, CUDA 13.2), and I think it's a quick one.
If you configure without MPI (
-D BUILD_MPI=off),pair_mace.cppfails to compile:The cause is in
PairMACE::coeff(): when CUDA is available it callsMPI_Comm_split_type(world, MPI_COMM_TYPE_SHARED, 0, MPI_INFO_NULL, &local)to find the node-local rank and pick a GPU from it. Those symbols only exist in a real MPI build — LAMMPS's bundled MPI stubs (whatBUILD_MPI=offgives you) don't define them, so the file won't compile and you can't build at all.Why it matters: a lot of people run MACE on one workstation GPU rather than a cluster, and the natural way to build that is serial (no MPI). Right now that path is simply broken — you can't get a
pair_style macebinary without dragging in MPI, even though on a single GPU there's nothing to split. It's a small papercut, but it blocks the most common "let me just try it on my GPU" setup.I have a fix, and it's tiny: guard the rank-splitting block with
#ifdef MPI_COMM_TYPE_SHAREDand default the local rank to 0. With real MPI nothing changes (same node-local-rank logic); without MPI there's a single rank, so rank 0 / GPU 0 is the right answer anyway.I tested it both ways: an only-the-source-differs compile (same flags) goes from failing to passing, and the resulting
lmpruns a 1536-atom water NVE with conserved total energy on the GPU.Happy to send a PR (the change is on a branch already). Opening this first in case you'd rather approach it differently.
(Separate, smaller thing: building cleanly on CUDA 13 with a recent toolchain also needed a few build-flag workarounds —
MKL_INCLUDE_DIR,FFT=KISS, and disabling the JPEG/PNG image deps. Glad to write those up as their own issue if useful.)