Repository navigation
Sort with many chares per GPU - #26
Open
AdvaitTahilyani wants to merge 8 commits into
Open
AdvaitTahilyani wants to merge 8 commits into
AdvaitTahilyani wants to merge 8 commits into
Conversation
With ~1,900 chares the sample sort still sent P buckets from every chare (P^2 piece and count messages): 2e9 elements at CNUM_ODF=2048 on one GPU ran past 300 s, and the same chare count on CPU took 8 s per sort. Above 64 participants the buckets now go to the first chare of each PE (at most 256); splitters sit at those chares' tile starts, so the sorted runs mostly land on the same PE, and chares without a bucket only wait for their result tile. The CPU case drops to 0.4 s; on one A100 the run completes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
adityapb
reviewed
Nov 6, 2026
adityapb
left a comment
Member
There was a problem hiding this comment.
Verdict: request changes.
This is a static review. Line numbers are at this PR's head.
The protocol change is consistent, so there's no hang:
- Owners wait for P counts.
- The root waits for
owner.size()S_NB messages. - Non-owners skip the sort.
The problem is where the bucket boundaries go.
- [major] Above 64 chares, almost all the data goes to one chare.
- Where:
executor_sort.cpp:886-904, together withchare_home_pe(array_region.hpp:459), which places 1-D chares round-robin. - Cause:
- The owners are the first chare on each PE, i.e. participants 0..E−1 (E = number of PEs).
- Splitter j sits at
pstart[owner[j]]/n ≈ j/P. - So buckets 0..E−2 get about one tile each, and the last owner gets
n·(1−(E−1)/P).
- Examples:
- With 4 GPUs and 128 chares, chare 3 sorts 97.7% of the array. For an argsort of 2e9 float32 elements that's about 70 GB on one GPU.
- The PR's own CPU +p2 run (~1,900 chares) puts 99.95% of the elements on chare 1.
- The output is still correct.
- Fix: put splitter j at fraction j/B (or at each owner PE's cumulative share), or pick owners evenly spaced among the participants.
- Still at #44.
- Where:
- Nit: the owner array is read through
reinterpret_cast<const int64_t*>at an offset that isn't 8-byte aligned for 1-, 2- or 4-byte keys whennsplis odd (:923). #28 switched the neighbouring reads tomemcpybut not this one.
Splitters sat at the owners' tile starts; owners are the first chare of each PE (participants 0..E-1 under round-robin placement), so the last bucket got nearly the whole array. Bucket j now ends at the cumulative share of the elements on owner PEs 0..j (evenly when kMaxBuckets leaves PEs without a bucket). The owner list is read with memcpy (unaligned after 1-4 byte keys). CNUM_SORT_DEBUG=1 prints the largest bucket per sort. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Author
Validated on the nc build of this head:
|
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Author
|
GPU check on 4 A100s: with 128 chares on 4 buckets, the largest bucket is 25.14–25.23% (even split: 25.00%). |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.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 #25.
~1,900 chares: 8 s → 0.4 s on CPU; the 2e9-element A100 sort no longer times out.
Tested (full stack): CPU +p1/+p2 15/15 originals, 25/25 ports, 30/30 ops; A100 1 GPU 15/15, 25/25, 30/30 and 4 GPUs (one process per GPU) 15/15, 25/25.
🤖 Generated with Claude Code