-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
[tune] nevergrad add points_to_evaluate #12207
Conversation
Great, that worked, thanks! I'll look into it shortly |
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.
Thanks for this contribution!
Besides the minor comments it would be good if you could add a test (e.g. in test_sample.py
). This test should instantiate a nevergrad searcher with a list of e.g. 3 points to evaluate and confirm that the first three sampled configurations are indeed these points.
Let me know if you need any help with that.
python/ray/tune/suggest/nevergrad.py
Outdated
|
||
current_best_params = [{ | ||
'width': 10, | ||
'height': 0, | ||
'activation': 0, # The index of "relu" | ||
}] |
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.
Let's use our usual quotes here ("
instead of '
)
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.
done
python/ray/tune/suggest/nevergrad.py
Outdated
point_to_evaluate = self._points_to_evaluate.pop(0) | ||
for key in self._space.value: | ||
if isinstance(self._space[key], ng.p.Choice): | ||
point_to_evaluate[key] = self._space[key].choices.value[point_to_evaluate[key]] |
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.
Question: Couldn't we pass e.g. activation: "relu"
in the points_to_evaluate
dict directly and omit this lookup?
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.
That's for sure. I did like this in the beginning, but I change it to be compatible with points_to_evaluate from HyperOptSearch.
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.
Let's do it with strings then (e.g. activation: "relu"
) and we'll change the hyperoptsearch implementation in a different PR.
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.
done
python/ray/tune/suggest/nevergrad.py
Outdated
if points_to_evaluate is None: | ||
self._points_to_evaluate = None | ||
else: | ||
assert isinstance(points_to_evaluate, (list, tuple)) | ||
self._points_to_evaluate = points_to_evaluate | ||
|
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.
Let's raise an actionable error message here.I'd suggest something like:
if not isinstance(points_to_evaluate, Sequence):
raise ValueError(
f"Invalid object type passed for `points_to_evaluate`: {type(points_to_evaluate)}. "
f"Please pass a list of points (dictionaries) instead.")
self._points_to_evaluate = list(points_to_evaluate)
(This would have to be linted)
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.
done
Should I add one more test in test_sample.py - something like testConvertNevergrad_best_params? |
Yep, let's call it |
added new test in test_sample.py |
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.
Almost done - just one final one line change
python/ray/tune/suggest/nevergrad.py
Outdated
f"Invalid object type passed for `points_to_evaluate`: {type(points_to_evaluate)}. " | ||
f"Please pass a list of points (dictionaries) instead.") | ||
else: | ||
self._points_to_evaluate = points_to_evaluate |
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 will either have to convert to a list here (i.e. self._points_to_evaluate = list(points_to_evaluate)
) or check for MutableSequence
above, as this implements the pop()
interface we use in the code below.
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.
done
That's awesome! Thanks! We'll let the tests run and assuming they pass we should be ready to merge. |
There's a few linting errors:
Could you fix them? (And run The other failing tests seem unrelated to this PR. |
Perfect! Thanks @viotemp1, that's a very useful contribution! This should be ready to merge cc @richardliaw |
thanks! |
Should I delete this branch? Sorry for the question ... |
Hi, you can delete the branch as the changes are included in the master now. So next time if you want to contribute something, you'd do the following steps:
You can then Yep, I'll file an issue to track the HyperOptSearch categorical feature! Thanks again! |
Thank you too! |
Why are these changes needed?
Add points_to_evaluate to NevergradSearch
Related issue number
Checks
scripts/format.sh
to lint the changes in this PR.