[cudax] __sharded: sort -- the MGMN distributed sort as the engine behind the sharded name - #6
Open
caugonnet wants to merge 17 commits into
Open
[cudax] __sharded: sort -- the MGMN distributed sort as the engine behind the sharded name#6caugonnet wants to merge 17 commits into
caugonnet wants to merge 17 commits into
Conversation
… the sharded name Two-tier end to end: the container tier manufactures the communicator/ environment/iterator/size ranges via bind_engine; the engine tier -- the __multi_gpu distributed sort -- owns the cross-place choreography and runs over in-process places unmodified, through the places communicator. The engine redistributes each rank's slice of the globally sorted sequence back to the rank's original element count, so shard sizes, offsets and capacities are unchanged by construction and the fixed-boundary contract of allocate_contiguous is preserved: sorting a contiguous sharded array leaves contiguous_data() reading as one globally sorted array. The engine slot is swappable behind the same name/contract (a future in-process placement-aware specialization is a performance change, not an API change). Tests: correctness vs std::sort over uniform/all-equal/pre-sorted/ reverse/duplicate-heavy distributions on uneven shards across 2 locality domains; custom comparator; shard metadata invariants (sizes, offsets, capacities, total preserved); contiguous arrays sorted and read back through the base pointer; repeated runs byte-identical (keys-only: the sorted multiset is unique); shape-mismatch refusal; empty no-op. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Stacked on #5 (review this diff against
sharded/communicator).sharded::sort(group, data, comp)— a global, in-place sort of a sharded array — completes the two-tier picture introduced in #5:bind_engine— engine temporaries come from each rank's environment, so scratch lands on the place whose rank uses it.__multi_gpudistributedsortruns over those ranges unmodified. The same MGMN construct that sorts across multi-process ranks sorts across in-process places, through the places communicator — the ladder's portability claim, exercised end to end.Contract
The engine delivers to each rank its slice of the globally sorted sequence, redistributed back to the rank's original element count. That composes exactly with the container's fixed-size contract: shard sizes, offsets and capacities are unchanged by construction, and — unlike the size-mutating compaction algorithms — contiguous (
allocate_contiguous) arrays are fully supported: after the sort,contiguous_data()reads as ONE globally sorted array through the base pointer. Sorting is not stable.The engine slot is deliberately swappable behind the same name and contract: a future in-process, placement-aware specialization would be a performance change, not an API change.
Tests (
cudax/test/sharded/algorithms/sort.cu, 2 locality domains)std::sortof the concatenated shards (byte-exact) over mixed distributions — uniform random, all-equal, pre-sorted, reverse-sorted, duplicate-heavy ints — on uneven shards (first shard ~2x the others, odd total);validate()clean after every sort;contiguous_data()as one plain array, byte-exact vs the sorted host reference;std::invalid_argumentbefore any engine work; empty arrays are a no-op.All places + sharded tests green on GB300 (sm_103a, CUDA 13.4, 2 locality domains): 28/28 ctest, built with
-Dcudax_ENABLE_NCCL=OFF.Design review with Andrei.
🤖 Generated with Claude Code