-
Notifications
You must be signed in to change notification settings - Fork 26.3k
Add logging for ProcessGroup backends. #73702
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
Add logging for ProcessGroup backends. #73702
Conversation
This PR adds logging to track usage of ProcessGroup backends. The change involves adding an `init()` method to the ProcessGroup base class and modifying all the subclasses to call it. We can't add logging directly in the ProcessGroup constructor since `getBackendName()` is pure virtual and can't be called from the base class constructor. See https://isocpp.org/wiki/faq/strange-inheritance#calling-virtuals-from-ctors for more details. Differential Revision: [D34596295](https://our.internmc.facebook.com/intern/diff/D34596295/) [ghstack-poisoned]
CI Flow Status⚛️ CI FlowRuleset - Version:
|
🔗 Helpful links
💊 CI failures summary and remediationsAs of commit 672e75e (more details on the Dr. CI page):
🕵️ 1 new failure recognized by patternsThe following CI failures do not appear to be due to upstream breakages:
|
This PR adds logging to track usage of ProcessGroup backends. The change involves adding an `init()` method to the ProcessGroup base class and modifying all the subclasses to call it. We can't add logging directly in the ProcessGroup constructor since `getBackendName()` is pure virtual and can't be called from the base class constructor. See https://isocpp.org/wiki/faq/strange-inheritance#calling-virtuals-from-ctors for more details. Differential Revision: [D34596295](https://our.internmc.facebook.com/intern/diff/D34596295/) ghstack-source-id: 150381852 Pull Request resolved: #73702
| protected: | ||
| // Implementations of this interface need to call this to setup | ||
| // appropriate logging etc. | ||
| void init(); |
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 would prefer to have a more descriptive name for this function. init sounds a bit confusing since the whole purpose of the base constructor is to initialize the object. How about record_usage(), or something along the line?
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.
So I was using the two-phase initialization pattern described here: https://isocpp.org/wiki/faq/strange-inheritance#calling-virtuals-from-ctor-idiom. Although, currently the init() method only does API usage logging. It can be repurposed to do additional initialization as well later. Otherwise we would end up with multiple methods like record_usage(), record_foo(), record_bar()` etc. that all need to be called by the subclasses
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.
Although I agree that the name record_usage() (deliberately) reduces the scope of the function, I would consider it a design smell if we needed to have further logic in our constructor that depends on virtual calls. Even in this particular case the cleaner, but BC-breaking, solution would be to take the backend name as a constructor parameter.
Having said that I don't have a strong objection about the name init(). One thing that we should mind though is if we want to preserve BC-compatibility, and consider init() as a place where we can potentially add further initialization logic, we have to make sure that all ProcessGroup implementations out there are updated to call it. Otherwise it will silently break implementations that don't call init().
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.
Although I agree that the name record_usage() (deliberately) reduces the scope of the function, I would consider it a design smell if we needed to have further logic in our constructor that depends on virtual calls. Even in this particular case the cleaner, but BC-breaking, solution would be to take the backend name as a constructor parameter.
I agree with this and if we were building this from scratch we wouldn't implement it this way. But the tricky thing is to do this in a backward compatible way. The solution in this PR is already a workaround and is probably the best way I know off to achieve this logging. The reason I chose init() was because I worry about the fact of having to do something like this a couple of more times.
Having said that I don't have a strong objection about the name init(). One thing that we should mind though is if we want to preserve BC-compatibility, and consider init() as a place where we can potentially add further initialization logic, we have to make sure that all ProcessGroup implementations out there are updated to call it. Otherwise it will silently break implementations that don't call init().
I did update a bunch of ProcessGroups in our repo already. Once this lands, I can probably create a PR for other repos. But there probably will be many ProcessGroups out there that we don't know about and hence I left a comment in our docs as a best effort mechanism.
Summary: Pull Request resolved: #73702 This PR adds logging to track usage of ProcessGroup backends. The change involves adding an `init()` method to the ProcessGroup base class and modifying all the subclasses to call it. We can't add logging directly in the ProcessGroup constructor since `getBackendName()` is pure virtual and can't be called from the base class constructor. See https://isocpp.org/wiki/faq/strange-inheritance#calling-virtuals-from-ctors for more details. ghstack-source-id: 150381852 Test Plan: check logging Reviewed By: cbalioglu Differential Revision: D34596295 fbshipit-source-id: 5baa7bfb53bdcd1b4032292c4e7715467f983288
|
Hey @pritamdamania87. |
Summary: Pull Request resolved: pytorch/pytorch#73702 This PR adds logging to track usage of ProcessGroup backends. The change involves adding an `init()` method to the ProcessGroup base class and modifying all the subclasses to call it. We can't add logging directly in the ProcessGroup constructor since `getBackendName()` is pure virtual and can't be called from the base class constructor. See https://isocpp.org/wiki/faq/strange-inheritance#calling-virtuals-from-ctors for more details. ghstack-source-id: 150381852 Test Plan: check logging Reviewed By: cbalioglu Differential Revision: D34596295 fbshipit-source-id: 5baa7bfb53bdcd1b4032292c4e7715467f983288 (cherry picked from commit b2344144fe0c25db02c2e958f2acd772e9cd4dc8)
Summary: Pull Request resolved: pytorch/pytorch#73702 This PR adds logging to track usage of ProcessGroup backends. The change involves adding an `init()` method to the ProcessGroup base class and modifying all the subclasses to call it. We can't add logging directly in the ProcessGroup constructor since `getBackendName()` is pure virtual and can't be called from the base class constructor. See https://isocpp.org/wiki/faq/strange-inheritance#calling-virtuals-from-ctors for more details. ghstack-source-id: 150381852 Test Plan: check logging Reviewed By: cbalioglu Differential Revision: D34596295 fbshipit-source-id: 5baa7bfb53bdcd1b4032292c4e7715467f983288 (cherry picked from commit b2344144fe0c25db02c2e958f2acd772e9cd4dc8)
Stack from ghstack:
This PR adds logging to track usage of ProcessGroup backends. The
change involves adding an
init()method to the ProcessGroup base class andmodifying all the subclasses to call it.
We can't add logging directly in the ProcessGroup constructor since
getBackendName()is pure virtual and can't be called from the base classconstructor. See
https://isocpp.org/wiki/faq/strange-inheritance#calling-virtuals-from-ctors for
more details.
Differential Revision: D34596295