Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

add launch from python code doc #3217

Merged
merged 9 commits into from
Jan 5, 2021
Merged

Conversation

J-shang
Copy link
Contributor

@J-shang J-shang commented Dec 22, 2020

TODO: modify experiment config url

@scarlett2018 scarlett2018 requested a review from kvartet December 25, 2020 01:34
@scarlett2018 scarlett2018 mentioned this pull request Dec 30, 2020
77 tasks

Overview
--------
This is a new way to launch experiments since ``nni v2.0``. Before, you need to configure our experiment in a yaml configuration file and launch the experiment through ``nnictl`` command. Now, you can also configure and run your experiment directly in the python file. If you are familiar with python programming, this will undoubtedly bring you more convenience.
Copy link
Contributor

Choose a reason for hiding this comment

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

our experiment -> your experiment?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed it


experiment = Experiment(tuner=foo_tuner, training_service='local')

Now, you have a ``Experiment`` instance with ``foo_tuner`` you have initialized in the previous step, and this experiment will launch trials on your local machine due to ``training_service='local'``.
Copy link
Contributor

@kvartet kvartet Dec 30, 2020

Choose a reason for hiding this comment

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

I saw training_service. Name of training service. Supported value: "local", "remote", "openpai" from the code comments, I don't know whether it supports other training services.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed it


Example
-------
Below is an example for this new launching approach. You can also find this code in ``examples/trials/mnist-tfv2/launch.py``.
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe

:githublink:`mnist-tfv2/launch.py <examples/trials/mnist-tfv2/launch.py>` 

will be better.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed it

experiment.config.training_service.use_active_gpu = True

experiment.run(8081)

Copy link
Contributor

@kvartet kvartet Dec 30, 2020

Choose a reason for hiding this comment

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

Perhaps we should add a note to indicate whether experiments launched from python can be managed by nnictl or nni client.


..

Step 1 - Initialize a tuner you want to use
Copy link
Contributor

Choose a reason for hiding this comment

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

I think "step by step" is not the best way to introduce a library, seems too verbose...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it is a quick start to a new way to launch experiment, not just a library, like https://nni.readthedocs.io/en/v2.0/Tutorial/QuickStart.html#three-steps-to-start-an-experiment

Copy link
Contributor

Choose a reason for hiding this comment

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

Well I think writing Python program and using a "ctl" tool is different. But I'm okay with current version.


Overview
--------
This is a new way to launch experiments since ``nni v2.0``. Before, you need to configure your experiment in a yaml configuration file and launch the experiment through ``nnictl`` command. Now, you can also configure and run your experiment directly in the python file. If you are familiar with python programming, this will undoubtedly bring you more convenience.
Copy link
Contributor

Choose a reason for hiding this comment

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

"the python file" -> "a python file"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fix it


.. code-block:: python

from nni.algorithms.hpo.foo_tuner import FooTuner
Copy link
Contributor

Choose a reason for hiding this comment

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

do we really have FooTuner? better to use a real and simple tuner as example

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fix it


..

Step 2 - Initialize a experiment instance and configure it
Copy link
Contributor

Choose a reason for hiding this comment

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

"a experiment" -> "an experiment"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fix it


.. code-block:: python

experiment.config.experiment_name = 'test'
Copy link
Contributor

Choose a reason for hiding this comment

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

better to make this part more real, for example, setting up a real local experiment

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fix it


Use the form like ``experiment.config.foo = 'bar'`` to configure your experiment.

See `parameter configuration <TBD>`__ required by different training services.
Copy link
Contributor

Choose a reason for hiding this comment

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

here is a broken link

Copy link
Contributor Author

Choose a reason for hiding this comment

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

waiting for #3222

.. autoclass:: nni.experiment.Experiment
:members:

.. autoclass:: nni.experiment.TrialJob
Copy link
Contributor

Choose a reason for hiding this comment

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

can this class be used in the new launch approach?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will check it

@@ -69,7 +69,7 @@ def __init__(self, tuner: Tuner, training_service: str) -> None:
A tuner instance.
training_service
Name of training service.
Supported value: "local", "remote", "openpai".
Supported value: "local", "remote", "openpai", "aml", "kubeflow", "frameworkcontroller", "adl".
Copy link
Contributor

Choose a reason for hiding this comment

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

so we support all the training services in v2.0?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It seems we don't support heterogeneous and DLTS? @liuzhe-lz

Copy link
Contributor

Choose a reason for hiding this comment

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

you can add "and hybrid training service."

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fix it

Copy link
Member

@scarlett2018 scarlett2018 left a comment

Choose a reason for hiding this comment

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

I made some change suggestions directly to the Howto.rst file.

@QuanluZhang QuanluZhang merged commit b4f0d32 into microsoft:v2.0 Jan 5, 2021
@J-shang J-shang deleted the doc-launch branch January 7, 2021 05:50
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants