Add SM 12.0 tunings for keys-only DeviceBatchedTopK #11953
All Vouch review confidence checks passed
Residual risk 0.33 = Change Risk (0.59) × (1 − Review Confidence (0.45)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.59 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 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.344
Real PR Conversation Timeline
1 comments
"Review active on #11953"
general
weight: 0.35
elstehle
Description
DeviceBatchedTopKhas measured tunings for SM 10.0 and SM 10.3, but on SM 12.0 (GeForce / RTX PRO Blackwell) it runs the default policies. This PR adds SM 12.0 tunings for keys-only, non-deterministic requests, measured on an RTX 5090, plus a shared-memory reduction in the worker-per-segment agent.As agreed in review, the wave-aware cluster-width search that earlier versions of this PR added to the dispatch has been split out. It will come back as a separate PR, folded into the existing launch-shape search without a new tuning flag and measured across architectures.
dispatch_batched_topk.cuhnow differs frommainonly in the policy selector.Cluster backend (
make_sm120_keys_cluster_policy), used for segments above 8K keys withmax_kbelow the static maximum segment size:- up to 16K keys: 10 bits, with the single-CTA path extended to 16K;
- up to 512K: 9 bits;
- [512K, 1M): 8 bits;
- [1M, 2M): 11 bits;
- 2M and above: 8 bits.
Baseline (one worker per segment) backend (
make_sm120_baseline_policy): the default worker shapes. Tiles of up to 1Ki keys use vectorized loads and direct stores, the 2Ki tile uses vectorized loads, and 4Ki and larger tiles keep the default warp-transpose loads and stores. The larger tiles were faster that way for decode-style batches with few segments and large k.Gating: the new policies apply only when the request is keys-only, uses
determinism::not_guaranteedwithtie_break::unspecified, and runs on exactlycompute_capability{12, 0}. Pairs, deterministic and explicit tie-break requests, and every other compute capability keep their current policies.Changes outside SM 12.0:
policy_selector_from_typesnow evaluates the baseline-coverage check for the baseline policy it actually returns, so the baseline policy can vary per CC. Instead of folding over the target CCs as theTODO(bgruber)suggested, it evaluates coverage for each named baseline policy. That removes the invariant the old comment described, and the TODO now covers only the fully general per-CC case.Performance: RTX 5090, CUDA 13.2, against current
mainf32 keys, nvbench
nv/cold/time/gpu/mean, speedup =main/ PR. Every run was made one at a time with at least two interleavedmain/PR rounds.segmented_topk.fixed.keys.base(segments of 64–1024 keys, 2^28 elements): 1.17x geomean over 19 configurations, 1.02x to 1.24x, none slower.segmented_topk.variable.keys.base(random pattern, k = 512, 1024, 2048; 1/4/16/64/256 segments). The 16K–1M segment sizes are disabled in the checked-in benchmark; I enabled them locally to reach the cluster tables.| max segment size | 1 seg | 4 segs | 16 segs | 64 segs | 256 segs | all |
|---|---|---|---|---|---|---|
| 512 | 1.006 | 1.000 | 1.003 | 1.010 | 1.118 | 1.026 |
| 1K | 1.000 | 1.000 | 1.001 | 1.011 | 1.032 | 1.009 |
| 2K | 1.000 | 1.007 | 1.008 | 1.003 | 1.016 | 1.007 |
| 4K | 1.000 | 1.000 | 1.001 | 1.002 | 1.001 | 1.001 |
| 8K | 1.007 | 1.002 | 1.005 | 1.000 | 1.000 | 1.003 |
| 16K | 1.125 | 1.169 | 0.998 | 1.169 | 1.192 | 1.128 |
| 32K | 1.168 | 1.056 | 1.127 | 1.181 | 1.220 | 1.149 |
| 64K | 1.353 | 1.226 | 1.723 | 1.360 | 1.932 | 1.497 |
| 128K | 1.167 | 1.065 | 1.242 | 1.126 | 1.116 | 1.142 |
| 256K | 1.152 | 1.137 | 1.153 | 1.154 | 1.116 | 1.142 |
| 512K | 1.244 | 1.304 | 1.165 | 1.229 | 1.191 | 1.226 |
| 1M | 1.002 | 1.043 | 1.001 | 0.995 | 1.001 | 1.008 |
Correctness
-Xptxas -warn-double-usagereports no double-precision instructions in the top-k code.History
catch2_test_device_batched_topk_sm120_tuning.cuwas removed inbae4813eaat review request. It was also the source of the earlier CI failures (constant-expression errors on CTK 12.0, MSVC C4127, and the CTK 12.9 GCC 7 build timeout).main. The baseline table now applies those settings per tile size, as described above.Notes for reviewers
cc == {12, 0}rather than>= 12.0.Checklist
🤖 Generated with Claude Code