Adding support for Kokkos kernel params autotuner#4830
Conversation
…ith lj/cut/kokkos as the prototype
…KOKKOS_GPU is defined
There was a problem hiding this comment.
Pull request overview
This pull request adds an autotuning feature for GPU kernel parameters in the KOKKOS package. The autotuner scans through combinations of team sizes (64-512 in steps of 32) and vector sizes (threads per atom: 1, 2, 4, 8, 16, 32) to find the optimal configuration that gives the best performance. The feature is disabled by default and can be enabled via the package kokkos auto/tuning command with a specified interval for performance measurement.
Key changes:
- Adds new
TuneKokkosclass that manages the scanning and performance measurement logic - Integrates autotuner into three pair styles:
pair_lj_cut,pair_lj_cut_coul_long, andpair_lj_charmm_coul_long - Adds
auto/tuningkeyword to thepackage kokkoscommand with interval parameter
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| src/KOKKOS/tune_kokkos.h | Header for new TuneKokkos class with performance tracking and parameter management |
| src/KOKKOS/tune_kokkos.cpp | Implementation of autotuner logic including parameter scanning, timing, and optimal selection |
| src/KOKKOS/pair_lj_cut_kokkos.h | Adds tuner member pointer to PairLJCutKokkos class |
| src/KOKKOS/pair_lj_cut_kokkos.cpp | Integrates autotuner in compute and init_style methods |
| src/KOKKOS/pair_lj_cut_coul_long_kokkos.h | Adds tuner member pointer to PairLJCutCoulLongKokkos class |
| src/KOKKOS/pair_lj_cut_coul_long_kokkos.cpp | Integrates autotuner in compute and init_style methods, adds missing copymode reset |
| src/KOKKOS/pair_lj_charmm_coul_long_kokkos.h | Adds tuner member pointer to PairLJCharmmCoulLongKokkos class |
| src/KOKKOS/pair_lj_charmm_coul_long_kokkos.cpp | Integrates autotuner in compute and init_style methods |
| src/KOKKOS/kokkos.h | Adds autotuning flag to KokkosLMP class |
| src/KOKKOS/kokkos.cpp | Implements auto/tuning command parsing and disables on non-GPU builds |
| cmake/Modules/Packages/KOKKOS.cmake | Adds tune_kokkos.cpp to KOKKOS package sources for CMake build |
| doc/src/package.rst | Documents the new auto/tuning keyword for package kokkos command |
|
Preliminary results from the autotuner:
|
… the last found optimal performance, updated to the doc page
…ir eam/kk needs only 1 parameter to tune
…ze and nbor/chunk/size, updated the doc page
|
@ndtrung81 I really like this new feature - thanks for this PR. Made several comments on the doc info for the autotuning option. Am ready to approve for merging once you respond. It would also be very good to add a couple of your perf plots for autotuning to the Benchmark web page. |
…ning = disabled at the bottom of the doc page
|
@sjplimp thank you for the feedback! I have updated the doc page with your suggestion to clarify the case when nevery is 0 and mention the defaults at the bottom of the page. Attached is the plot showing the performance with and without auto/tuning for Do you think they are suitable for the Benchmark page?
|
|
@ndtrung81 I think these should be added to the package command doc page, as well as the Benchmark page. Talk to @stanmoore1 about the Benchmark page. |
|
@stanmoore1 I also think the Benchmark page could be updated to report Benchmark timings that reflect the increased autotuning timesteps rates, where they make a difference, |
|
@ndtrung81 Have my other comments on the doc page been addressed? If so, then I will approve this PR for merging, |
|
@akohlmey per email, you can merge this when Trung completes his final (small) edits |
|
@akohlmey I have tried to address Steve's comments and edits. The doc page is good from my point of view. I will assign it to you, unless you need me to make more changes. Thanks! |
@ndtrung81 I made a few cosmetic changes to package.rst and am now running this one more through code review. A few minor findings:
Please check if these are valid concerns. |
|
@akohlmey thanks for the code review. These are valid concerns.
|
[...]
This was the result of the AI review. I was too tired to double check everything. |
|
@akohlmey I am done with addressing the concerns from code review. |
Then let me quickly merge it before somebody get any more ideas for changes... |

Summary
This PR adds a performance tuner for the GPU kernel launch parameters for the KOKKOS package. The tuner, if enabled, will scan through the possible values of the team sizes and vector sizes, measures the overall performance within a specified interval, and find the combination that gives the best performance. The optimal combination will be used for the
pair_compute_neighlistkernel(defined inpair_kokkos.h`) from that point on.This PR is built upon the features provided by #4573. Based on the findings of that PR, the most influential kernel parameters are
pair/team/sizeandthreads/per/atom, that is, teamsize and vectorsize, respectively, of the pair style kernels. That's the motivation for scanning over these 2 parameters in the /kk pair styles in this PR. Bond styles have a single parameter to tune (bond_block_size).Related Issue(s)
N/A
Author(s)
Trung Nguyen (U Chicago)
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
Should maintain backward compatiblity
Implementation Notes
It would be more efficient if the tuner can be refactored out of individual pair styles, to avoid the repetition for each /kk pair style.
Post Submission Checklist
Further Information, Files, and Links