Skip to content
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

Update OptunaSearch #1106

Merged
merged 6 commits into from
Jul 5, 2023
Merged

Conversation

skzhang1
Copy link
Collaborator

@skzhang1 skzhang1 commented Jul 1, 2023

Why are these changes needed?

To support multiple objectives global search. Copy from ray (1.13.1) https://github.com/ray-project/ray/blob/ray-1.13.1/python/ray/tune/suggest/optuna.py.

Related issue number

Checks

@skzhang1 skzhang1 self-assigned this Jul 1, 2023
Copy link
Collaborator

@sonichi sonichi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please compile the docstr using pydoc-markdown and check the website. I've marked places where I think there is a format issue.

setup.py Outdated
@@ -15,6 +15,7 @@

install_requires = [
"NumPy>=1.17.0rc1",
"packaging",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move to [blendsearch] option

@@ -70,7 +70,7 @@ def test_searchers():
searcher = OptunaSearch(["a", config["a"]], metric="m", mode="max")
try:
searcher.suggest("t0")
except ValueError:
except AttributeError:
# not enough values to unpack (expected 3, got 1)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this error message still correct?

@@ -33,6 +34,8 @@
Uniform,
)
from ..trial import flatten_dict, unflatten_dict
from packaging import version
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use try...except. Or move to where it's needed, if performance is not an issue.

[tutorial](https://optuna.readthedocs.io/en/stable/tutorial/10_key_features/002_configurations.html).
Warning - No actual computation should take place in the define-by-run

`Optuna <https://optuna.org/>`_ is a hyperparameter optimization library.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This syntax of URL doesn't work in our doc compilation.

Comment on lines +372 to +379
metric: The training result objective value attribute. If
None but a mode was passed, the anonymous metric ``_metric``
will be used per default. Can be a list of metrics for
multi-objective optimization.
mode: One of {min, max}. Determines whether objective is
minimizing or maximizing the metric attribute. Can be a list of
modes for multi-objective optimization (corresponding to
``metric``).
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also think this is a natural way for lexicographic optimization and would like this kind of API in the beginning. Let's discuss the API after this PR is merged.


Multi-objective optimization is supported:

.. code-block:: python
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

syntax for doc compilation

You can pass configs that will be evaluated first using
``points_to_evaluate``:

.. code-block:: python
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

syntax for doc compilation

Avoid re-running evaluated trials by passing the rewards together with
`points_to_evaluate`:

.. code-block:: python
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

syntax for doc compilation

define_search_space,
metric="loss",
mode="min")
tune.run(trainable, search_alg=optuna_search)
.. versionadded:: 0.8.8
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

syntax for doc compilation

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add test to cover the changes.

define_search_space,
metric="loss",
mode="min")
tune.run(trainable, search_alg=optuna_search)
.. versionadded:: 0.8.8
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

".. versionadded:: 0.8.8" Check if this version need to be changed?

@skzhang1 skzhang1 requested a review from sonichi July 3, 2023 12:53
@skzhang1 skzhang1 requested review from feiran-jia and yiranwu0 and removed request for feiran-jia July 4, 2023 13:37
@skzhang1 skzhang1 added this pull request to the merge queue Jul 5, 2023
Merged via the queue into microsoft:main with commit dd9202b Jul 5, 2023
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants