"docs/source/reference/vscode:/vscode.git/clone" did not exist on "d6a4975524f9dbbc7de1eb363d97a073cbdb9ea3"
Unverified Commit 26c58399 authored by Jiahang Xu's avatar Jiahang Xu Committed by GitHub
Browse files

Refine the doc of Hardware-aware NAS (#4033)

parent 8b388fca
......@@ -6,7 +6,7 @@ Hardware-aware NAS
EndToEnd Multi-trial SPOS Demo
------------------------------
Basically, this demo will select the model whose latency satisfy constraints to train.
To empower affordable DNN on the edge and mobile devices, hardware-aware NAS searches both high accuracy and low latency models. In particular, the search algorithm only considers the models within the target latency constraints during the search process.
To run this demo, first install nn-Meter from source code (Github repo link: https://github.com/microsoft/nn-Meter. Currently we haven't released this package, so development installation is required).
......@@ -23,19 +23,25 @@ Then run multi-trail SPOS demo:
How the demo works
------------------
To support latency-aware NAS, you first need a `Strategy` that supports filtering the models by latency. We provide such a filter named `LatencyFilter` in NNI and initialize a `Random` strategy with the filter:
To support hardware-aware NAS, you first need a `Strategy` that supports filtering the models by latency. We provide such a filter named `LatencyFilter` in NNI and initialize a `Random` strategy with the filter:
.. code-block:: python
simple_strategy = strategy.Random(model_filter=LatencyFilter(100)
simple_strategy = strategy.Random(model_filter=LatencyFilter(threshold=100, predictor=base_predictor))
``LatencyFilter`` will predict the models\' latency by using nn-Meter and filter out the models whose latency are larger than the threshold (i.e., ``100`` in this example).
You can also build your own strategies and filters to support more flexible NAS such as sorting the models according to latency.
Then, pass this strategy to ``RetiariiExperiment`` along with some additional arguments: ``parse_shape=True, dummy_input=dummy_input``:
Then, pass this strategy to ``RetiariiExperiment``:
.. code-block:: python
RetiariiExperiment(base_model, trainer, [], simple_strategy, True, dummy_input)
exp = RetiariiExperiment(base_model, trainer, strategy=simple_strategy)
Here, ``parse_shape=True`` means extracting shape info from the torch model as it is required by nn-Meter to predict latency. ``dummy_input`` is required for tracing shape info.
exp_config = RetiariiExeConfig('local')
...
exp_config.dummy_input = [1, 3, 32, 32]
exp.run(exp_config, port)
In ``exp_config``, ``dummy_input`` is required for tracing shape info.
......@@ -172,7 +172,7 @@ def _main(port):
simple_strategy = strategy.Random(model_filter=LatencyFilter(threshold=100, predictor=base_predictor))
exp = RetiariiExperiment(base_model, trainer, [], simple_strategy)
exp = RetiariiExperiment(base_model, trainer, strategy=simple_strategy)
exp_config = RetiariiExeConfig('local')
exp_config.trial_concurrency = 2
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment