MegEngine v1.9.0 Release Notes

MegEngine

Known Issue

  • 使用 megengine.random.RNG 的输入包含 0 维 tensor 场景,训练会报错。

HighLight

  • 本次版本性能有较大提升,大部分网络训练提速约 10% , host bound 严重的场景如检测模型,QAT 训练等有 20%~40% 的加速。尤其是在小 batch、amp 等情况下有显著提速。在 BaseCls 的多卡训练上验证,平均提速15.4%。
    • 支持在一些算子中,输出张量可以与输入张量共享数据(Memory Forwarding)。此时不会发生数据拷贝,只有当数据是共享的张量发生修改时,才会触发数据拷贝,保证共享这一部分数据的其他张量不会受到影响。涉及到的算子包括: megengine.functional.transposemegengine.functional.broadcast_tomegengine.functional.reshapemegengine.functional.expand_dims megengine.functional.split 、张量索引等。这样可以尽可能地减少数据拷贝的过程,性能得到提升。为了防止极端情况下显存异常,提供 megengine.config.disable_memory_forwarding 用于禁用这项功能。

Notice

  • 本次版本对 python3.5 的支持继续维持,从下个版本 MegEngine v1.10(MegBrain v8.17) 开始将停止,请大家注意提前做好准备。

Bug fixes

Python API

  • 修复使 @ 运算符与 megengine.functional.matmul 的行为一致。
  • 修复使用 megengine.functional.nn.pad ,输出 Tensor 值可能为全 0 的问题。
  • megengine.functional.nn.remap megengine.data.transform.Resize 添加 nearnest mode 模式。

通用组件

  • 修复在混合精度训练时无法使用 megengine.functional.nn.sync_batch_norm 的问题。
  • 修复全局优化 conv 与两个 nolinear 算子融合时出错的问题。
  • 修复不开 fastrun 的情况下大 kernel 卷积速度慢的问题。
  • 修复对输入为非 float32 的类型求导时不报错,并且没有梯度的问题。
  • 修复分布式训练 RPC 通信 IO 中断问题。
  • 修复 BatchNorm 对二阶导的支持问题。

New Features

Python API

  • megengine.functional.nn.conv1d megengine.functional.nn.conv2d 增加 padding_mode 参数,支持 zeros、reflect、replicate 模式。

CUDA

  • 添加大核的 direct conv 实现。
  • 添加 implicit bmm 大核 depthwise conv 的实现。
  • CUDA 上 resize 的 nearest mode 支持不止 1 和 3 的多通道输入。

通用组件

  • 基于业务降噪模型进行关于 cd4 优化,主要是添加 NHWC 和 NHWCD4 两种 format 之间的转换。在业务的降噪模型上验证性能提升 15% 左右。
  • 添加 int1 数据类型的支持。
  • tensor indexing 中支持 np.newaxis(None) 。

Improvements

通用组件

  • 优化性能,大部分网络训练提速约 10% , host bound严重的 vit、检测模型,在 QAT 场景有 20%~40% 的加速。
  • 提升 op dispatch 系统的性能。 修复了 v1.8 使用的新 dispatch 系统存在的性能问题,修复后性能与 v1.7 持平。
  • 提升 dispatch 系统 jit trace 性能。性能与 v1.7 相比略有提升。开启 trace 下部分模型训练性能提升如下, ResNet50 提升 0.7% , ShuffleNet 提升 9%, ATSS 提升 10%。
  • subgraph op 支持 shape 推导和 jit fusion 优化,并用 subgraph op 重写了部分由 elemwise 组合成的性能较差的op。优化后 megengine.functional.nn.hsigmoidmegengine.functional.nn.relu6megengine.functional.nn.prelumegengine.module.LeakyReLUmegengine.functional.nn.softplusmegengine.functional.nn.logsigmoidmegengine.functional.where 性能在大输入 shape 时与 pytorch 持平。
  • 提升batch_norm的性能,小尺寸下提升 4.3 倍。
  • 优化 reduce op 性能,速度提升 75%。

CUDA

  • 融合 conv 和 h_swish,部分模型性能提升。

MegEngine Lite

Bug fixes

  • lite 修复全局图优化接口 symbolvar 替换不完整导致 cuda 设备上无法使用的问题。
  • 修复 load_and_run lite 模型全局图优化接口与 fast-run 接口使用冲突的问题。
  • 修复 load_and_run 使用 “–cuda” 参数时报错的问题

New Features

  • lite-c 接口中添加错误码和全局获取错误码的接口 LITE_get_last_error_code
  • lite 增加通过虚拟地址查询物理地址的接口。
  • load_and_run 支持 lite 模型全局图优化。

Improvements

  • 优化 Lite 中 get_data_by_share python 接口的性能。在算法仓的模型中略有性能提升。

MegEngine

Bug fixes

Python API

  • make operator “@” behaves in a way consistent with the behavior of megengine.functional.matmul .
  • Fix the output tensor of megengine.functional.nn.pad may be all 0 .
  • Add the nearNest mode for megengine.functional.nn.remap and megengine.data.transform.Resize .

通用组件

  • Fix megengine.functional.nn.sync_batch_norm not being available when training with mixed precision.
  • Fix bug of fuse conv bias and two nolinear opr.
  • Fix the problem of poor performance of the large kernel convolution without fastrun.
  • Fixed bug gm attach non-float type does not report error without gradient.
  • Fix the IO interruption for RPC communication when distributed training.
  • Fix BatchNorm support for higher-order differentiation.

New Features

Python API

  • Add padding_mode parameter,support zeros、reflect、replicate mode for megengine.functional.nn.conv1d megengine.functional.nn.conv2d .

CUDA

  • Add implementation of large kernel’s direct conv algo.
  • Add implementation of large kernel’s depthwise conv by implicit bmm.
  • The nearest mode of resize on cuda supports more than 1 and 3 multi-channel inputs.

Common components

  • Add conversion between NHWC and NHWCD4 formats.
  • Add support for int1 dtype.
  • Add np.newaxis(None) for tensor indexing.

Improvements

Common components

  • Optimized performance, Most networks speed up to 10%, host bound heavy VIT or detection models, QAT scenarios speed up 20% to 40%.
  • Improve the performance of the op dispatch system. Fix the performance problems of the new dispatch system in version 1.8. After the repair, the performance is the same as that of version 1.7.
  • Improve the jit trace performance of the dispatch system. The performance is slightly improved compared to the 1.7 version.
    When trace is enabled, the training performance of some models is improved as follows, resnet50 0.7%, shufflenet 9%, and atss 10%.
  • Subgraph op supports shape infer and jit fusion optimization, and rewrites some ops with it.
    Performance of megengine.functional.nn.hsigmoidmegengine.functional.nn.relu6megengine.functional.nn.prelumegengine.module.LeakyReLUmegengine.functional.nn.softplusmegengine.functional.nn.logsigmoidmegengine.functional.where , and where is on par with pytorch for large input shapes.
  • Improve the performance of the op batch_norm by 4.3 times for small object.
  • Improve the performance of the op reduce,speed up 75%.

CUDA

  • Fusion of conv and h_swish, the performance of some models is improved.

MegEngine Lite

Bug fixes

  • Fix lite global layout transform symbolvar replace error.
  • Fix the conflict between load_and_run lite model global layout transform optimization interface and fast-run interface.
  • Fix load_and_run error when using “–cuda” parameter.

New Features

  • Add ‘LITE_get_last_error_code’ interface in lite-c.
  • Add get physic address interface in lite.
  • Load_and_run supports lite model global layout transform optimization.

Improvements

  • Optimize the get_data_by_share interface of LiteTensor.

1赞