maint(kokkosNL): nicer failure modes for large cutoffs in dense systems#45
Open
maint(kokkosNL): nicer failure modes for large cutoffs in dense systems#45
Conversation
Detect when the estimated neighbor count for the model cutoff and system density exceeds neigh_modify one, and error with a clear message telling the user exactly what neigh_modify line to add. Also add guards in the Kokkos NL builder (npair_kokkos, nbin_kokkos) to produce clear errors instead of SIGFPE when atoms_per_bin or mbins is zero.
HaoZeke
commented
Mar 8, 2026
PicoCentauri
reviewed
Mar 9, 2026
Per review: auto-set one/page when estimated neighbor count exceeds defaults, with an info message showing the adjustment. Users can still override manually. Also improve nbin_kokkos error message with explicit neigh_modify suggestion per PicoCentauri review.
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
neigh_modify oneand error with a message specifying the exactneigh_modifyline to addnpair_kokkosandnbin_kokkosto produce clear error messages instead of SIGFPE when bin parameters are degeneratefix_metatomicbinsize hack to apply whenever the user has not explicitly set binsize (not just whenpair_style none)Details
Dense systems with large cutoffs (e.g. PET-MAD with ~5.5 A interaction range) crash with SIGFPE in
NPairKokkosBuildFunctorGhost. Root causes:one=2000(max neighbors per atom) is too small for dense systems with large cutoffspair_metatomicdid not set binsize, andfix_metatomiconly set it whenpair_style noneChanges:
pair_metatomic::init_style: estimate neighbors from(4/3)*pi*(cutoff+skin)^3 * densitywith 2x safety margin; error if this exceedsneigh_modify one, with a message specifying the exact fixfix_metatomic::init: generalize binsize hack to apply wheneverbinsizeflagis unset; add the same density-based neighbor check with clear errornpair_kokkos.cpp: guardatoms_per_bin <= 0before the build while-loopnbin_kokkos.cpp: guardmbins <= 0inbin_atoms_setupExample error message:
Changes:
pair_metatomic::init_style: auto-setbinsize = 0.5 * max_cutoffwhen user has not setbinsizeflag; estimate neighbors from(4/3)*pi*(cutoff+skin)^3 * densitywith 2x safety margin; auto-increaseone/pagewith warningfix_metatomic::init: generalize binsize hack to apply wheneverbinsizeflagis unset (not justpair_style none); add same density-basedone/pageauto-increasenpair_kokkos.cpp: guardatoms_per_bin <= 0before the build while-loopnbin_kokkos.cpp: guardmbins <= 0inbin_atoms_setupUser workaround (still works as override):
neigh_modify one 100000 page 1000000 binsize 5.5cc @PicoCentauri
Related Issue(s)
Internal comments.
Author(s)
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
Implementation Notes
Post Submission Checklist
Further Information, Files, and Links