Skip to content

feat(rocrand): Implement Kernel Tuner for rocRAND. - #12750

Merged
NguyenNhuDi merged 39 commits into
developfrom
users/NguyenNhuDi/rocrand-begin-kernel-tuning-impl
Oct 8, 2026
Merged

NguyenNhuDi merged 39 commits into
developfrom
users/NguyenNhuDi/rocrand-begin-kernel-tuning-impl

Conversation

@NguyenNhuDi

@NguyenNhuDi NguyenNhuDi commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

Migration of the legacy tuner to use Kernel Tuner instead.

JIRA ID: AIPRIMS-236 & EXSWSTRHPC-322

Technical Details

A lot of addition was based on Kernel Tuner from rocPRIM . However there are some significant differences.

  • migrate.py does not exists for rocRAND. This is because rocRAND does not queue and tune types the way rocPRIM does. Instead it queues all distributions and different types through templated functions. Since this is the case the config file only ever consists of two functions that needs updating, and thus migrate.py is not needed.
  • genereate.py a lot of internal changes were made to accommodate the fact that key_type and value_type are not really used in rocRAND auto tuning.
  • parse.py was changed completely.

Since rocRAND is much more simple than rocPRIM we should be able to include all the changes in one PR. Currently we are done lfsr113 generators. This will be the TODO:

  • mrg31k3p
  • mrg32k3a
  • mt19937
  • mtgp32
  • philox4_32_10
  • three_fry2_32_20
  • three_fry2_64_20
  • threefry4_32_20
  • threefry4_64_20
  • xorwow

Test Plan

Generate all configs and test that it compiles, and that the output are not garbage.

Test Result

Pending test results.

Submission Checklist

@therock-pr-bot

therock-pr-bot Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

✅ All Checks Passed — Ready for Review

Check Status Details
📝 PR Description ✅ Pass —
⛔ Forbidden Files ✅ Pass —
🧪 Unit Test ⚠️ Warning Error: Source/code files changed without an accompanying unit test.
Expected: add at least one test file named like test_<name>.py / test_<name>.cpp (or <name>_test.*).
Current: code file(s) changed: projects/rocrand/library/src/rng/config/lfsr113_config.hpp, projects/rocrand/library/src/rng/config/mrg31k3p_config.hpp, projects/rocrand/library/src/rng/config/mrg32k3a_config.hpp, projects/rocrand/library/src/rng/config/mt19937_config.hpp, projects/rocrand/library/src/rng/config/mtgp32_config.hpp (+24 more); no test file found
🔎 pre-commit ✅ Pass —
🚫 Draft PR 🔜 To Be Enabled —
🚩 Feature Flag 🔜 To Be Enabled —
📊 Code Coverage 🔜 To Be Enabled —
🤖 therock-pr-bot ✅ Pass —

🎉 All checks passed! This PR is ready for review.

📖 Need help? See the Policy FAQ for details on every check and how to fix failures.

🙋 Wish to Override Policy?

@therock-pr-bot

Copy link
Copy Markdown

Pre-commit check failed

⛔ pre-commit failed

Please run locally:

  • python -m pip install pre-commit
  • pre-commit install
  • pre-commit run --all-files --show-diff-on-failure

This repo uses .pre-commit-config.yaml.

@NguyenNhuDi
NguyenNhuDi force-pushed the users/NguyenNhuDi/rocrand-begin-kernel-tuning-impl branch from 4bd0ed7 to baa1c50 Compare October 1, 2026 16:15
@NguyenNhuDi
NguyenNhuDi marked this pull request as ready for review October 1, 2026 16:25
@NguyenNhuDi
NguyenNhuDi requested review from a team as code owners October 1, 2026 16:25

@amd-mcieslak amd-mcieslak 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.

I've pulled the branch and am testing on gfx950 (MI355), and overall works well. However, Primbench settings (min/max GPU temp, warming/cooling time) can't be set from the CLI. I had to edit the template to lower min temp to 49 °C on MI355.

Claude found a couple of items to consider:

  1. The threefry 64 ULL change looks like it removes the output_type_supported primary template, which could break compilation of those wrappers. This might not be obvious when running: Kernel Tuner records compile errors as failed configs, so the run can look finished while producing no valid results. Should be checked.

  2. generate.py can write empty headers, and doesn't handle failed configs. Please check if Kernel Tuner stores failed configs with a string time (e.g. "CompilationFailedConfig", "RuntimeFailedConfig"). The "time" in c filter keeps those, so min(..., key=lambda c: c["time"]) could raise TypeError (str vs float) whenever a run has any failures. If every config failed, min() on an empty list raises ValueError instead.

@amd-jmahovsky amd-jmahovsky 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.

I found a few more potential issues.

Comment thread projects/rocrand/tuning/utils/utils.py Resolved
Comment thread projects/rocrand/tuning/utils/utils.py Resolved
@codecov

codecov Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop   #12750      +/-   ##
===========================================
- Coverage    72.12%   70.68%   -1.44%     
===========================================
  Files         2861     2940      +79     
  Lines       472095   484570   +12475     
  Branches     69805    69880      +75     
===========================================
+ Hits        340454   342487    +2033     
- Misses      107909   118190   +10281     
- Partials     23732    23893     +161     
Flag Coverage Δ *Carryforward flag
TensileLite-CPP 48.82% <ø> (-0.20%) ⬇️ Carriedforward from bad2c24
TensileLite-Unit 82.64% <ø> (-0.63%) ⬇️ Carriedforward from bad2c24
hipBLAS 90.62% <ø> (ø) Carriedforward from bad2c24
hipBLASLt 35.59% <ø> (-3.07%) ⬇️ Carriedforward from bad2c24
hipCUB 82.68% <ø> (ø) Carriedforward from bad2c24
hipDNN 86.64% <ø> (ø) Carriedforward from bad2c24
hipFFT 54.32% <ø> (ø) Carriedforward from bad2c24
hipRAND 76.12% <ø> (ø) Carriedforward from bad2c24
hipSOLVER 68.96% <ø> (ø) Carriedforward from bad2c24
hipSPARSE 86.99% <ø> (ø) Carriedforward from bad2c24
rocBLAS 48.24% <ø> (-0.01%) ⬇️ Carriedforward from bad2c24
rocFFT 47.11% <ø> (-1.67%) ⬇️ Carriedforward from bad2c24
rocRAND 57.45% <ø> (ø)
rocSOLVER 76.83% <ø> (+<0.01%) ⬆️ Carriedforward from bad2c24
rocSPARSE 74.75% <ø> (ø) Carriedforward from bad2c24
rocThrust 78.45% <ø> (-14.70%) ⬇️ Carriedforward from bad2c24

*This pull request uses carry forward flags. Click here to find out more.

Files with missing lines Coverage Δ
.../rocrand/library/src/rng/config/lfsr113_config.hpp 0.00% <ø> (ø)
...rocrand/library/src/rng/config/mrg31k3p_config.hpp 0.00% <ø> (ø)
...rocrand/library/src/rng/config/mrg32k3a_config.hpp 0.00% <ø> (ø)
.../rocrand/library/src/rng/config/mt19937_config.hpp 0.00% <ø> (ø)
...s/rocrand/library/src/rng/config/mtgp32_config.hpp 0.00% <ø> (ø)
...nd/library/src/rng/config/philox4_32_10_config.hpp 0.00% <ø> (ø)
.../library/src/rng/config/threefry2_32_20_config.hpp 0.00% <ø> (ø)
.../library/src/rng/config/threefry2_64_20_config.hpp 0.00% <ø> (ø)
.../library/src/rng/config/threefry4_32_20_config.hpp 0.00% <ø> (ø)
.../library/src/rng/config/threefry4_64_20_config.hpp 0.00% <ø> (ø)
... and 1 more

... and 210 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@therock-pr-bot

therock-pr-bot Bot commented Oct 5, 2026

Copy link
Copy Markdown

🎉 All checks passed! This PR is ready for review.

@amd-jmahovsky amd-jmahovsky 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.

Claude pointed out a bunch of edge case issues that can lead to data loss and crashes, but the most important thing is how we are calculating the time to compare performance: geometric mean vs arithmetic mean and how they weight slow vs faster tests.

@amd-jmahovsky amd-jmahovsky 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.

Another review pass. Looks like a few issues still.

Comment thread projects/rocrand/tuning/run_tuning.py Resolved

@amd-jmahovsky amd-jmahovsky 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.

LGTM

@NguyenNhuDi
NguyenNhuDi merged commit eadde76 into develop Oct 8, 2026
105 of 106 checks passed
@NguyenNhuDi
NguyenNhuDi deleted the users/NguyenNhuDi/rocrand-begin-kernel-tuning-impl branch October 8, 2026 20:52
assistant-librarian Bot pushed a commit to ROCm/rocRAND that referenced this pull request Oct 8, 2026
feat(rocrand): Implement Kernel Tuner for rocRAND.

## Motivation
Migration of the legacy tuner to use Kernel Tuner instead.

JIRA ID: AIPRIMS-236 & EXSWSTRHPC-322

## Technical Details

A lot of addition was based on Kernel Tuner from `rocPRIM` . However
there are some significant differences.
- `migrate.py` does not exists for `rocRAND`. This is because `rocRAND`
does not queue and tune types the way `rocPRIM` does. Instead it queues
all distributions and different types through templated functions. Since
this is the case the config file only ever consists of two functions
that needs updating, and thus `migrate.py` is not needed.
- `genereate.py` a lot of internal changes were made to accommodate the
fact that `key_type` and `value_type` are not really used in `rocRAND`
auto tuning.
 - `parse.py` was changed completely.

Since `rocRAND` is much more simple than `rocPRIM` we should be able to
include all the changes in one PR. Currently we are done `lfsr113`
generators. This will be the TODO:
 - [x] mrg31k3p
 - [x] mrg32k3a
 - [x] mt19937
 - [x] mtgp32
 - [x] philox4_32_10
 - [x] three_fry2_32_20
 - [x] three_fry2_64_20
 - [x] threefry4_32_20
 - [x] threefry4_64_20
 - [x] xorwow

## Test Plan

Generate all configs and test that it compiles, and that the output are
not garbage.

## Test Result

Pending test results.

## Submission Checklist

- [ ] Look over the contributing guidelines at
https://github.com/ROCm/TheRock/blob/main/GOVERNANCE.md#pull-requests.
@assistant-librarian

Copy link
Copy Markdown
Contributor

TheRock Submodule Bump Activity

Newest first

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants