← Back to Pull requests

feat(rocprim): Implement Kernel Tuner for Various Algorithms #12008

Closed
NguyenNhuDi closed this pull request without merging on Oct 15, 2026 17:12 UTC
View on GitHub
NguyenNhuDi NguyenNhuDi commented on Sep 11, 2026 21:13 UTC
Author

Motivation

Implement Kernel Tuner for Various Algorithms:
- device_find_first_of
- device_run_length_encode
- device_run_length_encode_non_trivial
- device_segmented_topk_air
- device_topk_air

JIRA ID: AIPRIMS-236 & EXSWSTRHPC-322

Technical Details

The rocPRIM config changes are due to running migrate.py (this updates the legacy config to be ready for Kernel Tuner)

This PR is built on top of #11678, do not merge until the mentioned PR has been merged

Recommended way to review this PR is to go to "Commit" and review the files per commit.

Test Plan

Local running of kernel tuner, making sure output matches legacy tuners and that there are no errors.

Test Result

Generated config files compiles, and all unit tests were passing locally

Submission Checklist

  • Look over the contributing guidelines at https://github.com/ROCm/ROCm/blob/develop/CONTRIBUTING.md#pull-requests.
  • Diff: 1945 lines (+1318 / -627) across 27 files Reviewer: amd-jmahovsky Review duration: 48718m
    All Vouch review confidence checks passed
    Residual risk 0.12 = Change Risk (0.72) × (1 − Review Confidence (0.83)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.72 · 1945 lines diff across 27 files
    0.72
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.71 · 5 substantive comment(s)
    0.71
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    82%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.400
    Mass File Touch mass_file_touch
    0.080
    Real PR Conversation Timeline
    45 items
    therock-pr-bot[bot] therock-pr-bot[bot] commented on Sep 11, 2026 21:17 UTC
    Bot

    <!-- therock-pr-bot-policy-check -->

    ✅ 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.<br>Expected: add at least one test file named like test_<name>.py / test_<name>.cpp (or <name>_test.*).<br>Current: code file(s) changed: projects/rocprim/rocprim/include/rocprim/device/detail/config/device_find_first_of.hpp, projects/rocprim/rocprim/include/rocprim/device/detail/config/device_run_length_encode.hpp, projects/rocprim/rocprim/include/rocprim/device/detail/config/device_run_length_encode_non_trivial.hpp, projects/rocprim/rocprim/include/rocprim/device/detail/config/device_search_n.hpp, projects/rocprim/rocprim/include/rocprim/device/detail/config/device_topk_air.hpp (+10 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[bot] therock-pr-bot[bot] commented on Sep 11, 2026 21:17 UTC
    Bot

    <!-- therock-pr-bot-fix-policies -->
    🎉 All checks passed! This PR is ready for review.

    amd-jmahovsky amd-jmahovsky commented on code on Sep 28, 2026 18:08 UTC
    Code Review
    projects/rocprim/tuning/run_tuning.py:1
    @@ -85,15 +85,20 @@ def get_available_algorithms() -> List[str]:
             "device_select_unique_by_key",
             "device_select_flag",
             "device_select_predicate",
    -        "device_select_unique"
    +        "device_select_unique",
    +        "device_find_first_of",
    +        "device_run_length_encode",
    +        "device_run_length_encode_non_trivial",
    +        "device_topk_air",
    +        "device_segmented_topk_air"
             "device_select_unique",

    This is a duplicate

    amd-jmahovsky amd-jmahovsky commented on code on Sep 28, 2026 18:09 UTC
    Code Review
    projects/rocprim/tuning/run_tuning.py:1
    @@ -85,15 +85,20 @@ def get_available_algorithms() -> List[str]:
             "device_select_unique_by_key",
             "device_select_flag",
             "device_select_predicate",
    -        "device_select_unique"
    +        "device_select_unique",
    +        "device_find_first_of",
    +        "device_run_length_encode",
    +        "device_run_length_encode_non_trivial",
    +        "device_topk_air",
    +        "device_segmented_topk_air"

    missing comma after

    amd-jmahovsky amd-jmahovsky commented on code on Sep 28, 2026 18:11 UTC
    Code Review
    projects/rocprim/tuning/confgen/templates/device_run_length_encode_non_trivial.h.jinja2:1
    @@ -0,0 +1,25 @@
    +{% extends "common/base.h.jinja2" %}
    +
    +{% block target_tparams %}
    +    template<class Target, class key_type>
    +{% endblock %}
    +
    +{% block params_type -%}
    +    non_trivial_runs_config_params
    +{%- endblock %}
    +
    +{% block config_guard scoped %}
    +    {{ mk_is_fp_type_check(type.key_type) }} && {{ mk_type_sz_check(type.key_type) }}
    +{% endblock %}
    +
    +{% block config_constructor -%}
    +    non_trivial_runs_config_params{ 
    +        { {{ config.block_size_x }}, {{ config.ipt }} },
    +        {{ config.block_load_func }}

    missing a comma here?

    amd-jmahovsky amd-jmahovsky requested changes on Sep 28, 2026 18:12 UTC
    Changes Requested Reviewer

    I found a few potential problems

    amd-mcieslak amd-mcieslak commented on Sep 28, 2026 19:28 UTC
    Reviewer

    I've been running Kernel Tuner on gfx950 and found a few things adjacent to this PR.
    (1) device_adjacent_difference_inplace.cpp.jinja2 has a stray {% endblock %}. Not introduced here, but this PR is the natural place to fix it.
    (2) Skipping already-completed algorithms only works partially. Should this be filed separately?

    amd-mcieslak amd-mcieslak commented on code on Sep 28, 2026 19:35 UTC
    Code Review
    projects/rocprim/tuning/run_tuning.py:1
    @@ -85,15 +85,20 @@ def get_available_algorithms() -> List[str]:
             "device_select_unique_by_key",
             "device_select_flag",
             "device_select_predicate",
    -        "device_select_unique"
    +        "device_select_unique",
    +        "device_find_first_of",
    +        "device_run_length_encode",
    +        "device_run_length_encode_non_trivial",
    +        "device_topk_air",
    +        "device_segmented_topk_air"
             "device_select_unique",

    Could we add a guard so it can't silently happen again?

    NguyenNhuDi NguyenNhuDi commented on code on Sep 29, 2026 15:36 UTC
    Code Review
    projects/rocprim/tuning/run_tuning.py:1
    @@ -85,15 +85,20 @@ def get_available_algorithms() -> List[str]:
             "device_select_unique_by_key",
             "device_select_flag",
             "device_select_predicate",
    -        "device_select_unique"
    +        "device_select_unique",
    +        "device_find_first_of",
    +        "device_run_length_encode",
    +        "device_run_length_encode_non_trivial",
    +        "device_topk_air",
    +        "device_segmented_topk_air"
             "device_select_unique",

    Maybe a better idea is to scrape the file names. I think I will do this to prevent this from happening again

    NguyenNhuDi NguyenNhuDi commented on Sep 29, 2026 15:54 UTC
    Author

    @NB4444 , @amd-jmahovsky added auto scrape for file names in run_tuning. Not sure if this is the best way to do it, if there is a cleaner way let me know

    NguyenNhuDi NguyenNhuDi commented on Sep 29, 2026 15:55 UTC
    Author

    @amd-mcieslak, it was actually not a stray endblock but a missing {% block benchmark_type % }. It must have got lost somewhere in all the changes. Thanks for catching that!

    amd-jmahovsky amd-jmahovsky commented on code on Sep 29, 2026 16:48 UTC
    Code Review
    projects/rocprim/tuning/tuner/templates/device_topk_air.cpp.jinja2:1
    @@ -0,0 +1,47 @@
    +{% extends "common/base.cpp.jinja2" %}
    +
    +{% block benchmarking_include %}
    +    #include "benchmark_device_topk_air.parallel.hpp"
    +{% endblock %}
    +
    +{% block config_constructor -%}
    +    rocprim::topk_air_config<
    +        {{ config.block_size_x }},
    +        {{ config.ipt }},
    +        {{ config.radix_bits }},
    +        {{ config.adapt_coeff }},
    +        {{ config.limit }}
    +    >
    +{%- endblock %}
    +
    +{% block benchmark_type %}
    +        using benchmark_type = device_topk_air_benchmark<key_type, value_type, config>;
    +{% endblock %}
    +
    +using key_type = {{ key_type }};

    Should these be in a block?

    amd-jmahovsky amd-jmahovsky commented on code on Sep 29, 2026 16:52 UTC
    Code Review
    projects/rocprim/tuning/confgen/templates/device_find_first_of.h.jinja2:1
    @@ -0,0 +1,19 @@
    +{% extends "common/base.h.jinja2" %}
    +
    +{% block target_tparams %}
    +template<class Target, class value_type>
    +{% endblock %}
    +
    +{% block config_guard scoped %}
    +    ({% if not type.value_type.is_floating %}!{% endif %}rocprim::is_floating_point<value_type>::value){% if type.value_type.size_min > 0 %} 

    Can this be {{ mk_is_fp_type_check(type.key_type) }} && {{ mk_type_sz_check(type.key_type) }} like in device_run_length_encode.h.jinja2‎?

    amd-jmahovsky amd-jmahovsky commented on code on Sep 29, 2026 16:56 UTC
    Code Review
    projects/rocprim/tuning/tuner/tuning_device_find_first_of.py:1
    @@ -0,0 +1,80 @@
    +#!/usr/bin/env python3
    +
    +# Copyright (c) 2025-2026 Advanced Micro Devices, Inc. All rights reserved.
    +#
    +# Permission is hereby granted, free of charge, to any person obtaining a copy
    +# of this software and associated documentation files (the "Software"), to deal
    +# in the Software without restriction, including without limitation the rights
    +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    +# copies of the Software, and to permit persons to whom the Software is
    +# furnished to do so, subject to the following conditions:
    +#
    +# The above copyright notice and this permission notice shall be included in
    +# all copies or substantial portions of the Software.
    +#
    +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
    +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    +# THE SOFTWARE.
    +
    +from typing import Optional, OrderedDict, Callable
    +from math import log2

    do we need to import log2?

    amd-jmahovsky amd-jmahovsky commented on code on Sep 29, 2026 16:57 UTC
    Code Review
    projects/rocprim/tuning/tuner/tuning_device_run_length_encode.py:1
    @@ -0,0 +1,83 @@
    +#!/usr/bin/env python3
    +
    +# Copyright (c) 2025-2026 Advanced Micro Devices, Inc. All rights reserved.
    +#
    +# Permission is hereby granted, free of charge, to any person obtaining a copy
    +# of this software and associated documentation files (the "Software"), to deal
    +# in the Software without restriction, including without limitation the rights
    +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    +# copies of the Software, and to permit persons to whom the Software is
    +# furnished to do so, subject to the following conditions:
    +#
    +# The above copyright notice and this permission notice shall be included in
    +# all copies or substantial portions of the Software.
    +#
    +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
    +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    +# THE SOFTWARE.
    +
    +from typing import Optional, OrderedDict, Callable
    +from math import log2

    do we need this import?

    amd-jmahovsky amd-jmahovsky commented on code on Sep 29, 2026 17:04 UTC
    Code Review
    projects/rocprim/tuning/tuner/tuning_device_segmented_topk_air.py:1
    @@ -0,0 +1,42 @@
    +#!/usr/bin/env python3
    +
    +# Copyright (c) 2025-2026 Advanced Micro Devices, Inc. All rights reserved.
    +#
    +# Permission is hereby granted, free of charge, to any person obtaining a copy
    +# of this software and associated documentation files (the "Software"), to deal
    +# in the Software without restriction, including without limitation the rights
    +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    +# copies of the Software, and to permit persons to whom the Software is
    +# furnished to do so, subject to the following conditions:
    +#
    +# The above copyright notice and this permission notice shall be included in
    +# all copies or substantial portions of the Software.
    +#
    +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
    +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    +# THE SOFTWARE.
    +
    +import sys
    +import os
    +
    +sys.path.append(f"{os.path.dirname(__file__)}/../")
    +sys.path.append(f"{os.path.dirname(__file__)}")
    +
    +from tuner.base_tuner import TunerArgs
    +from tuning_device_topk_air import Tuner
    +
    +class SegmentedTopkAirTuner(Tuner):

    Should it be written something like this, because the system is looking for a class named "Tuner" and right now we won't get the right one:

    from tuning_device_topk_air import Tuner as TopkAirTuner
    
      class Tuner(TopkAirTuner):
          @classmethod
          def _get_default_args(cls) -> TunerArgs:
              return TunerArgs(algo_full_name='device_segmented_topk_air')
    
      if __name__ == "__main__":
          Tuner.cli()
    
    

    amd-jmahovsky amd-jmahovsky commented on code on Sep 29, 2026 17:07 UTC
    Code Review
    projects/rocprim/tuning/run_tuning.py:1
    @@ -64,38 +66,7 @@ def import_module_from_file(file_path: str, module_name: str) -> Optional[Module
     
     def get_available_algorithms() -> List[str]:
         """Return list of supported tuning algorithms."""
    -    return sorted([
    -        "device_merge",
    -        "device_adjacent_find",
    -        "device_adjacent_difference",
    -        "device_adjacent_difference_inplace",
    -        "device_binary_search",
    -        "device_lower_bound",
    -        "device_upper_bound",
    -        "device_search_n",
    -        "device_merge_sort_block_merge",
    -        "device_merge_sort_block_sort",
    -        "device_radix_sort_block_sort",
    -        "device_partition_flag",
    -        "device_partition_predicate",
    -        "device_partition_three_way",
    -        "device_partition_two_way_flag",
    -        "device_partition_two_way_predicate",
    -        "device_select_predicated_flag",
    -        "device_select_unique_by_key",
    -        "device_select_flag",
    -        "device_select_predicate",
    -        "device_select_unique"
    -        "device_select_unique",
    -        "device_radix_sort_onesweep",
    -        "device_segmented_radix_sort",
    -        "device_scan",
    -        "device_scan_by_key"
    -        "device_reduce",
    -        "device_segmented_reduce",
    -        "device_reduce_by_key"
    -        # Add new algorithms here
    -    ])
    +    return sorted([re.sub(r'tuning_|.py', '', os.path.basename(i)) for i in glob(f'{BASE_DIR}/tuner/tuning_*')])

    Won't the glob also pick up things like "tuning_device_partition.py" and "tuning_device_select.py"? (I think these are helper modules.)

    amd-jmahovsky amd-jmahovsky commented on code on Sep 29, 2026 17:15 UTC
    Code Review
    projects/rocprim/tuning/run_tuning.py:1
    @@ -64,38 +66,7 @@ def import_module_from_file(file_path: str, module_name: str) -> Optional[Module
     
     def get_available_algorithms() -> List[str]:
         """Return list of supported tuning algorithms."""
    -    return sorted([
    -        "device_merge",
    -        "device_adjacent_find",
    -        "device_adjacent_difference",
    -        "device_adjacent_difference_inplace",
    -        "device_binary_search",
    -        "device_lower_bound",
    -        "device_upper_bound",
    -        "device_search_n",
    -        "device_merge_sort_block_merge",
    -        "device_merge_sort_block_sort",
    -        "device_radix_sort_block_sort",
    -        "device_partition_flag",
    -        "device_partition_predicate",
    -        "device_partition_three_way",
    -        "device_partition_two_way_flag",
    -        "device_partition_two_way_predicate",
    -        "device_select_predicated_flag",
    -        "device_select_unique_by_key",
    -        "device_select_flag",
    -        "device_select_predicate",
    -        "device_select_unique"
    -        "device_select_unique",
    -        "device_radix_sort_onesweep",
    -        "device_segmented_radix_sort",
    -        "device_scan",
    -        "device_scan_by_key"
    -        "device_reduce",
    -        "device_segmented_reduce",
    -        "device_reduce_by_key"
    -        # Add new algorithms here
    -    ])
    +    return sorted([re.sub(r'tuning_|.py', '', os.path.basename(i)) for i in glob(f'{BASE_DIR}/tuner/tuning_*')])

    Also the regex has a few problems. The '.' means 'match any one character' not 'match a dot'. So the ".py" means any character followed by ".py" which will mess up on something like "tuning_device_copy.py" by matching the first py.

    Claude suggests:
    r'^tuning_|\.py$'

    \. is a literal dot, and ^/$ anchor the matches to the start and end of the name.

    amd-jmahovsky amd-jmahovsky commented on code on Sep 29, 2026 17:25 UTC
    Code Review
    projects/rocprim/tuning/tuner/tuning_device_run_length_encode.py:1
    @@ -0,0 +1,83 @@
    +#!/usr/bin/env python3
    +
    +# Copyright (c) 2025-2026 Advanced Micro Devices, Inc. All rights reserved.
    +#
    +# Permission is hereby granted, free of charge, to any person obtaining a copy
    +# of this software and associated documentation files (the "Software"), to deal
    +# in the Software without restriction, including without limitation the rights
    +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    +# copies of the Software, and to permit persons to whom the Software is
    +# furnished to do so, subject to the following conditions:
    +#
    +# The above copyright notice and this permission notice shall be included in
    +# all copies or substantial portions of the Software.
    +#
    +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
    +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    +# THE SOFTWARE.
    +
    +from typing import Optional, OrderedDict, Callable
    +from math import log2
    +import sys
    +import os
    +
    +sys.path.append(f"{os.path.dirname(__file__)}/../")
    +
    +from utils import TYPE_CONFIGS
    +from tuner.base_tuner import BaseTuner, TunerArgs, COMMON_KEY_TYPES
    +
    +"""
    +Inclusive range for params tuning, edit these to adjust tuning grid range.
    +"""
    +BLOCK_SIZES = [128, 192, 256, 384, 512]
    +IPT = list(range(4,16))
    +
    +# this is not a tunable param
    +MAXLENGTH = [10, 1000]
    +
    +class Tuner(BaseTuner):
    +    @classmethod
    +    def _get_default_args(cls) -> TunerArgs:
    +        return TunerArgs(algo_full_name='device_run_length_encode')
    +
    +    def __init__(self, args: TunerArgs) -> None:
    +        super().__init__(args)
    +
    +    def _get_tune_params(self, key_type: str, value_type: Optional[str] = None) -> OrderedDict:
    +        params = OrderedDict()
    +        params['block_size_x'] = BLOCK_SIZES
    +        params['ipt'] = IPT
    +        params['max_length'] = MAXLENGTH

    max_length is not a tuneable param and should be removed from params

    amd-jmahovsky amd-jmahovsky commented on code on Sep 29, 2026 17:25 UTC
    Code Review
    projects/rocprim/tuning/tuner/tuning_device_run_length_encode.py:1
    @@ -0,0 +1,83 @@
    +#!/usr/bin/env python3
    +
    +# Copyright (c) 2025-2026 Advanced Micro Devices, Inc. All rights reserved.
    +#
    +# Permission is hereby granted, free of charge, to any person obtaining a copy
    +# of this software and associated documentation files (the "Software"), to deal
    +# in the Software without restriction, including without limitation the rights
    +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    +# copies of the Software, and to permit persons to whom the Software is
    +# furnished to do so, subject to the following conditions:
    +#
    +# The above copyright notice and this permission notice shall be included in
    +# all copies or substantial portions of the Software.
    +#
    +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
    +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    +# THE SOFTWARE.
    +
    +from typing import Optional, OrderedDict, Callable
    +from math import log2
    +import sys
    +import os
    +
    +sys.path.append(f"{os.path.dirname(__file__)}/../")
    +
    +from utils import TYPE_CONFIGS
    +from tuner.base_tuner import BaseTuner, TunerArgs, COMMON_KEY_TYPES
    +
    +"""
    +Inclusive range for params tuning, edit these to adjust tuning grid range.
    +"""
    +BLOCK_SIZES = [128, 192, 256, 384, 512]
    +IPT = list(range(4,16))
    +
    +# this is not a tunable param
    +MAXLENGTH = [10, 1000]
    +
    +class Tuner(BaseTuner):
    +    @classmethod
    +    def _get_default_args(cls) -> TunerArgs:
    +        return TunerArgs(algo_full_name='device_run_length_encode')
    +
    +    def __init__(self, args: TunerArgs) -> None:
    +        super().__init__(args)
    +
    +    def _get_tune_params(self, key_type: str, value_type: Optional[str] = None) -> OrderedDict:
    +        params = OrderedDict()
    +        params['block_size_x'] = BLOCK_SIZES
    +        params['ipt'] = IPT
    +        params['max_length'] = MAXLENGTH

    the MAX_LENGTH constant can also go away, I think

    amd-jmahovsky amd-jmahovsky commented on code on Sep 29, 2026 17:29 UTC
    Code Review
    projects/rocprim/tuning/tuner/tuning_device_run_length_encode.py:1
    @@ -0,0 +1,83 @@
    +#!/usr/bin/env python3
    +
    +# Copyright (c) 2025-2026 Advanced Micro Devices, Inc. All rights reserved.
    +#
    +# Permission is hereby granted, free of charge, to any person obtaining a copy
    +# of this software and associated documentation files (the "Software"), to deal
    +# in the Software without restriction, including without limitation the rights
    +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    +# copies of the Software, and to permit persons to whom the Software is
    +# furnished to do so, subject to the following conditions:
    +#
    +# The above copyright notice and this permission notice shall be included in
    +# all copies or substantial portions of the Software.
    +#
    +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
    +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    +# THE SOFTWARE.
    +
    +from typing import Optional, OrderedDict, Callable
    +from math import log2
    +import sys
    +import os
    +
    +sys.path.append(f"{os.path.dirname(__file__)}/../")
    +
    +from utils import TYPE_CONFIGS
    +from tuner.base_tuner import BaseTuner, TunerArgs, COMMON_KEY_TYPES
    +
    +"""
    +Inclusive range for params tuning, edit these to adjust tuning grid range.
    +"""
    +BLOCK_SIZES = [128, 192, 256, 384, 512]
    +IPT = list(range(4,16))
    +
    +# this is not a tunable param
    +MAXLENGTH = [10, 1000]
    +
    +class Tuner(BaseTuner):
    +    @classmethod
    +    def _get_default_args(cls) -> TunerArgs:
    +        return TunerArgs(algo_full_name='device_run_length_encode')
    +
    +    def __init__(self, args: TunerArgs) -> None:
    +        super().__init__(args)
    +
    +    def _get_tune_params(self, key_type: str, value_type: Optional[str] = None) -> OrderedDict:
    +        params = OrderedDict()
    +        params['block_size_x'] = BLOCK_SIZES
    +        params['ipt'] = IPT
    +        params['max_length'] = MAXLENGTH

    I think we want to run both MAX_LENGTH=10 and MAX_LENGTH=1000 and then average the results. Claude suggests changing the template:

     {% block benchmark_type %}
      {% endblock %}
    
      {% block benchmark_queue %}
          executor.queue<device_run_length_encode_benchmark<key_type, 10, config>>();
          executor.queue<device_run_length_encode_benchmark<key_type, 1000, config>>();
      {% endblock %}
    
      {% block get_time %}
          double sum = 0;
          double n = 0;
          for(const double & x : executor.get_all_bytes_per_second()){
              sum += (1000.0 * primbench::GiB) / x;
              n++;
          }
          return sum / n;
      {% endblock %}
    

    amd-mcieslak amd-mcieslak commented on Sep 29, 2026 17:58 UTC
    Reviewer

    The jinja template fix looks good.

    amd-jmahovsky amd-jmahovsky commented on code on Sep 29, 2026 18:02 UTC
    Code Review
    projects/rocprim/tuning/tuner/tuning_device_topk_air.py:1
    @@ -0,0 +1,79 @@
    +#!/usr/bin/env python3
    +
    +# Copyright (c) 2025-2026 Advanced Micro Devices, Inc. All rights reserved.
    +#
    +# Permission is hereby granted, free of charge, to any person obtaining a copy
    +# of this software and associated documentation files (the "Software"), to deal
    +# in the Software without restriction, including without limitation the rights
    +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    +# copies of the Software, and to permit persons to whom the Software is
    +# furnished to do so, subject to the following conditions:
    +#
    +# The above copyright notice and this permission notice shall be included in
    +# all copies or substantial portions of the Software.
    +#
    +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
    +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    +# THE SOFTWARE.
    +
    +from typing import Optional, OrderedDict, Callable
    +import sys
    +import os
    +
    +sys.path.append(f"{os.path.dirname(__file__)}/../")
    +
    +from tuner.base_tuner import BaseTuner, TunerArgs, COMMON_KEY_TYPES, COMMON_VALUE_TYPES
    +
    +"""
    +Inclusive range for params tuning, edit these to adjust tuning grid range.
    +"""
    +RADIX_BITS = [6, 7, 8]
    +BLOCK_SIZES = [64, 128, 256]
    +IPT = [2, 3, 4, 5, 6, 10]
    +ADAPT_COEFF = [256]
    +LIMIT = [32]
    +
    +class Tuner(BaseTuner):
    +    @classmethod
    +    def _get_default_args(cls) -> TunerArgs:
    +        return TunerArgs(algo_full_name='device_topk_air')
    +
    +    def __init__(self, args: TunerArgs) -> None:
    +        super().__init__(args)
    +
    +    def _get_tune_params(self, key_type: str, value_type: Optional[str] = None) -> OrderedDict:
    +        params = OrderedDict()
    +        params['block_size_x'] = BLOCK_SIZES
    +        params['ipt'] = IPT
    +        params['radix_bits'] = RADIX_BITS
    +        params['adapt_coeff'] = ADAPT_COEFF
    +        params['limit'] = LIMIT
    +
    +        return params
    +
    +    def _get_restrictions(
    +        self, key_type: str, val_type: Optional[str] = None
    +    ) -> Callable[[dict], bool]:
    +
    +        def validate(params):
    +            return True
    +
    +        return validate
    +
    +    def tune_all(self) -> None:
    +        """Tune for all value type combinations"""
    +
    +        VALUE_TYPES = COMMON_VALUE_TYPES + ["rocprim::empty_type"]

    Claude says this is a problem because of the rocprim:: prefix, where the rest of the tuner infrastructure is expecting just "empty_type" and things are silently failing. It proposes a solution that bypasses the issue:

        for key_type in COMMON_KEY_TYPES:
              self.tune_type(key_type)                    # keys-only
              for value_type in COMMON_VALUE_TYPES:
                  self.tune_type(key_type, value_type)
    

    I think this pattern is also used in tuning_device_merge.py.

    amd-mcieslak amd-mcieslak commented on Sep 29, 2026 18:07 UTC
    Contributor

    The auto-scrape is better than the assert guard. Good call! But doesn't the glob pick up all tuning_ files, including tuning_device_paritition.py and tuning_device_select.py? If so, they will show up in --list as available algorithms. Should they be excluded? Also, should the regex r'tuning_|.py' use an escape charater \.py and the glob us tuning_.py? It's minor but keeps the tuner from picking up any stray files.

    amd-jmahovsky amd-jmahovsky commented on code on Sep 29, 2026 18:10 UTC
    Code Review
    projects/rocprim/rocprim/include/rocprim/device/detail/config/device_run_length_encode.hpp:1

    There are two transpose lines here. Other configs are transpose, direct.

    amd-jmahovsky amd-jmahovsky commented on code on Sep 29, 2026 18:11 UTC
    Code Review
    projects/rocprim/rocprim/include/rocprim/device/detail/config/device_run_length_encode.hpp:1

    There are two transpose lines here. Other configs are transpose, direct.

    amd-jmahovsky amd-jmahovsky requested changes on Sep 29, 2026 18:11 UTC
    Changes Requested Reviewer

    I found a few things.

    NguyenNhuDi NguyenNhuDi commented on code on Sep 29, 2026 19:32 UTC
    Code Review
    projects/rocprim/tuning/tuner/tuning_device_segmented_topk_air.py:1
    @@ -0,0 +1,42 @@
    +#!/usr/bin/env python3
    +
    +# Copyright (c) 2025-2026 Advanced Micro Devices, Inc. All rights reserved.
    +#
    +# Permission is hereby granted, free of charge, to any person obtaining a copy
    +# of this software and associated documentation files (the "Software"), to deal
    +# in the Software without restriction, including without limitation the rights
    +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    +# copies of the Software, and to permit persons to whom the Software is
    +# furnished to do so, subject to the following conditions:
    +#
    +# The above copyright notice and this permission notice shall be included in
    +# all copies or substantial portions of the Software.
    +#
    +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
    +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    +# THE SOFTWARE.
    +
    +import sys
    +import os
    +
    +sys.path.append(f"{os.path.dirname(__file__)}/../")
    +sys.path.append(f"{os.path.dirname(__file__)}")
    +
    +from tuner.base_tuner import TunerArgs
    +from tuning_device_topk_air import Tuner
    +
    +class SegmentedTopkAirTuner(Tuner):

    I had no idea it did that. Thanks! Gonna have to make changes to search algos too then.

    NguyenNhuDi NguyenNhuDi commented on code on Sep 29, 2026 19:36 UTC
    Code Review
    projects/rocprim/tuning/tuner/tuning_device_find_first_of.py:1
    @@ -0,0 +1,80 @@
    +#!/usr/bin/env python3
    +
    +# Copyright (c) 2025-2026 Advanced Micro Devices, Inc. All rights reserved.
    +#
    +# Permission is hereby granted, free of charge, to any person obtaining a copy
    +# of this software and associated documentation files (the "Software"), to deal
    +# in the Software without restriction, including without limitation the rights
    +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    +# copies of the Software, and to permit persons to whom the Software is
    +# furnished to do so, subject to the following conditions:
    +#
    +# The above copyright notice and this permission notice shall be included in
    +# all copies or substantial portions of the Software.
    +#
    +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
    +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    +# THE SOFTWARE.
    +
    +from typing import Optional, OrderedDict, Callable
    +from math import log2

    nope, this is dead code from copying a file over

    NguyenNhuDi NguyenNhuDi commented on code on Sep 29, 2026 19:37 UTC
    Code Review
    projects/rocprim/tuning/tuner/tuning_device_run_length_encode.py:1
    @@ -0,0 +1,83 @@
    +#!/usr/bin/env python3
    +
    +# Copyright (c) 2025-2026 Advanced Micro Devices, Inc. All rights reserved.
    +#
    +# Permission is hereby granted, free of charge, to any person obtaining a copy
    +# of this software and associated documentation files (the "Software"), to deal
    +# in the Software without restriction, including without limitation the rights
    +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    +# copies of the Software, and to permit persons to whom the Software is
    +# furnished to do so, subject to the following conditions:
    +#
    +# The above copyright notice and this permission notice shall be included in
    +# all copies or substantial portions of the Software.
    +#
    +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
    +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    +# THE SOFTWARE.
    +
    +from typing import Optional, OrderedDict, Callable
    +from math import log2

    nope, same as above

    NguyenNhuDi NguyenNhuDi commented on code on Sep 29, 2026 19:38 UTC
    Code Review
    projects/rocprim/tuning/run_tuning.py:1
    @@ -64,38 +66,7 @@ def import_module_from_file(file_path: str, module_name: str) -> Optional[Module
     
     def get_available_algorithms() -> List[str]:
         """Return list of supported tuning algorithms."""
    -    return sorted([
    -        "device_merge",
    -        "device_adjacent_find",
    -        "device_adjacent_difference",
    -        "device_adjacent_difference_inplace",
    -        "device_binary_search",
    -        "device_lower_bound",
    -        "device_upper_bound",
    -        "device_search_n",
    -        "device_merge_sort_block_merge",
    -        "device_merge_sort_block_sort",
    -        "device_radix_sort_block_sort",
    -        "device_partition_flag",
    -        "device_partition_predicate",
    -        "device_partition_three_way",
    -        "device_partition_two_way_flag",
    -        "device_partition_two_way_predicate",
    -        "device_select_predicated_flag",
    -        "device_select_unique_by_key",
    -        "device_select_flag",
    -        "device_select_predicate",
    -        "device_select_unique"
    -        "device_select_unique",
    -        "device_radix_sort_onesweep",
    -        "device_segmented_radix_sort",
    -        "device_scan",
    -        "device_scan_by_key"
    -        "device_reduce",
    -        "device_segmented_reduce",
    -        "device_reduce_by_key"
    -        # Add new algorithms here
    -    ])
    +    return sorted([re.sub(r'tuning_|.py', '', os.path.basename(i)) for i in glob(f'{BASE_DIR}/tuner/tuning_*')])

    my inexperience with regex is shining brightly :)

    NguyenNhuDi NguyenNhuDi commented on code on Sep 29, 2026 19:42 UTC
    Code Review
    projects/rocprim/tuning/tuner/tuning_device_topk_air.py:1
    @@ -0,0 +1,79 @@
    +#!/usr/bin/env python3
    +
    +# Copyright (c) 2025-2026 Advanced Micro Devices, Inc. All rights reserved.
    +#
    +# Permission is hereby granted, free of charge, to any person obtaining a copy
    +# of this software and associated documentation files (the "Software"), to deal
    +# in the Software without restriction, including without limitation the rights
    +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    +# copies of the Software, and to permit persons to whom the Software is
    +# furnished to do so, subject to the following conditions:
    +#
    +# The above copyright notice and this permission notice shall be included in
    +# all copies or substantial portions of the Software.
    +#
    +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
    +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    +# THE SOFTWARE.
    +
    +from typing import Optional, OrderedDict, Callable
    +import sys
    +import os
    +
    +sys.path.append(f"{os.path.dirname(__file__)}/../")
    +
    +from tuner.base_tuner import BaseTuner, TunerArgs, COMMON_KEY_TYPES, COMMON_VALUE_TYPES
    +
    +"""
    +Inclusive range for params tuning, edit these to adjust tuning grid range.
    +"""
    +RADIX_BITS = [6, 7, 8]
    +BLOCK_SIZES = [64, 128, 256]
    +IPT = [2, 3, 4, 5, 6, 10]
    +ADAPT_COEFF = [256]
    +LIMIT = [32]
    +
    +class Tuner(BaseTuner):
    +    @classmethod
    +    def _get_default_args(cls) -> TunerArgs:
    +        return TunerArgs(algo_full_name='device_topk_air')
    +
    +    def __init__(self, args: TunerArgs) -> None:
    +        super().__init__(args)
    +
    +    def _get_tune_params(self, key_type: str, value_type: Optional[str] = None) -> OrderedDict:
    +        params = OrderedDict()
    +        params['block_size_x'] = BLOCK_SIZES
    +        params['ipt'] = IPT
    +        params['radix_bits'] = RADIX_BITS
    +        params['adapt_coeff'] = ADAPT_COEFF
    +        params['limit'] = LIMIT
    +
    +        return params
    +
    +    def _get_restrictions(
    +        self, key_type: str, val_type: Optional[str] = None
    +    ) -> Callable[[dict], bool]:
    +
    +        def validate(params):
    +            return True
    +
    +        return validate
    +
    +    def tune_all(self) -> None:
    +        """Tune for all value type combinations"""
    +
    +        VALUE_TYPES = COMMON_VALUE_TYPES + ["rocprim::empty_type"]

    This is addressed in #12186

    NguyenNhuDi NguyenNhuDi commented on code on Sep 29, 2026 19:42 UTC
    Code Review
    projects/rocprim/tuning/tuner/tuning_device_topk_air.py:1
    @@ -0,0 +1,79 @@
    +#!/usr/bin/env python3
    +
    +# Copyright (c) 2025-2026 Advanced Micro Devices, Inc. All rights reserved.
    +#
    +# Permission is hereby granted, free of charge, to any person obtaining a copy
    +# of this software and associated documentation files (the "Software"), to deal
    +# in the Software without restriction, including without limitation the rights
    +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    +# copies of the Software, and to permit persons to whom the Software is
    +# furnished to do so, subject to the following conditions:
    +#
    +# The above copyright notice and this permission notice shall be included in
    +# all copies or substantial portions of the Software.
    +#
    +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
    +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    +# THE SOFTWARE.
    +
    +from typing import Optional, OrderedDict, Callable
    +import sys
    +import os
    +
    +sys.path.append(f"{os.path.dirname(__file__)}/../")
    +
    +from tuner.base_tuner import BaseTuner, TunerArgs, COMMON_KEY_TYPES, COMMON_VALUE_TYPES
    +
    +"""
    +Inclusive range for params tuning, edit these to adjust tuning grid range.
    +"""
    +RADIX_BITS = [6, 7, 8]
    +BLOCK_SIZES = [64, 128, 256]
    +IPT = [2, 3, 4, 5, 6, 10]
    +ADAPT_COEFF = [256]
    +LIMIT = [32]
    +
    +class Tuner(BaseTuner):
    +    @classmethod
    +    def _get_default_args(cls) -> TunerArgs:
    +        return TunerArgs(algo_full_name='device_topk_air')
    +
    +    def __init__(self, args: TunerArgs) -> None:
    +        super().__init__(args)
    +
    +    def _get_tune_params(self, key_type: str, value_type: Optional[str] = None) -> OrderedDict:
    +        params = OrderedDict()
    +        params['block_size_x'] = BLOCK_SIZES
    +        params['ipt'] = IPT
    +        params['radix_bits'] = RADIX_BITS
    +        params['adapt_coeff'] = ADAPT_COEFF
    +        params['limit'] = LIMIT
    +
    +        return params
    +
    +    def _get_restrictions(
    +        self, key_type: str, val_type: Optional[str] = None
    +    ) -> Callable[[dict], bool]:
    +
    +        def validate(params):
    +            return True
    +
    +        return validate
    +
    +    def tune_all(self) -> None:
    +        """Tune for all value type combinations"""
    +
    +        VALUE_TYPES = COMMON_VALUE_TYPES + ["rocprim::empty_type"]

    The idea is to merge in that PR first and then this one

    NguyenNhuDi NguyenNhuDi commented on code on Sep 29, 2026 19:56 UTC
    Code Review
    projects/rocprim/tuning/tuner/templates/device_topk_air.cpp.jinja2:1
    @@ -0,0 +1,47 @@
    +{% extends "common/base.cpp.jinja2" %}
    +
    +{% block benchmarking_include %}
    +    #include "benchmark_device_topk_air.parallel.hpp"
    +{% endblock %}
    +
    +{% block config_constructor -%}
    +    rocprim::topk_air_config<
    +        {{ config.block_size_x }},
    +        {{ config.ipt }},
    +        {{ config.radix_bits }},
    +        {{ config.adapt_coeff }},
    +        {{ config.limit }}
    +    >
    +{%- endblock %}
    +
    +{% block benchmark_type %}
    +        using benchmark_type = device_topk_air_benchmark<key_type, value_type, config>;
    +{% endblock %}
    +
    +using key_type = {{ key_type }};

    yes

    NguyenNhuDi NguyenNhuDi commented on code on Sep 29, 2026 19:57 UTC
    Code Review
    projects/rocprim/tuning/confgen/templates/device_find_first_of.h.jinja2:1
    @@ -0,0 +1,19 @@
    +{% extends "common/base.h.jinja2" %}
    +
    +{% block target_tparams %}
    +template<class Target, class value_type>
    +{% endblock %}
    +
    +{% block config_guard scoped %}
    +    ({% if not type.value_type.is_floating %}!{% endif %}rocprim::is_floating_point<value_type>::value){% if type.value_type.size_min > 0 %} 

    yes

    amd-jmahovsky amd-jmahovsky approved these changes on Sep 30, 2026 18:01 UTC
    Approved Reviewer

    LGTM

    amd-mcieslak amd-mcieslak commented on Oct 01, 2026 15:04 UTC
    Contributor

    I checked 39eda1a directly. Both run-length-encode tuners fail on their first type, before anything is compiled:

        $ run_tuning.py --algo-regex run_length --max-fevals 1 --output-dir /tmp/out
    
        File "tuner/base_tuner.py", line 407, in _get_base_tune_kernel_args
            "restrictions": self._get_restrictions(types),
        File "tuner/tuning_device_run_length_encode.py", line 58, in _get_restrictions
            key_size = TYPE_CONFIGS[key_type].size
        TypeError: unhashable type: 'dict'
    

    Same at tuning_device_run_length_encode_non_trivial.py line 63.
    Can you please check?

    NguyenNhuDi NguyenNhuDi commented on Oct 01, 2026 17:52 UTC
    Author

    @amd-mcieslak thanks for pointing out that issue. It has now been fixed

    amd-mcieslak amd-mcieslak approved these changes on Oct 01, 2026 18:01 UTC
    Approved Reviewer

    LGTM

    therock-pr-bot[bot] therock-pr-bot[bot] commented on Oct 02, 2026 22:26 UTC
    Bot

    <!-- therock-pr-bot-precommit-failed -->

    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 commented on Oct 05, 2026 15:38 UTC
    Author

    closing in favor of #13007

    NguyenNhuDi NguyenNhuDi commented on Oct 15, 2026 16:09 UTC
    Author

    reopening cause hipccl might get nuked

    NguyenNhuDi NguyenNhuDi commented on Oct 15, 2026 17:12 UTC
    Author

    temp close to resolve some tests

    NguyenNhuDi NguyenNhuDi commented on Oct 15, 2026 18:13 UTC
    Author

    clsoing in favourof #13756

    Reviewers
    Assignees
    NguyenNhuDi NguyenNhuDi
    Labels
    risk: low confidence: 83.0% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 71.5% (HIGH) · Higher = larger blast radius
    71.5%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 83.0% · Lower = rushed or shallow review
    83.0%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 12.2% · Safe to merge
    12.2%