Unverified Commit 25db55ca authored by kvartet's avatar kvartet Committed by GitHub
Browse files

Update Chinese documents (#3243)

parent 53b565e4
# 编写搜索空间
通常,搜索空间是要在其中找到最好结构的候选项。 无论是经典 NAS 还是 One-Shot NAS,不同的搜索算法都需要搜索空间。 NNI 提供了统一的 API 来表达神经网络架构的搜索空间。
搜索空间可基于基础模型来构造。 这也是在已有模型上使用 NAS 的常用方法。 以 [PyTorch 上的 MNIST](https://github.com/pytorch/examples/blob/master/mnist/main.py) 为例。 注意,NNI 为 PyTorch 和 TensorFlow 提供了同样的搜索空间 API。
```python
from nni.nas.pytorch import mutables
class Net(nn.Module):
def __init__(self):
super(Net, self).__init__()
self.conv1 = mutables.LayerChoice([
nn.Conv2d(1, 32, 3, 1),
nn.Conv2d(1, 32, 5, 3)
]) # 尝试 3x3 和 5x5 的核
self.conv2 = nn.Conv2d(32, 64, 3, 1)
self.dropout1 = nn.Dropout2d(0.25)
self.dropout2 = nn.Dropout2d(0.5)
self.fc1 = nn.Linear(9216, 128)
self.fc2 = nn.Linear(128, 10)
def forward(self, x):
x = self.conv1(x)
x = F.relu(x)
# ... 与原始代码一样 ...
return output
```
以上示例在 conv1 上添加了 conv5x5 的选项。 修改非常简单,只需要声明 `LayerChoice` 并将原始的 conv3x3 和新的 conv5x5 作为参数即可。 就这么简单! 不需要修改 forward 函数。 可将 conv1 想象为没有 NAS 的模型。
如何表示可能的连接? 通过 `InputChoice` 来实现。 要在 MNIST 示例上使用跳过连接,需要增加另一层 conv3。 下面的示例中,从 conv2 的可能连接加入到了 conv3 的输出中。
```python
from nni.nas.pytorch import mutables
class Net(nn.Module):
def __init__(self):
# ... 相同 ...
self.conv2 = nn.Conv2d(32, 64, 3, 1)
self.conv3 = nn.Conv2d(64, 64, 1, 1)
# 声明只从搜索策略中选择一个或零个候选项
self.skipcon = mutables.InputChoice(n_candidates=1)
# ... 相同 ...
def forward(self, x):
x = self.conv1(x)
x = F.relu(x)
x = self.conv2(x)
x0 = self.skipcon([x]) # 从 [x] 中选择一个或 None
x = self.conv3(x)
if x0 is not None: # 跳接可用
x += x0
x = F.max_pool2d(x, 2)
# ... 相同 ...
return output
```
Input Choice 可被视为可调用的模块,它接收张量数组,输出其中部分的连接、求和、平均(默认为求和),或没有选择时输出 `None`。 与 Layer Choice 一样,Input Choice 要**`__init__` 中初始化,并在 `forward` 中调用。 这会让搜索算法找到这些 Choice,并进行所需的准备。</p>
`LayerChoice``InputChoice` 都是 **Mutable**。 Mutable 表示 "可变化的"。 与传统深度学习层、模型都是固定的不同,使用 Mutable 的模块,是一组可能选择的模型。
用户可为每个 Mutable 指定 **key**。 默认情况下,NNI 会分配全局唯一的,但如果需要共享 Choice(例如,两个 `LayerChoice` 有同样的候选操作,希望共享同样的 Choice。即,如果一个选择了第 i 个操作,第二个也要选择第 i 个操作),那么就应该给它们相同的 key。 key 标记了此 Choice,并会在存储的检查点中使用。 如果要增加导出架构的可读性,可为每个 Mutable 的 key 指派名称。 Mutable 高级用法(如,`LayerChoice``InputChoice`),参考 [Mutables](./NasReference.md)
定义了搜索空间后,下一步是从中找到最好的模型。 参考 [经典 NAS 算法](./ClassicNas.md)[One-Shot NAS 算法](./NasGuide.md)来查看如何从定义的搜索空间中进行搜索。
\ No newline at end of file
定义搜索空间
====================
通常,搜索空间是要在其中找到最好结构的候选项。 无论是经典 NAS 还是 One-Shot NAS,不同的搜索算法都需要搜索空间。 NNI 提供了统一的 API 来表达神经网络架构的搜索空间。
搜索空间可基于基础模型来构造。 这也是在已有模型上使用 NAS 的常用方法。 `MNIST on PyTorch <https://github.com/pytorch/examples/blob/master/mnist/main.py>`__ 是一个例子。 注意,NNI 为 PyTorch 和 TensorFlow 提供了同样的搜索空间 API。
.. code-block:: python
from nni.nas.pytorch import mutables
class Net(nn.Module):
def __init__(self):
super(Net, self).__init__()
self.conv1 = mutables.LayerChoice([
nn.Conv2d(1, 32, 3, 1),
nn.Conv2d(1, 32, 5, 3)
]) # try 3x3 kernel and 5x5 kernel
self.conv2 = nn.Conv2d(32, 64, 3, 1)
self.dropout1 = nn.Dropout2d(0.25)
self.dropout2 = nn.Dropout2d(0.5)
self.fc1 = nn.Linear(9216, 128)
self.fc2 = nn.Linear(128, 10)
def forward(self, x):
x = self.conv1(x)
x = F.relu(x)
# ... same as original ...
return output
以上示例在 conv1 上添加了 conv5x5 的选项。 修改非常简单,只需要声明 ``LayerChoice`` 并将原始的 conv3x3 和新的 conv5x5 作为参数即可。 就这么简单! 不需要修改 forward 函数。 可将 conv1 想象为没有 NAS 的模型。
如何表示可能的连接? 通过 ``InputChoice`` 来实现。 要在 MNIST 示例上使用跳过连接,需要增加另一层 conv3。 下面的示例中,从 conv2 的可能连接加入到了 conv3 的输出中。
.. code-block:: python
from nni.nas.pytorch import mutables
class Net(nn.Module):
def __init__(self):
# ... same ...
self.conv2 = nn.Conv2d(32, 64, 3, 1)
self.conv3 = nn.Conv2d(64, 64, 1, 1)
# declaring that there is exactly one candidate to choose from
# search strategy will choose one or None
self.skipcon = mutables.InputChoice(n_candidates=1)
# ... same ...
def forward(self, x):
x = self.conv1(x)
x = F.relu(x)
x = self.conv2(x)
x0 = self.skipcon([x]) # choose one or none from [x]
x = self.conv3(x)
if x0 is not None: # skipconnection is open
x += x0
x = F.max_pool2d(x, 2)
# ... same ...
return output
Input Choice 可被视为可调用的模块,它接收张量数组,输出其中部分的连接、求和、平均(默认为求和),或没有选择时输出 ``None``。 就像 layer choices, input choices 应该 **用** ``__init__`` **来初始化用** ``forward`` **来回调**。 这会让搜索算法找到这些 Choice,并进行所需的准备。
``LayerChoice`` and ``InputChoice`` 都是 **mutables**。 Mutable 表示 "可变化的"。 与传统深度学习层、模型都是固定的不同,使用 Mutable 的模块,是一组可能选择的模型。
用户可以为每一个 mutable 声明一个 key。 默认情况下,NNI 会分配全局唯一的,但如果需要共享 Choice(例如,两个 ``LayerChoice`` 有同样的候选操作,希望共享同样的 Choice。即,如果一个选择了第 i 个操作,第二个也要选择第 i 个操作),那么就应该给它们相同的 key。 key 标记了此 Choice,并会在存储的检查点中使用。 如果要增加导出架构的可读性,可为每个 Mutable 的 key 指派名称。 mutables 的高级用法请参照文档 `Mutables <./NasReference.rst>`__。
定义了搜索空间后,下一步是从中找到最好的模型。 至于如何从定义的搜索空间进行搜索请参阅 `classic NAS algorithms <./ClassicNas.rst>`__ 和 `one-shot NAS algorithms <./NasGuide.rst>`__ 。
...@@ -14,4 +14,5 @@ One-Shot NAS 算法利用了搜索空间中模型间的权重共享来训练超 ...@@ -14,4 +14,5 @@ One-Shot NAS 算法利用了搜索空间中模型间的权重共享来训练超
SPOS <SPOS> SPOS <SPOS>
CDARTS <CDARTS> CDARTS <CDARTS>
ProxylessNAS <Proxylessnas> ProxylessNAS <Proxylessnas>
TextNAS <TextNAS> TextNAS <TextNAS>
\ No newline at end of file Cream <Cream>
# 概述 概述
========
NNI (Neural Network Intelligence) 是一个工具包,可有效的帮助用户设计并调优机器学习模型的神经网络架构,复杂系统的参数(如超参)等。 NNI 的特性包括:易于使用,可扩展,灵活,高效。 NNI (Neural Network Intelligence) 是一个工具包,可有效的帮助用户设计并调优机器学习模型的神经网络架构,复杂系统的参数(如超参)等。 NNI 的特性包括:易于使用,可扩展,灵活,高效。
* **易于使用**:NNI 可通过 pip 安装。 只需要在代码中添加几行,就可以利用 NNI 来调优参数。 可使用命令行工具或 Web 界面来查看 Experiment。 * **易于使用**:NNI 可通过 pip 安装。 只需要在代码中添加几行,就可以利用 NNI 来调优参数。 可使用命令行工具或 Web 界面来查看 Experiment。
* **可扩展**:调优超参或网络结构通常需要大量的计算资源。NNI 在设计时就支持了多种不同的计算资源,如远程服务器组,训练平台(如:OpenPAI,Kubernetes),等等。 通过训练平台,可拥有同时运行数百个 Trial 的能力 * **可扩展**:调优超参或网络结构通常需要大量的计算资源。NNI 在设计时就支持了多种不同的计算资源,如远程服务器组,训练平台(如:OpenPAI,Kubernetes),等等。 根据您配置的培训平台的能力,可以并行运行数百个 Trial 。
* **灵活**:除了内置的算法,NNI 中还可以轻松集成自定义的超参调优算法,神经网络架构搜索算法,提前终止算法等等。 还可以将 NNI 连接到更多的训练平台上,如云中的虚拟机集群,Kubernetes 服务等等。 此外,NNI 还可以连接到外部环境中的特殊应用和模型上。 * **灵活**:除了内置的算法,NNI 中还可以轻松集成自定义的超参调优算法,神经网络架构搜索算法,提前终止算法等等。 还可以将 NNI 连接到更多的训练平台上,如云中的虚拟机集群,Kubernetes 服务等等。 此外,NNI 还可以连接到外部环境中的特殊应用和模型上。
* **高效**:NNI 在系统及算法级别上不断地进行优化。 例如:通过早期的反馈来加速调优过程。 * **高效**:NNI 在系统及算法级别上不断地进行优化。 例如:通过早期的反馈来加速调优过程。
下图显示了 NNI 的体系结构。 下图显示了 NNI 的体系结构。
<p align="center">
<img src="https://user-images.githubusercontent.com/16907603/92089316-94147200-ee00-11ea-9944-bf3c4544257f.png" alt="绘图" width="700"/>
</p>
## 主要概念 .. raw:: html
<p align="center">
<img src="https://user-images.githubusercontent.com/16907603/92089316-94147200-ee00-11ea-9944-bf3c4544257f.png" alt="drawing" width="700"/>
</p>
* *Experiment(实验)*: 表示一次任务,用来寻找模型的最佳超参组合,或最好的神经网络架构等。 它由 Trial 和自动机器学习算法所组成。 主要概念
------------
* *搜索空间*:是模型调优的范围。 例如,超参的取值范围。
* *Configuration(配置)*:配置是来自搜索空间的实例,每个超参都会有特定的值。 *
*Experiment(实验)*: 表示一次任务,例如,寻找模型的最佳超参组合,或最好的神经网络架构等。 它由 Trial 和自动机器学习算法所组成。
* *Trial*: 是一次独立的尝试,它会使用某组配置(例如,一组超参值,或者特定的神经网络架构)。 Trial 会基于提供的配置来运行。 *
*搜索空间*:是模型调优的范围。 例如,超参的取值范围。
* *Tuner(调优器)*: Tuner 个自动机器学习算法,会为下一个 Trial 生成新的配置。 新的 Trial 会使用这组配置来运行。 *
*Configuration(配置)*:配置是来自搜索空间的实例,每个超参都会有特定的值。
* *Assessor(评估器)*:分析 Trial 的中间结果(例如,定期评估数据集上的精度),来确定 Trial 是否应该被提前终止。 *
*Trial*:是一次独立的尝试,它会使用某组配置(例如,一组超参值,或者特定的神经网络架构)。 Trial 会基于提供的配置来运行。
* *训练平台*:是 Trial 的执行环境。 根据 Experiment 的配置,可以是本机,远程服务器组,或其它大规模训练平台(如,OpenPAI,Kubernetes)。 *
*Tuner(调优器)*:一种自动机器学习算法,会为下一个 Trial 生成新的配置。 新的 Trial 会使用这组配置来运行。
*
*Assessor(评估器)*:分析 Trial 的中间结果(例如,定期评估数据集上的精度),来确定 Trial 是否应该被提前终止。
*
*训练平台*:是 Trial 的执行环境。 根据 Experiment 的配置,可以是本机,远程服务器组,或其它大规模训练平台(如,OpenPAI,Kubernetes)。
Experiment 的运行过程为:Tuner 接收搜索空间并生成配置。 这些配置将被提交到训练平台,如本机,远程服务器组或训练集群。 执行的性能结果会被返回给 Tuner。 然后,再生成并提交新的配置。 Experiment 的运行过程为:Tuner 接收搜索空间并生成配置。 这些配置将被提交到训练平台,如本机,远程服务器组或训练集群。 执行的性能结果会被返回给 Tuner。 然后,再生成并提交新的配置。
每次 Experiment 执行时,用户只需要定义搜索空间,改动几行代码,就能利用 NNI 内置的 Tuner/Assessor 和训练平台来搜索最好的超参组合以及神经网络结构。 基本上分为三步: 每次 Experiment 执行时,用户只需要定义搜索空间,改动几行代码,就能利用 NNI 内置的 Tuner/Assessor 和训练平台来搜索最好的超参组合以及神经网络结构。 基本上分为三步:
> 第一步:[定义搜索空间](Tutorial/SearchSpaceSpec.md) ..
>
> 第二步:[改动模型代码](TrialExample/Trials.md) 步骤一:`定义搜索空间 <Tutorial/SearchSpaceSpec.rst>`__
>
> 第三步:[定义 Experiment 配置](Tutorial/ExperimentConfig.md) 步骤二:`改动模型代码 <TrialExample/Trials.rst>`__
步骤三:`定义实验配置 <Tutorial/ExperimentConfig.rst>`__
.. raw:: html
<p align="center">
<img src="https://user-images.githubusercontent.com/23273522/51816627-5d13db80-2302-11e9-8f3e-627e260203d5.jpg" alt="drawing"/>
</p>
<p align="center">
<img src="https://user-images.githubusercontent.com/23273522/51816627-5d13db80-2302-11e9-8f3e-627e260203d5.jpg" alt="绘图"/>
</p>
更多 Experiment 运行的详情,参考[快速入门](Tutorial/QuickStart.md) 可查看 `快速入门 <Tutorial/QuickStart.rst>`__ 来调优你的模型或系统
## 核心功能 核心功能
-------------
NNI 提供了并行运行多个实例以查找最佳参数组合的能力。 此功能可用于各种领域,例如,为深度学习模型查找最佳超参数,或查找具有真实数据的数据库和其他复杂系统的最佳配置。 NNI 提供了并行运行多个实例以查找最佳参数组合的能力。 此功能可用于各种领域,例如,为深度学习模型查找最佳超参数,或查找具有真实数据的数据库和其他复杂系统的最佳配置。
NNI 还希望提供用于机器学习和深度学习的算法工具包,尤其是神经体系结构搜索(NAS)算法,模型压缩算法和特征工程算法。 NNI 还希望提供用于机器学习和深度学习的算法工具包,尤其是神经体系结构搜索(NAS)算法,模型压缩算法和特征工程算法。
### 超参调优 超参调优
^^^^^^^^^^^^^^^^^^^^^
这是 NNI 最核心、基本的功能,其中提供了许多流行的[自动调优算法](Tuner/BuiltinTuner.md) ( Tuner) 以及 [提前终止算法](Assessor/BuiltinAssessor.md) ( Assessor)。 可查看[快速入门](Tutorial/QuickStart.md)来调优模型或系统。 基本上通过以上三步,就能开始 NNI Experiment。 这是 NNI 最核心、基本的功能,其中提供了许多流行的 `自动调优算法 <Tuner/BuiltinTuner.rst>`__ (即 Tuner) 以及 `提前终止算法 <Assessor/BuiltinAssessor.rst>`__ (即 Assessor。 可查看 `快速入门 <Tutorial/QuickStart.rst>`__ 来调优你的模型或系统。 基本上通过以上三步,就能开始 NNI Experiment。
### 通用 NAS 框架 通用 NAS 框架
^^^^^^^^^^^^^^^^^^^^^
此 NAS 框架可供用户轻松指定候选的神经体系结构,例如,可以为单个层指定多个候选操作(例如,可分离的 conv、扩张 conv),并指定可能的跳过连接。 NNI 将自动找到最佳候选。 另一方面,NAS 框架为其他类型的用户(如,NAS 算法研究人员)提供了简单的接口,以实现新的 NAS 算法。 NAS 详情及用法参考[这里](NAS/Overview.md) 此 NAS 框架可供用户轻松指定候选的神经体系结构,例如,可以为单个层指定多个候选操作(例如,可分离的 conv、扩张 conv),并指定可能的跳过连接。 NNI 将自动找到最佳候选。 另一方面,NAS 框架为其他类型的用户(如,NAS 算法研究人员)提供了简单的接口,以实现新的 NAS 算法。 NAS 详情及用法参考 `这里 <NAS/Overview.rst>`__
NNI 通过 Trial SDK 支持多种 one-shot(一次性) NAS 算法,如:ENAS、DARTS。 使用这些算法时,不需启动 NNI Experiment。 在 Trial 代码中加入算法,直接运行即可。 如果要调整算法中的超参数,或运行多个实例,可以使用 Tuner 并启动 NNI Experiment。 NNI 通过 Trial SDK 支持多种 one-shot(一次性) NAS 算法,如:ENAS、DARTS。 使用这些算法时,不需启动 NNI Experiment。 在 Trial 代码中加入算法,直接运行即可。 如果要调整算法中的超参数,或运行多个实例,可以使用 Tuner 并启动 NNI Experiment。
除了 one-shot NAS 外,NAS 还能以 NNI 模式运行,其中每个候选的网络结构都作为独立 Trial 任务运行。 在此模式下,与超参调优类似,必须启动 NNI Experiment 并为 NAS 选择 Tuner。 除了 one-shot NAS 外,NAS 还能以 NNI 模式运行,其中每个候选的网络结构都作为独立 Trial 任务运行。 在此模式下,与超参调优类似,必须启动 NNI Experiment 并为 NAS 选择 Tuner。
### 模型压缩 模型压缩
^^^^^^^^^^^^^^^^^
NNI 上的模型压缩包括剪枝和量化算法。 这些算法通过 NNI Trial SDK 提供。 可以直接在 Trial 代码中使用,并在不启动 NNI Experiment 的情况下运行 Trial 代码。 模型压缩的详细说明和算法可在[这里](Compressor/Overview.md)找到。 NNI 提供了一个易于使用的模型压缩框架来压缩深度神经网络,压缩后的网络通常具有更小的模型尺寸和更快的推理速度,
模型性能也不会有明显的下降。 NNI 上的模型压缩包括剪枝和量化算法。 这些算法通过 NNI Trial SDK 提供
。 可以直接在 Trial 代码中使用,并在不启动 NNI Experiment 的情况下运行 Trial 代码。 用户还可以使用 NNI 模型压缩框架集成自定义的剪枝和量化算法。
模型压缩中有不同的超参。 一种类型是在输入配置中的超参,例如,压缩算法的稀疏性、量化的位宽。 另一种类型是压缩算法的超参。 NNI 的超参调优可以自动找到最佳的压缩模型。 参考[简单示例](Compressor/AutoCompression.md) 模型压缩的详细说明和算法可在 `这里 <Compression/Overview.rst>`__ 找到
### 自动特征工程 自动特征工程
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
自动特征工程,为下游任务找到最有效的特征。 自动特征工程及其用法的详细说明可在[这里](FeatureEngineering/Overview.md)找到。 通过 NNI Trial SDK 支持,不必创建 NNI Experiment 只需在 Trial 代码中加入内置的自动特征工程算法,然后直接运行 Trial 代码。 自动特征工程,可以为下游任务找到最有效的特征。 自动特征工程及其用法的详细说明可在 `这里 <FeatureEngineering/Overview.rst>`__ 找到。 通过 NNI Trial SDK 支持,不必创建 NNI Experiment 只需在 Trial 代码中加入内置的自动特征工程算法,然后直接运行 Trial 代码。
自动特征工程算法通常有一些超参。 如果要自动调整这些超参,可以利用 NNI 的超参数调优,即选择调优算法(即 Tuner)并启动 NNI Experiment。 自动特征工程算法通常有一些超参。 如果要自动调整这些超参,可以利用 NNI 的超参数调优,即选择调优算法(即 Tuner)并启动 NNI Experiment。
## 了解更多信息 了解更多信息
--------------------
* [入门](Tutorial/QuickStart.md)
* [如何为 NNI 调整代码?](TrialExample/Trials.md)
* [NNI 支持哪些 Tuner?](Tuner/BuiltinTuner.md) * `入门 <Tutorial/QuickStart.rst>`__
* [如何自定义 Tuner?](Tuner/CustomizeTuner.md) * `如何为 NNI 调整代码? <TrialExample/Trials.rst>`__
* [NNI 支持哪些 Assessor?](Assessor/BuiltinAssessor.md) * `NNI 支持哪些 Tuner? <Tuner/BuiltinTuner.rst>`__
* [如何自定义 Assessor?](Assessor/CustomizeAssessor.md) * `如何自定义 Tuner? <Tuner/CustomizeTuner.rst>`__
* [如何在本机上运行 Experiment?](TrainingService/LocalMode.md) * `NNI 支持哪些 Assessor? <Assessor/BuiltinAssessor.rst>`__
* [如何在多机上运行 Experiment?](TrainingService/RemoteMachineMode.md) * `如何自定义 Assessor? <Assessor/CustomizeAssessor.rst>`__
* [如何在 OpenPAI 上运行 Experiment?](TrainingService/PaiMode.md) * `如何在本机上运行 Experiment? <TrainingService/LocalMode.rst>`__
* [示例](TrialExample/MnistExamples.md) * `如何在多机上运行 Experiment? <TrainingService/RemoteMachineMode.rst>`__
* [NNI 上的神经网络架构搜索](NAS/Overview.md) * `如何在 OpenPAI 上运行 Experiment? <TrainingService/PaiMode.rst>`__
* [NNI 上的自动模型压缩](Compressor/Overview.md) * `示例 <TrialExample/MnistExamples.rst>`__
* [NNI 上的自动特征工程](FeatureEngineering/Overview.md) * `NNI 上的神经网络架构搜索 <NAS/Overview.rst>`__
\ No newline at end of file * `NNI 上的自动模型压缩 <Compression/Overview.rst>`__
* `NNI 上的自动特征工程 <FeatureEngineering/Overview.rst>`__
# 更改日志 更改日志
=========
# 发布 1.8 - 8/27/2020 发布 1.9 - 10/22/2020
========================
## 主要更新 主要更新
-------------
神经网络架构搜索
^^^^^^^^^^^^^^^^^^^^^^^^^^
* 在 NAS 中增加 regularized evolution 算法 (#2802)
* 在搜索空间集合中增加 NASBench201 (#2766)
模型压缩
^^^^^^^^^^^^^^^^^
* AMC Pruner 改进:支持 resnet,复现 AMC 论文中的实验(示例代码使用默认参数) (#2876 #2906)
* 在一些 Pruner 中支持“约束感知”以提高模型压缩的效率 (#2657)
* 在 TensorFlow 版本的模型压缩代码中支持 "tf.keras.Sequential" (#2887)
* 在模型 FLOPS 计数器中支持自定义的 op (#2795)
* 在 QAT quantizer 中增加量化的偏置 (#2914)
训练平台
^^^^^^^^^^^^^^^^
* 支持在远程模式中使用 "preCommand" 配置 Python 环境 (#2875)
* 在 Windows 下支持 AML 训练平台 (#2882)
* 为远程训练平台添加 reuse 模式 (#2923)
Web 界面和 nnictl
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
* 重新设计 Web 界面的 "Overview" 页面 (#2914)
* 升级 node, yarn 和 FabricUI,激活 Eslint (#2894 #2873 #2744)
* 在超参调优图表和 "Trials detail" 页面的 Trial 表格中增加/删除列 (#2900)
* 美化 Web 界面的 JSON 格式显示 (#2863)
* 支持使用 nnictl 命令自动补全 (#2857)
UT & IT
-------
* 为 Experiment 导入导出数据增加集成测试 (#2878)
* 为用户安装的内置 Tuner 增加集成测试 (#2859)
* 为 nnictl 增加单元测试 (#2912)
文档
-------------
* 重构了模型压缩的文档结构 (#2919)
修复的 Bug
--------------------
* 修复正确使用 naïve evolution Tuner,Trial 失败的 Bug (#2695)
* 修复警告 "WARNING (nni.protocol) IPC pipeline not exists, maybe you are importing tuner/assessor from trial code?" (#2864)
* 修复保存/加载 Experiment 搜索空间的问题 (#2886)
* 修复 Experiment 导入数据的 Bug (#2878)
* 修复远程模式下 annotation 出现的问题 (python 3.8 ast 更新的问题) (#2881)
* 在 Web 界面上自定义 Trial 时,支持为类型是 "choice" 的超参数配置布尔值 (#3003)
发布 1.8 - 8/27/2020
=======================
主要更新
-------------
训练平台
^^^^^^^^^^^^^^^^
### 训练平台
* 在 Web 界面直接访问 Trial 日志 (仅支持本地模式) (#2718) * 在 Web 界面直接访问 Trial 日志 (仅支持本地模式) (#2718)
* 添加 OpenPAI Trial Job 详情链接 (#2703) * 添加 OpenPAI Trial Job 详情链接 (#2703)
* Reuse 模式中支持 GPU 调度器 (#2627) (#2769) * 在可重用的环境中支持 GPU 调度器 (#2627) (#2769)
* `trial_runner` 中的 `web_channel`加超时时间 (#2710) * 为 ``trial_runner`` 中的 ``web_channel`` 增加超时时间 (#2710)
* 在 AzureML 模式下展示环境配置错误信息 (#2724) * 在 AzureML 模式下展示环境配置错误信息 (#2724)
* 为在 OpenPAI 模式复制数据增加更多日志信息 (#2702) * 为在 OpenPAI 模式复制数据增加更多日志信息 (#2702)
### Web 界面,nnictl 和 nnicli Web 界面,nnictl 和 nnicli
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
* 改进超参数并行坐标图的绘制 (#2691) (#2759) * 改进超参数并行坐标图的绘制 (#2691) (#2759)
* 为 Trial Job 列表添加分页 (#2738) (#2773) * 为 Trial Job 列表添加分页 (#2738) (#2773)
...@@ -21,37 +94,49 @@ ...@@ -21,37 +94,49 @@
* 从 Web 界面中去掉多阶段支持 (#2760) * 从 Web 界面中去掉多阶段支持 (#2760)
* 支持保存和加载 Experiment (#2750) * 支持保存和加载 Experiment (#2750)
* 在导出结果的命令中增加导出中间结果的选项 (#2706) * 在导出结果的命令中增加导出中间结果的选项 (#2706)
* 增加了依据最高/最低指标列出 Trial 的[命令](https://github.com/microsoft/nni/blob/v1.8/docs/zh_CN/Tutorial/Nnictl.md#nnictl-trial) (#2747) * 增加了依据最高/最低指标列出 Trial 的 `命令 <https://github.com/microsoft/nni/blob/v1.8/docs/zh_CN/Tutorial/Nnictl.rst#nnictl-trial>`__ (#2747)
* 提升了 [nnicli](https://github.com/microsoft/nni/blob/v1.8/docs/zh_CN/nnicli_ref.md) 的用户体验,并附[示例](https://github.com/microsoft/nni/blob/v1.8/examples/notebooks/retrieve_nni_info_with_python.ipynb) (#2713) * 提升了 `nnicli <https://github.com/microsoft/nni/blob/v1.8/docs/zh_CN/nnicli_ref.rst>`__ 的用户体验,并附上 `示例 <https://github.com/microsoft/nni/blob/v1.8/examples/notebooks/retrieve_nni_info_with_python.ipynb>`__ (#2713)
神经网络架构搜索
^^^^^^^^^^^^^^^^^^^^^^^^^^
### 神经网络架构搜索
* [搜索空间集合: ENAS DARTS](https://github.com/microsoft/nni/blob/v1.8/docs/zh_CN/NAS/SearchSpaceZoo.md) (#2589) * `搜索空间集合ENAS and DARTS <https://github.com/microsoft/nni/blob/v1.8/docs/zh_CN/NAS/SearchSpaceZoo.rst>`__ (#2589)
* 用于在 NAS 基准测试中查询中间结果的 API (#2728) * 用于在 NAS 基准测试中查询中间结果的 API (#2728)
### 模型压缩 模型压缩
^^^^^^^^^^^^^^^^^
* 支持 TorchModuleGraph 的 List/Tuple Construct/Unpack 操作 (#2609) * 支持 TorchModuleGraph 的 List/Tuple Construct/Unpack 操作 (#2609)
* 模型加速改进: 支持 DenseNet 和 InceptionV3 (#2719) * 模型加速改进: 支持 DenseNet 和 InceptionV3 (#2719)
* 支持多个连续 tuple 的 unpack 操作 (#2768) * 支持多个连续 tuple 的 unpack 操作 (#2768)
* [比较支持的 Pruner 的表现的文档](https://github.com/microsoft/nni/blob/v1.8/docs/zh_CN/CommunitySharings/ModelCompressionComparison.md) (#2742) * `比较支持的 Pruner 的表现的文档 <https://github.com/microsoft/nni/blob/v1.8/docs/zh_CN/CommunitySharings/ModelCompressionComparison.rst>`__ (#2742)
* 新的 Pruners: [Sensitivity pruner](https://github.com/microsoft/nni/blob/v1.8/docs/zh_CN/Compressor/Pruner.md#sensitivity-pruner) (#2684) and [AMC pruner](https://github.com/microsoft/nni/blob/v1.8/docs/zh_CN/Compressor/Pruner.md) (#2573) (#2786) * 新的 Pruner:`Sensitivity pruner <https://github.com/microsoft/nni/blob/v1.8/docs/zh_CN/Compressor/Pruner.md#sensitivity-pruner>`__ (#2684) and `AMC pruner <https://github.com/microsoft/nni/blob/v1.8/docs/zh_CN/Compressor/Pruner.rst>`__ (#2573) (#2786)
* 支持 TensorFlow v2 的模型压缩 (#2755) * 支持 TensorFlow v2 的模型压缩 (#2755)
### 不兼容的改动 不兼容的改动
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
* 默认 Experiment 目录从 `$HOME/nni/experiments` 更新至 `$HOME/nni-experiments`. 如果希望查看通过之前的 NNI 版本创建的 Experiment,可以将这些 Experiment 目录从 `$HOME/nni/experiments` 手动移动至 `$HOME/nni-experiments`. (#2686) (#2753) * 默认 Experiment 目录从 ``$HOME/nni/experiments`` 更新至 ``$HOME/nni-experiments``。 如果希望查看通过之前的 NNI 版本创建的 Experiment,可以将这些 Experiment 目录从 ``$HOME/nni/experiments`` 手动移动至 ``$HOME/nni-experiments``。 (#2686) (#2753)
* 不再支持 Python 3.5 和 scikit-learn 0.20 (#2778) (#2777) (2783) (#2787) (#2788) (#2790) * 不再支持 Python 3.5 和 scikit-learn 0.20 (#2778) (#2777) (2783) (#2787) (#2788) (#2790)
### 其他 其它
^^^^^^
* 更新 Docker 镜像中的 Tensorflow 版本 (#2732) (#2735) (#2720) * 更新 Docker 镜像中的 Tensorflow 版本 (#2732) (#2735) (#2720)
## 示例 示例
--------
* 在 Assessor 示例中移除 gpuNum (#2641) * 在 Assessor 示例中移除 gpuNum (#2641)
## 文档 文档
-------------
* 改进自定义 Tuner 的文档 (#2628) * 改进自定义 Tuner 的文档 (#2628)
* 修复几处文档中的输入错误和语法错误 (#2637 #2638, 感谢 @tomzx) * 修复几处文档中的输入错误和语法错误 (#2637 #2638, 感谢 @tomzx)
...@@ -62,12 +147,14 @@ ...@@ -62,12 +147,14 @@
* 增加对 Colab 进行支持的教程 (#2700) * 增加对 Colab 进行支持的教程 (#2700)
* 改进模型压缩的文档结构 (#2676) * 改进模型压缩的文档结构 (#2676)
## 修复的 Bug 修复的 Bug
----------------------
* 修复训练平台的目录生成错误 (#2673) * 修复训练平台的目录生成错误 (#2673)
* 修复 Remote 训练平台使用 chmod 时的 Bug (#2689) * 修复 Remote 训练平台使用 chmod 时的 Bug (#2689)
* 通过内联导入 `_graph_utils` 修复依赖问题 (#2675) * 通过内联导入 ``_graph_utils`` 修复依赖问题 (#2675)
* 修复了 `SimulatedAnnealingPruner` 中的掩码问题 (#2736) * 修复了 ``SimulatedAnnealingPruner`` 中的掩码问题 (#2736)
* 修复了中间结果的图的缩放问题 (#2738) * 修复了中间结果的图的缩放问题 (#2738)
* 修复了在查询 NAS 基准测试时字典没有经过排序的问题 (#2728) * 修复了在查询 NAS 基准测试时字典没有经过排序的问题 (#2728)
* 修复了 Gradient Selector Dataloader Iterator 的导入问题 (#2690) * 修复了 Gradient Selector Dataloader Iterator 的导入问题 (#2690)
...@@ -76,77 +163,108 @@ ...@@ -76,77 +163,108 @@
* 修复了对指标中不常见类型的支持,包括 NaN 和 Infinity (#2782) * 修复了对指标中不常见类型的支持,包括 NaN 和 Infinity (#2782)
* 修复 nnictl experiment delete (#2791) * 修复 nnictl experiment delete (#2791)
# 发布 1.7 - 7/8/2020 发布 1.7 - 7/8/2020
======================
主要功能
--------------
## 主要功能 训练平台
^^^^^^^^^^^^^^^^
### 训练平台
* 支持 AML (Azure Machine Learning) 作为训练平台。 * 支持 AML (Azure Machine Learning) 作为训练平台。
* OpenPAI 任务可被重用。 当 Trial 完成时, OpenPAI 任务不会停止, 而是等待下一个 Trial。 [参考 OpenPAI 设置中的 reuse 标志](https://github.com/microsoft/nni/blob/master/docs/zh_CN/TrainingService/PaiMode.md#openpai-configurations) * OpenPAI 任务可被重用。 当 Trial 完成时, OpenPAI 任务不会停止, 而是等待下一个 Trial。 改进 `新的 OpenPAI 模式的文档 <https://github.com/microsoft/nni/blob/v1.7/docs/zh_CN/TrainingService/PaiMode.rst#openpai-configurations>`__.
* [支持在向训练平台上传代码目录时使用 .nniignore 忽略代码目录中的文件和目录](https://github.com/microsoft/nni/blob/v1.7/docs/zh_CN/TrainingService/Overview.md#how-to-use-training-service) * `支持在向训练平台上传代码目录时使用 .nniignore 忽略代码目录中的文件和目录 <https://github.com/microsoft/nni/blob/v1.7/docs/zh_CN/TrainingService/Overview.rst#how-to-use-training-service>`__.
### 神经网络架构搜索(NAS) 神经网络架构搜索(NAS)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
* [为 NAS 基准测试 (NasBench101, NasBench201, NDS) 提供了友好的 API](https://github.com/microsoft/nni/blob/v1.7/docs/zh_CN/NAS/Benchmarks.md)
* [在 TensorFlow 2.X 支持 Classic NAS(即非权重共享模式)](https://github.com/microsoft/nni/blob/v1.7/docs/zh_CN/NAS/ClassicNas.md) *
`为 NAS 基准测试 (NasBench101, NasBench201, NDS) 提供了友好的 API <https://github.com/microsoft/nni/blob/v1.7/docs/zh_CN/NAS/Benchmarks.rst>`__。
*
`在 TensorFlow 2.X 支持 Classic NAS(即非权重共享模式) <https://github.com/microsoft/nni/blob/v1.7/docs/zh_CN/NAS/ClassicNas.rst>`__。
模型压缩
^^^^^^^^^^^^^^^^^
### 模型压缩
* 改进模型加速:跟踪层之间的更多依赖关系,自动解决掩码冲突,支持剪枝 ResNet 的加速 * 改进模型加速:跟踪层之间的更多依赖关系,自动解决掩码冲突,支持剪枝 ResNet 的加速
* 增加新的 Pruner,包括 3 个模型剪枝算法:[NetAdapt Pruner](https://github.com/microsoft/nni/blob/v1.7/docs/zh_CN/Compressor/Pruner.md#netadapt-pruner)[SimulatedAnnealing Pruner](https://github.com/microsoft/nni/blob/v1.7/docs/zh_CN/Compressor/Pruner.md#simulatedannealing-pruner)[AutoCompress Pruner](https://github.com/microsoft/nni/blob/v1.7/docs/zh_CN/Compressor/Pruner.md#autocompress-pruner)[ADMM Pruner](https://github.com/microsoft/nni/blob/v1.7/docs/zh_CN/Compressor/Pruner.md#admm-pruner) * 增加新的 Pruner,包括三个模型剪枝算法: `NetAdapt Pruner <https://github.com/microsoft/nni/blob/v1.7/docs/zh_CN/Compressor/Pruner.md#netadapt-pruner>`__\ , `SimulatedAnnealing Pruner <https://github.com/microsoft/nni/blob/v1.7/docs/zh_CN/Compressor/Pruner.md#simulatedannealing-pruner>`__\ , `AutoCompress Pruner <https://github.com/microsoft/nni/blob/v1.7/docs/zh_CN/Compressor/Pruner.md#autocompress-pruner>`__\ , and `ADMM Pruner <https://github.com/microsoft/nni/blob/v1.7/docs/zh_CN/Compressor/Pruner.rst#admm-pruner>`__.
* 添加[模型敏感性分析工具](https://github.com/microsoft/nni/blob/v1.7/docs/zh_CN/Compressor/CompressionUtils.md)来帮助用户发现各层对剪枝的敏感性 * 增加 `模型灵敏度分析工具 <https://github.com/microsoft/nni/blob/v1.7/docs/zh_CN/Compressor/CompressionUtils.rst>`__ 来帮助用户发现各层对剪枝的敏感性。
* [用于模型压缩和 NAS 的简易 FLOPs 计算工具](https://github.com/microsoft/nni/blob/v1.7/docs/zh_CN/Compressor/CompressionUtils.md#model-flops-parameters-counter) *
`用于模型压缩和 NAS 的简易 FLOPs 计算工具 <https://github.com/microsoft/nni/blob/v1.7/docs/zh_CN/Compressor/CompressionUtils.rst#model-flops-parameters-counter>`__.
*
更新 Lottery Ticket Pruner 以导出中奖彩票
* 更新 Lottery Ticket Pruner 以导出中奖彩票 示例
^^^^^^^^
### 示例
* 在 NNI 上使用新的[自定义调优器 OpEvo](https://github.com/microsoft/nni/blob/v1.7/docs/zh_CN/TrialExample/OpEvoExamples.md) 自动优化张量算子 * 在 NNI 上使用新的 `自定义 Tuner OpEvo <https://github.com/microsoft/nni/blob/v1.7/docs/zh_CN/TrialExample/OpEvoExamples.rst>`__ 自动优化张量算子
### 内置 Tuner、Assessor、Advisor 内置 Tuner、Assessor、Advisor
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
* [允许自定义 Tuner、Assessor、Advisor 被安装为内置算法](https://github.com/microsoft/nni/blob/v1.7/docs/zh_CN/Tutorial/InstallCustomizedAlgos.md)
### Web 界面 * `允许自定义 Tuner、Assessor、Advisor 被安装为内置算法 <https://github.com/microsoft/nni/blob/v1.7/docs/zh_CN/Tutorial/InstallCustomizedAlgos.rst>`__.
Web 界面
^^^^^^^^^^^^^^
* 支持更友好的嵌套搜索空间可视化。 * 支持更友好的嵌套搜索空间可视化。
* 在超参数图中展示 Trial 的字典的键 * 在超参数图中展示 Trial 的字典的键
* 增强 Trial 持续时间展示 * 增强 Trial 持续时间展示
### 其它 其它
^^^^^^
* 提供工具函数用于合并从 NNI 获取到的参数 * 提供工具函数用于合并从 NNI 获取到的参数
* 支持在 OpenPAI 模式中设置 paiStorageConfigName * 支持在 OpenPAI 模式中设置 paiStorageConfigName
## 文档 文档
-------------
* 改进[模型压缩文档](https://github.com/microsoft/nni/blob/v1.7/docs/zh_CN/Compressor/Overview.md) * 改进 `模型压缩文档 <https://github.com/microsoft/nni/blob/v1.7/docs/zh_CN/Compressor/Overview.rst>`__
* 改进 NAS 基准测试的[文档](https://github.com/microsoft/nni/blob/v1.7/docs/zh_CN/NAS/Benchmarks.md)[示例](https://github.com/microsoft/nni/blob/v1.7/docs/zh_CN/NAS/BenchmarksExample.ipynb) * 改进 `NAS 基准测试的文档 <https://github.com/microsoft/nni/blob/v1.7/docs/zh_CN/NAS/Benchmarks.rst>`__
* 改进 [AzureML 训练平台的文档](https://github.com/microsoft/nni/blob/v1.7/docs/zh_CN/TrainingService/AMLMode.md) 和 `示例 <https://github.com/microsoft/nni/blob/v1.7/docs/zh_CN/NAS/BenchmarksExample.ipynb>`__ 。
* 改进 `AzureML 训练平台的文档 <https://github.com/microsoft/nni/blob/v1.7/docs/zh_CN/TrainingService/AMLMode.rst>`__
* 主页迁移到 readthedoc。 * 主页迁移到 readthedoc。
## 修复的 Bug 修复的 Bug
------------------
* 修复模型图中含有共享的 nn.Module 时的问题 * 修复模型图中含有共享的 nn.Module 时的问题
* 修复 `make build` 时的 nodejs OOM * 修复 ``make build`` 时的 nodejs OOM
* 修复 NASUI Bug * 修复 NASUI Bug
* 修复持续时间和中间结果图片更新问题 * 修复持续时间和中间结果图片更新问题
* 修复小的 Web 界面表格样式问题 * 修复小的 Web 界面表格样式问题
## 发布 1.6 - 5/26/2020 发布 1.6 - 5/26/2020
-----------------------
主要功能
^^^^^^^^^^^^^^
### 主要功能 新功能和改进
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#### 新功能和改进
* 将 IPC 限制提高至 100W * 将 IPC 限制提高至 100W
* 修改非本机训练平台中,将上传代码到存储的逻辑 * 修改非本机训练平台中,将上传代码到存储的逻辑
* SDK 版本支持 `__version__` * SDK 版本支持 ``__version__``
* 支持 Windows 下开发模式安装 * 支持 Windows 下开发模式安装
#### Web 界面 Web 界面
^^^^^^^^^^^^^^^
* 显示 Trial 的错误消息 * 显示 Trial 的错误消息
* 完善主页布局 * 完善主页布局
...@@ -155,65 +273,90 @@ ...@@ -155,65 +273,90 @@
* 在概述页面为 Trial 并发添加工具提示。 * 在概述页面为 Trial 并发添加工具提示。
* 在超参图中显示最好的 Trial * 在超参图中显示最好的 Trial
#### 超参优化更新 超参优化更新
^^^^^^^^^^^^^^^^^^
* 改进 PBT 的错误处理,并支持恢复 Experiment * 改进 PBT 的错误处理,并支持恢复 Experiment
#### NAS 更新 NAS 更新
^^^^^^^^^^^
* NAS 支持 TensorFlow 2.0 (预览版) [TF2.0 NAS 示例](https://github.com/microsoft/nni/tree/master/examples/nas/naive-tf) * NAS 支持 TensorFlow 2.0 (预览版) `TF2.0 NAS 示例 <https://github.com/microsoft/nni/tree/v1.6/examples/nas/naive-tf>`__
* LayerChoice 使用 OrderedDict * LayerChoice 使用 OrderedDict
* 优化导出格式 * 优化导出格式
* 应用固定架构后,将 LayerChoice 替换成选择的模块 * 应用固定架构后,将 LayerChoice 替换成选择的模块
#### 模型压缩改进 模型压缩改进
^^^^^^^^^^^^^^^^^^^^^^^^^
* 模型压缩支持 PyTorch 1.4 * 模型压缩支持 PyTorch 1.4
#### 训练平台改进 训练平台改进
^^^^^^^^^^^^^^^^^^^^^^^^
* 改进 OpenPAI YAML 的合并逻辑 * 改进 OpenPAI YAML 的合并逻辑
* 支持 Windows 在远程模式中作为远程机器 [Remote Mode](https://github.com/microsoft/nni/blob/master/docs/zh_CN/TrainingService/RemoteMachineMode.md#windows) * 支持 Windows 在远程模式中作为远程机器 `远程模式 <https://github.com/microsoft/nni/blob/v1.6/docs/zh_CN/TrainingService/RemoteMachineMode.rst#windows>`__
修复的 Bug
^^^^^^^^^^^^^^
### 修复的 Bug
* 修复开发模式安装 * 修复开发模式安装
* 当检查点没有 state_dict 时,SPOS 示例会崩溃 * 当检查点没有 state_dict 时,SPOS 示例会崩溃
* 修复失败 Trial 造成的表格排序问题 * 修复失败 Trial 造成的表格排序问题
* 支持多 Python 环境(如 conda,pyenv 等) * 支持多 Python 环境(如 conda,pyenv 等)
## 发布 1.5 - 4/13/2020 发布 1.5 - 4/13/2020
-----------------------
新功能和文档
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
### 新功能和文档 超参优化
^^^^^^^^^^^^^^^^^^^^^^^^^^
#### 超参优化
* 新 Tuner:[Population Based Training (PBT)](https://github.com/microsoft/nni/blob/master/docs/zh_CN/Tuner/PBTTuner.md) * 新 Tuner: `Population Based Training (PBT) <https://github.com/microsoft/nni/blob/v1.5/docs/zh_CN/Tuner/PBTTuner.rst>`__
* Trial 现在可以返回无穷大和 NaN 结果 * Trial 现在可以返回无穷大和 NaN 结果
#### 神经网络架构搜索 神经网络架构搜索
^^^^^^^^^^^^^^^^^^^^^^^^^^
* 新 NAS 算法:[TextNAS](https://github.com/microsoft/nni/blob/master/docs/zh_CN/NAS/TextNAS.md)
* ENAS 和 DARTS 现在可通过网页[可视化](https://github.com/microsoft/nni/blob/master/docs/zh_CN/NAS/Visualization.md)
#### 模型压缩 * 全新 NAS 算法:`TextNAS <https://github.com/microsoft/nni/blob/v1.5/docs/zh_CN/NAS/TextNAS.rst>`__
* 在 Web 界面 支持 ENAS 和 DARTS的 `可视化 <https://github.com/microsoft/nni/blob/v1.5/docs/zh_CN/NAS/Visualization.rst>`__
* 新 Pruner:[GradientRankFilterPruner](https://github.com/microsoft/nni/blob/master/docs/zh_CN/Compressor/Pruner.md#gradientrankfilterpruner) 模型压缩
^^^^^^^^^^^^^^^^^
* 全新 Pruner: `GradientRankFilterPruner <https://github.com/microsoft/nni/blob/v1.5/docs/zh_CN/Compressor/Pruner.rst#gradientrankfilterpruner>`__
* 默认情况下,Compressor 会验证配置 * 默认情况下,Compressor 会验证配置
* 重构:可将优化器作为 Pruner 的输入参数,从而更容易支持 DataParallel 和其它迭代剪枝方法。 这是迭代剪枝算法用法上的重大改动。 * 重构:可将优化器作为 Pruner 的输入参数,从而更容易支持 DataParallel 和其它迭代剪枝方法。 这是迭代剪枝算法用法上的重大改动。
* 重构了模型压缩示例 * 重构了模型压缩示例
* 添加了[实现模型压缩算法](https://github.com/microsoft/nni/blob/master/docs/zh_CN/Compressor/Framework.md)的文档 * 改进 `模型压缩算法 <https://github.com/microsoft/nni/blob/v1.5/docs/zh_CN/Compressor/Framework.rst>`__
训练平台
^^^^^^^^^^^^^^^^
#### 训练平台
* Kubeflow 现已支持 pytorchjob crd v1 (感谢贡献者 @jiapinai) * Kubeflow 现已支持 pytorchjob crd v1 (感谢贡献者 @jiapinai)
* 实验性的支持 [DLTS](https://github.com/microsoft/nni/blob/master/docs/zh_CN/TrainingService/DLTSMode.md) * 实验性地支持 `DLTS <https://github.com/microsoft/nni/blob/v1.5/docs/zh_CN/TrainingService/DLTSMode.rst>`__
文档的整体改进
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#### 文档的整体改进
* 语法、拼写以及措辞上的修改 (感谢贡献者 @AHartNtkn) * 语法、拼写以及措辞上的修改 (感谢贡献者 @AHartNtkn)
### 修复的 Bug 修复的 Bug
^^^^^^^^^^^^^^^^^^^^^^^^^
* ENAS 不能使用多个 LSTM 层 (感谢贡献者 @marsggbo) * ENAS 不能使用多个 LSTM 层 (感谢贡献者 @marsggbo)
* NNI 管理器的计时器无法取消订阅 (感谢贡献者 @guilhermehn) * NNI 管理器的计时器无法取消订阅 (感谢贡献者 @guilhermehn)
...@@ -224,334 +367,476 @@ ...@@ -224,334 +367,476 @@
* lottery ticket Pruner 中的 Bug * lottery ticket Pruner 中的 Bug
* 其它小问题 * 其它小问题
## 发布 1.4 - 2/19/2020 发布 1.4 - 2/19/2020
-----------------------
主要功能
^^^^^^^^^^^^^^
### 主要功能 神经网络架构搜索
^^^^^^^^^^^^^^^^^^^^^^^^^^
#### 神经网络架构搜索
* 支持 [C-DARTS](https://github.com/microsoft/nni/blob/v1.4/docs/zh_CN/NAS/CDARTS.md) 算法并增加对应[示例](https://github.com/microsoft/nni/tree/v1.4/examples/nas/cdarts) * 支持 `C-DARTS <https://github.com/microsoft/nni/blob/v1.4/docs/zh_CN/NAS/CDARTS.rst>`__ 算法并增加 `the 示例 <https://github.com/microsoft/nni/tree/v1.4/examples/nas/cdarts>`__ using it
* 初步支持 [ProxylessNAS](https://github.com/microsoft/nni/blob/v1.4/docs/zh_CN/NAS/Proxylessnas.md) 以及对应[示例](https://github.com/microsoft/nni/tree/v1.4/examples/nas/proxylessnas) * 初步支持 `ProxylessNAS <https://github.com/microsoft/nni/blob/v1.4/docs/zh_CN/NAS/Proxylessnas.rst>`__ 并增加 `示例 <https://github.com/microsoft/nni/tree/v1.4/examples/nas/proxylessnas>`__
* 为 NAS 框架增加单元测试 * 为 NAS 框架增加单元测试
#### 模型压缩 模型压缩
^^^^^^^^^^^^^^^^^
* 为压缩模型增加 DataParallel,并提供相应的 [示例](https://github.com/microsoft/nni/blob/v1.4/examples/model_compress/multi_gpu.py) * 为压缩模型增加 DataParallel,并提供 `示例 <https://github.com/microsoft/nni/blob/v1.4/examples/model_compress/multi_gpu.py>`__
* 支持压缩模型的[加速](https://github.com/microsoft/nni/blob/v1.4/docs/zh_CN/Compressor/ModelSpeedup.md)(试用版) * 支持模型压缩的 `加速 <https://github.com/microsoft/nni/blob/v1.4/docs/zh_CN/Compressor/ModelSpeedup.rst>`__ (试用版)
训练平台
^^^^^^^^^^^^^^^^
#### 训练平台
* 通过允许指定 OpenPAI 配置文件路径,来支持完整的 OpenPAI 配置 * 通过允许指定 OpenPAI 配置文件路径,来支持完整的 OpenPAI 配置
* 为新的 OpenPAI 模式(又称,paiK8S)增加示例配置 YAML 文件 * 为新的 OpenPAI 模式(又称,paiK8S)增加示例配置 YAML 文件
* 支持删除远程模式下使用 sshkey 的 Experiment (感谢外部贡献者 @tyusr) * 支持删除远程模式下使用 sshkey 的 Experiment (感谢外部贡献者 @tyusr)
#### Web 界面 Web 界面
^^^^^^^^^^^^
* Web 界面重构:采用 fabric 框架 * Web 界面重构:采用 fabric 框架
#### 其它 其它
^^^^^^
* 支持[在前台运行 NNI Experiment](https://github.com/microsoft/nni/blob/v1.4/docs/zh_CN/Tutorial/Nnictl#manage-an-experiment),即,`nnictl create/resume/view``--foreground` 参数
* 支持 `在前台运行 NNI 的 Experiment <https://github.com/microsoft/nni/blob/v1.4/docs/zh_CN/Tutorial/Nnictl#manage-an-experiment>`__\ , 即 ``nnictl create/resume/view`` 的 ``--foreground`` 参数
* 支持取消 UNKNOWN 状态的 Trial。 * 支持取消 UNKNOWN 状态的 Trial。
* 支持最大 50MB 的搜索空间文件 (感谢外部贡献者 @Sundrops) * 支持最大 50MB 的搜索空间文件 (感谢外部贡献者 @Sundrops)
### 文档 文档
^^^^^^^^^^^^^
* 改进 NNI readthedocs 的[目录索引结构](https://nni.readthedocs.io/zh/latest/) * 改进 NNI readthedocs 的 `索引目录结果 <https://nni.readthedocs.io/zh/latest/>`__ of NNI readthedocs
* 改进 [NAS 文档](https://github.com/microsoft/nni/blob/v1.4/docs/zh_CN/NAS/NasGuide.md) * 改进 `NAS 文档 <https://github.com/microsoft/nni/blob/v1.4/docs/zh_CN/NAS/NasGuide.rst>`__
* 改进[新的 OpenPAI 模式的文档](https://github.com/microsoft/nni/blob/v1.4/docs/zh_CN/TrainingService/PaiMode.md) * 增加 `PAI 模式的文档 <https://github.com/microsoft/nni/blob/v1.4/docs/zh_CN/TrainingService/PaiMode.rst>`__
*[NAS](https://github.com/microsoft/nni/blob/v1.4/docs/zh_CN/NAS/QuickStart.md)[模型压缩](https://github.com/microsoft/nni/blob/v1.4/docs/zh_CN/Compressor/QuickStart.md)增加入门指南 * 为 `NAS <https://github.com/microsoft/nni/blob/v1.4/docs/zh_CN/NAS/QuickStart.md>`__ 和 `模型压缩 <https://github.com/microsoft/nni/blob/v1.4/docs/zh_CN/Compressor/QuickStart.md>`__ 增加快速入门指南
* 改进支持 [EfficientNet](https://github.com/microsoft/nni/blob/v1.4/docs/zh_CN/TrialExample/EfficientNet.md) 的文档 * 改进 `EfficientNet 的文档 <https://github.com/microsoft/nni/blob/v1.4/docs/zh_CN/TrialExample/EfficientNet.rst>`__
修复的 Bug
^^^^^^^^^^^^^^^^^^^
### 修复的 Bug
* 修复在指标数据和 JSON 格式中对 NaN 的支持 * 修复在指标数据和 JSON 格式中对 NaN 的支持
* 修复搜索空间 `randint` 类型的 out-of-range Bug * 修复搜索空间 ``randint`` 类型的 out-of-range Bug
* 修复模型压缩中导出 ONNX 模型时的错误张量设备的 Bug * 修复模型压缩中导出 ONNX 模型时的错误张量设备的 Bug
* 修复新 OpenPAI 模式(又称,paiK8S)下,错误处理 nnimanagerIP 的 Bug * 修复新 OpenPAI 模式(又称,paiK8S)下,错误处理 nnimanagerIP 的 Bug
## 发布 1.3 - 12/30/2019 发布 1.3 - 12/30/2019
------------------------
主要功能
^^^^^^^^^^^^^^
支持神经网络架构搜索算法
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
### 主要功能 * 增加 `但路径一次性 <https://github.com/microsoft/nni/tree/v1.3/examples/nas/spos/>`__ 算法和示例
#### 支持神经网络架构搜索算法 模型压缩算法支持
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
* [单路径一次性](https://github.com/microsoft/nni/tree/v1.3/examples/nas/spos/)算法和示例
#### 模型压缩算法支持 * 增加 `知识蒸馏 <https://github.com/microsoft/nni/blob/v1.3/docs/zh_CN/TrialExample/KDExample.rst>`__ 算法和示例
* Pruners
* [知识蒸馏](https://github.com/microsoft/nni/blob/v1.3/docs/zh_CN/TrialExample/KDExample.md)算法和使用示例 * `L2Filter Pruner <https://github.com/microsoft/nni/blob/v1.3/docs/zh_CN/Compressor/Pruner.rst#3-l2filter-pruner>`__
* Pruners * `ActivationAPoZRankFilterPruner <https://github.com/microsoft/nni/blob/v1.3/docs/zh_CN/Compressor/Pruner.md#1-activationapozrankfilterpruner>`__
* [L2Filter Pruner](https://github.com/microsoft/nni/blob/v1.3/docs/zh_CN/Compressor/Pruner.md#3-l2filter-pruner) * `ActivationMeanRankFilterPruner <https://github.com/microsoft/nni/blob/v1.3/docs/zh_CN/Compressor/Pruner.md#2-activationmeanrankfilterpruner>`__
* [ActivationAPoZRankFilterPruner](https://github.com/microsoft/nni/blob/v1.3/docs/zh_CN/Compressor/Pruner.md#1-activationapozrankfilterpruner)
* [ActivationMeanRankFilterPruner](https://github.com/microsoft/nni/blob/v1.3/docs/zh_CN/Compressor/Pruner.md#2-activationmeanrankfilterpruner)
* [BNN Quantizer](https://github.com/microsoft/nni/blob/v1.3/docs/zh_CN/Compressor/Quantizer.md#bnn-quantizer)
#### 训练平台 * `BNN Quantizer <https://github.com/microsoft/nni/blob/v1.3/docs/zh_CN/Compressor/Quantizer.md#bnn-quantizer>`__
训练平台
*
OpenPAI 的 NFS 支持
* OpenPAI 的 NFS 支持
从 OpenPAI v0.11开始,HDFS 不再用作默认存储,可将 NFS、AzureBlob 或其他存储用作默认存储。 在本次版本中,NNI 扩展了对 OpenPAI 最近改动的支持,可与 OpenPAI v0.11 及后续版本的默认存储集成。 从 OpenPAI v0.11开始,HDFS 不再用作默认存储,可将 NFS、AzureBlob 或其他存储用作默认存储。 在本次版本中,NNI 扩展了对 OpenPAI 最近改动的支持,可与 OpenPAI v0.11 及后续版本的默认存储集成。
* Kubeflow 更新适配 *
Kubeflow 更新适配
适配 Kubeflow 0.7 对 tf-operator 的新支持。 适配 Kubeflow 0.7 对 tf-operator 的新支持。
### 工程(代码和生成自动化) 工程(代码和生成自动化)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
* 启用 [ESLint](https://eslint.org/) 静态代码分析。 * 启用 `ESLint <https://eslint.org/>`__ 静态代码分析
小改动和 Bug 修复
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
### 小改动和 Bug 修复
* 正确识别内置 Tuner 和定制 Tuner * 正确识别内置 Tuner 和定制 Tuner
* Dispatcher 基类的日志 * Dispatcher 基类的日志
* 修复有时 Tuner、Assessor 的失败会终止 Experiment 的 Bug。 * 修复有时 Tuner、Assessor 的失败会终止 Experiment 的 Bug。
* 修复本机作为远程计算机的[问题](https://github.com/microsoft/nni/issues/1852) * 修复本机作为远程计算机的 `问题 <https://github.com/microsoft/nni/issues/1852>`__
* SMAC Tuner 中 Trial 配置的去重 [ticket](https://github.com/microsoft/nni/issues/1364) * SMAC Tuner 中 Trial 配置的去重 `ticket <https://github.com/microsoft/nni/issues/1364>`__
## 发布 1.2 - 12/02/2019 发布 1.2 - 12/02/2019
------------------------
### 主要功能
主要功能
* [特征工程](https://github.com/microsoft/nni/blob/v1.2/docs/zh_CN/FeatureEngineering/Overview.md) ^^^^^^^^^^^^^^
- 新增特征工程接口
- 特征选择算法: [Gradient feature selector](https://github.com/microsoft/nni/blob/v1.2/docs/zh_CN/FeatureEngineering/GradientFeatureSelector.md) & [GBDT selector](https://github.com/microsoft/nni/blob/v1.2/docs/zh_CN/FeatureEngineering/GBDTSelector.md)
- [特征工程示例](https://github.com/microsoft/nni/tree/v1.2/examples/feature_engineering) * `特征工程 <https://github.com/microsoft/nni/blob/v1.2/docs/zh_CN/FeatureEngineering/Overview.rst>`__
- 神经网络结构搜索在 NNI 上的应用
- [新的 NAS 接口](https://github.com/microsoft/nni/blob/v1.2/docs/zh_CN/NAS/NasInterface.md) * 新增特征工程接口
- NAS 算法: [ENAS](https://github.com/microsoft/nni/blob/v1.2/docs/zh_CN/NAS/Overview.md#enas), [DARTS](https://github.com/microsoft/nni/blob/v1.2/docs/zh_CN/NAS/Overview.md#darts), [P-DARTS](https://github.com/microsoft/nni/blob/v1.2/docs/zh_CN/NAS/Overview.md#p-darts) (PyTorch) * 新增特征选择算法:`Gradient feature selector <https://github.com/microsoft/nni/blob/v1.2/docs/zh_CN/FeatureEngineering/GradientFeatureSelector.md>`__ & `GBDT selector <https://github.com/microsoft/nni/blob/v1.2/docs/zh_CN/FeatureEngineering/GBDTSelector.md>`__
- 经典模式下的 NAS(每次 Trial 独立运行) * `特征工程示例 <https://github.com/microsoft/nni/tree/v1.2/examples/feature_engineering>`__
- 模型压缩
- [新增模型剪枝算法](https://github.com/microsoft/nni/blob/v1.2/docs/zh_CN/Compressor/Overview.md): lottery ticket 剪枝算法, L1Filter Pruner, Slim Pruner, FPGM Pruner * 神经网络结构搜索在 NNI 上的应用
- [新增模型量化算法](https://github.com/microsoft/nni/blob/v1.2/docs/zh_CN/Compressor/Overview.md): QAT Quantizer, DoReFa Quantizer
- 支持导出压缩后模型的 API。 * `全新 NAS 接口 <https://github.com/microsoft/nni/blob/v1.2/docs/zh_CN/NAS/NasInterface.md>`__
- 训练平台 * NAS 算法:`ENAS <https://github.com/microsoft/nni/blob/v1.2/docs/zh_CN/NAS/Overview.md#enas>`__\ , `DARTS <https://github.com/microsoft/nni/blob/v1.2/docs/zh_CN/NAS/Overview.md#darts>`__\ , `P-DARTS <https://github.com/microsoft/nni/blob/v1.2/docs/zh_CN/NAS/Overview.rst#p-darts>`__ (PyTorch)
- 支持 OpenPAI 令牌身份验证 * 经典模式下的 NAS(每次 Trial 独立运行)
- 示例:
- [使用 NNI 自动调优 rocksdb 配置的示例](https://github.com/microsoft/nni/tree/v1.2/examples/trials/systems/rocksdb-fillrandom) * 模型压缩
- [新的支持 TensorFlow 2.0 的 Trial 示例](https://github.com/microsoft/nni/tree/v1.2/examples/trials/mnist-tfv2)
- 改进 * `全新模型剪枝算法 <https://github.com/microsoft/nni/blob/v1.2/docs/zh_CN/Compressor/Overview.md>`__: lottery ticket 修剪, L1Filter Pruner, Slim Pruner, FPGM Pruner
- 远程训练平台中不需要 GPU 的 Trial 任务改为使用随机调度,不再使用轮询调度。 * `全新模型量化算法 <https://github.com/microsoft/nni/blob/v1.2/docs/zh_CN/Compressor/Overview.md>`__\ : QAT quantizer, DoReFa quantizer
- 添加 pylint 规则来检查拉取请求,新的拉取请求需要符合 [pylint 规则](https://github.com/microsoft/nni/blob/v1.2/pylintrc) * 支持导出压缩后模型的 API。
- Web 界面和用户体验
- 支持用户添加自定义 Trial。 * 训练平台
- 除了超参外,用户可放大缩小详细图形。
- 文档 * 支持 OpenPAI 令牌身份验证
- 改进了 NNI API 文档,增加了更多的 docstring。
* 示例:
### 修复的 Bug
* `使用 NNI 自动调优 rocksdb 配置示例 <https://github.com/microsoft/nni/tree/v1.2/examples/trials/systems/rocksdb-fillrandom>`__.
- 修复当失败的 Trial 没有指标时,表格的排序问题。 -Issue #1773 * `支持 TensorFlow 2.0 的 MNIST Trial 示例 <https://github.com/microsoft/nni/tree/v1.2/examples/trials/mnist-tfv2>`__.
- 页面切换时,保留选择的(最大、最小)状态。 -PR#1710
- 使超参数图的默认指标 yAxis 更加精确。 -PR#1736 * 改进
- 修复 GPU 脚本权限问题。 -Issue #1665
* 远程训练平台中不需要 GPU 的 Trial 任务改为使用随机调度,不再使用轮询调度。
## 发布 1.1 - 10/23/2019 * 添加 pylint 规则来检查拉取请求,新的拉取请求需要符合 `pylint 规则 <https://github.com/microsoft/nni/blob/v1.2/pylintrc>`__。
### 主要功能 * Web 门户和用户体验
* 新 Tuner: [PPO Tuner](https://github.com/microsoft/nni/blob/v1.1/docs/zh_CN/Tuner/PPOTuner.md) * 支持用户添加自定义 Trial。
* [查看已停止的 Experiment](https://github.com/microsoft/nni/blob/v1.1/docs/zh_CN/Tutorial/Nnictl.md#view) * 除了超参外,用户可放大缩小详细图形。
* Tuner 可使用专门的 GPU 资源(参考[教程](https://github.com/microsoft/nni/blob/v1.1/docs/zh_CN/Tutorial/ExperimentConfig.md)中的 `gpuIndices` 了解详情)
* 改进 Web 界面 * 文档
- Trial 详情页面可列出每个 Trial 的超参,以及开始结束时间(需要通过 "add column" 添加)
- 优化大型 Experiment 的显示性能 * 改进了 NNI API 文档,增加了更多的 docstring。
- 更多示例
- [EfficientNet PyTorch 示例](https://github.com/ultmaster/EfficientNet-PyTorch) Bug 修复
- [Cifar10 NAS 示例](https://github.com/microsoft/nni/blob/v1.1/examples/trials/nas_cifar10/README.md) ^^^^^^^^^^^^^
- [模型压缩工具包 - Alpha 发布](https://github.com/microsoft/nni/blob/v1.1/docs/zh_CN/Compressor/Overview.md):我们很高兴的宣布 NNI 的模型压缩工具包发布了。它还处于试验阶段,会根据使用反馈来改进。 诚挚邀请您使用、反馈,或更多贡献
### 修复的 Bug * 修复当失败的 Trial 没有指标时,表格的排序问题。 -Issue #1773
* 页面切换时,保留选择的(最大、最小)状态。 -PR#1710
* 使超参数图的默认指标 yAxis 更加精确。 -PR#1736
* 修复 GPU 脚本权限问题。 -Issue #1665
发布 1.1 - 10/23/2019
------------------------
主要功能
^^^^^^^^^^^^^^
* 全新 tuner: `PPO Tuner <https://github.com/microsoft/nni/blob/v1.1/docs/zh_CN/Tuner/PPOTuner.md>`__
* `查看早停 Experiment <https://github.com/microsoft/nni/blob/v1.1/docs/zh_CN/Tutorial/Nnictl.md#view>`__
* Tuner 可使用专门的 GPU 资源(参考 `tutorial <https://github.com/microsoft/nni/blob/v1.1/docs/zh_CN/Tutorial/ExperimentConfig.md>`__ 中的 ``gpuIndices`` 了解详情)
* 改进 WEB 界面
* Trial 详情页面可列出每个 Trial 的超参,以及开始结束时间(需要通过 "add column" 添加)
* 优化大型 Experiment 的显示性能
* 更多示例
* `EfficientNet PyTorch 示例 <https://github.com/ultmaster/EfficientNet-PyTorch>`__
* `Cifar10 NAS 示例 <https://github.com/microsoft/nni/blob/v1.1/examples/trials/nas_cifar10/README.rst>`__
* `模型压缩工具包 - Alpha 阶段 <https://github.com/microsoft/nni/blob/v1.1/docs/zh_CN/Compressor/Overview.md>`__:我们很高兴的宣布 NNI 的模型压缩工具包发布了。它还处于试验阶段,会根据使用反馈来改进。 诚挚邀请您使用、反馈,或更多贡献
修复的 Bug
^^^^^^^^^^
* 当搜索空间结束后,多阶段任务会死锁 (issue #1204) * 当搜索空间结束后,多阶段任务会死锁 (issue #1204)
* 没有日志时,`nnictl` 会失败 (issue #1548) * 没有日志时,``nnictl`` 会失败 (issue #1548)
## 发布1.0 - 9/2/2019 发布1.0 - 9/2/2019
----------------------
### 主要功能
主要功能
* Tuners 和 Assessors ^^^^^^^^^^^^^^
- 支持自动特征生成和选择 -Issue#877 -PR #1387
+ 提供自动特征接口 *
+ 基于 Beam 搜索的 Tuner Tuners 和 Assessors
+ [增加 Pakdd 示例](https://github.com/microsoft/nni/tree/master/examples/trials/auto-feature-engineering)
+ 添加并行算法提高 TPE 在高并发下的性能。 -PR #1052
+ 为 hyperband 支持多阶段 -PR #1257 * 支持自动特征生成和选择 -Issue#877 -PR #1387
+ 训练平台
* 提供自动特征接口
- 支持私有 Docker Registry -PR #755 * 基于 Beam 搜索的 Tuner
* `增加 Pakdd 示例 <https://github.com/microsoft/nni/tree/v1.9/examples/trials/auto-feature-engineering>`__
* 改进
* 增加 RestFUL API 的 Python 包装,支持通过代码获取指标的值 PR #1318 * 添加并行算法提高 TPE 在高并发下的性能。 -PR #1052
* 新的 Python API : get_experiment_id(), get_trial_id() -PR #1353 -Issue #1331 & -Issue#1368 * 为 hyperband 支持多阶段 -PR #1257
* 优化 NAS 搜索空间 -PR #1393
+ 使用 _type 统一 NAS 搜索空间 -- "mutable_type"e *
+ 更新随机搜索 Tuner 训练平台
+ 将 gpuNum 设为可选 -Issue #1365
+ 删除 OpenPAI 模式下的 outputDir 和 dataDir 配置 -Issue #1342
+ 在 Kubeflow 模式下创建 Trial 时,codeDir 不再被拷贝到 logDir -Issue #1224 * 支持私有 Docker Registry -PR #755
+ Web 界面和用户体验
- 在 Web 界面的搜索过程中显示最好指标的曲线 -Issue #1218 * 改进
- 在多阶段 Experiment 中,显示参数列表的当前值 -Issue1210 -PR #1348
- 在 AddColumn 中增加 "Intermediate count" 选项。 -Issue #1210 * 增加 RestFUL API 的 Python 包装,支持通过代码获取指标的值 PR #1318
- 在 Web 界面中支持搜索参数的值 -Issue #1208 * 新的 Python API : get_experiment_id(), get_trial_id() -PR #1353 -Issue #1331 &amp; -Issue#1368
- 在默认指标图中,启用指标轴的自动缩放 -Issue #1360 * 优化 NAS 搜索空间 -PR #1393
- 在命令行中为 nnictl 命令增加详细文档的连接 -Issue #1260
- 用户体验改进:显示 Error 日志 -Issue #1173 * 使用 _type 统一 NAS 搜索空间 -- "mutable_type"e
- 文档 * 更新随机搜索 Tuner
- 更新文档结构 -Issue #1231 * 将 gpuNum 设为可选 -Issue #1365
- (已删除) 多阶段文档的改进 -Issue #1233 -PR #1242 * 删除 OpenPAI 模式下的 outputDir 和 dataDir 配置 -Issue #1342
+ 添加配置示例 * 在 Kubeflow 模式下创建 Trial 时,codeDir 不再被拷贝到 logDir -Issue #1224
+ [Web 界面描述改进](Tutorial/WebUI.md) -PR #1419
*
### 修复的 Bug Web 门户和用户体验
* (Bug 修复)修复 0.9 版本中的链接 -Issue #1236
* 在 Web 界面的搜索过程中显示最好指标的曲线 -Issue #1218
* 在多阶段 Experiment 中,显示参数列表的当前值 -Issue1210 -PR #1348
* 在 AddColumn 中增加 "Intermediate count" 选项。 -Issue #1210
* 在 Web 界面中支持搜索参数的值 -Issue #1208
* 在默认指标图中,启用指标轴的自动缩放 -Issue #1360
* 在命令行中为 nnictl 命令增加详细文档的连接 -Issue #1260
* 用户体验改进:显示 Error 日志 -Issue #1173
*
文档
* 更新文档结构 -Issue #1231
* (已删除) 多阶段文档的改进 -Issue #1233 -PR #1242
* 添加配置示例
* `改进 WebUI 描述 <Tutorial/WebUI.rst>`__ -PR #1419
Bug 修复
^^^^^^^^^^^^^^^^^^
* (Bug 修复)修复 0.9 版本中的链接 -Issue #1236
* (Bug 修复)自动完成脚本 * (Bug 修复)自动完成脚本
* (Bug 修复) 修复管道中仅检查脚本中最后一个命令退出代码的问题。 -PR #1417 * (Bug 修复) 修复管道中仅检查脚本中最后一个命令退出代码的问题。 -PR #1417
* (Bug 修复) Tuner 的 quniform -Issue #1377 * (Bug 修复) Tuner 的 quniform -Issue #1377
* (Bug fix) 'quniform' 在 GridSearch 和其它 Tuner 之间的含义不同。 -Issue #1335 * (Bug fix) 'quniform' 在 GridSearch 和其它 Tuner 之间的含义不同。 * -Issue #1335
* (Bug 修复)"nnictl experiment list" 将 "RUNNING" 状态的 Experiment 显示为了 "INITIALIZED" -PR #1388 * (Bug 修复)"nnictl experiment list" 将 "RUNNING" 状态的 Experiment 显示为了 "INITIALIZED" -PR #1388
* (Bug 修复) 在 NNI dev 安装模式下无法安装 SMAC。 -Issue #1376 * (Bug 修复) 在 NNI dev 安装模式下无法安装 SMAC。 -Issue #1376
* (Bug 修复) 无法点击中间结果的过滤按钮 -Issue #1263 * (Bug 修复) 无法点击中间结果的过滤按钮 -Issue #1263
* (Bug 修复) API "/api/v1/nni/trial-jobs/xxx" 在多阶段 Experiment 无法显示 Trial 的所有参数 -Issue #1258 * (Bug 修复) API "/api/v1/nni/trial-jobs/xxx" 在多阶段 Experiment 无法显示 Trial 的所有参数 -Issue #1258
* (Bug 修复) 成功的 Trial 没有最终结果,但 Web 界面显示成了 ×××(FINAL) -Issue #1207 * (Bug 修复) 成功的 Trial 没有最终结果,但 Web 界面显示成了 ×××(FINAL) -Issue #1207
* (Bug 修复) nnictl stop -Issue #1298 * (Bug 修复) nnictl stop -Issue #1298
* (Bug 修复) 修复安全警告 * (Bug 修复) 修复安全警告
* (Bug 修复) 超参页面损坏 -Issue #1332 * (Bug 修复) 超参页面损坏 -Issue #1332
* (Bug 修复) 运行 flake8 测试来查找 Python 语法错误和未定义的名称 -PR #1217 * (Bug 修复) 运行 flake8 测试来查找 Python 语法错误和未定义的名称 -PR #1217
## 发布 0.9 - 7/1/2019 发布 0.9 - 7/1/2019
----------------------
### 主要功能 主要功能
^^^^^^^^^^^^^^
* 通用 NAS 编程接口
* 为 NAS 接口添加 `enas-mode``oneshot-mode`[PR #1201](https://github.com/microsoft/nni/pull/1201#issue-291094510)
* [有 Matern 核的高斯 Tuner](Tuner/GPTuner.md)
* (已删除) 支持多阶段 Experiment * 生成 NAS 编程接口
* 为多阶段 Experiment 增加新的训练平台:pai 模式从 v0.9 开始支持多阶段 Experiment。 * 为 NAS 接口增加 ``enas-mode`` and ``oneshot-mode``: `PR #1201 <https://github.com/microsoft/nni/pull/1201#issue-291094510>`__
* 为以下内置 Tuner 增加多阶段的功能:
* TPE, Random Search, Anneal, Naïve Evolution, SMAC, Network Morphism, Metis Tuner。 *
* Web 界面 `有 Matern 核的高斯过程 Tuner <Tuner/GPTuner.rst>`__
* 在 Web 界面中可比较 Trial。 有关详细信息,参考[查看 Trial 状态](Tutorial/WebUI.md) *
* 允许用户调节 Web 界面的刷新间隔。 有关详细信息,参考[查看概要页面](Tutorial/WebUI.md) (已删除) 支持多阶段 Experiment
* 更友好的显示中间结果。 有关详细信息,参考[查看 Trial 状态](Tutorial/WebUI.md)
* [命令行接口](Tutorial/Nnictl.md)
* `nnictl experiment delete`:删除一个或多个 Experiment,包括其日志,结果,环境信息核缓存。 用于删除无用的 Experiment 结果,或节省磁盘空间。 * 为多阶段 Experiment 增加新的训练平台:pai 模式从 v0.9 开始支持多阶段 Experiment。
* `nnictl platform clean`:用于清理目标平台的磁盘空间。 所提供的 YAML 文件包括了目标平台的信息,与 NNI 配置文件的格式相同。 * 为以下内置 Tuner 增加多阶段的功能:
### Bug 修复和其它更新 * TPE, Random Search, Anneal, Naïve Evolution, SMAC, Network Morphism, Metis Tuner。
* 改进 Tuner 安装过程:增加 [sklearn](https://scikit-learn.org/stable/) 依赖。 *
* (Bug 修复) 连接 OpenPAI 失败的 HTTP 代码 - [Issue #1076](https://github.com/microsoft/nni/issues/1076) Web 界面
* (Bug 修复) 为 OpenPAI 平台验证文件名 - [Issue #1164](https://github.com/microsoft/nni/issues/1164)
* 在 Web 界面中可比较 Trial。 详情参考 `查看 Trial 状态 <Tutorial/WebUI.rst>`__
* 允许用户调节 Web 界面的刷新间隔。 详情参考 `查看 Summary 界面 <Tutorial/WebUI.rst>`__
* 更友好的显示中间结果。 详情参考 `查看 Trial 状态 <Tutorial/WebUI.rst>`__
* `命令行接口 <Tutorial/Nnictl.rst>`__
* ``nnictl experiment delete``:删除一个或多个 Experiment,包括其日志,结果,环境信息核缓存。 用于删除无用的 Experiment 结果,或节省磁盘空间。
* ``nnictl platform clean``:用于清理目标平台的磁盘空间。 所提供的 YAML 文件包括了目标平台的信息,与 NNI 配置文件的格式相同。
Bug 修复和其它更新
* 改进 Tuner 安装过程:增加 < `sklearn <https://scikit-learn.org/stable/>`__ 依赖。
* (Bug 修复) 连接 OpenPAI 失败的 HTTP 代码 - `Issue #1076 <https://github.com/microsoft/nni/issues/1076>`__
* (Bug 修复) 为 OpenPAI 平台验证文件名 - `Issue #1164 <https://github.com/microsoft/nni/issues/1164>`__
* (Bug 修复) 更新 Metis Tunerz 中的 GMM * (Bug 修复) 更新 Metis Tunerz 中的 GMM
* (Bug 修复) Web 界面负数的刷新间隔时间 - [Issue #1182](https://github.com/microsoft/nni/issues/1182), [Issue #1185](https://github.com/microsoft/nni/issues/1185) * (Bug 修复) Web 界面负数的刷新间隔时间 - `Issue #1182 <https://github.com/microsoft/nni/issues/1182>`__ , `Issue #1185 <https://github.com/microsoft/nni/issues/1185>`__
* (Bug 修复) 当只有一个超参时,Web 界面的超参无法正确显示 - [Issue #1192](https://github.com/microsoft/nni/issues/1192) * (Bug 修复) 当只有一个超参时,Web 界面的超参无法正确显示 - `Issue #1192 <https://github.com/microsoft/nni/issues/1192>`__
## 发布 0.8 - 6/4/2019 发布 0.8 - 6/4/2019
----------------------
### 主要功能 主要功能
^^^^^^^^^^^^^^
* 在 Windows 上支持 NNI 的 OpenPAI 和远程模式
* 在 Windows 上支持 NNI 的 OpenPAI 和远程模式
* NNI 可在 Windows 上使用 OpenPAI 模式 * NNI 可在 Windows 上使用 OpenPAI 模式
* NNI 可在 Windows 上使用 OpenPAI 模式 * NNI 可在 Windows 上使用 OpenPAI 模式
* GPU 的高级功能
* GPU 的高级功能
* 在本机或远程模式上,可在同一个 GPU 上运行多个 Trial。 * 在本机或远程模式上,可在同一个 GPU 上运行多个 Trial。
* 在已经运行非 NNI 任务的 GPU 上也能运行 Trial * 在已经运行非 NNI 任务的 GPU 上也能运行 Trial
* 支持 Kubeflow v1beta2 操作符
* 支持 Kubeflow v1beta2 操作符
* 支持 Kubeflow TFJob/PyTorchJob v1beta2 * 支持 Kubeflow TFJob/PyTorchJob v1beta2
* [通用 NAS 编程接口](https://github.com/microsoft/nni/blob/v0.8/docs/zh_CN/GeneralNasInterfaces.md)
* `通用 NAS 编程接口 <https://github.com/microsoft/nni/blob/v0.8/docs/zh_CN/GeneralNasInterfaces.md>`__
* 实现了 NAS 的编程接口,可通过 NNI Annotation 很容易的表达神经网络架构搜索空间 * 实现了 NAS 的编程接口,可通过 NNI Annotation 很容易的表达神经网络架构搜索空间
* 提供新命令 `nnictl trial codegen` 来调试 NAS 代码生成部分 * 提供新命令 ``nnictl trial codegen`` 来调试 NAS 代码生成部分
* 提供 NAS 编程接口教程,NAS 在 MNIST 上的示例,用于 NAS 的可定制的随机 Tuner * 提供 NAS 编程接口教程,NAS 在 MNIST 上的示例,用于 NAS 的可定制的随机 Tuner
* 支持在恢复 Experiment 时,同时恢复 Tuner 和 Advisor 的状态 * 支持在恢复 Experiment 时,同时恢复 Tuner 和 Advisor 的状态
* 在恢复 Experiment 时,Tuner 和 Advisor 会导入已完成的 Trial 的数据。 * 在恢复 Experiment 时,Tuner 和 Advisor 会导入已完成的 Trial 的数据。
* Web 界面 * Web 界面
* 改进拷贝 Trial 参数的设计 * 改进拷贝 Trial 参数的设计
* 在 hyper-parameter 图中支持 'randint' 类型 * 在 hyper-parameter 图中支持 'randint' 类型
* 使用 ComponentUpdate 来避免不必要的刷新 * 使用 ComponentUpdate 来避免不必要的刷新
### Bug 修复和其它更新 Bug 修复和其它更新
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
* 修复 `nnictl update` 不一致的命令行风格 * 修复 ``nnictl update`` 不一致的命令行风格
* SMAC Tuner 支持导入数据 * SMAC Tuner 支持导入数据
* 支持 Experiment 状态从 ERROR 回到 RUNNING * 支持 Experiment 状态从 ERROR 回到 RUNNING
* 修复表格的 Bug * 修复表格的 Bug
* 优化嵌套搜索空间 * 优化嵌套搜索空间
* 优化 'randint' 类型,并支持下限 * 优化 'randint' 类型,并支持下限
* [比较不同超参搜索调优算法](CommunitySharings/HpoComparison.md) * `超参调优算法的对比 <CommunitySharings/HpoComparison.rst>`__
* [NAS 算法的对比](CommunitySharings/NasComparison.md) * `NAS 算法对比 <CommunitySharings/NasComparison.rst>`__
* [Recommenders 上的实践](CommunitySharings/RecommendersSvd.md) * `NNI 在推荐上的应用 <CommunitySharings/RecommendersSvd.rst>`__
发布 0.7 - 4/29/2018
-----------------------
主要功能
^^^^^^^^^^^^^^
## 发布 0.7 - 4/29/2018
### 主要功能 * `在 WIndows 上支持 NNI <Tutorial/InstallationWin.rst>`__
* [支持在 Windows 上使用 NNI](Tutorial/InstallationWin.md)
* NNI 可在 Windows 上使用本机模式 * NNI 可在 Windows 上使用本机模式
* [支持新的 Advisor: BOHB](Tuner/BohbAdvisor.md)
* `全新 advisor: BOHB <Tuner/BohbAdvisor.rst>`__
* 支持新的 BOHB Advisor,这是一个健壮而有效的超参调优算法,囊括了贝叶斯优化和 Hyperband 的优点 * 支持新的 BOHB Advisor,这是一个健壮而有效的超参调优算法,囊括了贝叶斯优化和 Hyperband 的优点
* [支持通过 nnictl 来导入导出 Experiment 数据](Tutorial/Nnictl.md)
* `支持通过 nnictl 来导入导出 Experiment 数据 <Tutorial/Nnictl.rst>`__
* 在 Experiment 执行完后,可生成分析结果报告 * 在 Experiment 执行完后,可生成分析结果报告
* 支持将先前的调优数据导入到 Tuner 和 Advisor 中 * 支持将先前的调优数据导入到 Tuner 和 Advisor 中
* [可为 NNI Trial 任务指定 GPU](Tutorial/ExperimentConfig.md#localConfig)
* `为 NNI Trial 任务指定 GPU 设备 <Tutorial/ExperimentConfig.rst#localConfig>`__
* 通过 gpuIndices 配置来为 Trial 任务指定GPU。如果 Experiment 配置文件中有 gpuIndices,则只有指定的 GPU 会被用于 NNI 的 Trial 任务。 * 通过 gpuIndices 配置来为 Trial 任务指定GPU。如果 Experiment 配置文件中有 gpuIndices,则只有指定的 GPU 会被用于 NNI 的 Trial 任务。
* 改进 Web 界面
* 改进 Web 界面
* 在 Web 界面上使用十进制格式的指标 * 在 Web 界面上使用十进制格式的指标
* 添加多阶段训练相关的提示 * 添加多阶段训练相关的提示
* 可将超参复制为 Python dict 格式 * 可将超参复制为 Python dict 格式
* 可将提前终止的 Trial 数据传入 Tuner。 * 可将提前终止的 Trial 数据传入 Tuner。
* 为 nnictl 提供更友好的错误消息
* 为 nnictl 提供更友好的错误消息
* 为 YAML 文件格式错误提供更有意义的错误信息 * 为 YAML 文件格式错误提供更有意义的错误信息
### Bug 修复 Bug 修复
^^^^^^^^^^^^^^
* 运行 nnictl stop 的异步 Dispatcher 模式时,无法杀掉所有的 Python 线程 * 运行 nnictl stop 的异步 Dispatcher 模式时,无法杀掉所有的 Python 线程
* nnictl --version 不能在 make dev-install 下使用 * nnictl --version 不能在 make dev-install 下使用
* OpenPAI 平台下所有的 Trial 任务状态都是 'WAITING' * OpenPAI 平台下所有的 Trial 任务状态都是 'WAITING'
## 发布 0.6 - 4/2/2019 发布 0.6 - 4/2/2019
----------------------
主要功能
^^^^^^^^^^^^^^
### 主要功能
* [版本检查](TrainingService/PaiMode.md) * `版本检查 <TrainingService/PaiMode.rst>`__
* 检查 nniManager 和 trialKeeper 的版本是否一致 * 检查 nniManager 和 trialKeeper 的版本是否一致
* [提前终止的任务也可返回最终指标](https://github.com/microsoft/nni/issues/776)
* `为早停的任务报告最终指标 <https://github.com/microsoft/nni/issues/776>`__
* 如果 includeIntermediateResults 为 true,最后一个 Assessor 的中间结果会被发送给 Tuner 作为最终结果。 includeIntermediateResults 的默认值为 false。 * 如果 includeIntermediateResults 为 true,最后一个 Assessor 的中间结果会被发送给 Tuner 作为最终结果。 includeIntermediateResults 的默认值为 false。
* [分离 Tuner/Assessor](https://github.com/microsoft/nni/issues/841)
* `独立的 Tuner/Assessor <https://github.com/microsoft/nni/issues/841>`__
* 增加两个管道来分离 Tuner 和 Assessor 的消息 * 增加两个管道来分离 Tuner 和 Assessor 的消息
* 使日志集合功能可配置 * 使日志集合功能可配置
* 为所有 Trial 增加中间结果的视图 * 为所有 Trial 增加中间结果的视图
### Bug 修复 Bug 修复
^^^^^^^^^^^^^^
* [为 OpenPAI 增加 shmMB 配置](https://github.com/microsoft/nni/issues/842) * `为 OpenPAI 增加 shmMB 配置 <https://github.com/microsoft/nni/issues/842>`__
* 修复在指标为 dict 时,无法显示任何结果的 Bug。 * 修复在指标为 dict 时,无法显示任何结果的 Bug。
* 修复 hyperband 中浮点类型的计算问题 * 修复 hyperband 中浮点类型的计算问题
* 修复 SMAC Tuner 中搜索空间转换的错误 * 修复 SMAC Tuner 中搜索空间转换的错误
* 修复 Web 界面中解析 Experiment 的错误格式 * 修复 Web 界面中解析 Experiment 的错误格式
* 修复 Metis Tuner 冷启动时的错误 * 修复 Metis Tuner 冷启动时的错误
## 发布 0.5.2 - 3/4/2019 发布 0.5.2 - 3/4/2019
------------------------
改进
^^^^^^^^^^^^
### 改进
* 提升 Curve fitting Assessor 的性能。 * 提升 Curve fitting Assessor 的性能。
### 文档 文档
^^^^^^^^^^^^^
* 发布中文文档网站:https://nni.readthedocs.io/zh/latest/ * 发布中文文档网站:https://nni.readthedocs.io/zh/latest/
* 调试和维护:https://nni.readthedocs.io/zh/latest/Tutorial/HowToDebug.html * 调试和维护:https://nni.readthedocs.io/zh/latest/Tutorial/HowToDebug.html
* Tuner、Assessor 参考:https://nni.readthedocs.io/zh/latest/sdk_reference.html#tuner * Tuner、Assessor 参考:https://nni.readthedocs.io/zh/latest/sdk_reference.html#tuner
### Bug 修复和其它更新 Bug 修复和其它更新
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
* 修复了在某些极端条件下,不能正确存储任务的取消状态。 * 修复了在某些极端条件下,不能正确存储任务的取消状态。
* 修复在使用 SMAC Tuner 时,解析搜索空间的错误。 * 修复在使用 SMAC Tuner 时,解析搜索空间的错误。
...@@ -560,68 +845,96 @@ ...@@ -560,68 +845,96 @@
* 为远程服务器、OpenPAI 和 Kubeflow 训练平台在 Azure 中增加集成测试。 * 为远程服务器、OpenPAI 和 Kubeflow 训练平台在 Azure 中增加集成测试。
* 在 OpenPAI 客户端中支持 Pylon 路径。 * 在 OpenPAI 客户端中支持 Pylon 路径。
## 发布 0.5.1 - 1/31/2018 发布 0.5.1 - 1/31/2018
-------------------------
改进
^^^^^^^^^^^^
### 改进
* 可配置[日志目录](https://github.com/microsoft/nni/blob/v0.5.1/docs/ExperimentConfig_zh_CN.md) * 支持配置 `log 目录 <https://github.com/microsoft/nni/blob/v0.5.1/docs/ExperimentConfig.md>`__
* 支持[不同级别的日志](https://github.com/microsoft/nni/blob/v0.5.1/docs/ExperimentConfig_zh_CN.md),使其更易于调试。 * 支持 `不同级别的日志 <https://github.com/microsoft/nni/blob/v0.5.1/docs/ExperimentConfig.md>`__,使其更易于调试。
文档
^^^^^^^^^^^^^
### 文档
* 重新组织文档,新的主页位置:https://nni.readthedocs.io/zh/latest/ * 重新组织文档,新的主页位置:https://nni.readthedocs.io/zh/latest/
### Bug 修复和其它更新 Bug 修复和其它更新
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
* 修复了 Python 虚拟环境中安装的 Bug,并重构了安装逻辑。 * 修复了 Python 虚拟环境中安装的 Bug,并重构了安装逻辑。
* 修复了在最新的 OpenPAI 下存取 HDFS 失败的问题。 * 修复了在最新的 OpenPAI 下存取 HDFS 失败的问题。
* 修复了有时刷新 stdout 会造成 Experiment 崩溃的问题。 * 修复了有时刷新 stdout 会造成 Experiment 崩溃的问题。
## 发布 0.5.0 - 01/14/2019 发布 0.5.0 - 01/14/2019
--------------------------
### 主要功能 主要功能
^^^^^^^^^^^^^^
#### 支持新的 Tuner 和 Assessor 支持新的 Tuner 和 Assessor
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
* 支持新的 [Metis Tuner](Tuner/MetisTuner.md)。 对于**在线**超参调优的场景,Metis 算法已经被证明非常有效。
* 支持 [ENAS customized tuner](https://github.com/countif/enas_nni)。由 GitHub 社区用户所贡献。它是神经网络的搜索算法,能够通过强化学习来学习神经网络架构,比 NAS 的性能更好。
* 支持 [Curve fitting (曲线拟合)Assessor](Assessor/CurvefittingAssessor.md),通过曲线拟合的策略来实现提前终止 Trial。
* [权重共享的](https://github.com/microsoft/nni/blob/v0.5/docs/AdvancedNAS.md)高级支持:为 NAS Tuner 提供权重共享,当前支持 NFS。
#### 改进训练平台 * 支持 `Metis tuner <Tuner/MetisTuner.rst>`__ 对于\ **在线**\ 超参调优的场景,Metis 算法已经被证明非常有效。
* 支持 `ENAS customized tuner <https://github.com/countif/enas_nni>`__。由 GitHub 社区用户所贡献。它是神经网络的搜索算法,能够通过强化学习来学习神经网络架构,比 NAS 的性能更好。
* 支持 `Curve fitting assessor <Assessor/CurvefittingAssessor.rst>`__,通过曲线拟合的策略来实现提前终止 Trial。
* `权重共享的 <https://github.com/microsoft/nni/blob/v0.5/docs/AdvancedNAS.md>`__ 高级支持:为 NAS Tuner 提供权重共享,当前支持 NFS。
改进训练平台
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
* `FrameworkController 训练服务 <TrainingService/FrameworkControllerMode.rst>`__:支持使用在 Kubernetes 上使用 FrameworkController 运行。
* [FrameworkController 训练平台](TrainingService/FrameworkControllerMode.md):支持使用在 Kubernetes 上使用 FrameworkController 运行。
* FrameworkController 是 Kubernetes 上非常通用的控制器(Controller),能用来运行基于各种机器学习框架的分布式作业,如 TensorFlow,Pytorch, MXNet 等。 * FrameworkController 是 Kubernetes 上非常通用的控制器(Controller),能用来运行基于各种机器学习框架的分布式作业,如 TensorFlow,Pytorch, MXNet 等。
* NNI 为作业定义了统一而简单的规范。 * NNI 为作业定义了统一而简单的规范。
* 如何使用 FrameworkController 的 MNIST 样例。 * 如何使用 FrameworkController 的 MNIST 样例。
#### 改进用户体验 改进用户体验
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
* 为 OpenPAI, Kubeflow 和 FrameworkController 模式提供更好的日志支持。
* 为 OpenPAI, Kubeflow 和 FrameworkController 模式提供更好的日志支持。
* 改进后的日志架构能将尝试的 stdout/stderr 通过 HTTP POST 方式发送给 NNI 管理器。 NNI 管理器将 Trial 的 stdout/stderr 消息存储在本地日志文件中。 * 改进后的日志架构能将尝试的 stdout/stderr 通过 HTTP POST 方式发送给 NNI 管理器。 NNI 管理器将 Trial 的 stdout/stderr 消息存储在本地日志文件中。
* 在 WEB 界面上显示 Trial 日志的链接。 * 在 WEB 界面上显示 Trial 日志的链接。
* 支持将最终结果显示为键值对。 * 支持将最终结果显示为键值对。
## 发布 0.4.1 - 12/14/2018 发布 0.4.1 - 12/14/2018
--------------------------
主要功能
^^^^^^^^^^^^^^
### 主要功能 支持新的 Tuner
^^^^^^^^^^^^^^^^^^
#### 支持新的 Tuner
* 支持新的 [network morphism](Tuner/NetworkmorphismTuner.md) Tuner * 支持 `network morphism <Tuner/NetworkmorphismTuner.rst>`__ Tuner
#### 改进训练平台 改进训练服务
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
*[Kubeflow 训练平台](TrainingService/KubeflowMode.md)的依赖从 kubectl CLI 迁移到 [Kubernetes API](https://kubernetes.io/docs/concepts/overview/kubernetes-api/) 客户端。
* Kubeflow 训练服务支持 [Pytorch-operator](https://github.com/kubeflow/pytorch-operator) 将 `Kubeflow 训练平台 <TrainingService/KubeflowMode.rst>`__ 的依赖从 kubectl CLI 迁移到 `Kubernetes API <https://kubernetes.io/docs/concepts/overview/kubernetes-api/>`__ 客户端。
* Kubeflow 训练服务支持 `Pytorch-operator <https://github.com/kubeflow/pytorch-operator>`__。
* 改进将本地代码文件上传到 OpenPAI HDFS 的性能。 * 改进将本地代码文件上传到 OpenPAI HDFS 的性能。
* 修复 OpenPAI 在 WEB 界面的 Bug:当 OpenPAI 认证过期后,Web 界面无法更新 Trial 作业的状态。 * 修复 OpenPAI 在 WEB 界面的 Bug:当 OpenPAI 认证过期后,Web 界面无法更新 Trial 作业的状态。
#### 改进 NNICTL 改进 NNICTL
^^^^^^^^^^^^^^^^^^^
* 在 nnictl 和 WEB 界面中显示 NNI 的版本信息。 可使用 **nnictl -v** 来显示安装的 NNI 版本。 * 在 nnictl 和 WEB 界面中显示 NNI 的版本信息。 可使用 **nnictl -v** 来显示安装的 NNI 版本。
#### 改进 WEB 界面 改进 WEB 界面
^^^^^^^^^^^^^^^^^^
* 在 Experiment 运行中可修改并发数量 * 在 Experiment 运行中可修改并发数量
* 增加指向 NNI Github 的反馈链接,可直接创建问题 * 增加指向 NNI Github 的反馈链接,可直接创建问题
...@@ -630,126 +943,178 @@ ...@@ -630,126 +943,178 @@
* 为指标数值图提供自动缩放的数轴 * 为指标数值图提供自动缩放的数轴
* 改进 Annotation,支持在搜索空间中显示实际的选项 * 改进 Annotation,支持在搜索空间中显示实际的选项
### 新示例 新样例
^^^^^^^^^^^^
* [FashionMnist](https://github.com/microsoft/nni/tree/master/examples/trials/network_morphism)使用 network morphism Tuner * `FashionMnist <https://github.com/microsoft/nni/tree/v1.9/examples/trials/network_morphism>`__ 使用 network morphism Tuner
* 使用 PyTorch [分布式 MNIST 示例](https://github.com/microsoft/nni/tree/master/examples/trials/mnist-distributed-pytorch) * 改进 PyTorch 中的 `分布式 MNIST 示例 <https://github.com/microsoft/nni/tree/v1.9/examples/trials/mnist-distributed-pytorch>`__
## 发布 0.4 - 12/6/2018 发布 0.4 - 12/6/2018
-----------------------
### 主要功能 主要功能
^^^^^^^^^^^^^^
* `Kubeflow 训练平台 <TrainingService/KubeflowMode.rst>`__
* [Kubeflow 训练平台](TrainingService/KubeflowMode.md)
* 支持 tf-operator * 支持 tf-operator
* 使用 Kubeflow 的[分布式 Trial 示例](https://github.com/microsoft/nni/tree/master/examples/trials/mnist-distributed/dist_mnist.py) * Kubeflow 上的 `分布式 Trial 示例 <https://github.com/microsoft/nni/tree/v1.9/examples/trials/mnist-distributed/dist_mnist.py>`__
* [网格搜索 Tuner](Tuner/GridsearchTuner.md)
* [Hyperband Tuner](Tuner/HyperbandAdvisor.md) * `Grid search tuner <Tuner/GridsearchTuner.rst>`__
* 支持在 MAC 上运行 NNI Experiment * `Hyperband tuner <Tuner/HyperbandAdvisor.rst>`__
* Web 界面 * 支持在 MAC 上运行 NNI 实验
* 支持 hyperband Tuner * Web 界面
* 支持 hyperband 调参器
* 移除 tensorboard 按钮 * 移除 tensorboard 按钮
* 显示 Experiment 的错误消息 * 显示实验的错误消息
* 显示搜索空间和 Trial 配置的行号 * 显示搜索空间和尝试配置的行号
* 支持通过指定的 Trial id 来搜索 * 支持通过指定的尝试 id 来搜索
* 显示 Trial 的 hdfsLogPath * 显示尝试的 hdfsLogPath
* 下载 Experiment 参数 * 下载实验参数
其它
^^^^^^
### 其它
* 异步调度 * 异步调度
* 更新 Docker 文件,增加 pytorch 库 * 更新 Docker 文件,增加 pytorch 库
* 重构 'nnictl stop' 过程,发送 SIGTERM 给 NNI 管理器进程,而不是调用停止 Restful API. * 重构 'nnictl stop' 过程,发送 SIGTERM 给 NNI 管理器进程,而不是调用停止 Restful API.
* 修复 OpenPAI 训练平台的 Bug * OpenPAI 训练服务修复缺陷
* 在 NNI 管理器中为 OpenPAI 集群配置文件支持 IP 配置(nniManagerIp),来修复用户计算机没有 eth0 设备的问题。 * 在 NNI 管理器中为 OpenPAI 集群配置文件支持 IP 配置(nniManagerIp),来修复用户计算机没有 eth0 设备的问题。
* codeDir 中的文件数量上限改为1000,避免用户无意中填写了 root 目录。 * codeDir 中的文件数量上限改为1000,避免用户无意中填写了 root 目录。
* 移除 OpenPAI 作业的 stdout 日志中无用的 ‘metrics is empty’。 在新指标被记录时,仅输出有用的消息,来减少用户检查 OpenPAI Trial 输出时的困惑。 * 移除 OpenPAI 作业的 stdout 日志中无用的 ‘metrics is empty’。 在新指标被记录时,仅输出有用的消息,来减少用户检查 OpenPAI Trial 输出时的困惑。
* 在 Trial keeper 的开始增加时间戳。 * 在尝试 keeper 的开始增加时间戳。
发布 0.3.0 - 11/2/2018
-------------------------
NNICTL 的新功能和更新
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
## 发布 0.3.0 - 11/2/2018 *
支持同时运行多个实验。
### NNICTL 的新功能和更新 在 v0.3 以前,NNI 仅支持一次运行一个实验。 此版本开始,用户可以同时运行多个 Experiment。 每个实验都需要一个唯一的端口,第一个实验会像以前版本一样使用默认端口。 需要为其它实验指定唯一端口:
* 支持同时运行多个 Experiment。 .. code-block:: bash
在 v0.3 以前,NNI 仅支持一次运行一个 Experiment。 此版本开始,用户可以同时运行多个 Experiment。 每个 Experiment 都需要一个唯一的端口,第一个 Experiment 会像以前版本一样使用默认端口。 需要为其它 Experiment 指定唯一端口:
```bash
nnictl create --port 8081 --config <config file path>
```
* 支持更新最大 Trial 的数量。 使用 `nnictl update --help` 了解详情。 或参考 [NNICTL](Tutorial/Nnictl.md) 查看完整帮助。 nnictl create --port 8081 --config <config file path>
### API 的新功能和更新 *
支持更新最大尝试的数量。
使用 ``nnictl update --help`` 了解详情。 或参考 `NNICTL Spec <Tutorial/Nnictl.rst>`__ 查看完整帮助。
* <span style="color:red"><strong>不兼容的改动</strong></span>:nn.get_parameters() 改为 nni.get_next_parameter。 所有以前版本的样例将无法在 v0.3 上运行,需要重新克隆 NNI 代码库获取新样例。 如果在自己的代码中使用了 NNI,也需要相应的更新。 API 的新功能和更新
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
*
:raw-html:`<span style="color:red">**不兼容的变化**</span>`\ : nn.get_parameters() 改为 nni.get_next_parameter。 所有以前版本的样例将无法在 v0.3 上运行,需要重新克隆 NNI 代码库获取新样例。 如果在自己的代码中使用了 NNI,也需要相应的更新。
*
新 API **nni.get_sequence_id()**。
每个尝试任务都会被分配一个唯一的序列数字,可通过 nni.get_sequence_id() API 来获取。
.. code-block:: bash
git clone -b v0.3 https://github.com/microsoft/nni.git
*
**nni.report_final_result(result)** API 对结果参数支持更多的数据类型。
可用类型:
* 新 API **nni.get_sequence_id()**。 每个尝试任务都会被分配一个唯一的序列数字,可通过 nni.get_sequence_id() API 来获取。
```bash
git clone -b v0.3 https://github.com/microsoft/nni.git
```
* **nni.report_final_result(result)** API 对结果参数支持更多的数据类型。
可用类型:
* int * int
* float * float
* 包含有 'default' 键值的 dict,'default' 的值必须为 int 或 float。 dict 可以包含任何其它键值对。 * 包含有 'default' 键值的 dict,'default' 的值必须为 int 或 float。 dict 可以包含任何其它键值对。
### 支持新的 Tuner 新的内置调参器
^^^^^^^^^^^^^^^^^
* **Batch Tuner(批处理调参器)** 会执行所有曹参组合,可被用来批量提交尝试任务。
### 新示例 **Batch Tuner(批处理调参器)** 会执行所有曹参组合,可被用来批量提交尝试任务。
* 公共的 NNI Docker 映像: 新样例
^^^^^^^^^^^^
```bash
docker pull msranni/nni:latest
```
* 新的 Trial 示例:[NNI Sklearn 示例](https://github.com/microsoft/nni/tree/master/examples/trials/sklearn)
* 新的竞赛示例:[Kaggle Competition TGS Salt](https://github.com/microsoft/nni/tree/master/examples/trials/kaggle-tgs-salt) *
公共的 NNI Docker 映像:
### 其它 .. code-block:: bash
* 界面重构,参考[网页文档](Tutorial/WebUI.md),了解如何使用新界面。 docker pull msranni/nni:latest
*
新的 Trial 示例: `NNI Sklearn Example <https://github.com/microsoft/nni/tree/v0.3/examples/trials/sklearn>`__
* 全新比赛示例 `Kaggle Competition TGS Salt Example <https://github.com/microsoft/nni/tree/v0.2/examples/trials/kaggle-tgs-salt>`__
其它
^^^^^^
* 界面重构,参考 `WebUI 文档 <Tutorial/WebUI.rst>`__,了解如何使用新界面。
* 持续集成:NNI 已切换到 Azure pipelines。 * 持续集成:NNI 已切换到 Azure pipelines。
## 发布 0.2.0 - 9/29/2018 发布 0.2.0 - 9/29/2018
-------------------------
主要功能
^^^^^^^^^^^^^^
### 主要功能 * 支持 `OpenPAI <https://github.com/microsoft/pai>`__ (又称 pai) 训练平台 (参考 `这里 <TrainingService/PaiMode.rst>`__ 来了解如何在 OpenPAI 下提交 NNI 任务)
* 支持 [OpenPAI](https://github.com/microsoft/pai) (又称 pai) 训练平台 (参考[这里](TrainingService/PaiMode.md)来了解如何在 OpenPAI 下提交 NNI 任务) * 支持 pai 模式的训练服务。 NNI 尝试可发送至 OpenPAI 集群上运行
* 支持 pai 模式的训练平台。 NNI Trial 可发送至 OpenPAI 集群上运行
* NNI 尝试输出 (包括日志和模型文件) 会被复制到 OpenPAI 的 HDFS 中。 * NNI 尝试输出 (包括日志和模型文件) 会被复制到 OpenPAI 的 HDFS 中。
* 支持 [SMAC](https://www.cs.ubc.ca/~hutter/papers/10-TR-SMAC.pdf) Tuner (参考[这里](Tuner/SmacTuner.md),了解如何使用 SMAC Tuner)
* [SMAC](https://www.cs.ubc.ca/~hutter/papers/10-TR-SMAC.pdf) 基于 Sequential Model-Based Optimization (SMBO). 它会利用使用过的突出的模型(高斯随机过程模型),并将随机森林引入到SMBO中,来处理分类参数。 NNI 的 SMAC 通过包装 [SMAC3](https://github.com/automl/SMAC3) 来支持。
* 支持将 NNI 安装在 [conda](https://conda.io/docs/index.html) 和 Python 虚拟环境中。
* 其它
* 更新 ga squad 示例与相关文档
* 用户体验改善及 Bug 修复
## 发布 0.1.0 - 9/10/2018 (首个版本) * 支持 `SMAC <https://www.cs.ubc.ca/~hutter/papers/10-TR-SMAC.pdf>`__ tuner (参考 `这里 <Tuner/SmacTuner.rst>`__ 来了解如何使用 SMAC tuner)
* `SMAC <https://www.cs.ubc.ca/~hutter/papers/10-TR-SMAC.pdf>`__ 基于 Sequential Model-Based Optimization (SMBO). 它会利用使用过的突出的模型(高斯随机过程模型),并将随机森林引入到SMBO中,来处理分类参数。 NNI 的 SMAC 通过包装 `SMAC3 <https://github.com/automl/SMAC3>`__ 来支持。
* 支持将 NNI 安装在 `conda <https://conda.io/docs/index.html>`__ 和 Python 虚拟环境中。
* 其它
* 更新 ga squad 样例与相关文档
* 用户体验改善及缺陷修复
发布 0.1.0 - 9/10/2018 (首个版本)
-------------------------------------------
首次发布 Neural Network Intelligence (NNI)。 首次发布 Neural Network Intelligence (NNI)。
### 主要功能 主要功能
^^^^^^^^^^^^^^
* 安装和部署
* 安装和部署
* 支持 pip 和源代码安装 * 支持 pip 和源代码安装
* 支持本机(包括多 GPU 卡)训练和远程多机训练模式 * 支持本机(包括多 GPU 卡)训练和远程多机训练模式
* Tuner,Assessor 和 Trial
* 调参器,评估器和尝试
* 支持的自动机器学习算法包括: hyperopt_tpe, hyperopt_annealing, hyperopt_random, 和 evolution_tuner。 * 支持的自动机器学习算法包括: hyperopt_tpe, hyperopt_annealing, hyperopt_random, 和 evolution_tuner。
* 支持评估器(提前终止)算法包括:medianstop。 * 支持评估器(提前终止)算法包括:medianstop。
* 提供 Python API 来自定义 Tuner 和 Assessor * 提供 Python API 来自定义调参器和评估器
* 提供 Python API 来包装尝试代码,以便能在 NNI 中运行 * 提供 Python API 来包装尝试代码,以便能在 NNI 中运行
* Experiment
* 实验
* 提供命令行工具 'nnictl' 来管理实验 * 提供命令行工具 'nnictl' 来管理实验
* 提供网页界面来查看并管理实验 * 提供网页界面来查看并管理实验
* 持续集成
* 使用 Ubuntu 的 [travis-ci](https://github.com/travis-ci) 来支持持续集成 * 持续集成
* 其它
* 支持简单的 GPU 任务调度 * 使用 Ubuntu 的 `travis-ci <https://github.com/travis-ci>`__ 来支持持续集成
\ No newline at end of file
* 其它
* 支持简单的 GPU 任务调度
研究和出版物
=========================
为了使自动模型设计、调优真正实用和强大,我们同时致力于工具链的开发和科学研究。 一方面,我们的主要工作是工具链的开发。 另一方面,我们的工作旨在改进这个工具链,重新思考 AutoML 中具有挑战性问题(包括系统和算法),并提出优雅的解决方案。 下面列出了我们的一些研究成果,我们鼓励在 AutoML 涌现出更多的研究工作,并希望和更多优秀的研究者合作。
系统研究
---------------
* `Retiarii: A Deep Learning Exploratory-Training Framework <https://www.usenix.org/system/files/osdi20-zhang_quanlu.pdf>`__
.. code-block:: bibtex
@inproceedings{zhang2020retiarii,
title={Retiarii: A Deep Learning Exploratory-Training Framework},
author={Zhang, Quanlu and Han, Zhenhua and Yang, Fan and Zhang, Yuge and Liu, Zhe and Yang, Mao and Zhou, Lidong},
booktitle={14th $\{$USENIX$\}$ Symposium on Operating Systems Design and Implementation ($\{$OSDI$\}$ 20)},
pages={919--936},
year={2020}
}
* `AutoSys: The Design and Operation of Learning-Augmented Systems <https://www.usenix.org/system/files/atc20-liang-chieh-jan.pdf>`__
.. code-block:: bibtex
@inproceedings{liang2020autosys,
title={AutoSys: The Design and Operation of Learning-Augmented Systems},
author={Liang, Chieh-Jan Mike and Xue, Hui and Yang, Mao and Zhou, Lidong and Zhu, Lifei and Li, Zhao Lucis and Wang, Zibo and Chen, Qi and Zhang, Quanlu and Liu, Chuanjie and others},
booktitle={2020 $\{$USENIX$\}$ Annual Technical Conference ($\{$USENIX$\}$$\{$ATC$\}$ 20)},
pages={323--336},
year={2020}
}
* `Gandiva: Introspective Cluster Scheduling for Deep Learning <https://www.usenix.org/system/files/osdi18-xiao.pdf>`__
.. code-block:: bibtex
@inproceedings{xiao2018gandiva,
title={Gandiva: Introspective cluster scheduling for deep learning},
author={Xiao, Wencong and Bhardwaj, Romil and Ramjee, Ramachandran and Sivathanu, Muthian and Kwatra, Nipun and Han, Zhenhua and Patel, Pratyush and Peng, Xuan and Zhao, Hanyu and Zhang, Quanlu and others},
booktitle={13th $\{$USENIX$\}$ Symposium on Operating Systems Design and Implementation ($\{$OSDI$\}$ 18)},
pages={595--610},
year={2018}
}
算法研究
------------------
全新算法
^^^^^^^^^^^^^^
* `TextNAS: A Neural Architecture Search Space Tailored for Text Representation <https://arxiv.org/pdf/1912.10729.pdf>`__
.. code-block:: bibtex
@inproceedings{wang2020textnas,
title={TextNAS: A Neural Architecture Search Space Tailored for Text Representation.},
author={Wang, Yujing and Yang, Yaming and Chen, Yiren and Bai, Jing and Zhang, Ce and Su, Guinan and Kou, Xiaoyu and Tong, Yunhai and Yang, Mao and Zhou, Lidong},
booktitle={AAAI},
pages={9242--9249},
year={2020}
}
* `Cream of the Crop: Distilling Prioritized Paths For One-Shot Neural Architecture Search <https://papers.nips.cc/paper/2020/file/d072677d210ac4c03ba046120f0802ec-Paper.pdf>`__
.. code-block:: bibtex
@article{peng2020cream,
title={Cream of the Crop: Distilling Prioritized Paths For One-Shot Neural Architecture Search},
author={Peng, Houwen and Du, Hao and Yu, Hongyuan and Li, Qi and Liao, Jing and Fu, Jianlong},
journal={Advances in Neural Information Processing Systems},
volume={33},
year={2020}
}
* `Metis: Robustly tuning tail latencies of cloud systems <https://www.usenix.org/system/files/conference/atc18/atc18-li-zhao.pdf>`__
.. code-block:: bibtex
@inproceedings{li2018metis,
title={Metis: Robustly tuning tail latencies of cloud systems},
author={Li, Zhao Lucis and Liang, Chieh-Jan Mike and He, Wenjia and Zhu, Lianjie and Dai, Wenjun and Jiang, Jin and Sun, Guangzhong},
booktitle={2018 $\{$USENIX$\}$ Annual Technical Conference ($\{$USENIX$\}$$\{$ATC$\}$ 18)},
pages={981--992},
year={2018}
}
* `OpEvo: An Evolutionary Method for Tensor Operator Optimization <https://arxiv.org/abs/2006.05664>`__
.. code-block:: bibtex
@article{gao2020opevo,
title={OpEvo: An Evolutionary Method for Tensor Operator Optimization},
author={Gao, Xiaotian and Wei, Cui and Zhang, Lintao and Yang, Mao},
journal={arXiv preprint arXiv:2006.05664},
year={2020}
}
评估和理解
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
* `Deeper insights into weight sharing in neural architecture search <https://arxiv.org/pdf/2001.01431.pdf>`__
.. code-block:: bibtex
@article{zhang2020deeper,
title={Deeper insights into weight sharing in neural architecture search},
author={Zhang, Yuge and Lin, Zejun and Jiang, Junyang and Zhang, Quanlu and Wang, Yujing and Xue, Hui and Zhang, Chen and Yang, Yaming},
journal={arXiv preprint arXiv:2001.01431},
year={2020}
}
* `How Does Supernet Help in Neural Architecture Search? <https://arxiv.org/abs/2010.08219>`__
.. code-block:: bibtex
@article{zhang2020does,
title={How Does Supernet Help in Neural Architecture Search?},
author={Zhang, Yuge and Zhang, Quanlu and Yang, Yaming},
journal={arXiv preprint arXiv:2010.08219},
year={2020}
}
应用
^^^^^^^^^^^^
* `AutoADR: Automatic Model Design for Ad Relevance <https://arxiv.org/pdf/2010.07075.pdf>`__
.. code-block:: bibtex
@inproceedings{chen2020autoadr,
title={AutoADR: Automatic Model Design for Ad Relevance},
author={Chen, Yiren and Yang, Yaming and Sun, Hong and Wang, Yujing and Xu, Yu and Shen, Wei and Zhou, Rong and Tong, Yunhai and Bai, Jing and Zhang, Ruofei},
booktitle={Proceedings of the 29th ACM International Conference on Information \& Knowledge Management},
pages={2365--2372},
year={2020}
}
# 框架和库的支持
通过内置的 Python API,NNI 天然支持所有 Python (` 版本 >= 3.6`) 语言的 AI 框架,可使用所有超参调优和神经网络搜索算法。 NNI 还为常见场景提供了一些示例和教程,使上手更容易。
## 支持的 AI 框架
* **[PyTorch]** https://github.com/pytorch/pytorch
* [MNIST-pytorch](../../examples/trials/mnist-distributed-pytorch)
* [CIFAR-10](TrialExample/Cifar10Examples.md)
* [TGS salt identification chanllenge](../../examples/trials/kaggle-tgs-salt/README_zh_CN.md)
* [Network morphism](../../examples/trials/network_morphism/README_zh_CN.md)
* **[TensorFlow]** https://github.com/tensorflow/tensorflow
* [MNIST-tensorflow](../../examples/trials/mnist-distributed)
* [Squad](../../examples/trials/ga_squad/README_zh_CN.md)
* **[Keras]** https://github.com/keras-team/keras
* [MNIST-keras](../../examples/trials/mnist-keras)
* [Network morphism](../../examples/trials/network_morphism/README_zh_CN.md)
* **[MXNet]** https://github.com/apache/incubator-mxnet
* **[Caffe2]** https://github.com/BVLC/caffe
* **[CNTK (Python 语言)]** https://github.com/microsoft/CNTK
* **[Spark MLlib]** http://spark.apache.org/mllib/
* **[Chainer]** https://chainer.org/
* **[Theano]** https://pypi.org/project/Theano/
如果能[贡献更多示例](Tutorial/Contributing.md),会对其他 NNI 用户有很大的帮助。
## 支持的库
NNI 也支持其它 Python 库,包括一些基于 GBDT 的算法:XGBoost, CatBoost 以及 lightGBM。
* **[Scikit-learn]** https://scikit-learn.org/stable/
* [Scikit-learn](TrialExample/SklearnExamples.md)
* **[XGBoost]** https://xgboost.readthedocs.io/en/latest/
* **[CatBoost]** https://catboost.ai/
* **[LightGBM]** https://lightgbm.readthedocs.io/en/latest/
* [Auto-gbdt](TrialExample/GbdtExample.md)
这只是 NNI 支持的一小部分库。 如果对 NNI 感兴趣,可参考[教程](TrialExample/Trials.md)来继续学习。
除了这些案例,也欢迎更多的用户将 NNI 应用到自己的工作中,如果有任何疑问,请参考[实现 Trial](TrialExample/Trials.md)。 如果想成为 NNI 的贡献者,无论是分享示例,还是实现 Tuner 或其它内容,我们都非常期待您的参与。更多信息请[参考这里](Tutorial/Contributing.md)
\ No newline at end of file
.. role:: raw-html(raw)
:format: html
框架和库的支持
==============================
通过内置的 Python API,NNI 天然支持所有 Python( ``版本 >= 3.6`` )语言的 AI 框架,可使用所有超参调优和神经网络搜索算法。 NNI 还为常见场景提供了一些示例和教程,使上手更容易。
支持的 AI 框架
-----------------------
* `PyTorch <https://github.com/pytorch/pytorch>`__
* :githublink:`MNIST-pytorch <examples/trials/mnist-distributed-pytorch>`
* `CIFAR-10 <./TrialExample/Cifar10Examples.rst>`__
* :githublink:`TGS salt identification chanllenge <examples/trials/kaggle-tgs-salt/README.md>`
* :githublink:`Network_morphism <examples/trials/network_morphism/README.md>`
* `TensorFlow <https://github.com/tensorflow/tensorflow>`__
* :githublink:`MNIST-tensorflow <examples/trials/mnist-distributed>`
* :githublink:`Squad <examples/trials/ga_squad/README.md>`
* `Keras <https://github.com/keras-team/keras>`__
* :githublink:`MNIST-keras <examples/trials/mnist-keras>`
* :githublink:`Network_morphism <examples/trials/network_morphism/README.md>`
* `MXNet <https://github.com/apache/incubator-mxnet>`__
* `Caffe2 <https://github.com/BVLC/caffe>`__
* `CNTK (Python language) <https://github.com/microsoft/CNTK>`__
* `Spark MLlib <http://spark.apache.org/mllib/>`__
* `Chainer <https://chainer.org/>`__
* `Theano <https://pypi.org/project/Theano/>`__
鼓励您为其他的 NNI 用户\ `贡献更多示例 <Tutorial/Contributing.rst>`__
支持的库
-----------------
NNI 也支持其它 Python 库,包括一些基于 GBDT 的算法:XGBoost, CatBoost 以及 lightGBM。
* `Scikit-learn <https://scikit-learn.org/stable/>`__
* `Scikit-learn <TrialExample/SklearnExamples.rst>`__
* `XGBoost <https://xgboost.readthedocs.io/en/latest/>`__
* `CatBoost <https://catboost.ai/>`__
* `LightGBM <https://lightgbm.readthedocs.io/en/latest/>`__
* `Auto-gbdt <TrialExample/GbdtExample.rst>`__
这只是 NNI 支持的一小部分库。 如果对 NNI 感兴趣,可参考 `此教程 <TrialExample/Trials.rst>`__ 来继续学习。
除了这些案例,也欢迎更多的用户将 NNI 应用到自己的工作中,如果有任何疑问,请参考 `在 NNI 上实现 Trial <TrialExample/Trials.rst>`__ 。 如果想成为 NNI 的贡献者,无论是分享示例,还是实现 Tuner 或其它内容,我们都非常期待您的参与。更多信息请参考 `这里 <Tutorial/Contributing.rst>`__ 。
**在 Azure Machine Learning 上运行 Experiment**
===
NNI 支持在 [AML](https://azure.microsoft.com/zh-cn/services/machine-learning/) 上运行 Experiment,称为 aml 模式。
## 设置环境
步骤 1. 参考[指南](../Tutorial/QuickStart.md)安装 NNI。
步骤 2. 通过此 [链接](https://azure.microsoft.com/en-us/free/services/machine-learning/) 创建 Azure 账户/订阅。 如果已有 Azure 账户/订阅,跳过此步骤。
步骤 3. 在机器上安装 Azure CLI,参照[](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli?view=azure-cli-latest)安装指南。
步骤 4. 从CLI验证您的Azure订阅。 要进行交互式身份验证,请打开命令行或终端并使用以下命令:
```
az login
```
步骤 5. 使用 Web 浏览器登录Azure帐户,并创建机器学习资源。 需要选择资源组并指定工作空间的名称。 之后下载 `config.json`,该文件将会在后面用到。 ![](../../img/aml_workspace.png)
步骤 6. 创建 AML 集群作为计算集群。 ![](../../img/aml_cluster.png)
步骤 7. 打开命令行并安装 AML 环境。
```
python3 -m pip install azureml
python3 -m pip install azureml-sdk
```
## 运行 Experiment
`examples/trials/mnist-tfv1` 为例。 NNI 的 YAML 配置文件如下:
```yaml
authorName: default
experimentName: example_mnist
trialConcurrency: 1
maxExecDuration: 1h
maxTrialNum: 10
trainingServicePlatform: aml
searchSpacePath: search_space.json
#可选项: true, false
useAnnotation: false
tuner:
#可选项: TPE, Random, Anneal, Evolution, BatchTuner, MetisTuner, GPTuner
#SMAC (SMAC should be installed through nnictl)
builtinTunerName: TPE
classArgs:
#可选项: maximize, minimize
optimize_mode: maximize
trial:
command: python3 mnist.py
codeDir: .
image: msranni/nni
gpuNum: 1
amlConfig:
subscriptionId: ${replace_to_your_subscriptionId}
resourceGroup: ${replace_to_your_resourceGroup}
workspaceName: ${replace_to_your_workspaceName}
computeTarget: ${replace_to_your_computeTarget}
```
注意:如果用 aml 模式运行,需要在 YAML 文件中设置 `trainingServicePlatform: aml`
[本机模式](LocalMode.md)的 Trial 配置相比,aml 模式下的键值还有:
* image
* 必填。 作业中使用的 Docker 映像名称。 此示例中的镜像 `msranni/nni` 只支持 GPU 计算集群。
amlConfig:
* subscriptionId
* 必填,Azure 订阅的 Id
* resourceGroup
* 必填,Azure 订阅的资源组
* workspaceName
* 必填,Azure 订阅的工作空间
* computeTarget
* 必填,要在 AML 工作区中使用的计算机集群名称。 见步骤6。
* maxTrialNumPerGpu
* 可选,用于指定 GPU 设备上的最大并发 Trial 的数量。
* useActiveGpu
* 可选,用于指定 GPU 上存在其他进程时是否使用此 GPU。 默认情况下,NNI 仅在 GPU 中没有其他活动进程时才使用 GPU。
amlConfig 需要的信息可以从步骤 5 下载的 `config.json` 找到。
运行以下命令来启动示例示例 Experiment:
```
git clone -b ${NNI_VERSION} https://github.com/microsoft/nni
cd nni/examples/trials/mnist-tfv1
# 修改 config.aml ...
nnictl create --config config_aml.yml
```
`${NNI_VERSION}` 替换为发布的版本或分支名称,例如:`v1.8`
**在 Azure Machine Learning 上运行 Experiment**
===================================================
NNI 支持在 `AML <https://azure.microsoft.com/zh-cn/services/machine-learning/>`__ 上运行 Experiment,称为 aml 模式。
设置环境
-----------------
步骤 1. 参考 `指南 <../Tutorial/QuickStart.rst>`__ 安装 NNI。
步骤 2. 通过此 `链接 <https://azure.microsoft.com/zh-cn/free/services/machine-learning/>`__ 创建 Azure 账户/订阅。 如果已有 Azure 账户/订阅,跳过此步骤。
步骤 3. 在机器上安装 Azure CLI,参照 `此 <https://docs.microsoft.com/en-us/cli/azure/install-azure-cli?view=azure-cli-latest>`__ 安装指南。
步骤 4. 从 CLI 验证您的 Azure 订阅。 要进行交互式身份验证,请打开命令行或终端并使用以下命令:
.. code-block:: bash
az login
步骤 5. 使用 Web 浏览器登录 Azure 帐户,并创建机器学习资源。 需要选择资源组并指定工作空间的名称。 之后下载 ``config.json``,该文件将会在后面用到。
.. image:: ../../img/aml_workspace.png
:target: ../../img/aml_workspace.png
:alt:
步骤 6. 创建 AML 集群作为计算集群。
.. image:: ../../img/aml_cluster.png
:target: ../../img/aml_cluster.png
:alt:
步骤 7. 打开命令行并安装 AML 环境。
.. code-block:: bash
python3 -m pip install azureml
python3 -m pip install azureml-sdk
运行实验
-----------------
以 ``examples/trials/mnist-tfv1`` 为例。 NNI 的 YAML 配置文件如下:
.. code-block:: yaml
authorName: default
experimentName: example_mnist
trialConcurrency: 1
maxExecDuration: 1h
maxTrialNum: 10
trainingServicePlatform: aml
searchSpacePath: search_space.json
#choice: true, false
useAnnotation: false
tuner:
#choice: TPE, Random, Anneal, Evolution, BatchTuner, MetisTuner, GPTuner
#SMAC (SMAC should be installed through nnictl)
builtinTunerName: TPE
classArgs:
#choice: maximize, minimize
optimize_mode: maximize
trial:
command: python3 mnist.py
codeDir: .
image: msranni/nni
gpuNum: 1
amlConfig:
subscriptionId: ${replace_to_your_subscriptionId}
resourceGroup: ${replace_to_your_resourceGroup}
workspaceName: ${replace_to_your_workspaceName}
computeTarget: ${replace_to_your_computeTarget}
注意:如果用 aml 模式运行,需要在 YAML 文件中设置 ``trainingServicePlatform: aml`` 。
与 `本机模式 <LocalMode.rst>`__ 的 Trial 配置相比,aml 模式下的键值还有:
* image
* 必填。 作业中使用的 Docker 映像名称。 NNI 支持 ``msranni/nni`` 的映像来跑 jobs。
.. code-block:: bash
注意:映像是基于 cuda 环境来打包的,可能并不适用于 aml 模式 CPU 集群。
amlConfig:
* subscriptionId
* 必填,Azure 订阅的 Id
* resourceGroup
* 必填,Azure 订阅的资源组
* workspaceName
* 必填,Azure 订阅的工作空间
* computeTarget
* 必填,要在 AML 工作区中使用的计算机集群名称。 `参考文档 <https://docs.microsoft.com/zh-cn/azure/machine-learning/concept-compute-target>`__ 了解步骤 6。
* maxTrialNumPerGpu
* 可选,默认值为 1。 用于指定 GPU 设备上的最大并发 Trial 的数量。
* useActiveGpu
* 可选,默认为 false。 用于指定 GPU 上存在其他进程时是否使用此 GPU。 默认情况下,NNI 仅在 GPU 中没有其他活动进程时才使用 GPU。
amlConfig 需要的信息可以从步骤 5 下载的 ``config.json`` 找到。
运行以下命令来启动示例示例 Experiment:
.. code-block:: bash
git clone -b ${NNI_VERSION} https://github.com/microsoft/nni
cd nni/examples/trials/mnist-tfv1
# modify config_aml.yml ...
nnictl create --config config_aml.yml
将 ``${NNI_VERSION}`` 替换为发布的版本或分支名称,例如:``v1.9``。
在 AdaptDL 上运行 Experiment
============================
NNI 支持在 `AdaptDL <https://github.com/petuum/adaptdl>`__ 上运行,称为 AdaptDL 模式。 在开始使用 NNI 的 AdaptDL 模式前,需要有一个 Kubernetes 集群,可以是私有部署的,或者是 `Azure Kubernetes Service(AKS) <https://azure.microsoft.com/zh-cn/services/kubernetes-service/>`__,并需要一台配置好 `kubeconfig <https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig/>`__ 的 Ubuntu 计算机连接到此 Kubernetes 集群。 在 AdaptDL 模式下,每个 Trial 程序会在 AdaptDL 集群中作为一个 Kubeflow 作业来运行。
AdaptDL 旨在使动态资源环境(例如共享集群和云)中的分布式深度学习变得轻松高效。
部署 Kubernetes 的准备工作
-----------------------------------
#. 采用 **Kubernetes 1.14** 或更高版本。 根据下面的指南设置 Kubernetes 环境: `on Azure <https://azure.microsoft.com/zh-cn/services/kubernetes-service/>`__\ , `on-premise <https://kubernetes.io/docs/setup/>`__ , `cephfs <https://kubernetes.io/docs/concepts/storage/storage-classes/#ceph-rbd>`__\ 和 `microk8s with storage add-on enabled <https://microk8s.io/docs/addons>`__。
#. Helm 将 **AdaptDL Scheduler** 安装到 Kubernetes 集群中。 参照 `指南 <https://adaptdl.readthedocs.io/en/latest/installation/install-adaptdl.html>`__ 来设置 AdaptDL scheduler。
#. 配置 **kubeconfig** 文件,NNI 将使用此配置与 Kubernetes API 服务交互。 默认情况下,NNI 管理器会使用 $(HOME)/.kube/config 作为 kubeconfig 文件的路径。 也可以通过环境变量 **KUBECONFIG** 来指定其它 kubeconfig 文件。 根据 `指南 <https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig>`__ 了解更多 kubeconfig 的信息。
#. 如果 NNI Trial 作业需要 GPU 资源,需按照 `指南 <https://github.com/NVIDIA/k8s-device-plugin>`__ 来配置 **Kubernetes 下的 Nvidia 插件**。
#. (可选)准备 **NFS服务器** 并导出通用装载作为外部存储。
#. 参考 `指南 <../Tutorial/QuickStart.rst>`__ 安装 **NNI**。
验证先决条件
^^^^^^^^^^^^^^^^^^^^
.. code-block:: bash
nnictl --version
# Expected: <version_number>
.. code-block:: bash
kubectl version
# Expected that the kubectl client version matches the server version.
.. code-block:: bash
kubectl api-versions | grep adaptdl
# Expected: adaptdl.petuum.com/v1
运行实验
-----------------
在 ``examples/trials/cifar10_pytorch`` 目录下,``CIFAR10`` 示例充分 handel 了 AdaptDL 调度程序。 (\ ``main_adl.py`` 和 ``config_adl.yaml``\ )
这是将 AdaptDL 用作训练平台的模板配置规范。
.. code-block:: yaml
authorName: default
experimentName: minimal_adl
trainingServicePlatform: adl
nniManagerIp: 10.1.10.11
logCollection: http
tuner:
builtinTunerName: GridSearch
searchSpacePath: search_space.json
trialConcurrency: 2
maxTrialNum: 2
trial:
adaptive: false # optional.
image: <image_tag>
imagePullSecrets: # optional
- name: stagingsecret
codeDir: .
command: python main.py
gpuNum: 1
cpuNum: 1 # optional
memorySize: 8Gi # optional
nfs: # optional
server: 10.20.41.55
path: /
containerMountPath: /nfs
checkpoint: # optional
storageClass: dfs
storageSize: 1Gi
下文中没有提及的 config 可以参考这篇文档:
`default specs defined in the NNI doc </Tutorial/ExperimentConfig.html#configuration-spec>`__。
* **trainingServicePlatform**\ : 选择 ``adl`` 以将 Kubernetes 集群与 AdaptDL 调度程序一起使用。
* **nniManagerIp**\ : *必填* ,为了 ``adl`` 训练平台能从群集中获取正确的信息和 metric 。
具有启动 NNI 实验的 NNI 管理器(NNICTL)的计算机的IP地址。
* **logCollection**\ : *推荐* 设置 ``http``。 它将通过 http 将群集上的 trial log 收集到计算机。
* **tuner**\ : 支持 Tuun tuner 和所有的 NNI built-in tuners (仅限于 NNI PBT tuners 的 checkpoint 功能)。
* **trial**\ : 定义了 ``adl`` trial 的规格。
* **namespace**\: (*可选*\ ) Kubernetes 命名空间启动 trial。 默认值是 ``default``。
* **adaptive**\ : (*可选*\ ) 是否开启 AdaptDL trainer。 设置为 ``true``,这项工作是抢占性和适应性的。
* **image**\ : trial 的 docker image。
* **imagePullSecret**\ : (*可选*\ ) 如果使用私人注册表,
需要提供密码才能成功提取 image。
* **codeDir**\ : 容器的工作目录。 ``.`` 意味着默认的工作目录是 image 定义的。
* **command**\ : 启动 trial 的 bash 命令。
* **gpuNum**\ : trial 需要一系列 GPUs。 必须是非负整数。
* **cpuNum**\ : (*可选*\ ) trial 需要一系列 CPUs。 必须是非负整数。
* **memorySize**\ : (*可选*\ ) trial 需要的内存大小。 需要按照 Kubernetes 来。
`默认设置 <https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/#meaning-of-memory>`__。
* **nfs**\ : (*可选*\ ) 安装外部存储。 使用 NFS 的详情请看下文。
* **checkpoint** (*可选*\ ) 模型检查点的存储设置。
* **storageClass**\ : 有关如何使用 ``storageClass`` 请参考 `Kubernetes storage 文档 <https://kubernetes.io/docs/concepts/storage/storage-classes/>`__ 。
* **storageSize**\ : 此值应足够大以适合模型的检查点,否则可能导致 "disk quota exceeded" 错误。
NFS 存储
^^^^^^^^^^^
可能已经在上述配置规范中注意到,
*可选* 部分可用于配置 NFS 外部存储。 当不需要外部存储时,例如 docker image 足以容纳代码和数据时,它是可选的。
请注意,``adl`` 训练平台不能把 NFS 挂载到本地开发机器上,因此可以手动将 NFS 挂载到本地,管理文件系统,复制数据或代码等。
然后,使用适当的配置,``adl`` 训练平台可以针对每个 trial 将其安装到 kubernetes:
* **server**\ : NFS 服务地址,如 IP 地址或者 domain。
* **path**\ : NFS 服务导出路径,如 NFS 中可以安装到 trials 的绝对路径。
* **containerMountPath**\ : 在要安装上述 NFS **path** 的容器绝对路径中,
以便于每条 trial 都可以连上 NFS。
在每个 trial 的容器中,可以用这个路径去连接 NFS。
用例:
* 如果训练 trials 依赖于大型数据集,则可能需要先将其下载到NFS上,
并安装它,以便可以在多个试用版之间共享。
* 容器的存储是临时性的,在试用期结束后,将删除 trial 容器。
因此,如果要导出训练的模型,
可以将NFS安装到试用版上,以保留并导出训练的模型。
简而言之,并没有限制 trial 如何读取或写入 NFS 存储,因此可以根据需要灵活使用它。
通过日志流监控
----------------------
遵循特定 trial 的日志流:
.. code-block:: bash
nnictl log trial --trial_id=<trial_id>
.. code-block:: bash
nnictl log trial <experiment_id> --trial_id=<trial_id>
请注意,在 trial 结束且其窗格已删除后,
无法通过该命令检索日志。
但是,仍然可以访问过去的试用记录
根据以下方法。
通过 TensorBoard 进行监控
----------------------------------------------
在 NNI 的背景下,一个实验有多条 trial。
为了在模型调整过程的各个 trial 之间轻松进行比较,
我们支持 TensorBoard 集成。 这里有一个实验
一个独立的 TensorBoard 日志目录,即 dashboard。
当被监控的实验处于 running 状态时你可以使用 TensorBoard。
换言之,不支持监视已经停止的实验。
在 trial 容器中,可以访问两个环境变量:
* ``ADAPTDL_TENSORBOARD_LOGDIR``\ : 当前实验 TensorBoard 日志目录,
* ``NNI_TRIAL_JOB_ID``\ : 当前 ``trial`` 的 job id。
建议将它们作为 trial 目录加入,
以 Python 举例:
.. code-block:: python
import os
tensorboard_logdir = os.path.join(
os.getenv("ADAPTDL_TENSORBOARD_LOGDIR"),
os.getenv("NNI_TRIAL_JOB_ID")
)
如果实验停止,记录在此处的数据
(由 *以上envs* 定义,用于使用以下命令进行监视)
会丢掉。 要保留记录的数据,可以使用外部存储设备(例如 安装 NFS)
导出并在本地查看 TensorBoard。
通过上述设置,可以通过 TensorBoard 轻松监控实验。
.. code-block:: bash
nnictl tensorboard start
如果有很多实验同时运行的话,可以使用
.. code-block:: bash
nnictl tensorboard start <experiment_id>
将提供访问 tensorboard 的Web URL。
请注意,可以灵活地为 tensorboard 设置本地 ``--port`` 。
**在 DLTS 上运行 Experiment**
===
NNI 支持在 [DLTS](https://github.com/microsoft/DLWorkspace.git) 上运行 Experiment ,称之为 dlts 模式。 在开始使用 NNI dlts 模式之前,应该有访问 DLTS 仪表板的账号。
## 设置环境
步骤 1. 从 DLTS 仪表板中选择集群,关于仪表板地址,需咨询管理员。
![选择集群](../../img/dlts-step1.png)
步骤 2. 准备 NNI 配置 YAML,如下所示:
```yaml
# 将此字段设置为 "dlts"
trainingServicePlatform: dlts
authorName: your_name
experimentName: auto_mnist
trialConcurrency: 2
maxExecDuration: 3h
maxTrialNum: 100
searchSpacePath: search_space.json
useAnnotation: false
tuner:
builtinTunerName: TPE
classArgs:
optimize_mode: maximize
trial:
command: python3 mnist.py
codeDir: .
gpuNum: 1
image: msranni/nni
# 访问 DLTS 的配置
dltsConfig:
dashboard: # Ask administrator for the cluster dashboard URL
```
记得将群集仪表板地址填到最后一行。
步骤 3. 打开群集的工作目录,将 NNI 配置和相关代码放入目录中。
![复制配置](../../img/dlts-step3.png)
步骤 4. 将 NNI 管理器任务提交到指定的群集。
![提交 Job](../../img/dlts-step4.png)
步骤 5. 转到新创建的任务选项卡,单击端口 40000 的链接检查 Trial 的信息。
![查看 NNI Web 界面](../../img/dlts-step5.png)
**在 DLTS 上运行 Experiment**
=================================
NNI 支持在 `DLTS <https://github.com/microsoft/DLWorkspace.git>`__\ 上运行 Experiment ,称之为 dlts 模式。 在开始使用 NNI dlts 模式之前,应该有访问 DLTS 仪表板的账号。
设置环境
-----------------
步骤 1. 从 DLTS 仪表板中选择集群,关于仪表板地址,需咨询管理员。
.. image:: ../../img/dlts-step1.png
:target: ../../img/dlts-step1.png
:alt: Choose Cluster
步骤 2. 准备 NNI 配置 YAML,如下所示:
.. code-block:: yaml
# Set this field to "dlts"
trainingServicePlatform: dlts
authorName: your_name
experimentName: auto_mnist
trialConcurrency: 2
maxExecDuration: 3h
maxTrialNum: 100
searchSpacePath: search_space.json
useAnnotation: false
tuner:
builtinTunerName: TPE
classArgs:
optimize_mode: maximize
trial:
command: python3 mnist.py
codeDir: .
gpuNum: 1
image: msranni/nni
# Configuration to access DLTS
dltsConfig:
dashboard: # Ask administrator for the cluster dashboard URL
记得将群集仪表板地址填到最后一行。
步骤 3. 打开群集的工作目录,将 NNI 配置和相关代码放入目录中。
.. image:: ../../img/dlts-step3.png
:target: ../../img/dlts-step3.png
:alt: Copy Config
步骤 4. 将 NNI 管理器任务提交到指定的群集。
.. image:: ../../img/dlts-step4.png
:target: ../../img/dlts-step4.png
:alt: Submit Job
步骤 5. 转到新创建的任务选项卡,单击端口 40000 的链接检查 Trial 的信息。
.. image:: ../../img/dlts-step5.png
:target: ../../img/dlts-step5.png
:alt: View NNI WebUI
# 在 FrameworkController 上运行 Experiment
=== NNI 支持使用 [FrameworkController](https://github.com/Microsoft/frameworkcontroller),来运行 Experiment,称之为 frameworkcontroller 模式。 FrameworkController 构建于 Kubernetes 上,用于编排各种应用。这样,可以不用为某个深度学习框架安装 Kubeflow 的 tf-operator 或 pytorch-operator 等。 而直接用 FrameworkController 作为 NNI Experiment 的训练平台。
## 私有部署的 Kubernetes 的准备工作
1. 采用 Kubernetes 1.8 或更高版本。 根据[指南](https://kubernetes.io/docs/setup/)来安装 Kubernetes。
2. 配置 **kubeconfig** 文件,NNI 将使用此配置与 Kubernetes API 服务交互。 默认情况下,NNI 管理器会使用 $(HOME)/.kube/config 作为 kubeconfig 文件的路径。 也可以通过环境变量 **KUBECONFIG** 来指定其它 kubeconfig 文件。 根据[指南](https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig)了解更多 kubeconfig 的信息。
3. 如果 NNI Trial 作业需要 GPU 资源,需按照[指南](https://github.com/NVIDIA/k8s-device-plugin)来配置 **Kubernetes 下的 Nvidia 插件**
4. 准备 **NFS 服务器** 并导出通用的装载 (mount),推荐将 NFS 服务器路径映射到 `root_squash 选项`,否则可能会在 NNI 复制文件到 NFS 时出现权限问题。 参考[页面](https://linux.die.net/man/5/exports),来了解关于 root_squash 选项,或 **Azure File Storage**
5. 在安装 NNI 并运行 nnictl 的计算机上安装 **NFS 客户端**。 运行此命令安装 NFSv4 客户端:
```bash
apt-get install nfs-common
```
6. 参考[指南](../Tutorial/QuickStart.md)安装 **NNI**
## Azure 部署的 Kubernetes 的准备工作
1. NNI 支持基于 Azure Kubernetes Service 的 Kubeflow,参考[指南](https://azure.microsoft.com/zh-cn/services/kubernetes-service/)来设置 Azure Kubernetes Service。
2. 安装 [Azure CLI](https://docs.microsoft.com/zh-cn/cli/azure/install-azure-cli?view=azure-cli-latest)**kubectl**。 使用 `az login` 命令来设置 Azure 账户吗,并将 kubectl 客户端连接到 AKS,参考此[指南](https://docs.microsoft.com/zh-cn/azure/aks/kubernetes-walkthrough#connect-to-the-cluster)
3. 参考此[指南](https://docs.microsoft.com/zh-cn/azure/storage/common/storage-quickstart-create-account?tabs=portal)来创建 Azure 文件存储账户。 NNI 需要 Azure Storage Service 来存取代码和输出文件。
4. NNI 需要访问密钥来连接 Azure 存储服务,NNI 使用 [Azure Key Vault](https://azure.microsoft.com/zh-cn/services/key-vault/) 服务来保护私钥。 设置 Azure Key Vault 服务,并添加密钥到 Key Vault 中来存取 Azure 存储账户。 参考[指南](https://docs.microsoft.com/zh-cn/azure/key-vault/quick-create-cli)来存储访问密钥。
## 安装 FrameworkController
参考[指南](https://github.com/Microsoft/frameworkcontroller/tree/master/example/run)来在 Kubernetes 集群中配置 FrameworkController。NNI 通过 statefulset 模式来 支持 FrameworkController。 如果集群需要认证,则需要为 FrameworkController 创建服务账户并授予权限,然后将 FrameworkController 服务账户的名称设置到 NNI Experiment 配置中。 [参考文档](https://github.com/Microsoft/frameworkcontroller/tree/master/example/run#run-by-kubernetes-statefulset)
## 设计
参考[Kubeflow 训练平台](KubeflowMode.md)的设计,FrameworkController 训练平台与其类似。
## 示例
FrameworkController 配置文件的格式如下:
```yaml
authorName: default
experimentName: example_mnist
trialConcurrency: 1
maxExecDuration: 10h
maxTrialNum: 100
#可选项: local, remote, pai, kubeflow, frameworkcontroller
trainingServicePlatform: frameworkcontroller
searchSpacePath: ~/nni/examples/trials/mnist-tfv1/search_space.json
#可选项: true, false
useAnnotation: false
tuner:
#可选项: TPE, Random, Anneal, Evolution
builtinTunerName: TPE
classArgs:
#可选项: maximize, minimize
optimize_mode: maximize
assessor:
builtinAssessorName: Medianstop
classArgs:
optimize_mode: maximize
trial:
codeDir: ~/nni/examples/trials/mnist-tfv1
taskRoles:
- name: worker
taskNum: 1
command: python3 mnist.py
gpuNum: 1
cpuNum: 1
memoryMB: 8192
image: msranni/nni:latest
frameworkAttemptCompletionPolicy:
minFailedTaskCount: 1
minSucceededTaskCount: 1
frameworkcontrollerConfig:
storage: nfs
nfs:
server: {your_nfs_server}
path: {your_nfs_server_exported_path}
```
如果使用了 Azure Kubernetes Service,需要在 YAML 文件中如下设置 `frameworkcontrollerConfig`
```yaml
frameworkcontrollerConfig:
storage: azureStorage
serviceAccountName: {your_frameworkcontroller_service_account_name}
keyVault:
vaultName: {your_vault_name}
name: {your_secert_name}
azureStorage:
accountName: {your_storage_account_name}
azureShare: {your_azure_share_name}
```
注意:如果用 FrameworkController 模式运行,需要在 YAML 文件中显式设置 `trainingServicePlatform: frameworkcontroller`
FrameworkController 模式的 Trial 配置格式,是 FrameworkController 官方配置的简化版。参考 [frameworkcontroller 的 tensorflow 示例](https://github.com/Microsoft/frameworkcontroller/blob/master/example/framework/scenario/tensorflow/cpu/tensorflowdistributedtrainingwithcpu.yaml) 了解详情。
frameworkcontroller 模式中的 Trial 配置使用以下主键:
* taskRoles: 配置文件中可以设置多个任务角色,每个任务角色都是在 Kubernetes 集群中的基本执行单元。
* name: 任务角色的名字,例如,"worker", "ps", "master"。
* taskNum: 任务角色的实例数量。
* command: 在容器中要执行的用户命令。
* gpuNum: 容器要使用的 GPU 数量。
* cpuNum: 容器中要使用的 CPU 数量。
* memoryMB: 容器的内存限制。
* image: 用来创建 pod,并运行程序的 Docker 映像。
* frameworkAttemptCompletionPolicy: 运行框架的策略,参考[用户手册](https://github.com/Microsoft/frameworkcontroller/blob/master/doc/user-manual.md#frameworkattemptcompletionpolicy)了解更多信息。 这些策略可以用来控制 pod,例如,如果 worker 任务停止了,但 ps 还在运行,要通过完成策略来停止 ps。
## 如何运行示例
准备好配置文件后,通过运行 nnictl 来启动 Experiment。 在 FrameworkController 上开始 Experiment 的方法与 Kubeflow 类似,可参考[指南](KubeflowMode.md)了解更多信息。
## 版本校验
从 0.6 开始,NNI 支持版本校验,详情参考[这里](PaiMode.md)
\ No newline at end of file
在 FrameworkController 上运行 Experiment
========================================
NNI 支持使用 `FrameworkController <https://github.com/Microsoft/frameworkcontroller>`__,来运行 Experiment,称之为 frameworkcontroller 模式。 FrameworkController 构建于 Kubernetes 上,用于编排各种应用。这样,可以不用为某个深度学习框架安装 Kubeflow 的 tf-operator 或 pytorch-operator 等。 而直接用 FrameworkController 作为 NNI Experiment 的训练平台。
私有部署的 Kubernetes 的准备工作
-----------------------------------------------
#. 采用 **Kubernetes 1.8** 或更高版本。 根据 `指南 <https://kubernetes.io/docs/setup/>`__ 来安装 Kubernetes。
#. 配置 **kubeconfig** 文件,NNI 将使用此配置与 Kubernetes API 服务交互。 默认情况下,NNI 管理器会使用 ``$(HOME)/.kube/config`` 作为 kubeconfig 文件的路径。 也可以通过环境变量 **KUBECONFIG** 来指定其它 kubeconfig 文件。 根据 `指南 <https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig>`__ 了解更多 kubeconfig 的信息。
#. 如果 NNI Trial 作业需要 GPU 资源,需按照 `指南 <https://github.com/NVIDIA/k8s-device-plugin>`__ 来配置 **Kubernetes 下的 Nvidia 插件**。
#. 准备 **NFS 服务器** 并导出通用的装载 (mount),推荐将 NFS 服务器路径映射到 **root_squash 选项**,否则可能会在 NNI 复制文件到 NFS 时出现权限问题。 参考 `页面 <https://linux.die.net/man/5/exports>`__,来了解关于 root_squash 选项,或 **Azure File Storage**。
#. 在安装 NNI 并运行 nnictl 的计算机上安装 **NFS 客户端**。 运行此命令安装 NFSv4 客户端:
.. code-block:: bash
apt-get install nfs-common
#. 参考 `指南 <../Tutorial/QuickStart.rst>`__ 安装 **NNI**。
Azure 部署的 Kubernetes 的准备工作
-----------------------------------------
#. NNI 支持基于 Azure Kubernetes Service 的 Kubeflow,参考 `指南 <https://azure.microsoft.com/zh-cn/services/kubernetes-service/>`__ 来设置 Azure Kubernetes Service。
#. 安装 `Azure CLI <https://docs.microsoft.com/en-us/cli/azure/install-azure-cli?view=azure-cli-latest>`__ 和 ``kubectl``。 使用 ``az login`` 命令来设置 Azure 账户,并将 kubectl 客户端连接到 AKS,参考此 `指南 <https://docs.microsoft.com/zh-cn/azure/aks/kubernetes-walkthrough#connect-to-the-cluster>`__。
#. 参考此 `指南 <https://docs.microsoft.com/zh-cn/azure/storage/common/storage-quickstart-create-account?tabs=portal>`__ 来创建 Azure 文件存储账户。 NNI 需要 Azure Storage Service 来存取代码和输出文件。
#. NNI 需要访问密钥来连接 Azure 存储服务,NNI 使用 `Azure Key Vault <https://azure.microsoft.com/zh-cn/services/key-vault/>`__ 服务来保护私钥。 设置 Azure Key Vault 服务,并添加密钥到 Key Vault 中来存取 Azure 存储账户。 参考 `指南 <https://docs.microsoft.com/zh-cn/azure/key-vault/quick-create-cli>`__ 来存储访问密钥。
安装 FrameworkController
-------------------------
参考 `指南 <https://github.com/Microsoft/frameworkcontroller/tree/master/example/run>`__ 来在 Kubernetes 集群中配置 FrameworkController。NNI 通过 statefulset 模式来 支持 FrameworkController。 如果集群需要认证,则需要为 FrameworkController 创建服务账户并授予权限,然后将 FrameworkController 服务账户的名称设置到 NNI Experiment 配置中。 `参考文档 <https://github.com/Microsoft/frameworkcontroller/tree/master/example/run#run-by-kubernetes-statefulset>`__。
设计
------
请参考 `Kubeflow training service <KubeflowMode.rst>`__ 的设计, FrameworkController training service pipeline 与其相似。
示例
-------
FrameworkController 配置文件的格式如下:
.. code-block:: yaml
authorName: default
experimentName: example_mnist
trialConcurrency: 1
maxExecDuration: 10h
maxTrialNum: 100
#choice: local, remote, pai, kubeflow, frameworkcontroller
trainingServicePlatform: frameworkcontroller
searchSpacePath: ~/nni/examples/trials/mnist-tfv1/search_space.json
#choice: true, false
useAnnotation: false
tuner:
#choice: TPE, Random, Anneal, Evolution
builtinTunerName: TPE
classArgs:
#choice: maximize, minimize
optimize_mode: maximize
assessor:
builtinAssessorName: Medianstop
classArgs:
optimize_mode: maximize
trial:
codeDir: ~/nni/examples/trials/mnist-tfv1
taskRoles:
- name: worker
taskNum: 1
command: python3 mnist.py
gpuNum: 1
cpuNum: 1
memoryMB: 8192
image: msranni/nni:latest
frameworkAttemptCompletionPolicy:
minFailedTaskCount: 1
minSucceededTaskCount: 1
frameworkcontrollerConfig:
storage: nfs
nfs:
server: {your_nfs_server}
path: {your_nfs_server_exported_path}
如果使用了 Azure Kubernetes Service,需要在 YAML 文件中如下设置 ``frameworkcontrollerConfig``:
.. code-block:: yaml
frameworkcontrollerConfig:
storage: azureStorage
serviceAccountName: {your_frameworkcontroller_service_account_name}
keyVault:
vaultName: {your_vault_name}
name: {your_secert_name}
azureStorage:
accountName: {your_storage_account_name}
azureShare: {your_azure_share_name}
注意:如果用 FrameworkController 模式运行,需要在 YAML 文件中显式设置 ``trainingServicePlatform: frameworkcontroller``。
FrameworkController 模式的 Trial 配置格式,是 FrameworkController 官方配置的简化版。参考 `frameworkcontroller 的 tensorflow 示例 <https://github.com/Microsoft/frameworkcontroller/blob/master/example/framework/scenario/tensorflow/cpu/tensorflowdistributedtrainingwithcpu.yaml>`__ 了解详情。
frameworkcontroller 模式中的 Trial 配置使用以下主键:
* taskRoles: 配置文件中可以设置多个任务角色,每个任务角色都是在 Kubernetes 集群中的基本执行单元。
* name: 任务角色的名字,例如,"worker", "ps", "master"。
* taskNum: 任务角色的实例数量。
* command: 在容器中要执行的用户命令。
* gpuNum: 容器要使用的 GPU 数量。
* cpuNum: 容器中要使用的 CPU 数量。
* memoryMB: 容器的内存限制。
* image: 用来创建 pod,并运行程序的 Docker 映像。
* frameworkAttemptCompletionPolicy: 运行框架的策略,参考 `用户手册 <https://github.com/Microsoft/frameworkcontroller/blob/master/doc/user-manual.rst#frameworkattemptcompletionpolicy>`__ 了解更多信息。 这些策略可以用来控制 pod,例如,如果 worker 任务停止了,但 ps 还在运行,要通过完成策略来停止 ps。
如何运行示例
------------------
准备好配置文件后,通过运行 nnictl 来启动 Experiment。 在 FrameworkController 上开始 Experiment 的方法与 Kubeflow 类似,可参考 `指南 <KubeflowMode.rst>`__ 了解更多信息。
版本校验
-------------
从 0.6 开始,NNI 支持版本校验,详情参考 `这里 <PaiMode.rst>`__。
**在异构模式下运行 Experiment**
===========================================
在异构模式下运行 NNI 意味着 NNI 将同时在多种培训平台上运行试验工作。 例如,NNI 可以同时将试用作业提交到远程计算机和 AML。
设置环境
----------------------
NNI 的异构模式目前支持 `local <./LocalMode.rst>`__\ , `remote <./RemoteMachineMode.rst>`__\ , `PAI <./PaiMode.rst>`__\ 和 `AML <./AMLMode.rst>`__ 四种训练环境。在使用这些模式开始实验之前,应在平台上设置对应的环境。环境设置的详细信息,参见以上文档。
运行实验
--------------------
以 `examples/trials/mnist-tfv1` 为例。 NNI 的 YAML 配置文件如下:
.. code-block:: yaml
authorName: default
experimentName: example_mnist
trialConcurrency: 2
maxExecDuration: 1h
maxTrialNum: 10
trainingServicePlatform: heterogeneous
searchSpacePath: search_space.json
#choice: true, false
useAnnotation: false
tuner:
builtinTunerName: TPE
classArgs:
#choice: maximize, minimize
optimize_mode: maximize
trial:
command: python3 mnist.py
codeDir: .
gpuNum: 1
heterogeneousConfig:
trainingServicePlatforms:
- local
- remote
remoteConfig:
reuse: true
machineList:
- ip: 10.1.1.1
username: bob
passwd: bob123
异构模式的配置:
heterogeneousConfig:
* trainingServicePlatforms. 必填。 该字段指定用于异构模式的平台,值使用 yaml 列表格式。 NNI 支持在此字段中设置 `local`, `remote`, `aml`, `pai` 。
.. Note:: 如果将平台设置为 trainingServicePlatforms 模式,则用户还应该为平台设置相应的配置。 例如,如果使用 ``remote`` 作为平台,还应设置 ``machineList`` 和 ``remoteConfig`` 配置。
# NNI 中如何实现训练平台 NNI 中如何实现训练平台
========================================
## 概述 概述
--------
TrainingService 是与平台管理、任务调度相关的模块。 TrainingService 在设计上为了便于实现,将平台相关的公共属性抽象成类。用户只需要继承这个抽象类,并根据平台特点实现子类,便能够实现 TrainingService。 TrainingService 是与平台管理、任务调度相关的模块。 TrainingService 在设计上为了便于实现,将平台相关的公共属性抽象成类。用户只需要继承这个抽象类,并根据平台特点实现子类,便能够实现 TrainingService。
## 系统架构 系统架构
-------------------
![](../../img/NNIDesign.jpg)
NNI 的架构如图所示。 NNIManager 是系统的核心管理模块,负责调用 TrainingService 来管理 Trial,并负责不同模块之间的通信。 Dispatcher 是消息处理中心。 TrainingService 是管理任务的模块,它和 NNIManager 通信,并且根据平台的特点有不同的实现。 当前,NNI 支持[本机](LocalMode.md)[远程平台](RemoteMachineMode.md)[OpenPAI 平台](PaiMode.md)[Kubeflow 平台](KubeflowMode.md) 以及 [FrameworkController 平台](FrameworkControllerMode.md) .. image:: ../../img/NNIDesign.jpg
:target: ../../img/NNIDesign.jpg
:alt:
NNI 的架构如图所示。 NNIManager 是系统的核心管理模块,负责调用 TrainingService 来管理 Trial,并负责不同模块之间的通信。 Dispatcher 是消息处理中心。 TrainingService 是管理任务的模块,它和 NNIManager 通信,并且根据平台的特点有不同的实现。 NNI 目前支持的平台有 `local platfrom <LocalMode.md>`__\
,`remote platfrom <RemoteMachineMode.md>`__\ , `PAI platfrom <PaiMode.md>`__\ , `kubeflow platform <KubeflowMode.md>`__ 和 `FrameworkController platfrom <FrameworkControllerMode.rst>`__。
本文中,会介绍 TrainingService 的简要设计。 如果要添加新的 TrainingService,只需要继承 TrainingServcie 类并实现相应的方法,不需要理解NNIManager、Dispatcher 等其它模块的细节。 本文中,会介绍 TrainingService 的简要设计。 如果要添加新的 TrainingService,只需要继承 TrainingServcie 类并实现相应的方法,不需要理解NNIManager、Dispatcher 等其它模块的细节。
## 代码文件夹结构 代码文件夹结构
------------------------
NNI 的文件夹结构如下: NNI 的文件夹结构如下:
nni .. code-block:: bash
|- deployment
|- docs nni
|- examaples |- deployment
|- src |- docs
| |- nni_manager |- examaples
| | |- common |- src
| | |- config | |- nni_manager
| | |- core | | |- common
| | |- coverage | | |- config
| | |- dist | | |- core
| | |- rest_server | | |- coverage
| | |- training_service | | |- dist
| | | |- common | | |- rest_server
| | | |- kubernetes | | |- training_service
| | | |- local | | | |- common
| | | |- pai | | | |- kubernetes
| | | |- remote_machine | | | |- local
| | | |- test | | | |- pai
| |- sdk | | | |- remote_machine
| |- webui | | | |- test
|- test | |- sdk
|- tools | |- webui
| |-nni_annotation |- test
| |-nni_cmd |- tools
| |-nni_gpu_tool | |-nni_annotation
| |-nni_trial_tool | |-nni_cmd
| |-nni_gpu_tool
| |-nni_trial_tool
`nni/src` 文件夹存储 NNI 的大部分源代码。 这个文件夹中的代码和 NNIManager、TrainingService、SDK、WebUI 等模块有关。 用户可以在 `nni/src/nni_manager/common/trainingService.ts` 文件中找到 TrainingService 抽象类的代码,并且把自己实现的子类放到 `nni/src/nni_manager/training_service` 文件夹下。 如果用户实现了自己的 TrainingService,还需要同时实现相应的单元测试代码,并把单元测试放到 `nni/src/nni_manager/training_service/test` 文件夹下。
``nni/src`` 文件夹存储 NNI 的大部分源代码。 这个文件夹中的代码和 NNIManager、TrainingService、SDK、WebUI 等模块有关。 用户可以在 ``nni/src/nni_manager/common/trainingService.ts`` 文件中找到 TrainingService 抽象类的代码,并且把自己实现的子类放到 ``nni/src/nni_manager/training_service`` 文件夹下。 如果用户实现了自己的 TrainingService,还需要同时实现相应的单元测试代码,并把单元测试放到 ``nni/src/nni_manager/training_service/test`` 文件夹下。
## TrainingService 函数解释
TrainingService 函数解释
abstract class TrainingService { --------------------------------------
public abstract listTrialJobs(): Promise<TrialJobDetail[]>;
public abstract getTrialJob(trialJobId: string): Promise<TrialJobDetail>; .. code-block:: bash
public abstract addTrialJobMetricListener(listener: (metric: TrialJobMetric) => void): void;
public abstract removeTrialJobMetricListener(listener: (metric: TrialJobMetric) => void): void; abstract class TrainingService {
public abstract submitTrialJob(form: JobApplicationForm): Promise<TrialJobDetail>; public abstract listTrialJobs(): Promise<TrialJobDetail[]>;
public abstract updateTrialJob(trialJobId: string, form: JobApplicationForm): Promise<TrialJobDetail>; public abstract getTrialJob(trialJobId: string): Promise<TrialJobDetail>;
public abstract get isMultiPhaseJobSupported(): boolean; public abstract addTrialJobMetricListener(listener: (metric: TrialJobMetric) => void): void;
public abstract cancelTrialJob(trialJobId: string, isEarlyStopped?: boolean): Promise<void>; public abstract removeTrialJobMetricListener(listener: (metric: TrialJobMetric) => void): void;
public abstract setClusterMetadata(key: string, value: string): Promise<void>; public abstract submitTrialJob(form: JobApplicationForm): Promise<TrialJobDetail>;
public abstract getClusterMetadata(key: string): Promise<string>; public abstract updateTrialJob(trialJobId: string, form: JobApplicationForm): Promise<TrialJobDetail>;
public abstract cleanUp(): Promise<void>; public abstract get isMultiPhaseJobSupported(): boolean;
public abstract run(): Promise<void>; public abstract cancelTrialJob(trialJobId: string, isEarlyStopped?: boolean): Promise<void>;
} public abstract setClusterMetadata(key: string, value: string): Promise<void>;
public abstract getClusterMetadata(key: string): Promise<string>;
public abstract cleanUp(): Promise<void>;
public abstract run(): Promise<void>;
}
TrainingService 父类有一些抽象方法,用户需要继承并实现这些抽象方法。 TrainingService 父类有一些抽象方法,用户需要继承并实现这些抽象方法。
...@@ -71,29 +83,30 @@ TrainingService 父类有一些抽象方法,用户需要继承并实现这些 ...@@ -71,29 +83,30 @@ TrainingService 父类有一些抽象方法,用户需要继承并实现这些
ClusterMetadata 是与平台细节相关的数据,例如,ClusterMetadata 在远程服务器的定义是: ClusterMetadata 是与平台细节相关的数据,例如,ClusterMetadata 在远程服务器的定义是:
export class RemoteMachineMeta { .. code-block:: bash
public readonly ip : string;
public readonly port : number; export class RemoteMachineMeta {
public readonly username : string; public readonly ip : string;
public readonly passwd?: string; public readonly port : number;
public readonly sshKeyPath?: string; public readonly username : string;
public readonly passphrase?: string; public readonly passwd?: string;
public gpuSummary : GPUSummary | undefined; public readonly sshKeyPath?: string;
/* GPU Reservation info, the key is GPU index, the value is the job id which reserves this GPU*/ public readonly passphrase?: string;
public gpuReservation : Map<number, string>; public gpuSummary : GPUSummary | undefined;
/* GPU Reservation info, the key is GPU index, the value is the job id which reserves this GPU*/
constructor(ip : string, port : number, username : string, passwd : string, public gpuReservation : Map<number, string>;
sshKeyPath : string, passphrase : string) {
this.ip = ip; constructor(ip : string, port : number, username : string, passwd : string,
this.port = port; sshKeyPath : string, passphrase : string) {
this.username = username; this.ip = ip;
this.passwd = passwd; this.port = port;
this.sshKeyPath = sshKeyPath; this.username = username;
this.passphrase = passphrase; this.passwd = passwd;
this.gpuReservation = new Map<number, string>(); this.sshKeyPath = sshKeyPath;
} this.passphrase = passphrase;
} this.gpuReservation = new Map<number, string>();
}
}
Metadata 中包括了主机地址,用户名和其它平台相关配置。 用户需要定义自己的 Metadata 格式,并在这个方法中相应实现。 这个方法在 Experiment 启动之前调用。 Metadata 中包括了主机地址,用户名和其它平台相关配置。 用户需要定义自己的 Metadata 格式,并在这个方法中相应实现。 这个方法在 Experiment 启动之前调用。
...@@ -105,20 +118,21 @@ Metadata 中包括了主机地址,用户名和其它平台相关配置。 用 ...@@ -105,20 +118,21 @@ Metadata 中包括了主机地址,用户名和其它平台相关配置。 用
SubmitTrialJob 是用来提交新 Trial 任务的函数,需要生成一个 TrialJobDetail 类型的任务实例。 TrialJobDetail 定义如下: SubmitTrialJob 是用来提交新 Trial 任务的函数,需要生成一个 TrialJobDetail 类型的任务实例。 TrialJobDetail 定义如下:
interface TrialJobDetail { .. code-block:: bash
readonly id: string;
readonly status: TrialJobStatus; interface TrialJobDetail {
readonly submitTime: number; readonly id: string;
readonly startTime?: number; readonly status: TrialJobStatus;
readonly endTime?: number; readonly submitTime: number;
readonly tags?: string[]; readonly startTime?: number;
readonly url?: string; readonly endTime?: number;
readonly workingDirectory: string; readonly tags?: string[];
readonly form: JobApplicationForm; readonly url?: string;
readonly sequenceId: number; readonly workingDirectory: string;
isEarlyStopped?: boolean; readonly form: JobApplicationForm;
} readonly sequenceId: number;
isEarlyStopped?: boolean;
}
根据不同的实现,用户可能需要把 Trial 任务放入队列中,并不断地从队里中取出任务进行提交。 或者也可以直接在这个方法中完成作业提交过程。 根据不同的实现,用户可能需要把 Trial 任务放入队列中,并不断地从队里中取出任务进行提交。 或者也可以直接在这个方法中完成作业提交过程。
...@@ -128,7 +142,7 @@ SubmitTrialJob 是用来提交新 Trial 任务的函数,需要生成一个 Tri ...@@ -128,7 +142,7 @@ SubmitTrialJob 是用来提交新 Trial 任务的函数,需要生成一个 Tri
**updateTrialJob(trialJobId: string, form: JobApplicationForm)** **updateTrialJob(trialJobId: string, form: JobApplicationForm)**
调用此函数可更新 Trial 的任务状态,Trial 任务状态根据不同的平台来检测,并需要更新为 `RUNNING`, `SUCCEED`, `FAILED` 等状态。 调用此函数可更新 Trial 的任务状态,Trial 任务状态根据不同的平台来检测,并需要更新为 ``RUNNING``, ``SUCCEED``, ``FAILED`` 等状态。
**getTrialJob(trialJobId: string)** **getTrialJob(trialJobId: string)**
...@@ -140,7 +154,7 @@ SubmitTrialJob 是用来提交新 Trial 任务的函数,需要生成一个 Tri ...@@ -140,7 +154,7 @@ SubmitTrialJob 是用来提交新 Trial 任务的函数,需要生成一个 Tri
**addTrialJobMetricListener(listener: (metric: TrialJobMetric) => void)** **addTrialJobMetricListener(listener: (metric: TrialJobMetric) => void)**
NNI 会启动一个 EventEmitter 来处理任务的指标数据,如果有检测到有新的数据,EventEmitter就会被触发,来执行相应的事件。 用户需要在这个方法中开始 EventEmitter。 NNI 会启动一个 EventEmitter 来处理任务的指标数据,如果有检测到有新的数据,EventEmitter 就会被触发,来执行相应的事件。 用户需要在这个方法中开始 EventEmitter。
**removeTrialJobMetricListener(listener: (metric: TrialJobMetric) => void)** **removeTrialJobMetricListener(listener: (metric: TrialJobMetric) => void)**
...@@ -154,18 +168,24 @@ Run() 函数是 TrainingService 的主循环,用户可以在这个函数中循 ...@@ -154,18 +168,24 @@ Run() 函数是 TrainingService 的主循环,用户可以在这个函数中循
当实验结束后,此方法用来清除实验环境。 用户需要在这个方法中实现与平台相关的清除操作。 当实验结束后,此方法用来清除实验环境。 用户需要在这个方法中实现与平台相关的清除操作。
## TrialKeeper 工具 TrialKeeper 工具
----------------
NNI 提供了 TrialKeeper 工具,用来帮助维护 Trial 任务。 可以在 `nni/tools/nni_trial_tool` 文件夹中找到 TrialKeeper 的源代码。 如果想要运行在云平台上,这是维护任务的好工具。 NNI 提供了 TrialKeeper 工具,用来帮助维护 Trial 任务。 可以在 ``nni/tools/nni_trial_tool`` 文件夹中找到 TrialKeeper 的源代码。 如果想要运行在云平台上,这是维护任务的好工具。
TrialKeeper 的架构如下: TrialKeeper 的架构如下:
![](../../img/trialkeeper.jpg)
当用户需要在远程云平台上运行作业,要把作业启动的命令行传入 TrailKeeper 中,并在远程云平台上启动 TrailKeeper 进程。 注意,TrialKeeper 在远程平台中使用 RESTful 服务来和 TrainingService 进行通信,用户需要在本地机器启动一个 RESTful 服务来接受 TrialKeeper 的请求。 关于 RESTful 服务的源代码可以在 `nni/src/nni_manager/training_service/common/clusterJobRestServer.ts` 文件夹中找到. .. image:: ../../img/trialkeeper.jpg
:target: ../../img/trialkeeper.jpg
:alt:
当用户需要在远程云平台上运行作业,要把作业启动的命令行传入 TrailKeeper 中,并在远程云平台上启动 TrailKeeper 进程。 注意,TrialKeeper 在远程平台中使用 RESTful 服务来和 TrainingService 进行通信,用户需要在本地机器启动一个 RESTful 服务来接受 TrialKeeper 的请求。 关于 RESTful 服务的源代码可以在 ``nni/src/nni_manager/training_service/common/clusterJobRestServer.ts`` 文件夹中找到。
## 参考 参考
---------
有关调试的进一步信息,可参考[这里](../Tutorial/HowToDebug.md) 有关调试的进一步信息,可参考 `这里 <../Tutorial/HowToDebug.rst>`__
如何参与贡献的指南,请参考[这里](../Tutorial/Contributing.md) 如何参与贡献的指南,请参考 `这里 <../Tutorial/Contributing.rst>`__。
\ No newline at end of file
# 在 Kubeflow 上运行 Experiment
===
NNI 支持在 [Kubeflow](https://github.com/kubeflow/kubeflow)上运行,称为 kubeflow 模式。 在开始使用 NNI 的 Kubeflow 模式前,需要有一个 Kubernetes 集群,可以是私有部署的,或者是 [Azure Kubernetes Service(AKS)](https://azure.microsoft.com/zh-cn/services/kubernetes-service/),并需要一台配置好 [kubeconfig](https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig/) 的 Ubuntu 计算机连接到此 Kubernetes 集群。 如果不熟悉 Kubernetes,可先浏览[这里](https://kubernetes.io/docs/tutorials/kubernetes-basics/)。 在 kubeflow 模式下,每个 Trial 程序会在 Kubernetes 集群中作为一个 Kubeflow 作业来运行。
## 私有部署的 Kubernetes 的准备工作
1. 采用 Kubernetes 1.8 或更高版本。 根据[指南](https://kubernetes.io/docs/setup/)来安装 Kubernetes。
2. 在 Kubernetes 集群中下载、安装、部署 **Kubeflow**。 根据[指南](https://www.kubeflow.org/docs/started/getting-started/)安装 Kubeflow。
3. 配置 **kubeconfig** 文件,NNI 将使用此配置与 Kubernetes API 服务交互。 默认情况下,NNI 管理器会使用 $(HOME)/.kube/config 作为 kubeconfig 文件的路径。 也可以通过环境变量 **KUBECONFIG** 来指定其它 kubeconfig 文件。 根据[指南](https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig)了解更多 kubeconfig 的信息。
4. 如果 NNI Trial 作业需要 GPU 资源,需按照[指南](https://github.com/NVIDIA/k8s-device-plugin)来配置 **Kubernetes 下的 Nvidia 插件**
5. 准备 **NFS 服务器** 并导出通用的装载 (mount),推荐将 NFS 服务器路径映射到 `root_squash 选项`,否则可能会在 NNI 复制文件到 NFS 时出现权限问题。 参考[页面](https://linux.die.net/man/5/exports),来了解关于 root_squash 选项,或 **Azure File Storage**
6. 在安装 NNI 并运行 nnictl 的计算机上安装 **NFS 客户端**。 运行此命令安装 NFSv4 客户端: ```apt-get install nfs-common```
7. 参考[指南](../Tutorial/QuickStart.md)安装 **NNI**
## Azure 部署的 Kubernetes 的准备工作
1. NNI 支持基于 Azure Kubernetes Service 的 Kubeflow,参考[指南](https://azure.microsoft.com/zh-cn/services/kubernetes-service/)来设置 Azure Kubernetes Service。
2. 安装 [Azure CLI](https://docs.microsoft.com/zh-cn/cli/azure/install-azure-cli?view=azure-cli-latest)**kubectl**。 使用 `az login` 命令来设置 Azure 账户吗,并将 kubectl 客户端连接到 AKS,参考此[指南](https://docs.microsoft.com/zh-cn/azure/aks/kubernetes-walkthrough#connect-to-the-cluster)
3. 在 Azure Kubernetes Service 上部署 Kubeflow,参考此[指南](https://www.kubeflow.org/docs/started/getting-started/)
4. 参考此[指南](https://docs.microsoft.com/zh-cn/azure/storage/common/storage-quickstart-create-account?tabs=portal)来创建 Azure 文件存储账户。 NNI 需要 Azure Storage Service 来存取代码和输出文件。
5. NNI 需要访问密钥来连接 Azure 存储服务,NNI 使用 [Azure Key Vault](https://azure.microsoft.com/zh-cn/services/key-vault/) 服务来保护私钥。 设置 Azure Key Vault 服务,并添加密钥到 Key Vault 中来存取 Azure 存储账户。 参考[指南](https://docs.microsoft.com/zh-cn/azure/key-vault/quick-create-cli)来存储访问密钥。
## 设计
![](../../img/kubeflow_training_design.png) Kubeflow 训练平台会实例化一个 Kubernetes 客户端来与 Kubernetes 集群的 API 服务器交互。
对于每个 Trial,会上传本机 codeDir 路径(在 nni_config.yml 中配置)中的所有文件,包括 parameter.cfg 这样的生成的文件到存储卷中。 当前支持两种存储卷:[nfs](https://en.wikipedia.org/wiki/Network_File_System)[Azure 文件存储](https://azure.microsoft.com/zh-cn/services/storage/files/),需要在 NNI 的 YAML 文件中进行配置。 当文件准备好后,Kubeflow 训练平台会调用 Kubernetes 的 API 来创建 Kubeflow 作业 ([tf-operator](https://github.com/kubeflow/tf-operator) 作业或 [pytorch-operator](https://github.com/kubeflow/pytorch-operator) 作业) ,并将存储卷挂载到作业的 pod 中。 Kubeflow 作业的输出文件,例如 stdout, stderr, trial.log 以及模型文件,也会被复制回存储卷。 NNI 会在网页中显示每个 Trial 的存储卷的 URL,以便浏览日志和输出文件。
## 支持的操作符(operator)
NNI 仅支持 Kubeflow 的 tf-operator 和 pytorch-operator,其它操作符未经测试。 可以在配置文件中设置操作符类型。 这是 tf-operator 的设置:
```yaml
kubeflowConfig:
operator: tf-operator
```
这是 pytorch-operator 的设置:
```yaml
kubeflowConfig:
operator: pytorch-operator
```
如果要使用 tf-operator,需要在 Trial 配置中设置 `ps``worker`。如果要使用 pytorch-operator,需要在 Trial 配置中设置 `master``worker`
## 支持的存储类型
NNI 支持使用 NFS 和 Azure 存储来存储代码和输出文件,可在配置文件进行相应的配置。
NFS 存储配置如下:
```yaml
kubeflowConfig:
storage: nfs
nfs:
# NFS 服务器 IP, 如 10.10.10.10
server: {your_nfs_server_ip}
# NFS 服务器的导出路径,如 /var/nfs/nni
path: {your_nfs_server_export_path}
```
如果使用了 Azure 存储,需要在 YAML 文件中如下设置 `kubeflowConfig`
```yaml
kubeflowConfig:
storage: azureStorage
keyVault:
vaultName: {your_vault_name}
name: {your_secert_name}
azureStorage:
accountName: {your_storage_account_name}
azureShare: {your_azure_share_name}
```
## 运行 Experiment
`examples/trials/mnist-tfv1` 为例。 这是一个 TensorFlow 作业,使用了 Kubeflow 的 tf-operator。 NNI 的 YAML 配置文件如下:
```yaml
authorName: default
experimentName: example_mnist
trialConcurrency: 2
maxExecDuration: 1h
maxTrialNum: 20
#可选项: local, remote, pai, kubeflow
trainingServicePlatform: kubeflow
searchSpacePath: search_space.json
#可选项: true, false
useAnnotation: false
tuner:
#可选项: TPE, Random, Anneal, Evolution
builtinTunerName: TPE
classArgs:
#可选项: maximize, minimize
optimize_mode: maximize
assessor:
builtinAssessorName: Medianstop
classArgs:
optimize_mode: maximize
trial:
codeDir: .
worker:
replicas: 2
command: python3 dist_mnist.py
gpuNum: 1
cpuNum: 1
memoryMB: 8196
image: msranni/nni:latest
ps:
replicas: 1
command: python3 dist_mnist.py
gpuNum: 0
cpuNum: 1
memoryMB: 8196
image: msranni/nni:latest
kubeflowConfig:
operator: tf-operator
apiVersion: v1alpha2
storage: nfs
nfs:
# NFS 服务器 IP,如 10.10.10.10
server: {your_nfs_server_ip}
# NFS 服务器的导出路径,如 /var/nfs/nni
path: {your_nfs_server_export_path}
```
注意:如果用 Kubeflow 模式运行,需要在 YAML 文件中显式设置 `trainingServicePlatform: kubeflow`
如果要运行 Pytorch 作业,需要如下配置:
```yaml
authorName: default
experimentName: example_mnist_distributed_pytorch
trialConcurrency: 1
maxExecDuration: 1h
maxTrialNum: 10
#可选项: local, remote, pai, kubeflow
trainingServicePlatform: kubeflow
searchSpacePath: search_space.json
#可选项: true, false
useAnnotation: false
tuner:
#可选项: TPE, Random, Anneal, Evolution
builtinTunerName: TPE
classArgs:
#可选项: maximize, minimize
optimize_mode: minimize
trial:
codeDir: .
master:
replicas: 1
command: python3 dist_mnist.py
gpuNum: 1
cpuNum: 1
memoryMB: 2048
image: msranni/nni:latest
worker:
replicas: 1
command: python3 dist_mnist.py
gpuNum: 0
cpuNum: 1
memoryMB: 2048
image: msranni/nni:latest
kubeflowConfig:
operator: pytorch-operator
apiVersion: v1alpha2
nfs:
# NFS 服务器 IP,如 10.10.10.10
server: {your_nfs_server_ip}
# NFS 服务器导出路径,如 /var/nfs/nni
path: {your_nfs_server_export_path}
```
Kubeflow 模式的配置有下列主键:
* codeDir
* 代码目录,存放训练代码和配置文件
* worker (必填)。 此部分用于配置 TensorFlow 的 worker 角色
* replicas
* 必填。 需要运行的 TensorFlow woker 角色的数量,必须为正数。
* command
* 必填。 用来运行 Trial 作业的命令,例如: ```python mnist.py```
* memoryMB
* 必填。 Trial 程序的内存需求,必须为正数。
* cpuNum
* gpuNum
* image
* 必填。 在 kubeflow 模式中,Kubernetes 会安排 Trial 程序在 [Pod](https://kubernetes.io/docs/concepts/workloads/pods/pod/) 中执行。 此键用来指定 Trial 程序的 pod 使用的 Docker 映像。
* [Docker Hub](https://hub.docker.com/) 上有预制的 NNI Docker 映像 [msranni/nni](https://hub.docker.com/r/msranni/nni/)。 它包含了用来启动 NNI Experiment 所依赖的所有 Python 包,Node 模块和 JavaScript。 生成此 Docker 映像的文件在[这里](https://github.com/Microsoft/nni/tree/master/deployment/docker/Dockerfile)。 可以直接使用此映像,或参考它来生成自己的映像。
* privateRegistryAuthPath
* 可选字段,指定 `config.json` 文件路径。此文件,包含了 Docker 注册的认证令牌,用来从私有 Docker 中拉取映像。 [参考文档](https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/)
* apiVersion
* 必填。 Kubeflow 的 API 版本。
* ps (可选)。 此部分用于配置 TensorFlow 的 parameter 服务器角色。
* master (可选)。 此部分用于配置 PyTorch 的 parameter 服务器角色。
完成并保存 NNI Experiment 配置文件后(例如可保存为:exp_kubeflow.yml),运行以下命令:
```bash
nnictl create --config exp_kubeflow.yml
```
来在 Kubeflow 模式下启动 Experiment。 NNI 会为每个 Trial 创建 Kubeflow tfjob 或 pytorchjob,作业名称的格式为 `nni_exp_{experiment_id}_trial_{trial_id}`。 可以在 Kubernetes 面板中看到创建的 Kubeflow tfjob。
注意:Kubeflow 模式下,NNIManager 会启动 RESTful 服务,监听端口为 NNI 网页服务器的端口加1。 例如,如果网页端口为`8080`,那么 RESTful 服务器会监听在 `8081`端口,来接收运行在 Kubernetes 中的 Trial 作业的指标。 因此,需要在防火墙中启用端口 `8081` 的 TCP 协议,以允许传入流量。
当一个 Trial 作业完成后,可以在 NNI 网页的概述页面(如:http://localhost:8080/oview)中查看 Trial 的信息。
## 版本校验
从 0.6 开始,NNI 支持版本校验,详情参考[这里](PaiMode.md)
如果在使用 Kubeflow 模式时遇到任何问题,请到 [NNI Github](https://github.com/Microsoft/nni) 中创建问题。
\ No newline at end of file
在 Kubeflow 上运行 Experiment
=============================
NNI 支持在 `Kubeflow <https://github.com/kubeflow/kubeflow>`__ 上运行,称为 kubeflow 模式。 在开始使用 NNI 的 Kubeflow 模式前,需要有一个 Kubernetes 集群,可以是私有部署的,或者是 `Azure Kubernetes Service(AKS) <https://azure.microsoft.com/zh-cn/services/kubernetes-service/>`__,并需要一台配置好 `kubeconfig <https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig/>`__ 的 Ubuntu 计算机连接到此 Kubernetes 集群。 如果不熟悉 Kubernetes,可先浏览 `这里 <https://kubernetes.io/docs/tutorials/kubernetes-basics/>`__ 。 在 kubeflow 模式下,每个 Trial 程序会在 Kubernetes 集群中作为一个 Kubeflow 作业来运行。
私有部署的 Kubernetes 的准备工作
-----------------------------------------------
#. 采用 **Kubernetes 1.8** 或更高版本。 根据 `指南 <https://kubernetes.io/docs/setup/>`__ 来安装 Kubernetes。
#. 在 Kubernetes 集群中下载、安装、部署 **Kubeflow**。 根据 `指南 <https://www.kubeflow.org/docs/started/getting-started/>`__ 来安装 Kubeflow。
#. 配置 **kubeconfig** 文件,NNI 将使用此配置与 Kubernetes API 服务交互。 默认情况下,NNI 管理器会使用 ``$(HOME)/.kube/config`` 作为 kubeconfig 文件的路径。 也可以通过环境变量 **KUBECONFIG** 来指定其它 kubeconfig 文件。 根据 `指南 <https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig>`__ 了解更多 kubeconfig 的信息。
#. 如果 NNI Trial 作业需要 GPU 资源,需按照 `指南 <https://github.com/NVIDIA/k8s-device-plugin>`__ 来配置 **Kubernetes 下的 Nvidia 插件**。
#. 准备 **NFS 服务器** 并导出通用的装载 (mount),推荐将 NFS 服务器路径映射到 **root_squash 选项**,否则可能会在 NNI 复制文件到 NFS 时出现权限问题。 参考 `页面 <https://linux.die.net/man/5/exports>`__,来了解关于 root_squash 选项,或 **Azure File Storage**。
#. 在安装 NNI 并运行 nnictl 的计算机上安装 **NFS 客户端**。 运行此命令安装 NFSv4 客户端:
.. code-block:: bash
apt-get install nfs-common
#. 参考 `指南 <../Tutorial/QuickStart.rst>`__ 安装 **NNI**。
Azure 部署的 Kubernetes 的准备工作
-----------------------------------------
#. NNI 支持基于 Azure Kubernetes Service 的 Kubeflow,参考 `指南 <https://azure.microsoft.com/zh-cn/services/kubernetes-service/>`__ 来设置 Azure Kubernetes Service。
#. 安装 `Azure CLI <https://docs.microsoft.com/en-us/cli/azure/install-azure-cli?view=azure-cli-latest>`__ 和 ``kubectl``。 使用 ``az login`` 命令来设置 Azure 账户,并将 kubectl 客户端连接到 AKS,参考此 `指南 <https://docs.microsoft.com/zh-cn/azure/aks/kubernetes-walkthrough#connect-to-the-cluster>`__。
#. 在 Azure Kubernetes Service 上部署 Kubeflow,参考此 `指南 <https://www.kubeflow.org/docs/started/getting-started/>`__。
#. 参考此 `指南 <https://docs.microsoft.com/zh-cn/azure/storage/common/storage-quickstart-create-account?tabs=portal>`__ 来创建 Azure 文件存储账户。 NNI 需要 Azure Storage Service 来存取代码和输出文件。
#. NNI 需要访问密钥来连接 Azure 存储服务,NNI 使用 `Azure Key Vault <https://azure.microsoft.com/zh-cn/services/key-vault/>`__ 服务来保护私钥。 设置 Azure Key Vault 服务,并添加密钥到 Key Vault 中来存取 Azure 存储账户。 参考 `指南 <https://docs.microsoft.com/zh-cn/azure/key-vault/quick-create-cli>`__ 来存储访问密钥。
设计
------
.. image:: ../../img/kubeflow_training_design.png
:target: ../../img/kubeflow_training_design.png
:alt:
Kubeflow 训练平台会实例化一个 Kubernetes 客户端来与 Kubernetes 集群的 API 服务器交互。
对于每个 Trial,会上传本机 codeDir 路径(在 nni_config.yml 中配置)中的所有文件,包括 parameter.cfg 这样的生成的文件到存储卷中。 当前支持两种存储卷:`nfs <https://zh.wikipedia.org/wiki/Network_File_System>`__ 和 `azure file storage <https://azure.microsoft.com/zh-cn/services/storage/files/>`__,需要在 NNI 的 YAML 文件中进行配置。 当文件准备好后,Kubeflow 训练平台会调用 Kubernetes 的 API 来创建 Kubeflow 作业 (\ `tf-operator <https://github.com/kubeflow/tf-operator>`__ 作业或 `pytorch-operator <https://github.com/kubeflow/pytorch-operator>`__ 作业) ,并将存储卷挂载到作业的 pod 中。 Kubeflow 作业的输出文件,例如 stdout, stderr, trial.log 以及模型文件,也会被复制回存储卷。 NNI 会在网页中显示每个 Trial 的存储卷的 URL,以便浏览日志和输出文件。
支持的操作符(operator)
-----------------------------------------
NNI 仅支持 Kubeflow 的 tf-operator 和 pytorch-operator,其它操作符未经测试。
可以在配置文件中设置操作符类型。
这是 tf-operator 的设置:
.. code-block:: yaml
kubeflowConfig:
operator: tf-operator
这是 pytorch-operator 的设置:
.. code-block:: yaml
kubeflowConfig:
operator: pytorch-operator
如果要使用 tf-operator,需要在 Trial 配置中设置 ``ps`` 和 ``worker``。如果要使用 pytorch-operator,需要在 Trial 配置中设置 ``master`` 和 ``worker``。
支持的存储类型
----------------------
NNI 支持使用 NFS 和 Azure 存储来存储代码和输出文件,可在配置文件进行相应的配置。
NFS 存储配置如下:
.. code-block:: yaml
kubeflowConfig:
storage: nfs
nfs:
# Your NFS server IP, like 10.10.10.10
server: {your_nfs_server_ip}
# Your NFS server export path, like /var/nfs/nni
path: {your_nfs_server_export_path}
如果使用了 Azure 存储,需要在 YAML 文件中如下设置 ``kubeflowConfig``:
.. code-block:: yaml
kubeflowConfig:
storage: azureStorage
keyVault:
vaultName: {your_vault_name}
name: {your_secert_name}
azureStorage:
accountName: {your_storage_account_name}
azureShare: {your_azure_share_name}
运行实验
-----------------
以 ``examples/trials/mnist-tfv1`` 为例。 这是一个 TensorFlow 作业,使用了 Kubeflow 的 tf-operator。 NNI 的 YAML 配置文件如下:
.. code-block:: yaml
authorName: default
experimentName: example_mnist
trialConcurrency: 2
maxExecDuration: 1h
maxTrialNum: 20
#choice: local, remote, pai, kubeflow
trainingServicePlatform: kubeflow
searchSpacePath: search_space.json
#choice: true, false
useAnnotation: false
tuner:
#choice: TPE, Random, Anneal, Evolution
builtinTunerName: TPE
classArgs:
#choice: maximize, minimize
optimize_mode: maximize
assessor:
builtinAssessorName: Medianstop
classArgs:
optimize_mode: maximize
trial:
codeDir: .
worker:
replicas: 2
command: python3 dist_mnist.py
gpuNum: 1
cpuNum: 1
memoryMB: 8196
image: msranni/nni:latest
ps:
replicas: 1
command: python3 dist_mnist.py
gpuNum: 0
cpuNum: 1
memoryMB: 8196
image: msranni/nni:latest
kubeflowConfig:
operator: tf-operator
apiVersion: v1alpha2
storage: nfs
nfs:
# Your NFS server IP, like 10.10.10.10
server: {your_nfs_server_ip}
# Your NFS server export path, like /var/nfs/nni
path: {your_nfs_server_export_path}
注意:如果用 Kubeflow 模式运行,需要在 YAML 文件中显式设置 ``trainingServicePlatform: kubeflow``。
如果要运行 Pytorch 作业,需要如下配置:
.. code-block:: yaml
authorName: default
experimentName: example_mnist_distributed_pytorch
trialConcurrency: 1
maxExecDuration: 1h
maxTrialNum: 10
#choice: local, remote, pai, kubeflow
trainingServicePlatform: kubeflow
searchSpacePath: search_space.json
#choice: true, false
useAnnotation: false
tuner:
#choice: TPE, Random, Anneal, Evolution
builtinTunerName: TPE
classArgs:
#choice: maximize, minimize
optimize_mode: minimize
trial:
codeDir: .
master:
replicas: 1
command: python3 dist_mnist.py
gpuNum: 1
cpuNum: 1
memoryMB: 2048
image: msranni/nni:latest
worker:
replicas: 1
command: python3 dist_mnist.py
gpuNum: 0
cpuNum: 1
memoryMB: 2048
image: msranni/nni:latest
kubeflowConfig:
operator: pytorch-operator
apiVersion: v1alpha2
nfs:
# Your NFS server IP, like 10.10.10.10
server: {your_nfs_server_ip}
# Your NFS server export path, like /var/nfs/nni
path: {your_nfs_server_export_path}
kubeflow 模式的配置有下列主键:
* codeDir
* 代码目录,存放训练代码和配置文件
* worker (必填)。 此部分用于配置 TensorFlow 的 worker 角色
* replicas
* 必填。 需要运行的 TensorFlow woker 角色的数量,必须为正数。
* command
* 必填。 用来运行 Trial 作业的命令,例如:``python mnist.py``。
* memoryMB
* 必填。 Trial 程序的内存需求,必须为正数。
* cpuNum
* gpuNum
* image
* 必填。 在 kubeflow 模式中,Kubernetes 会安排 Trial 程序在 `Pod <https://kubernetes.io/docs/concepts/workloads/pods/pod/>`__ 中执行。 此键用来指定 Trial 程序的 pod 使用的 Docker 映像。
* 我们已经 build 了一个 docker image :githublink:`msranni/nni <deployment/docker/Dockerfile>`。 可以直接使用此映像,或参考它来生成自己的映像。
* privateRegistryAuthPath
* 可选字段,指定 ``config.json`` 文件路径。此文件,包含了 Docker 注册的认证令牌,用来从私有 Docker 中拉取映像。 `参考文档 <https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/>`__。
* apiVersion
* 必填。 Kubeflow 的 API 版本。
* ps (可选)。 此部分用于配置 TensorFlow 的 parameter 服务器角色。
* master (可选)。 此部分用于配置 PyTorch 的 parameter 服务器角色。
完成并保存 NNI Experiment 配置文件后(例如可保存为:exp_kubeflow.yml),运行以下命令:
.. code-block:: bash
nnictl create --config exp_kubeflow.yml
来在 Kubeflow 模式下启动实验。 NNI 会为每个 Trial 创建 Kubeflow tfjob 或 pytorchjob,作业名称的格式为 ``nni_exp_{experiment_id}_trial_{trial_id}``。
可以在 Kubernetes 面板中看到创建的 Kubeflow tfjob。
注意:Kubeflow 模式下,NNIManager 会启动 RESTful 服务,监听端口为 NNI 网页服务器的端口加1。 例如,如果网页端口为 ``8080``,那么 RESTful 服务器会监听在 ``8081`` 端口,来接收运行在 Kubernetes 中的 Trial 作业的指标。 因此,需要在防火墙中启用端口 ``8081`` 的 TCP 协议,以允许传入流量。
当一个 Trial 作业完成后,可以在 NNI 网页的概述页面(如:http://localhost:8080/oview)中查看 Trial 的信息。
版本校验
-------------
从 0.6 开始,NNI 支持版本校验,详情参考 `这里 <PaiMode.rst>`__。
如果在使用 Kubeflow 模式时遇到任何问题,请到 `NNI Github repo <https://github.com/Microsoft/nni>`__ 中创建问题。
# **教程:使用 NNI API 在本地创建和运行 Experiment**
本教程会使用 [~/examples/trials/mnist-tfv1] 示例来解释如何在本地使用 NNI API 来创建并运行 Experiment。
> 在开始前
要有一个使用卷积层对 MNIST 分类的代码,如 `mnist_before.py`
> 第一步:更新模型代码
对代码进行以下改动来启用 NNI API:
1.1 声明 NNI API
在 Trial 代码中通过 `import nni` 来导入 NNI API。
1.2 获取预定义的参数
参考下列代码片段:
RECEIVED_PARAMS = nni.get_next_parameter()
来获得 Tuner 分配的超参值。 `RECEIVED_PARAMS` 是一个对象,例如:
{"conv_size": 2, "hidden_size": 124, "learning_rate": 0.0307, "dropout_rate": 0.2029}
1.3 返回结果
使用 API:
`nni.report_intermediate_result(accuracy)`
返回 `accuracy` 的值给 Assessor。
使用 API:
`nni.report_final_result(accuracy)`
返回 `accuracy` 的值给 Tuner。
将改动保存到 `mnist.py` 文件中。
**注意**
accuracy - 如果使用 NNI 内置的 Tuner/Assessor,那么 `accuracy` 必须是数值(如 float, int)。在定制 Tuner/Assessor 时 `accuracy` 可以是任何类型的 Python 对象。
Assessor(评估器)- 会根据 Trial 的历史值(即其中间结果),来决定这次 Trial 是否应该提前终止。
Tuner(调参器) - 会根据探索的历史(所有 Trial 的最终结果)来生成下一组参数、架构。
> 第二步:定义搜索空间
`Step 1.2 获取预定义的参数` 中使用的超参定义在 `search_space.json` 文件中:
{
"dropout_rate":{"_type":"uniform","_value":[0.1,0.5]},
"conv_size":{"_type":"choice","_value":[2,3,5,7]},
"hidden_size":{"_type":"choice","_value":[124, 512, 1024]},
"learning_rate":{"_type":"uniform","_value":[0.0001, 0.1]}
}
参考[定义搜索空间](../Tutorial/SearchSpaceSpec.md)进一步了解。
> 第三步:定义 Experiment
>
> > 3.1 启用 NNI API 模式
要启用 NNI 的 API 模式,需要将 useAnnotation 设置为 *false*,并提供搜索空间文件的路径(即第一步中定义的文件):
useAnnotation: false
searchSpacePath: /path/to/your/search_space.json
在 NNI 中运行 Experiment,只需要:
* 可运行的 Trial 的代码
* 实现或选择 Tuner
* 准备 YAML 的 Experiment 配置文件
* (可选) 实现或选择 Assessor
**准备 Trial**
> 在克隆代码后,可以在 ~/nni/examples 中找到一些示例,运行 `ls examples/trials` 查看所有 Trial 示例。
先从 NNI 提供的简单 Trial 示例,如 MNIST 开始。 NNI 示例在代码目录的 examples 中,运行 `ls ~/nni/examples/trials` 可以看到所有 Experiment 的示例。 执行下面的命令可轻松运行 NNI 的 mnist 示例:
python ~/nni/examples/trials/mnist-annotation/mnist.py
上面的命令会写在 YAML 文件中。 参考[这里](../TrialExample/Trials.md)来写出自己的 Experiment 代码。
**准备 Tuner**: NNI 支持多种流行的自动机器学习算法,包括:Random Search(随机搜索),Tree of Parzen Estimators (TPE),Evolution(进化算法)等等。 也可以实现自己的 Tuner(参考[这里](../Tuner/CustomizeTuner.md))。下面使用了 NNI 内置的 Tuner:
tuner:
builtinTunerName: TPE
classArgs:
optimize_mode: maximize
*builtinTunerName* 用来指定 NNI 中的 Tuner,*classArgs* 是传入到 Tuner的参数(内置 Tuner 在[这里](../Tuner/BuiltinTuner.md)),*optimization_mode* 表明需要最大化还是最小化 Trial 的结果。
**准备配置文件**:实现 Trial 的代码,并选择或实现自定义的 Tuner 后,就要准备 YAML 配置文件了。 NNI 为每个 Trial 示例都提供了演示的配置文件,用命令`cat ~/nni/examples/trials/mnist-annotation/config.yml` 来查看其内容。 大致内容如下:
```yaml
authorName: your_name
experimentName: auto_mnist
# 并发运行数量
trialConcurrency: 2
# Experiment 运行时间
maxExecDuration: 3h
# 可为空,即数量不限
maxTrialNum: 100
# 可选值为: local, remote
trainingServicePlatform: local
# 搜索空间文件
searchSpacePath: search_space.json
# 可选值为: true, false
useAnnotation: true
tuner:
builtinTunerName: TPE
classArgs:
optimize_mode: maximize
trial:
command: python mnist.py
codeDir: ~/nni/examples/trials/mnist-annotation
gpuNum: 0
```
因为这个 Trial 代码使用了 NNI Annotation 的方法(参考[这里](../Tutorial/AnnotationSpec.md) ),所以*useAnnotation* 为 true。 *command* 是运行 Trial 代码所需要的命令,*codeDir* 是 Trial 代码的相对位置。 命令会在此目录中执行。 同时,也需要提供每个 Trial 进程所需的 GPU 数量。
完成上述步骤后,可通过下列命令来启动 Experiment:
nnictl create --config ~/nni/examples/trials/mnist-annotation/config.yml
参考[这里](../Tutorial/Nnictl.md)来了解 *nnictl* 命令行工具的更多用法。
## 查看 Experiment 结果
Experiment 应该一直在运行。 除了 *nnictl* 以外,还可以通过 NNI 的网页来查看 Experiment 进程,进行控制和其它一些有意思的功能。
## 使用多个本地 GPU 加快搜索速度
下列步骤假设本机有 4 块 NVIDIA GPUs,参考 [tensorflow with GPU support](https://www.tensorflow.org/install/gpu)。 演示启用了 4 个并发的 Trial 任务,每个 Trial 任务使用了 1 块 GPU。
**准备配置文件**:NNI 提供了演示用的配置文件,使用 `cat examples/trials/mnist-annotation/config_gpu.yml` 来查看。 trailConcurrency 和 gpuNum 与基本配置文件不同:
...
# 可同时运行的 Trial 数量
trialConcurrency: 4
...
trial:
command: python mnist.py
codeDir: ~/nni/examples/trials/mnist-annotation
gpuNum: 1
用下列命令运行 Experiment:
nnictl create --config ~/nni/examples/trials/mnist-annotation/config_gpu.yml
可以用 *nnictl* 命令行工具或网页界面来跟踪训练过程。 *nvidia_smi* 命令行工具能在训练过程中查看 GPU 使用情况。
\ No newline at end of file
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