Repository navigation
sort/argsort/topk tie order matches upstream on libc++ platforms (#33) - #82
Merged
Merged
Conversation
…droid (#33) Upstream's unstable sort is its C++ runtime's std::sort over (value, index): insertion sort below 24 elements, introsort above, so long tied rows come back permuted; topk is partial_sort when k*64 <= n, else nth_element (+ a sort of the first k-1 when sorted). libcxx_sort.rs transcribes those; the cpu path uses them where libc++ is upstream's runtime (Apple, Android). Linux and Windows keep the stable order: a named divergence from their own upstream, #81. Also adds aten.sort.stable (was NotImplementedError) and refuses topk on bool, as upstream does on cpu. tests/ops/test_sortties.py: 22,728 cells measured on upstream macOS arm64; 10,719 red before, all green after; forcing the stable order back turns 5 tests red. Golden 12255/12255 with tie-heavy cases (exact order on libc++ hosts, values and pairing elsewhere). The mps readback set is 90 (README, STATUS).
Member
Author
|
Paused (user's instruction). CI run 37352766424 still in progress at pause; not yet checked. |
… only (#33, #81) CI run 37352766424 (linux) failed SELF-TEST on exactly that pair: off a libc++ host the tie check falls back to values and pairing, which a lockstep permutation passes. The BLIND_BY_DESIGN entry is added only when _LIBCXX_HOST is False, so on macOS the fault must still be caught (it is; self-test PASS), and a simulated linux run passes with that one declared blindness.
Contributor
Gate on CI (issue #24)Full gate: 130 suites = 122 run on at least one CI runner + 8 local-only. The local gate (
Local-only: verified by no CI runner (8)
Suites that verified nothing, or failed, on a runner
Every suite, every runner
A SKIP is unverified on that runner, never passed. UNVERIFIED means the suite ran and every one of its tests skipped by name. |
# Conflicts: # .github/scripts/gate_suites.py # tests/golden/cases.py # tests/golden/test_x86pins.py
3 tasks
b-re-w
added a commit
that referenced
this pull request
Oct 16, 2026
Conflicts: the mps host-readback count. develop's #82 (#33) added aten.sort.stable (89 -> 90) and this branch moved index.Tensor and gather onto the device (89 -> 87), so the merged count is 88: MPS_HOST_READBACK_OPS [&str; 88] (the compiler checks the length), README, README_ko, STATUS.md and matrix.md section 7.19 say so. Rebuilt: test_shim (readback derivation), test_mpsindex, test_mpscb, test_sortties, test_remeasure2, test_cuda ok; golden 12515/12515.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #33. Opens #81 for Linux (libstdc++) and Windows (MSVC STL).
Defect fixed
sort,argsortandtopkorder tied values exactly as upstream does. Upstream uses libc++'sstd::sort/partial_sort/nth_element, transcribed inlibcxx_sort.rs.topkon bool now refuses, as upstream does on cpu.Feature added
aten.sort.stable. It raised NotImplementedError before.Not a match (named)
test_sorttiesskips its libc++-order tests by name there.Test added
tests/ops/test_sortties.py, 13 tests over 22,728 cells measured on upstream (macOS arm64):OrderAlgo::Stableback turns 5 tests red (2,000 cells).tests/ops/sortties_oracle.jsonis 3.7 MB.Documentation corrected
aten.sort.stablereads back likesort.default. Updated in README, README_ko and STATUS.sort.stableon mps. The gate showed that claim was unverified, so it was removed.Gate (worktree, local)
build.pyself-tests that need.caches/.Not done
read_flat.multinomial's andunique's internal sorts are untouched.