-
Notifications
You must be signed in to change notification settings - Fork 337
Intra-node shared memory (SHM) optimizations for CPU primitives #458
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Hi @gaopengff! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at [email protected]. Thanks! |
if (is_intra_node(context->size)) { | ||
shm(opts); | ||
return; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we move this into the allreduce() function above? fits a bit better there since we pick the algorithm at that level
may be nice to add a RING_LOCAL or RING_SHMEM algorithm selector as well
@@ -153,6 +154,15 @@ void ring( | |||
const auto slot = Slot::build(kAllreduceSlotPrefix, opts.tag); | |||
const size_t totalBytes = opts.elements * opts.elementSize; | |||
|
|||
|
|||
if (is_intra_node(context->size)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should also check if the tensor is a CUDA tensor and bypass if it is
|
||
bool is_intra_node(const int size) { | ||
// must launch with torchrun | ||
auto local_size_string = std::getenv("LOCAL_WORLD_SIZE"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this check is safe -- for torchft for instance we often run with Gloo only cross host and if you're using an 8x8 configuration this would trigger shm logic for cross host comms
This PR is for RFC #455. It has implemented shm allreduce.