Skip to content

[ROCm] Batch the single-block topk gather and shorten its warp scan - #199848

Closed
pruthvistony wants to merge 3 commits into
pytorch:mainfrom
ROCm:jeffdaily/rocm-topk-gather-batched
Closed

pruthvistony wants to merge 3 commits into
pytorch:mainfrom
ROCm:jeffdaily/rocm-topk-gather-batched

Conversation

@pruthvistony

@pruthvistony pruthvistony commented Oct 5, 2026 •

Copy link
Copy Markdown
Collaborator

Performance improvement for topK on ROCm.

#199425 made ROCm's single-block gatherTopK deterministic with an ordered per-warp exchange that costs a barrier and a shuffle scan per gather iteration. On MI355X that left the path 2 to 4% behind the old atomicAdd kernel.

This makes the exchange cheaper and less frequent while keeping the output order and tie choice unchanged. The cross-warp scan uses readlane broadcasts on all non-SPIR-V targets, plus DPP row adds on GFX9; wave32 and SPIR-V keep a shuffle scan. Slices longer than the block run four block-strided sub-iterations per barrier, with two 16-bit counts per LDS word. Elements equal to the k-th value are ranked during phase 1, so phase 2 skips its second pass over the slice unless a thread holds more than two of them.

The kernel was generated with AMD's GEAK optimization workflow driving Claude, against a harness that required output bit-identical to #199425 and compiled every candidate for gfx950, gfx1100, gfx1151 and amdgcnspirv.

With #171940's benchmark, the single-block configurations are 1.09x faster than #199425 on MI355X (gfx950), about 5% ahead of the atomicAdd kernel, and 1.04x faster on Radeon Pro W7800 (gfx1100). Multi-block and sort paths are unchanged.

Test Plan

test_topk_deterministic_ties now also covers slices longer than the block, with both heavy and light ties, which reach the multi-round gather and the phase-2 fallback. Outside the test suite, output was bit-identical to #199425 on 384 seeded configurations on gfx950 and gfx1100.

python test/test_sort_and_select.py -k topk
python test/test_torch.py -k topk

This PR was authored with the help of Claude (AI assistant).
Author - Jeff Daily [email protected]

cc @jeffdaily @sunway513 @jithunnair-amd @ROCmSupport @jataylo @hongxiayang @naromero77amd @pragupta @jerrymannil @xinyazhang

pytorch#199425 made ROCm's single-block gatherTopK deterministic with an ordered per-warp exchange. That exchange costs a barrier and a shuffle scan per gather iteration, leaving the path about 4% behind the old atomicAdd kernel and about 10% behind on long slices.

This pays for the exchange less often and more cheaply. Each barrier round now covers four block-strided sub-iterations, with two 16-bit counts per LDS word. The cross-warp scan uses DPP row adds and readlane on GFX9, and wave32 and SPIR-V keep the shuffle scan. Elements equal to the k-th value are ranked during phase 1, so phase 2 normally skips its second pass over the slice. Output order and tie choice are unchanged.

The kernel was generated with AMD's GEAK optimization workflow driving Claude. The harness required output bit-identical to pytorch#199425 and compiled every candidate for gfx950, gfx1100, gfx1151 and amdgcnspirv.

With pytorch#171940's benchmark, the single-block configurations are 1.13x faster than pytorch#199425 on MI355X (gfx950), at parity with the previous atomicAdd kernel, and 1.04x faster on Radeon Pro W7800 (gfx1100). Multi-block and sort paths are unchanged.

## Test Plan

Output is bit-identical to pytorch#199425 on 384 seeded configurations covering fp32, fp16 and bf16, random and tie-heavy inputs, and sorted and unsorted results. A 50-rerun determinism check is clean. Both were run on gfx950 and gfx1100.

    python test/test_sort_and_select.py -k topk
    python test/test_torch.py -k topk

This PR was authored with the help of Claude (AI assistant).
…lices

Remove the unreachable phase-2 call in the single-round path and the unused writeResult parameter, derive kFlagOverflow from the round shape instead of passing it, trim tuning notes from the design comment, and extend test_topk_deterministic_ties to slices longer than the block so the multi-round gather and the phase-2 fallback are exercised.

Authored with Claude.
@pytorch-bot pytorch-bot Bot added the module: rocm AMD GPU support for Pytorch label Oct 5, 2026
@pytorch-bot

pytorch-bot Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/199848

Note: Links to docs will display an error until the docs builds have been completed.

❌ You can merge normally! (5 Unrelated Failures), 9 Unclassified Failures

As of commit f9f3fe1 with merge base 44e8a35 (image):

NEW FAILURES SUPPRESSED BY AI (non-blocking) - The following jobs failed, but the AI CI Advisor judged the failures not to be evidence against this change:

UNCLASSIFIED FAILURES - DrCI could not classify the following jobs because the workflow did not run on the merge base. The failures may be pre-existing on trunk or introduced by this PR:

FLAKY - The following jobs failed but were likely due to flakiness present on trunk:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@pruthvistony pruthvistony added topic: not user facing topic category ciflow/op-benchmark Trigger microbenchmark for operations. rocm This tag is for PRs from ROCm team ciflow/rocm-mi300 Trigger "default" config CI on ROCm MI300 ciflow/rocm-mi200 Trigger "default" config CI on ROCm MI200 ciflow/rocm-mi350 Trigger "default" config CI on ROCm MI350 runners labels Oct 5, 2026
@pytorch-bot

pytorch-bot Bot commented Oct 5, 2026

Copy link
Copy Markdown

Warning: Unknown label ciflow/rocm-mi350.
Currently recognized labels are

  • ciflow/b200
  • ciflow/b200-distributed
  • ciflow/b200-symm-mem
  • ciflow/binaries
  • ciflow/binaries_libtorch
  • ciflow/binaries_wheel
  • ciflow/docker
  • ciflow/dtensor
  • ciflow/h100
  • ciflow/h100-cutlass-backend
  • ciflow/h100-distributed
  • ciflow/h100-symm-mem
  • ciflow/inductor
  • ciflow/inductor-cu126
  • ciflow/inductor-micro-benchmark
  • ciflow/inductor-micro-benchmark-cpu-x86
  • ciflow/inductor-pallas
  • ciflow/inductor-perf-compare
  • ciflow/inductor-perf-test-nightly-rocm-mi300
  • ciflow/inductor-perf-test-nightly-rocm-mi350
  • ciflow/inductor-perf-test-nightly-x86-zen
  • ciflow/inductor-perf-test-nightly-xpu
  • ciflow/inductor-periodic
  • ciflow/inductor-rocm-mi200
  • ciflow/inductor-rocm-mi300
  • ciflow/mps
  • ciflow/native-aot
  • ciflow/nightly
  • ciflow/op-benchmark
  • ciflow/periodic
  • ciflow/periodic-rocm-mi200
  • ciflow/periodic-rocm-mi300
  • ciflow/periodic-rocm-mi350
  • ciflow/periodic-strict
  • ciflow/pull
  • ciflow/riscv64
  • ciflow/rocm-mi200
  • ciflow/rocm-mi300
  • ciflow/rocm-nightly
  • ciflow/rocm-preview
  • ciflow/rocm-rx7900
  • ciflow/s390
  • ciflow/slow
  • ciflow/slow-rocm-mi200
  • ciflow/torchtitan
  • ciflow/triton_binaries
  • ciflow/trunk
  • ciflow/tsan
  • ciflow/unstable
  • ciflow/win-arm64
  • ciflow/xpu

Please add the new label to .github/pytorch-probot.yml

@pruthvistony
pruthvistony requested a review from jeffdaily October 5, 2026 23:01
@github-actions github-actions Bot added bot-triaged This is a label only to be used by the auto triage bot triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module labels Oct 5, 2026
@eqy
eqy removed their request for review October 6, 2026 15:10
The phase-1 bound check now runs before the round writes its slots, so a bad k-th value from radixSelect trips the assert before any out-of-bounds store. The deterministic-ties test also runs each case on the transposed tensor along dim=0, which exercises the in-slice stride math of the multi-round gather.

Test Plan (MI355X, gfx950):

```
python test/test_sort_and_select.py -k topk
python test/test_torch.py -k topk
```

Authored with the help of Claude (AI assistant).
@jeffdaily jeffdaily added ciflow/rocm-rx7900 Trigger "default" config CI on ROCm RX7900 Radeon (Navi31/gfx1100) GPUs ciflow/trunk Trigger trunk jobs on your pull request release notes: rocm mandatorylabel module: performance Issues related to performance, either of kernel code or framework glue and removed topic: not user facing topic category labels Oct 6, 2026

@jeffdaily jeffdaily left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Besides CI on mi200/mi300/mi350/rx7900, the gather was checked in a standalone harness against a CPU reference of the tie rule: native gfx950, native gfx1100, and the amdgcnspirv build JIT-finalized on both (running as wave64 and wave32) all pass 352/352 with identical output.

@jeffdaily

Copy link
Copy Markdown
Collaborator

@pytorchbot merge -i

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged while ignoring the following 14 checks: rocm-mi200 / linux-jammy-rocm-py3.11-mi200 / test (default, 1, 10, linux.rocm.gpu.mi210.1), operator_microbenchmark / opmicrobenchmark-test-b200 / test (operator_microbenchmark_matmul_test, 1, 1, linux.dgx.b200), operator_microbenchmark / opmicrobenchmark-test-b200 / test (operator_microbenchmark_scaled_mm_test, 1, 1, linux.dgx.b200), operator_microbenchmark / opmicrobenchmark-test-b200 / test (operator_microbenchmark_optimizer_test, 1, 1, linux.dgx.b200), operator_microbenchmark / opmicrobenchmark-test-b200 / test (operator_microbenchmark_conv_test, 1, 1, linux.dgx.b200), operator_microbenchmark / opmicrobenchmark-test-b200 / test (operator_microbenchmark_activation_test, 1, 1, linux.dgx.b200), operator_microbenchmark / opmicrobenchmark-test-b200 / test (operator_microbenchmark_bmm_test, 1, 1, linux.dgx.b200), operator_microbenchmark / opmicrobenchmark-test-b200 / test (operator_microbenchmark_addmm_test, 1, 1, linux.dgx.b200), operator_microbenchmark / opmicrobenchmark-test-b200 / test (operator_microbenchmark_norm_test, 1, 1, linux.dgx.b200), operator_microbenchmark / opmicrobenchmark-test-b200 / test (operator_microbenchmark_mm_test, 1, 1, linux.dgx.b200), operator_microbenchmark / opmicrobenchmark-test-b200 / test (operator_microbenchmark_scaled_grouped_mm_test, 1, 1, linux.dgx.b200), attention_op_microbenchmark / attention-microbenchmark-test-b200 / test (attention_microbenchmark_test, 1, 1, linux.dgx.b200), operator_benchmark / x86-opbenchmark-test / test (cpu_operator_benchmark_short, 1, 1, mt-l-x86iavx512-48-384), operator_benchmark / aarch64-opbenchmark-test / test (cpu_operator_benchmark_short, 1, 1, mt-l-arm64g4-16-62)

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

cyyever pushed a commit to BakeLab/pytorch that referenced this pull request Oct 11, 2026
…ytorch#199848)

Performance improvement for topK on ROCm.

pytorch#199425 made ROCm's single-block gatherTopK deterministic with an ordered per-warp exchange that costs a barrier and a shuffle scan per gather iteration. On MI355X that left the path 2 to 4% behind the old atomicAdd kernel.

This makes the exchange cheaper and less frequent while keeping the output order and tie choice unchanged. The cross-warp scan uses readlane broadcasts on all non-SPIR-V targets, plus DPP row adds on GFX9; wave32 and SPIR-V keep a shuffle scan. Slices longer than the block run four block-strided sub-iterations per barrier, with two 16-bit counts per LDS word. Elements equal to the k-th value are ranked during phase 1, so phase 2 skips its second pass over the slice unless a thread holds more than two of them.

The kernel was generated with AMD's GEAK optimization workflow driving Claude, against a harness that required output bit-identical to pytorch#199425 and compiled every candidate for gfx950, gfx1100, gfx1151 and amdgcnspirv.

With pytorch#171940's benchmark, the single-block configurations are 1.09x faster than pytorch#199425 on MI355X (gfx950), about 5% ahead of the atomicAdd kernel, and 1.04x faster on Radeon Pro W7800 (gfx1100). Multi-block and sort paths are unchanged.

## Test Plan

`test_topk_deterministic_ties` now also covers slices longer than the block, with both heavy and light ties, which reach the multi-round gather and the phase-2 fallback. Outside the test suite, output was bit-identical to pytorch#199425 on 384 seeded configurations on gfx950 and gfx1100.

```
python test/test_sort_and_select.py -k topk
python test/test_torch.py -k topk
```

This PR was authored with the help of Claude (AI assistant).
Author - Jeff Daily <[email protected]>

Pull Request resolved: pytorch#199848
Approved by: https://github.com/jeffdaily

Co-authored-by: Jeff Daily <[email protected]>
jeffdaily added a commit to ROCm/pytorch that referenced this pull request Oct 12, 2026
Picks up pytorch#199848 and pytorch#199947, which postdate the branch base. Clean merge, no conflicts.
jeffdaily added a commit to ROCm/pytorch that referenced this pull request Oct 12, 2026
radixSelectRegs' lanesBelow and the single-block topk gather's laneRank (from pytorch#199848) are the same mbcnt helper. TensorTopK.cu includes SortingRadixSelect.cuh, so this keeps one copy there under the name laneRank and drops the one in TensorTopK.cu. No behavior change: the gfx950 device code object in libtorch_hip.so is byte-identical with and without this commit.

Test Plan:

```
python test/test_sort_and_select.py -k topk -k kthvalue
python test/test_ops.py -k _median_cuda -k _topk_cuda -k _kthvalue_cuda
```

Written with Claude.
pytorchmergebot pushed a commit that referenced this pull request Oct 12, 2026
## Linked issue or supporting maintainer

Supported by @jeffdaily

## Summary

radixSelect finds the k-th value for topk, kthvalue, median and nanmedian. Its ROCm version re-reads the slice (from global memory, or from its 3 KB shared-memory cache once the candidates fit) on every 2-bit radix pass, and spends two barriers per pass combining per-warp counts, so the single-block kernels are dominated by its serial latency.

This keeps slices of up to REGS_MAX_E x blockDim elements in registers for the whole selection, loaded and converted once (REGS_MAX_E is 20 on GFX9 and 14 elsewhere, which keeps wave32 kernels at 16 waves per SIMD). 1-byte types off GFX9 keep the general path, which was faster for them on gfx1100. For k <= 16 from either end, a pre-pass bounds the answer with the per-wave maxima and ranks the few candidates directly, falling back to the radix walk when too many keys tie. On GFX9 the per-pass count combine uses one barrier with DPP adds; other targets keep the two-barrier combine, which is cheaper there with 32 warps per block. The general path, still used for 8-byte types and longer slices, also gets cheaper. Only ROCm code in SortingRadixSelect.cuh changes.

A note at the top of the register-path section explains which path runs for which dtype, slice length and k, lists the steps of the register path (labeled sections of radixSelectRegs), and maps them to the test cases. The features, in suggested review order:

| Feature | Lines (approx.) | What it does | Covered by |
|---|---|---|---|
| Path choice, in radixSelect's ROCm branch | 20 | Picks the register path and its rows per thread E from the dtype and slice length | test_select_ties_at_dtype_extremes (slice lengths at each E boundary; uint8/int8 take the general path on wave32) |
| Register path, steps 1 and 4: load once, radix walk over the held keys, one-time compaction of the survivors | 400 | Removes the per-pass re-read and re-convert; most of the speedup | the new test and the existing topk, kthvalue and median tests |
| Step 2, k = 1 (or n): one block-wide max reduction | 20 | Answers without a radix walk | the new test, k = 1 and n |
| Step 3, k <= 16 from either end: threshold pre-pass | 290 | Answers small k from a few candidates; heavy ties fall back to the walk | the new test: k = 2 to 17 and mirrors, few-distinct-value rows, 8-bit ties at the maximum |
| GFX9 only: 16-bin counting with DPP and LDS atomics | 170 | Halves the passes on wave64 | every register-path test on GFX9 |
| General path: one-barrier findPattern, remaining count in registers, no refill once done | 190 | Faster 8-byte types and long slices | the existing topk, kthvalue and median tests |

The register path was generated with AMD's GEAK optimization workflow driving Claude, then ported, fixed for signed and 64-bit index types, 8-byte types and wave32 shared-memory bounds, tuned for wave32 on gfx1100, and documented for review.

Geomean speedup over main, single-block configurations of #171940's topk benchmark (48) and of a kthvalue/median matrix (24 each):

| | topk | kthvalue | median |
|---|---|---|---|
| MI355X (gfx950) | 2.14x | 3.20x | 2.90x |
| Radeon Pro W7800 (gfx1100) | 1.43x* | 1.68x | 1.67x |

\* gfx1100 topk was measured with #199848's gather on both sides.

On gfx950, int64 and float64 kthvalue and median are 1.36x and 1.44x faster. Multi-block and sort paths are unchanged. No benchmarked single-block configuration is slower than main on either GPU.

## Test Plan

New test_select_ties_at_dtype_extremes checks topk, kthvalue, median and nanmedian values exactly against CPU for seven dtypes, with ties at the dtype minimum, maximum and NaN, contiguous and strided slices at each register-path size, k at each step boundary, small-k candidate counts at both ends of each of the pre-pass's ranking methods, and tie-heavy rows that overflow the small-k pre-pass. Outside the test suite, returned values were bit-identical to main on 12,198 configurations (nine dtypes, slices of 257 to 300,000 elements, random, tie-heavy and special values, contiguous and strided), and a randomized comparison against CPU over the same edges matched main on every case, on gfx950 and gfx1100. Indices are unchanged: topk and kthvalue derive them from the selected value, and since #199947 median and nanmedian return the first occurrence of the median value, so identical values give identical indices.

```
python test/test_sort_and_select.py -k topk
python test/test_sort_and_select.py -k kthvalue
python test/test_sort_and_select.py -k test_select_ties_at_dtype_extremes
python test/test_reductions.py -k median
python test/test_ops.py -k _topk_cuda
python test/test_ops.py -k _kthvalue_cuda
python test/test_ops.py -k _median_cuda
```

This PR was authored with the help of Claude (AI assistant).

Pull Request resolved: #200328
Approved by: https://github.com/jeffdaily

Co-authored-by: Jeff Daily <[email protected]>
jeffdaily added a commit to ROCm/pytorch that referenced this pull request Oct 14, 2026
pytorch#200328 was reverted because the new ROCm helpers in SortingRadixSelect.cuh call max and min unqualified inside namespace at::native. When <ATen/ATen.h> or <torch/torch.h> is included first, unqualified lookup stops at the at::native::max and at::native::min Tensor overloads, so the HIP global overloads are never considered and the build fails with "no matching function for call to 'max'". OSS never includes the header in that order; Meta-internal ROCm builds do.

All 26 calls in the header are now ::max and ::min, the overloads they already resolve to in OSS, so the generated code is unchanged. Three unqualified min calls in the topk gather in TensorTopK.cu (from pytorch#199848) have the same problem when the whole file is compiled after ATen.h and are qualified the same way. No other unqualified call in these files collides with an ATen operator name.

Test Plan

On gfx950 (wave64, GFX9 branches) and gfx1100 (wave32, non-GFX9 branches): built with `pip install -e . -v --no-build-isolation`, then compiled the hipified TensorTopK and Sorting sources with the build's own compile flags plus -fsyntax-only, preceded by <ATen/ATen.h>, <ATen/NativeFunctions.h> and <torch/torch.h>. Before the change this fails with the errors from the revert; after it, both compile clean. TensorTopK objects are byte-identical before and after (ignoring the per-compile cuid). Tests, all passing:

```
python test/test_sort_and_select.py -k topk
python test/test_sort_and_select.py -k kthvalue
python test/test_sort_and_select.py -k test_select_ties_at_dtype_extremes
python test/test_reductions.py -k median
python test/test_ops.py -k _topk_cuda
python test/test_ops.py -k _kthvalue_cuda
python test/test_ops.py -k _median_cuda
```

Authored with Claude.
pytorchmergebot pushed a commit that referenced this pull request Oct 15, 2026
## Linked issue or supporting maintainer

Supported by @jeffdaily

## Summary

radixSelect finds the k-th value for topk, kthvalue, median and nanmedian. Its ROCm version re-reads the slice (from global memory, or from its 3 KB shared-memory cache once the candidates fit) on every 2-bit radix pass, and spends two barriers per pass combining per-warp counts, so the single-block kernels are dominated by its serial latency.

This keeps slices of up to REGS_MAX_E x blockDim elements in registers for the whole selection, loaded and converted once (REGS_MAX_E is 20 on GFX9 and 14 elsewhere, which keeps wave32 kernels at 16 waves per SIMD). 1-byte types off GFX9 keep the general path, which was faster for them on gfx1100. For k <= 16 from either end, a pre-pass bounds the answer with the per-wave maxima and ranks the few candidates directly, falling back to the radix walk when too many keys tie. On GFX9 the per-pass count combine uses one barrier with DPP adds; other targets keep the two-barrier combine, which is cheaper there with 32 warps per block. The general path, still used for 8-byte types and longer slices, also gets cheaper. Only ROCm code in SortingRadixSelect.cuh changes.

A note at the top of the register-path section explains which path runs for which dtype, slice length and k, lists the steps of the register path (labeled sections of radixSelectRegs), and maps them to the test cases. The features, in suggested review order:

| Feature | Lines (approx.) | What it does | Covered by |
|---|---|---|---|
| Path choice, in radixSelect's ROCm branch | 20 | Picks the register path and its rows per thread E from the dtype and slice length | test_select_ties_at_dtype_extremes (slice lengths at each E boundary; uint8/int8 take the general path on wave32) |
| Register path, steps 1 and 4: load once, radix walk over the held keys, one-time compaction of the survivors | 400 | Removes the per-pass re-read and re-convert; most of the speedup | the new test and the existing topk, kthvalue and median tests |
| Step 2, k = 1 (or n): one block-wide max reduction | 20 | Answers without a radix walk | the new test, k = 1 and n |
| Step 3, k <= 16 from either end: threshold pre-pass | 290 | Answers small k from a few candidates; heavy ties fall back to the walk | the new test: k = 2 to 17 and mirrors, few-distinct-value rows, 8-bit ties at the maximum |
| GFX9 only: 16-bin counting with DPP and LDS atomics | 170 | Halves the passes on wave64 | every register-path test on GFX9 |
| General path: one-barrier findPattern, remaining count in registers, no refill once done | 190 | Faster 8-byte types and long slices | the existing topk, kthvalue and median tests |

The register path was generated with AMD's GEAK optimization workflow driving Claude, then ported, fixed for signed and 64-bit index types, 8-byte types and wave32 shared-memory bounds, tuned for wave32 on gfx1100, and documented for review.

Geomean speedup over main, single-block configurations of #171940's topk benchmark (48) and of a kthvalue/median matrix (24 each):

| | topk | kthvalue | median |
|---|---|---|---|
| MI355X (gfx950) | 2.14x | 3.20x | 2.90x |
| Radeon Pro W7800 (gfx1100) | 1.43x* | 1.68x | 1.67x |

\* gfx1100 topk was measured with #199848's gather on both sides.

On gfx950, int64 and float64 kthvalue and median are 1.36x and 1.44x faster. Multi-block and sort paths are unchanged. No benchmarked single-block configuration is slower than main on either GPU.

## Test Plan

New test_select_ties_at_dtype_extremes checks topk, kthvalue, median and nanmedian values exactly against CPU for seven dtypes, with ties at the dtype minimum, maximum and NaN, contiguous and strided slices at each register-path size, k at each step boundary, small-k candidate counts at both ends of each of the pre-pass's ranking methods, and tie-heavy rows that overflow the small-k pre-pass. Outside the test suite, returned values were bit-identical to main on 12,198 configurations (nine dtypes, slices of 257 to 300,000 elements, random, tie-heavy and special values, contiguous and strided), and a randomized comparison against CPU over the same edges matched main on every case, on gfx950 and gfx1100. Indices are unchanged: topk and kthvalue derive them from the selected value, and since #199947 median and nanmedian return the first occurrence of the median value, so identical values give identical indices.

```
python test/test_sort_and_select.py -k topk
python test/test_sort_and_select.py -k kthvalue
python test/test_sort_and_select.py -k test_select_ties_at_dtype_extremes
python test/test_reductions.py -k median
python test/test_ops.py -k _topk_cuda
python test/test_ops.py -k _kthvalue_cuda
python test/test_ops.py -k _median_cuda
```

This PR was authored with the help of Claude (AI assistant).

Pull Request resolved: #200328
Approved by: https://github.com/jeffdaily

Co-authored-by: Jeff Daily <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot-triaged This is a label only to be used by the auto triage bot ciflow/op-benchmark Trigger microbenchmark for operations. ciflow/rocm-mi200 Trigger "default" config CI on ROCm MI200 ciflow/rocm-mi300 Trigger "default" config CI on ROCm MI300 ciflow/rocm-mi350 Trigger "default" config CI on ROCm MI350 runners ciflow/rocm-rx7900 Trigger "default" config CI on ROCm RX7900 Radeon (Navi31/gfx1100) GPUs ciflow/trunk Trigger trunk jobs on your pull request Merged module: performance Issues related to performance, either of kernel code or framework glue module: rocm AMD GPU support for Pytorch open source release notes: rocm mandatorylabel rocm This tag is for PRs from ROCm team triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants