-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Refine runtime feature discovery python API and add documentation to … #14130
Conversation
5da0748
to
7a39b9a
Compare
docs/api/python/libinfo/libinfo.md
Outdated
✔ DIST_KVSTORE, | ||
✔ CXX14, | ||
✔ SIGNAL_HANDLER, | ||
✖ DEBUG] |
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.
❤️ this
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 copied from you :-)
a74d87f
to
9b1463f
Compare
@larroy Thanks for your contribution! |
9b1463f
to
0366b48
Compare
python/mxnet/runtime.py
Outdated
feature_dict = {f.name: f.enabled for f in libinfo_features()} | ||
if tocheck not in feature_dict: | ||
raise RuntimeError("Feature '{}' is unknown, known features are: {}".format(tocheck, list(feature_dict.keys()))) | ||
return feature_dict[tocheck] |
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.
if a dictionary is easier to operate, should the libinfo_features return a dictionary?
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 prefer to keep ordering as in a list. Going from list to dict is oneliner. Also we don't get a dict from C.
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.
is the order information useful? I always thought of it as a set. also, by defining your own data structure class, you can define more pythonic behaviors such as __contains__
and __getitem__
to make it easier for feature check.
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.
They are grouped if you see the enum definition as some features are related, semantically is a set as you describe. For using contains as you propose we would have to wrap the list in a containing class. I don't see a lot of value on complicating this further TBH. Could you provide an example of what you have in mind if you feel strongly about it?
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 feel stongly about the change. What I had in mind was something like:
>>> features = mx.runtime.libinfo_features()
>>> 'NCCL' in features
True
>>> 'nccl' in features
True
>>> nccl_idx = 2;
>>> nccl_idx in features
True
>>> features['NCCL']
✔ NCCL
>>> features['NCCL'].index
2
>>> features['NCCL'].enabled
True
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 see, that looks nice. On the upside repeated calls are more efficient than my proposal. On the downside I think the primary case which is to check if a feature is enabled is less ergonomic due to the syntactic sugar. I think a simple function with a single arg is always clearer. A good point is that it should be case insensitive. I'm a bit torn. I will refine it a bit more.
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.
Just curious: is the index information useful to user? Why do we even need to expose index?
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.
@apeforest I just removed it.
@@ -29,6 +29,17 @@ def test_libinfo_features(): | |||
ok_(type(features) is list) | |||
ok_(len(features) > 0) | |||
|
|||
def test_is_enabled(): |
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 this test run in a docker image with CUDA on the machine without GPU?
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.
Not sure I get what's the intention.
cb99c05
to
f09ed43
Compare
I made the suggested changed, please have another look and merge if you are good with it, thanks. |
8f66288
to
ede3f71
Compare
6cb7a82
to
dd432b7
Compare
apache#14130) * Refine runtime feature discovery python API and add documentation to Python API docs * Fix lint * Provide is_enabled method to check if feature is present from string * Refine docs, add is_enabled * Fix encoding * Fix doc * Address CR suggestions * remove index as per CR suggestion * Fix lint * runtime * Fix doc * Add license
Thanks for the merge and the review. |
apache#14130) * Refine runtime feature discovery python API and add documentation to Python API docs * Fix lint * Provide is_enabled method to check if feature is present from string * Refine docs, add is_enabled * Fix encoding * Fix doc * Address CR suggestions * remove index as per CR suggestion * Fix lint * runtime * Fix doc * Add license
apache#14130) * Refine runtime feature discovery python API and add documentation to Python API docs * Fix lint * Provide is_enabled method to check if feature is present from string * Refine docs, add is_enabled * Fix encoding * Fix doc * Address CR suggestions * remove index as per CR suggestion * Fix lint * runtime * Fix doc * Add license
apache#14130) * Refine runtime feature discovery python API and add documentation to Python API docs * Fix lint * Provide is_enabled method to check if feature is present from string * Refine docs, add is_enabled * Fix encoding * Fix doc * Address CR suggestions * remove index as per CR suggestion * Fix lint * runtime * Fix doc * Add license
…Python API docs
Description
see title
@aaronmarkham
Checklist
Essentials
Please feel free to remove inapplicable items for your PR.
Changes