fix(rocprim): kernel tuner tuning template and device benchmark fixes #15571
All Vouch review confidence checks passed
Residual risk 0.23 = Change Risk (0.57) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.57 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
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.388
Shallow Review Depth
shallow_review_depth
0.289
Ai Authored
ai_authored
0.050
Real PR Conversation Timeline
1 comments
"Review active on #15571"
general
weight: 0.35
amd-jmahovsky
Motivation
While auto-tuning gfx950 in #14598, we compared the tuned configs against develop. About 400 benchmark cases came out flat or slower. We traced them to bugs in the rocPRIM benchmarks and the Kernel Tuner rather than to the configs themselves. They fall into three groups:
1. Configs that measured the same: some benchmarks never passed the tuned config to rocPRIM, so every candidate ran the default config.
2. Search too narrow: the tuner tried only a small fraction of the valid configs, some of which then failed at runtime.
3. Tuned at one problem shape: the tuner timed one input shape and size, while the benchmarks sweep many.
This PR should be merged before #14598. The gfx950 configs in #14598 need to be re-tuned with these fixes.
## Technical Details
### Group 1: Configs that measured the same
1.
adjacent_differenceandhistogrambenchmarks ignoredConfigbenchmark_device_adjacent_difference.hppcalledcommon::dispatch_adjacent_differencewithout<Config>.benchmark_device_histogram.hppcalledhistogram_even,multi_histogram_even,histogram_rangeandmulti_histogram_rangewithout it. Every tuning candidate therefore randefault_configand timed the same (1.00–1.02× spread). Fixed by passingConfigto both the temp-storage query and the timed call. The histogrammeta()labels now report the real config instead of"default".2.
segmented_topk_airnever launched a kernelMinSegmentLengthdefaulted to 0, sok = min_segment_length / 2was always 0. rocPRIM returns early whenK == 0, so the benchmark timed an empty call and reported ~26 TB/s.- The default minimum is now 100, with
static_asserts requiring a minimum of at least 2 and no larger than the maximum.-
generate_offsetsmerges a too-short tail into the previous segment.- Results for this benchmark are not comparable with develop.
3. Histogram tuner shapes and scoring
- The tuner now uses the benchmark's per-type bin scale instead of 1. The scale changes how low-entropy inputs spread across bins, and so how much atomic contention there is.
- int128 uses the benchmark's 16 × 16 and 256 × 1 shapes.
- Configs are scored by the geometric mean of time instead of the mean of bytes per second.
### Group 2: Search too narrow
4.
merge_sort_block_mergemeasured a different config from the one it emittedThe template timed
<bs, ipt, 0, 128, bs, ipt>, while the tuner recorded, and confgen emitted, odd-even256 / 1 / 201072. The template now builds the config from the recorded parameters.5.
merge_sort_block_mergeinfresultsThe benchmark's default-config pre-sort produces blocks smaller than any merge tile above 1024 items. rocPRIM then returns
hipErrorAssert, the benchmark skips timing, and the tuner recordsinf. confgen discards those configs anyway. The restriction now requiresblock_size * ipt <= 1024, which removes everyinfand leaves 10 configs per type, small enough forbrute_force.6.
select_unique_by_keytemplate did not compileThere was no
benchmark_typeoverride, so the template referenced a benchmark class that doesn't exist. It now usesdevice_select_unique_by_key_benchmark.7.
radix_sort_onesweepLDS probe7.
radix_sort_onesweepLDS probeiptit tested, even after a failure, and accepted every smalleript. That let oversized configs through, giving 123CompilationFailedConfigentries. It now caches both the largestiptthat fit and the smallest that didn't.ipt, but the onesweep kernel's LDS is sized bysort_ipt.8.
--param-overridesfor staged tuningKernel Tuner counts repeat visits and cache hits against
max_fevals, so dual_annealing tried only ~38 distinct configs per type in segmented_radix_sort's ~1.1M-config space. The new flag takes a JSON object that replaces parameter value lists. A value of"best"pins a parameter, for each type, to its best cached result, which allows staged brute-force tuning. Parameter names and order are unchanged, so existing caches stay compatible.run_tuning.pynow also forwards--save-metadata.Group 3: Tuned at one problem shape
9. Geometric mean as the default score
The base template scores a config by the geometric mean of ms/GiB over all queued benchmarks, so each shape counts equally. With one queued benchmark this is just its time. Six duplicate
get_timeoverrides were removed. search_n, adjacent_find and run_length_encode previously used an arithmetic mean, which let the slowest shape decide.10. Tuner shapes now match the benchmarks
11. Tuning size matches the benchmark
adjacent_difference (and in-place) and search_n now tune at 2 GiB, and reduce at 512 MiB. All were previously tuned at 128 MiB.
Test Plan
benchmark_device_segmented_topk_air.cppfor gfx950.Test Results
Submission Checklist
🤖 Generated with Claude Code