MegEngine

MegEngine 是一个快速、可拓展、易于使用且支持自动求导的深度学习框架

APACHE-2.0 License

Downloads
55
Stars
4.7K
Committers
47

Bot releases are hidden (Show)

MegEngine - MegEngine v1.7.0

Published by megvii-mge almost 3 years ago

MegEngine

HighLight

  • dump_with_testcase_mge.py 脚本删除,功能都挪入 megengine.jit.trace.dump 中,使用请参考 导出序列化模型文件
  • MgeConvert 可将 mge/TracedModule 模型转换为第三方模型文件,支持 Caffe、TFLite 和 ONNX 框架。使用参考 ReadMe

Bug Fixes

通用组件

  • 修复python3.8下的语法问题。
  • 修复学习率不能为0的问题。
  • 增加指数操作特判逻辑以保证结果的一致性,如x**2和x*x,x**3和x*x*x等的一致性。
  • 修复了业务线 det int4 模型在全局图优化 dump 时的问题。修复后全局图优化会检查 opr 的 format,若 format 不匹配 nchw 就不做全局图优化。
  • 解决 tensor.mean() 在以 fp32 计算,fp16 输出时溢出的问题。
  • 修复求导规则失败后异常过多的问题,通过条件判断仅输出必要异常,便于 gdb 调试。
  • 修复无法将 tensor 转换为量化 int4 类型的问题。
  • 修复禁止 DTR 功能时未释放相关资源的问题。
  • 解决 DTR 平方根采样不随机的问题,解决后 resnet1202 训练速度可提升5%。
  • 删除 DTR 中所有 swap 接口。
  • 显存分配默认开启去碎片功能,去除 enable_defrag 接口。
  • 修复scripts/cmake-build/*.sh脚本-n参数。
  • 使用官方构建脚本构建nccl。
  • 修复让 fbs 序列化使用正确的版本号。
  • imperative中支持设置fast-run的workspace限制,以解决开 fastrun 训练 OOM 问题。
  • 修复 megengine.functional.nn.layer_norm 在 AMP 上的运行错误。

CUDA

  • 当 CUBLAS_VERSION < 11200( CUBLAS 版本低于 11.2 )且 batch 为 1 时,如果 shape 过大,则关闭 cublas batched matmul 算法,避免运行崩溃。
  • 修复使 kernel size 较大时(例如 160x160 ),可找到正确的算法。
  • 修复 CUDA 下卷积 illegal memory access 的问题。
  • 修复 cuda11 下,部分模型 cudnnConvBiasActivation 崩溃的问题。
  • 修复带 BatchConvBias 的模型开启 nchw32 图优化时模型运行报错的问题。

python API

  • 添加 layer_norm API 文档。
  • megengine.utils.module_stats 支持字典输入。
  • megengine.functional.full :修改返回值的 dtype 为传入的数字的 dtype ,而不是默认 float32 。
  • 修复使用 PReLU 的模型无法被 trace 的问题。

基础组件

  • 优化 low bit 类型的信息描述。
  • 修复使 module 的 tensors 和 named_tensors 接口只返回 Tensor 类型的数据。
  • 修复 gcc 和 clang 编译选项没对齐带来的精度问题。

周边工具

  • 使用load and run 工具推理增加支持 u16 和 s16 输入数据。
  • 修复 load_and_run 获取模型内存「--get-static-mem-info」选项不生效的问题。

x86

  • 修复 conv_bias Operator 计算错误问题。

发版流程

  • 修复在 TracedModule 中插入自定义 QATModule 后 trace 状态有误的问题。
  • 修复 TracedModule 拍平之后的图中部分 Node 未重命名。
  • 修复 TracedModule 无法插入 _name 属性相同的 Module 。
  • 修复让不在megengine.functional.nn 里定义的函数可被 TracedModule 正确地 trace 。
  • TracedModule 中修复 module dict 遍历操作无法被 trace 的问题。
  • 修复使用相同 tensor node 的 functional 调用时 flatten 时 node.users 不正确的问题。

OpenCL

  • 修改OpenCL算法搜索的cache更新策略,当cache key一样时用最新的而不是之前的,以解决更换cache触发了从source编译kernel,导致运行速度变慢的问题。

Compatibility violation

ARM

  • 优化Arm中Sigmoid的计算性能。

New Features

Python API

  • 增加 pixel_shuffle opr 。
  • megengine.random.permutation 增加支持 Tensor 输入。
  • 增加megengine.random.shuffle opr 。
  • 添加 layer_norm 的支持。
  • 增加 megengine.functional.nn.hinge_loss
  • 增加 megengine.functional.nn.pad
  • megengine.functional.nn.local_response_norm 在 Functional 和 Module 中添加 LRN(局部相应归一化)支持。
  • megengine.functional.nn.conv_transpose2d megengine.functional.nn.conv_transpose3d 增加 group 参数支持。

通用组件

  • 添加 megengine.coalesce_free_memory 接口,用于回收空闲内存。
  • 修复 module.PixelShuffle 报错问题。
  • 支持构造 uint16 tensor 。
  • BatchNorm 添加支持 NHWC format 。
  • 支持 bazel 编译 flatbuffer ,使用编译参数 --copt "-DMGB_ENABLE_FBS_SERIALIZATION=1" 编译的 load and run 可以运行开源版本 MegEngine dump 的模型。
  • 支持在 windows 上直接使用 MegEngine 的动态库以减少 windows 中 whl 包的大小。
  • 修复同一个进程中同时使用 MegEngine 和 Pytorch 崩溃问题。
  • 训练时自动打开 defrag 功能,显存不够且显存碎片严重时可合并显存碎片。
  • 支持 record 模式中输出 tensor 的内存地址可自定义修改。
  • megengine.functional.nn.cvt_color OPR 增加 bgr2gray mode 。

周边工具

  • 删除 dump_with_testcase_mge.py,将其功能放在jit.dump接口中。
  • 为 SmallVector 等 MegEngine 自定义容器增加调试脚本,在 gdb 调试时可以查看容器内容,如下图所示。注意:gdb 只有在 MegBrain 根目录运行的时候才自动有效。

基础组件

  • Reduce 算子支持 nchw44 format 。
  • Elemwise 算子支持 nchw88 的 format 。
  • 针对nhwc int8 conv,添加融合 conv 和 typecvt 图优化。
  • megengine.optimizer.SGD 增加 nesterov momentum 支持。
  • 支持 C++ 模型内存/显存可视化。

ARM

  • 优化非连续情况下的transpose性能,在aarch64 下加速比 1.3。
  • Arm 平台支持 NHWC Int16 输入,fp32 输出的 elemwise。
  • 增加支持了 nchw、nchw44+fp32、nchw88+fp16 的 linear 的 upsample2 ,大幅优化了 ARM 上 linear resize 性能。
  • 优化 channel wise conv 实现,在 feature map 较小时有 1.5x 加速。
  • conv 加入 nchw88 format 的 fp16 支持。
  • 优化 arm 中非连续的 relayout kernel,在开启 record 的情况下推理平均用时在 sdm660 上可以减少约 50% ; subtensor opr 的用时占比减少约70% 。
  • 优化 Arm Elemwise 中 N1HW 的 broadcast 情况,单个计算性能有 1 倍以上提升。

X86

  • X86下添加 reproduceable 属性的 6x16 的 matmul 支持。

CUDA

  • BatchNorm 算子支持 nhwc format 。

发版流程

  • TracedModule node 命名规则变更, 对 expr 的 GetAttr 根据目的进行融合。
    node 修改为 name 、qualname 两个名字,命名规则参见如下规则。node._name 用法不变,node._orig_name 需要修改为 node.qualname 使用 。
    qualname

    • 通过 qualname 可以找到该 Node 是哪个 Module 或 Module 中第几个操作产生了该 Tensor 或 Module。
    • 当 Node 所对应的 Tensor 或 Module 是模型的 attribute 时,qualname 与 attribute 的路径一致。
    • 当 Node 所对应的 Tensor 是通过调用一个 Module 而生成时,qualname = 该 Module 的在模型中的路径 + ".[out]"。
    • 当 Node 所对应的 Tensor 是通过调用一个 function 而生成时,qualname = 该 Node 所在 Graph 的 qualname + ".[func_函数名_函数在当前 Module 中的调用次数]"。
    • 当 Node 所对应的 Tensor 是通过调用某个 Tensor 的 method 而生成时,qualname = 该 Node 所在 Graph 的 qualname + ".[method_方法名_该方法在当前 Module 中的调用次数]"。
    • 当 Node 所对应的 Tensor 是通过调用一个 opdef 而生成时,qualname = 该 Node 所在 Graph 的 qualname + ".[def_opdef名_该 opdef 在当前 Module 中的调用次数]"。
    • 其它:qualname = 该 Node 所在 Graph 的 qualname +"[.Node的名字]"。

    name:

    • 如果该 Node 所对应的 Tensor 或 Module 是模型的 attribute,name 为 Node 的 qualname 与 Graph 的 qualname 的 “差值” 去重后得到, 则 name = Node 的qualname - Node 所在 Graph 的qualname。例如:ResNet18.layer1.block0.conv- ResNet18.layer1 = block0.conv → block0_conv → block0_conv + 去重后缀。
    • 当 Node 所对应的 Tensor 是通过调用一个 Module 而生成时,name qualname = 该 Module 所对应 ModuleNode 的 name + "_out" + 去重后缀。
    • 当 Node 所对应的 Tensor 是通过调用一个 function 而生成时,qualname = 函数名 + "_out" + 去重后缀。
    • 当 Node 所对应的 Tensor 是通过调用某个 Tensor 的 method 而生成时,qualname = 方法名 + "_out" + 去重后缀。
    • 当 Node 所对应的 Tensor 是通过调用一个 opdef 而生成时,qualname = opdef名 + "_out" + 去重后缀。
    • 其它:name = 形参的参数名 或 用户定义的名字。

MegEngine Lite

Bug Fixes

  • 修复调用 enable_profile_performance 接口,在 OpenCL 平台的运行性能分析数据为0的问题。
  • 修复 tensor 等在线程结束后无法被其他线程使用的问题,修改为全局变量并加锁。
  • 修复 lite 中 rknn 设置 tensor 属性类型错误。
  • 修复 MegEngineLite 编译 midout 失败的问题。
  • 修复lite中纯C接口编译错误问题。
  • 修复 MegEngine Lite 模型load之后推导输出 tensor shape 错误的问题。
  • 修复 lite Python 接口中异步执行回调函数错误问题。

New Features

  • 添加 LITE_get_static_memory_alloc_info 接口,用于静态内存分析以及可视化。
  • 支持在执行之前获得模型输出的 Tensor Shape。
  • Lite 支持用户指定输入输出内存地址。
  • Load and run 重构到 Lite 下,并删除原目录「sdk/load-and-run」。文档正在撰写中,待正式版本中可以提供。
  • Lite 中 C 接口的回调函数支持传递 void* 参数。

MegEngine

HighLight

  • The dump_with_testcase_mge.py script is deleted, and the functions are moved into megengine.jit.trace.dump, please refer to Export Serialized Model File .
  • MgeConver can convert mge/TracedModule models into third-party model files, and supports Caffe, TFLite and ONNX frameworks. Use reference ReadMe .

Bug Fixes

Common components

  • Fix the syntax problem under python3.8.
  • Fix the problem that the learning rate cannot be 0.
  • Increase the special judgment logic of exponential operation to ensure the consistency of the results, such as the consistency of x**2 and x*x, x**3 and x*x*x, etc.
  • Fixed the problem when the business line det int4 model optimized dump in the global graph. After the repair, the global graph optimization will check the format of opr. If the format does not match nchw, the global graph optimization will not be performed.
  • Solve the problem of overflow when tensor.mean() is calculated with fp32 and fp16 is output.
  • Fix the problem of too many exceptions after the derivation rule fails, and only necessary exceptions are output through conditional judgment, which is convenient for gdb debugging.
  • Fix the problem that tensor cannot be converted to quantized int4 type.
  • Fixed the issue that related resources were not released when the DTR function was disabled.
  • Solve the problem that DTR square root sampling is not random. After solving the problem, resnet1202 training speed can be increased by 5%.
  • Delete all swap interfaces in DTR.
  • The video memory allocation defaults to enable the de-fragmentation function and remove the enable_defrag interface.
  • Fix scripts/cmake-build/*.sh script -n parameter.
  • Use the official build script to build nccl.
  • Fix to use the correct version number for fbs serialization.
  • Imperative supports setting fast-run workspace restrictions to solve the problem of opening fastrun training OOM.
  • Fix the running error of megengine.functional.nn.layer_norm on AMP.

CUDA

  • When CUBLAS_VERSION <11200 (CUBLAS version is lower than 11.2) and batch is 1, if the shape is too large, turn off the cublas batched matmul algorithm to avoid running crashes.
  • Fix that when the kernel size is larger (for example, 160x160), the correct algorithm can be found.
  • Fix the problem of illegal memory access of convolution under CUDA.
  • Fixed the problem that some models cudnnConvBiasActivation crash under cuda11.
  • Fix the problem that the model with BatchConvBias will report an error when the nchw32 graph is optimized.

python API

  • Added layer_norm API documentation.
  • megengine.utils.module_stats supports dictionary input.
  • megengine.functional.full: Modify the dtype of the return value to the dtype of the number passed in, instead of the default float32.
  • Fix the problem that the model using PReLU cannot be traced.

Basic components

  • Optimize the information description of the low bit type.
  • Fix the module's tensors and named_tensors interfaces to only return data of type Tensor.
  • Fix the accuracy problem caused by the misalignment of gcc and clang compilation options.

Peripheral tools

  • Use load and run tool inference to increase support for u16 and s16 input data.
  • Fix the problem that the option of load_and_run to obtain model memory “--get-static-mem-info” does not take effect.

x86

  • Fix the calculation error of conv_bias Operator.

Release process

  • Fix the problem that the trace status is incorrect after inserting a custom QATModule in the traced module.
  • Fix that some nodes in the figure after TracedModule are flattened are not renamed.
  • Fix TracedModule cannot insert Module with the same _name attribute.
  • Fix to make it not in megengine.functional.nn The defined function can be traced correctly by TracedModule.
  • Fixed the problem that module dict traversal operation cannot be traced in TracedModule.
  • Fix the problem that node.users is incorrect when flattening the functional call of the same tensor node.

OpenCL

  • Modify the cache update strategy of the OpenCL algorithm search. When the cache key is the same, use the latest instead of the previous one to solve the problem that the replacement of the cache triggers the compilation of the kernel from the source, which causes the running speed to slow down.

Compatibility violation

ARM

  • Optimize the calculation performance of Sigmoid in Arm.

New Features

Python API

  • Add pixel_shuffle opr.
  • megengine.random.permutation adds support for Tensor input.
  • Add megengine.random.shuffle opr.
  • Add support for layer_norm.
  • Add megengine.functional.nn.hinge_loss.
  • megengine.functional.nn.local_response_norm adds LRN (local response normalization) support in Functional and Module.
  • megengine.functional.nn.conv_transpose2d megengine.functional.nn.conv_transpose3d adds group parameter support.

Common components

  • Add megengine.coalesce_free_memory interface to reclaim free memory.
  • Fix the error report of module.PixelShuffle.
  • Support the construction of uint16 tensor.
  • BatchNorm adds support for NHWC format.
  • Support bazel to compile flatbuffer, use compiling parameter --copt "-DMGB_ENABLE_FBS_SERIALIZATION=1" to compile load and run to run the open source version of MegEngine dump model.
  • Support the direct use of MegEngine's dynamic library on windows to reduce the size of the whl package in windows.
  • Fixed a crash when using MegEngine and Pytorch in the same process at the same time.
  • The defrag function is automatically turned on during training, and the video memory fragments can be merged when the video memory is insufficient and the video memory fragments are severe.
  • Support the memory address of output tensor in record mode can be customized and modified.
  • Added bgr2gray mode for megengine.functional.nn.cvt_color OPR.

Peripheral tools

  • Delete dump_with_testcase_mge.py and put its function in the jit.dump interface.
  • Add debugging scripts to MegEngine custom containers such as SmallVector, and you can view the contents of the container during gdb debugging, as shown in the figure below. Note: gdb is only effective when the root directory of MegBrain is running.

Basic components

  • Reduce operator supports nchw44 format.
  • The Elemwise operator supports the format of nchw88.
  • For nhwc int8 conv, add fusion conv and typecvt graph optimization.
  • megengine.optimizer.SGD adds nesterov momentum support.
  • Support C++ model memory/video memory visualization, please refer to [Static Graph Memory Visualization Tool User Guide] () for usage.

ARM

  • Optimize the transpose performance in non-continuous situations, with a speedup of 1.3 under aarch64.
  • Arm platform supports elemwise of NHWC Int16 input and fp32 output.
  • Added support for linear upsample2 of nchw, nchw44+fp32, and nchw88+fp16, greatly optimizing the linear resize performance on ARM.
  • Optimize the implementation of channel wise conv, with a 1.5x speedup when the feature map is small.
  • conv added fp16 support of nchw88 format.
  • Optimize the non-continuous relayout kernel in the arm. When the record is turned on, the average inference time can be reduced by about 50% on the sdm660; the time-consuming ratio of the subtensor opr can be reduced by about 70%.
  • Optimize the broadcast situation of N1HW in Arm Elemwise, and the single calculation performance has been improved by more than 1 times.

X86

  • Added support for 6x16 matmul with reproduceable attribute under X86.

CUDA

  • BatchNorm operator supports nhwc format.

Release process

  • The naming rule of TracedModule node is changed, and GetAttr of expr is merged according to the purpose.
    Modify node to name and qualname. The usage of node._name remains unchanged, and node._orig_name needs to be modified to use node.qualname.

MegEngine Lite

Bug Fixes

  • Fix the problem that the running performance analysis data on the OpenCL platform is 0 when the enable_profile_performance interface is called.
  • Fix the problem that tensor, etc. cannot be used by other threads after the thread ends. Modify it to a global variable and lock it.
  • Fix the wrong type of tensor set by rknn in lite.
  • Fix the problem that MegEngineLite fails to compile midout.
  • Fix the compilation error of pure C interface in lite.
  • Fix the problem that the tensor shape of the deduced output is wrong after the MegEngine Lite model is loaded.
  • Fixed an error in the asynchronous execution of the callback function in the lite Python interface.

New Features

  • Add LITE_get_static_memory_alloc_info interface for static memory analysis and visualization.
  • Support Tensor Shape to get model output before execution.
  • Lite supports users to specify input and output memory addresses.
  • Load and run is refactored to Lite, and the original directory "sdk/load-and-run" is deleted. The document is being written and will be available in the official version.
  • The callback function of the C interface in Lite supports passing void* parameters.
MegEngine - v1.7.1.m1

Published by megvii-mge almost 3 years ago

MegEngine - MegEngine v1.6.0

Published by kagome1007 about 3 years ago

HighLight


trace module

基于 MegEngine 的应用落地方案 Trace Module 正式开源。
Trace Module 由一个普通的 Module 通过 trace_module 方法转换得到,仅由 MegEngine 的数据结构而构成,可脱离用户源代码被训练、序列化以及反序列化、以及图手术。其优点如下。

  • graph 基于 mge.Module 和 mge.function 构建,便于与源代码相对应,且能与第三方框架的 OP 对应上。
  • 图手术直观,可直接查看 graph ,了解修改后的 graph 是否与预期一致。
  • 可基于 TracedModule 进行训练。
  • 基于动态图,调试方便,所见即所得。

Custom Op

提供可以将用户自定义的 C++/CUDA 算子快速集成入 MegEngine 的工具,以达成更好性能效果。

全局图优化

新增全局图优化支持,可以自动做 format 转换和 padding,增强易用性。您不用再关心是否需要开哪个图优化选项,例如「-- enable-nchw32」,在检测模型验证获得 5% 左右加速。本次版本增加对 cuda 平台支持,ARM/X86 等更多平台进行中,使用如下命令尝鲜使用:
load_and_run /path/to/model --layout-transform cuda

MegEngine Lite

MegEngine Lite 正式开源,请参考使用指南
MegEngine Lite 是模型直达 SDK 的解决方案,充分发挥 MegEngine 的高效,多平台的推理能力,为用户提供简洁、易用的 C++、C、python 多种模型推理接口,同时 MegEngine Lite 也可以接入其他的推理框架,便于业务集成。

Bug Fixes


Python API

  • 修复 megengine.functional.nn.dropout 在 inference 模式下输出不正确的问题。
  • 修复 megengine.functional.vision.warp_perspective 文档公式错误的问题。
  • 修复 megengine.functional.sub 的 API 接口说明。
  • 删除已经弃用的 megengine.jit.trace.trace 接口。
  • linspace/arange 修改 dtype 为 fp32 支持更多数据类型。
  • 修复 megengine.functional.nn.dropout 在 inference 模式下的返回值错误的问题。

通用组件

  • 修复训练模型时打开 fastrun 之后显存 OOM 问题。
  • 修复开启 DTR 时由于重算链过长导致递归栈溢出的问题。
  • 修复 fp16 midout 编译失败的问题。
  • 修复 python fastrun 错误,确保读取 cache 的正确性。
  • 计算图 dump的边界情况处理不完整:修复导出 json 文件时把 inf 或者 nan 直接写成 number,导致MegHair profile_analyze.py 分析无法再解析的错误。
  • 修复 tensor detach 后不能被 trace 的问题。
  • 修复异步执行错误 (async error) 报错到无关地方的问题,同时添加引导说明以帮助用户理解报错原因。
  • 修复了在系统已安装 LLVM-12-dev 的情况下引发的 Cmake 构建失败的问题。
  • 修复用户通过设置 LD_LIBRARY_PATH 环境变量指定链接库时 Cmake 编译失败的问题。
  • 修复 Tensor Interpreter 一个错误多次抛异常的问题。之前已经出错的 tensor 被当前 OP 使用时不再重复报错,直接跳过。
  • 修复 Cmake 编译 llvm 报错。

周边工具

  • 修复静态内存分析的工具中统计 GPU 静态内存分配信息的错误。
  • 缩短 cutlass 中gemm kernel 的命名长度,修复由于目录层级太多造成的 windows 编译失败的问题。
  • 修复项目上使用 SNPE Loader 时,如果初始化失败时,Megbrain 没有及时抛出异常的问题。

CUDA

  • 禁用 CUDA 平台部分 matmul 算法的 TensorCore 优化。原因是 TensorCore 优化引入的隐>式类型转换有潜在精度问题。
  • cuda10 关闭 cublas Lt 算法,因为它会对 fp32 的输入做隐式的类型转换,然后调用 fp16 的 tensorcore,可能引入精度问题。

ARM

  • 修复 ROCm 中 Pooling 计算错误的问题。

New Features


Python API

  • interpolate 支持 nearest 和 bilinear 模式。
  • 增加混合并行下的数据排布变换支持。对多机算子,可以指定 axis 表示对高维 tensor 对应维度进行切分或者合并。
  • 增加 python 侧获取 nvidia gpu 的 compute capability 的 API: megengine.get_cuda_compute_capability。

混合精度训练

  • 修改添加 weight_scaler/bias_scaler 的方式,从需要手动在模型内添加改为通过接口 get_scaled_model 实现自动添加。

通用组件

  • Conv backward fp16 精度增加支持 NHWC 格式。
  • 优化异步错误的表达方式,给予更多提示信息。

CUDA

  • 添加 tensorcore fp16 matmul 算法。
  • sass conv int8 优化后,单个 conv 性能有 5%~10% 的提升。
  • 添加 cutlass nhwc int8 imma conv kernel ,相对于 nchw4 dp4a 提升大约 10%-200% 。全局图优化功能 ready 后可开启对应 algo 获得收益。

ARM

  • 新增 NCHW88 格式的 channel wise 卷积实现,fp32 下部分场景可加速约 1.5 倍。
  • 新增 arm nchw88 fp16 的 channel wise 卷积 kernel。

Improvements


Python API

  • DTR 优化,各模型测试速度平均提升约10%,ResNet50 8 卡最大 batchsize 达500, GL 8 卡最大 batchsize 达 110, ViT 8 卡最大 batchsize 达 300 。
  • 新增 megengine.functional.nn.split ,替换之前用其他 op 拼接的实现,速度提升约 5 倍。
  • megengine.functional.split、megengine.functional.cond_take 、advance indexing、Indexing(Set)MultiAxisVec、setsubtensor、subtensor 支持空 tensor 输入。
  • 为 megengine.functional.sub 添加 docstring。
  • python API 文档转换成 google style , 详情参考这里
MegEngine - MegEngine v1.6.0-rc1

Published by megvii-mge about 3 years ago

HighLight

  • MegEngine Lite 是模型直达SDK的解决方案,充分发挥 MegEngine 的高效,多平台的推理能力,为用户提供简洁、易用的 C++、C、python 多种模型推理接口,同时 MegEngine Lite 也可以接入其他的推理框架,便于业务集成。
  • 尝鲜体验通道如下,请参考使用指南
    python3 -m pip install megengine==1.6.0rc1 -f https://megengine.org.cn/whl/mge.html

Known Issue

由于对fastrun fp16 的特殊 case 加了一些判断,AMP 整体性能有10%左右的下降。

Bug Fixes

Python API

  • 解决 LSQ 量化算子初始化格式错误问题。
  • 当自定义求导 Function 的 forward 输入为非 Tensor 参数时,修改报错信息更可读。
    • 原报错信息:RuntimeError: can not find op_trait by GenericPyOp .
    • 现报错信息:TypeError: op GenericPyOp expect type Tensor as inputs, got int actually
  • 修复 module 通过 setattr 自动命名时,对同一个实例多次设置到相同属性会误报错误信息的问题。
  • 修复 is_single_machine 可能导致自定义 launcher 报错的检查逻辑。
  • 修复报错信息 ,输出 device 逻辑名称和物理名称的完整信息,以便于 debug 因为 device 不一致的计算问题。
    • 原报错信息:RuntimeError: ambiguous device: cpu0:0 vs cpu0:0 .
    • 现报错信息:RuntimeError: ambiguous device: CompNode("cpu0:0" from "xpux:0") vs CompNode("cpu0:0" from "cpux:0") .

通用组件

  • 修复从 vs code terminal 无法构建 macos 的 wheel 包的问题。
  • 统一lb_memory在环境变量、python 、C++ 里的单位为MB,解决 int 类型参数较大时溢出的问题。
  • 将 span dist too large 从 warning 降级成 deug log,避免展示一堆无用的 warning。
  • 修复开启 DTR 时由于重算链过长导致递归栈溢出的问题。
  • 修复 fp16 midout 编译失败的问题。
  • 修复 python fastrun 错误,确保读取cache的正确性

CUDA

  • 修复 cutlass 链接时候 crash。
  • 修复设置了环境变量 CUDA_CACHE_PATH 但仍然报相关警告信息的问题。
  • 缩短 cutlass 文件名以修复在 windows 上的编译错误。
  • 修复 cutlass cmake 编译依赖。

第三方硬件

  • 增加第三方的 loader 读模型失败后报错功能,避免返回 null ptr 导致后续程序崩溃。

发版流程

  • 修复图手术中 replace opr 错误导致输出名字被改动的问题。

周边工具

  • 修复 windows 编译准备脚本。
  • 在 hub 缓存的模型中加入 MegEngine 版本信息,以解决当 MegEngine 版本更新之后,若有 breaking change,而用户的 ~/.cache/megengine/hub 中还是老代码,则可能在使用 megengine.hub.load 时因 API 版本不同出现兼容性问题。
  • 修复静态内存分析的工具中统计 GPU 静态内存分配信息的错误。

New Features

Python API

  • interpolate 支持 nearest 和 bilinear 模式
  • 增加 conv_transpose2d 的量化 module 。
  • 增加 cumsum 算子,行为和 pytorch 一致。和 MegDL 差别如下。
    • axis 必须指定,而不是不指定就偷偷帮你 flatten
    • 没有暴露 exclusive 和 reverse 这两个参数
  • 增加 Reduce OPR 对空 Tensor 支持。具体行为如下。
    • sum: => 0
    • mean: => nan
    • prod: => 1
    • min: 报异常
    • max: 报异常
    • sum_sqr: 报异常

混合精度训练

  • 修改添加 weight_scaler/bias_scaler 的方式,从需要手动在模型内添加改为通过接口 get_scaled_model 实现自动添加。

CUDA

  • 添加 tensorcore fp16 matmul 算法。

通用组件

  • 新增加环境变量 MGB_REGISTER_SEGV_HANDLER (默认关闭)。该环境变量打开时,MegEngine 只打印自己的堆栈, 而默认不注册 SEGV signal。
MegEngine - MegEngine v1.5.0

Published by megvii-mge about 3 years ago

Compatibility violation

  • 去掉不必要的隐式类型转换,以解决性能和显存的问题。
    • 使用影响:不再接受 numpy array 作为 functional 的 input ,需要转换为MegEngine 的 Tensor 类型。

HighLight

  • DTR 升级
    • 在 trace 的静态构造模式下支持用 DTR 算法优化计算图的显存峰值,与 Sublinear 相比,ResNet 50 单卡最大 batch size 350->450,八卡 300→450。
    • 动态图模式下支持无阈值开启,用户无需指定 eviction_threshold。
  • 支持混合精度训练。
  • 增加高阶导支持(试验版)。

Bug Fixes

Python API

  • 修复对 nvof 输出形状的计算。
  • launcher 中 fork thread 之前检查 CUDA 是否初始化。
  • 修复 expand_dims 中对 scalar 未处理的问题。
  • 修复 F.topk 中 kth_only=True 不可用的问题。
  • 从 state dict 创建模型参数对应的 Tensor 时不使用 cache ,以防止 inplace 修改参数导致的错误结果。
  • megengine.random.RNG:修复了当 RNG 被定义成一个 全局变量,程序退出时,系统报错的问题。
  • megengine.random.seed:修复对 random seed 的重置,使用相同的 seed( ) 值,每次生成的随即数相同,与 numpy 保持一致。

CUDA

  • 修复tensorRT runtime,支持 int8 nchw4 输入,可以减少显存用量。
  • 修复 cuDNN ConvolutionBackwardData获取算法时候错误。

周边工具

  • 修复 Windows 中 cmake 开启 asan 不工作问题。
  • 修复 toposort 能按定义序获取 opr 顺序。
  • 修复对量化模型统计计算参数 std 时报错的问题,修复 pooling 的 kernel size 为 2d 时,参数量统计会报错 type 问题,支持统计量返回 dims

通用组件

  • 关闭 TEE 模式下的 static 内存统计功能,以保证 TEE 环境的安全性。
  • 修复 x86 matmul 算子在输出 tensor 不连续时候计算错误。
  • 修复 oss 模型序列化中的兼容性问题。
  • 修复 dump 模型时的 device 类型。

New Features

Python API

  • 增加 lsq 算子。
  • DTR 中去除需要用户指定的 threshold。
  • 增加 opr _has_inf。
  • 分布式训练增加user_pop函数在用户获取自定义的 key-value pair后释放资源。
  • 废弃 get_device_count_by_fork。
  • 增加单机利用 cpu shared memory 做 allreduce 的功能。 在 launcher 中设置 backend="auto" 即可在不支持p2p通信的 GPU 中开启 cpu shared memory。
  • 增加 unfold。
  • 增加 silu 和 gelu。
  • interpolate 对 channel=1 或 3 的 input 增加 nearest 和 bicubic mode。
  • 增加 op 实现 gamma、beta、poisson 和 permutation 等随机算子。

ARM

  • 新增 nchw44 layout 下第一层卷积为 K1x1S1 的优化。

CUDA

  • CUDA topK 支持 FP16 数据类型。

通用组件

  • 修复多 batch 精度抖动问题,fast-run 增加忽略 batch size 功能
  • 修改 CUDA JIT 配置接口。
  • 新增统计计算图中内存使用信息的功能。
  • 集合通信增加对 uint8 的支持。
  • 增加 trace、PowC、elemwise 算子支持空的输入输出。
  • 增加 bn 推理模式下的梯度反传。
  • 支持对 metadata 的序列化。
  • 新增 RelayoutEmitter,便于 Tensor 处理复杂的 Layout 变换

Improvements

ARM

优化 ARM pooling 和多线程性能。

CUDA

  • 重构 cutlass 相关 kernel 的生成逻辑。
  • 重构 CUDA relayout format 相关 kernels。
  • CUDA topK 支持 fp16 数据类型

通用组件

Pooling 算子支持 fast-run 搜参功能。

  • 重构 profiler 功能,并添加对 trace 的支持。
  • Group 卷积支持新版 fast-run。
  • 优化 x88 pooling 性能。

Compatibility violation

  • Remove undesired implicit type conversion.
    • The effects of use : It no longer accepts numpy array as functional input and needs to be converted to Tensor type.

HighLight

  • DTR
  • Support DTR memory optimization for static graph under trace mode. Compared with Sublinear, the maximum batch size of training a ResNet 50 increases from 350 to 450 with 1 gpu, and from 300 to 450 with 8 gpu.
  • In dynamic graph , DTR can be used without the need to specify memory eviction threshold.
  • Add mix precision.
  • Support higher-order differentiation (experimental).

Bug Fixes

Python API

  • Fix nvof output shape computation.
  • Add CUDA env check before fork thread in launcher.
  • Fix expand_dims for scalar.
  • Fix F.topk with kth_only.
  • The cache is not used when creating the tensors corresponding to the model parameters from the state dict to prevent incorrect results caused by inplace modification of the parameters.
  • megengine.random.RNG : Fix the system error during the program exit.
  • megengine.random.seed : Fix the reset of random seed when using the same seed value.

CUDA

  • Repair the tensorRT runtime and support input in nchw4 format, int8 dtype, which may reduce memory usage.
  • Fix cuDNN convolutionbackwarddata error when getting algorithm.

Tools

  • Fix asan don’t work in windows when build with cmake.
  • Fix toposort to get definition order.
  • Fix module status error.

General Components

  • Turn off the static memory statistics function in TEE to ensure the safety of the TEE environment.
  • Fix the compute error of X86 matmul operator when output tensor is not continuous
  • Fix compatibility error of oss model.
  • Fix dump device error with const.

New Features

Python API

  • Add lsq opr.
  • Remove eviction threshold in DTR.
  • Add _has_inf opr.
  • Add user_pop function to get user defined key-value pair and delete the resources when the get is done.
  • Deprecate get_device_count_by_fork.
  • Enable shared memory allreduce on a single machine.
  • Add unfold.
  • Add silu and gelu.
  • Interpolate supports nearest and bicubic modes for tensors with the channel as 1 or 3.
  • Add random op's including gamma, beta, poisson and permutation.

ARM

  • Add optimization of first layer Convolution with param K1x1S1 in nchw44.

CUDA

  • CUDA topK operator supports fp16 data types.

General Components

  • Fix the problem of multi batch precision jitter, and ignoring batch size option in fast-run.
  • Modify CUDA JIT configuration interface.
  • Add recording memory usage information function in compute graph.
  • Enable uint8 for collective communication.
  • Add more support to empty IO.
  • Add bn inference backward.
  • Add support of serializing metadata.
  • A new relayemitter is added to facilitate complex layout transformations of tensor

Improvements

ARM

  • Optimize ARM pooling and multithread performance.

CUDA

  • Refactor the generation logic of cutlass related kernels.
  • Refactor CUDA relayout format related kernels
  • CUDA topK operator supports fp16 data types

General Components

  • The pooling operator supports fast-run.
  • Refactor the profiler function and add support for MegEngine trace.
  • The group Convolution operator supports the new version of fast-run.
  • Add algo for x86 max pooling for W13S1 under NCHW88.
MegEngine - MegEngine v1.4.0

Published by megvii-mge over 3 years ago

Highlights

Python API

  • 重构 DTR 相关的 API 并修复其中随机数算子相关的 bug。
  • 新增 gradient clip 相关 API。
  • 新增 correlation 算子。
  • 新增 sliding_window 算子。
  • 重构随机数生成的代码,解决随机数生成速度慢的问题。
  • 添加了参数量/计算量统计与可视化工具。

问题修复

CUDA

  • 修复 NCHW4 layout 使用 cuDNN8.0.4 时候 convbias 中融合Z错误。
  • 修复多个库用了不同版本的 cub 可能带来的隐藏链接问题。

Python API

  • argmax 和 argmin 的 axis 参数接受负数。
  • 如果 attach 到 grad manager 的参数不是 iterable of tensors 时报错。
  • 退出前删除已有的 tensor 以避免非零的退出码。
  • 修复动态图下使用 fastrun 查询算法结果过慢的问题。
  • 如果 batch normalization 的 mode 在 dump 时是 training 就报错。
  • 修复 param pack 中的 UAF。
  • 修复 gather 求导卡住。
  • 修复 trace 中 tensor 共享存储时导致的 bug。

分布式训练

  • 修复程序退出释放资源时多线程竞态问题。

周边工具

  • 修复 dump_with_mge.py 脚本中的 bug。
  • 修复 CUDA pytest 概率下卡死。
  • 修复 VOC dataset 中缺失的 class_colors。
  • 修复 VarNode 的 inplace 操作时的 bug。

文档

  • API 文档修复了 BN momentum 描述。

通用组件

  • 修复 fast-run workspace 限制 bug。
  • 修复 elementise mode 中 enum 和 string 类型比较时的 bug。
  • 修复 optimizer 在 step 时修改了 param.grad 的问题。
  • 修复了 Lighting 中的 scale 范围。
  • 修复 fast run 从 cache 中找算法时过滤规则缺失的问题。
  • 模型 dump 支持 backward opr。
  • 修改 TensorRT Runtime Opr 的是否有batch的判断依据,只根据输入来判断。
  • 修复由 module setattr 引起的打印 module 出错的问题。

新功能

通用组件

  • dnn opt assert 时增加输出关键 log 的功能。
  • 为了更好的支持后续功能,对 fastrun cache 结构做了重构。

周边工具

  • 添加命令行工具 mge 以便捷调用 tools 目录中的脚本,并支持 bash 补全。

参数量/计算量统计与可视化工具

  • 统计类型增加 norm 和 pooling。
  • 增加 统计 activations 功能 (比 flops 更能反应GPU性能)。
  • 增加递归更改 module status。
  • module_stats 的 input_size 参数修改为 input_shapes,表示可支持复数。
  • 对于 flops/parameters/activations 支持返回值。
  • 支持关掉打印信息便于自动化脚本集成。

发版流程

  • 构建系统从 make 迁移到 ninjia ,优化发版时间。

Python API

  • 重构随机数生成的代码,解决随机数生成速度慢的问题。
  • 添加 MegEngine.ConvTranspose3D。

改进

CUDA

  • 增加 CUDA conv_bwd_data 和 conv_bwd_filter 算法精度抖动测试。

Python API

  • 增加计算 loss 时的 reduction 选项。
  • trace 可以返回任意类型的输出。

周边工具

  • 对 qat and quantized module 增加__repr__ 方法。
  • 避免 load_graph 时不必要的 "span dist too large" 警告。
  • 提升统计工具的用户体验。

通用组件

  • 增加 CUDA API 调用的 cache。

Known Issue

  • 在开启DTR训练时,可能会出现申请显存失败的报错日志,这说明当前正在进行碎片整理,整理后程序可能可以继续运行。

MegEngine Release Notes

Highlights

Python API

  • The API of Dynamic Tensor Rematerialization is refactored and there is a minor bug fix to work around random operators.
  • Add gradient clip.
  • Add correlation operator.
  • Add sliding_window operator.
  • Refactor random operator and resolve the performance issue.
  • Add parameter/calculation statistics and visualization.

Bug Fixes

CUDA

  • Fix fusing Z error in convbias when use nchw4 layout in cuDNN8.0.4.
  • Fix potential linking issues caused by multiple libraries using different versions of cub.

Python API

  • Argmax and argmin accept negtive axis.
  • Error out if parameters attached to grad manager are not iterable of tensors.
  • Delete existing tensors before compnode finalizing to avoid non-zero exit code.
  • Fix overhead of query algorithm when execution strategy is set to PROFILE.
  • Error out if batch normalization is dumped in training mode.
  • Fix UAF in param pack.
  • Fix hanging when taking gradient to gather operator.
  • Fix bug in trace when memory is shared between tenors.

Distributed Training

  • Fix multi-thread race condition when the program exits.

Tools

  • Minor fixes to the dump_with_mge.py script
  • Fix CUDA pytest random hang.
  • Fix missed class_colors in VOC dataset.
  • Fix bug of VarNode inplace operations.

Documents

  • Fix  BN momentum description of API documentation.

General components

  • Fix fast run workspace limitation bug.
  • Fix comparison between enum and string types for elemwise mode.
  • Fix the problem that the optimizer modifies param.grad during step.
  • Fix the scale range of Lighting.
  • Fix the problem of incomplete filtering rules when fast run searches for algorithms from the cache.
  • Support dumping backward opr.
  • Modify TensorRT Runtime Opr to determine whether there is a batch dim, only set based on input dim.
  • Fix the problem of printing module error caused by module setattr.

New Features

General components

  • Add more critical log when assert occurs.
  • In order to better support future work, the fastrun cache structure has been refactored.

Tools

  • Add the command line tool mge to conveniently call the scripts in the tools directory, and support bash completion.

Parameter/calculation statistics and visualization

  • Statistics type adds support norm and pooling .
  • Add support activation statistics.
  • Change module status recursively.
  • The input_size parameter of module_stats is modified to input_shapes.
  • Support return value of flops/parameters/activations.
  • Support preventing information print to facilitate the integration of automated scripts.

Release workflow

  • Build system migration from make to ninjia.

Python API

  • Refactor random operator and resolve the performance issue.
  • Add MegEngine.ConvTranspose3D.

Improvements

CUDA

  • Add CUDA  conv_bwd_Data and conv_bwd_Filter algorithm accuracy shake check.

Python API

  • Add reduction choices to loss functions.
  • Make trace return any kind of output.

Tools

  • Add repr method for qat and quantized module.
  • Avoid unnecessary "span dist too large" warning in load_graph.
  • Improve statistical tools' user experience .

General components

  • Add CUDA API cache.

Known Issue

  • When DTR training is enabled, there may be some error logs showing that allocating memory has failed. This indicates that the program is currently in defragmentation phase and the program may continue to run after defragmentation.
MegEngine - MegEngine v1.4.0-rc1

Published by megvii-mge over 3 years ago

Highlights

  • 增加动态图下通过重计算优化显存使用的功能。增加 2 行代码,即可在相同显存情况下,训练 3 倍大的模型。
  • 尝鲜体验通道:
    pip3 install megengine==1.4.0rc1 -f https://megengine.org.cn/whl/mge.html

问题修复

通用组件

  • 修复设置 no-profiling-on-shape-change 之后,MatMul 依然搜参问题。
  • 修复 const tensor 缓存导致的越训越慢问题。

CUDA

  • 修复销毁 MegEngine cuda 和 cuDNN 的顺序问题。
  • 修复 CUTLASS GEMM 奔溃问题,增加了 block size 限制。
  • 修复 TensorRT runtime opr profiling 功能。

Python API

  • 修复 optimizer 的 state_dict 带来的副作用。
  • 修复 trace 中的 gopt level。

量化

  • 修复 Quantized.Concat 的 forward。
  • 修复 easy quant 中的 zero scale。

周边工具

  • 修复 TensorBoard 中的节点显示。
  • 修复 Module 扩展结构时的自动命名。
  • 修复 module stats 中对 group conv 的 FLOPs 计算。

新功能

通用组件

  • dnn 默认开启 log ,并打印 error 信息,并提供用户设置 log level 的接口。

ARM

  • arm上默认打开 dot 支持,并兼容在不支持 8.2 指令集的机器上运行。

CUDA

  • 增加 CUDA compnode 直接获取内存相关信息。

Python API

  • 增加动态图下通过重计算优化显存使用的功能。
  • 增加 AdamW 优化器。
  • 增加 varnode 的 array 方法。
  • warp_perspective 支持 mat_idx。

周边工具

  • 对 NetworkNode 增加 repr 方法。
  • 增加 opgraph 的 optimize-for-inference 接口。
  • 增加 module_stats 和 net_visualize 的总结输出。
  • 增加 NetWorkNode 对 receptive_field 的统计量。
  • 设置 network_visualize 的 log_path 为可选参数 。

改进

周边工具

  • 优化算子的自动命名规则。

其他说明

通用组件

  • 重构 CPU CompNode,使 default_cpu 不支持 record。
  • 使用 algo attitude 替换 algo reproducible 属性。

Python API

  • 移动 nvof 到 vision,同时兼容原有用法。

Highlights

  • Dynamic Tensor Rematerialization [Kirisame et al., 2021] is implemented in MegEngine. With two more lines of code, you can train a model twice larger given the same memory budget.
  • Welcome to try it out through :
    pip3 install megengine==1.4.0rc1 -f https://megengine.org.cn/whl/mge.html

Bug Fixes

General components

  • Fix MatMul opr tuning bug when setting no-profiling-on-shape-change.
  • Fix const tensor cache.

CUDA

  • Fix the destroying order of cudnn and cuda in MegEngine.
  • Fix the cutlass gemm crash by limiting the block size.
  • Fix TensorRT runtime opr profiling.

Python API

  • Fix bugs in optimizer's state_dict.
  • Fix gopt level in trace.

Quantization

  • Fix quantized concat forward.
  • Fix zero scale bug of easy quant.

Tools

  • Fix node display bug in tensorboard.
  • Fix auto naming bug when expanding structure.
  • Fix module stats calculate flops bug for group conv and remove model status change.

New Features

General components

  • DNN turns on log by default, prints error information, and provides an interface for users to set the log level.

ARM

  • dot is turned on by default on ARM, and it is compatible to run on machines that do not support the 8.2 instruction set.

CUDA

  • Enable CUDA compnode directly obtain memory related information.

Python API

  • Add dynamic tensor rematerialization.
  • Add AdamW optimzer.
  • Add array method for varnode.
  • Support F.warp_perspective with mat_idx.

Tools

  • Add repr for NetworkNode.
  • Add optimize-for-inference interface for opgraph.
  • Add summary print for module_stats and network_visualize.
  • Add support of receptive_field stats for NetworkNode.
  • Set network_visualize's log_path as an optional flag.

Improvements

Tools

  • Optimize the op's auto naming rules.

Others

Tools

  • Refactored CPU compnode so that default_cpu does not support record.
  • Replace algo reproducible attribute with algo attributes.

Python API

  • Move nvof to vision, compatible with old usage.
MegEngine - MegEngine v1.3.1

Published by megvii-mge over 3 years ago

兼容性破坏

问题修复

通用组件

  • 修复使用trace时,broadcast op在输入输出shape一致情况下报错的问题
  • 修复异步队列导致多卡crash的问题
  • 修复当module中包含list等container时自动命名出错的问题
  • 修复module state_dict在keep_var时被修改内部state值的问题
  • 修复Strategy枚举中OPTIMIZED的拼写错误

周边工具

  • 修复可视化工具节点显示的问题
  • 修复统计工具计算flops问题
  • 修复统计工具内部修改module状态的问题

量化

  • 修复量化concat module forward出错的问题
     

新功能

周边工具

  • 可视化工具增加log_path作为可选项
  • 可视化和统计工具增加summary输出
  • 统计工具增加感受野支持

Compatibility violation

  • No

Bug Fixes

General components

  • Fix the problem of broadcast op reporting an error when the input and output shapes are the same when using trace
  • Fix the crash of distributing training caused by asynchronous queue
  • Fix the problem of automatic naming errors when the module contains containers such as a list
  • Fix the problem that the internal state value of module state_dict is modified with the keep_var setting
  • Fix the spelling error of OPTIMIZED in Strategy enumeration

Tools

  • Fix the problem of network visualization tool node display
  • Fix the problem of statistics tools calculating flops
  • Fix the problem of modifying the module status in the module_stats tools

Quantization

  • Fix the problem of the quantized concat module forward
     

New Features

Tools

  • Network visualization tool add log_path as an option
  • Network visualization tool and the module_stats add a summary print
  • Statistics tool add support receptive field
MegEngine - MegEngine v1.3.0

Published by megvii-mge over 3 years ago

兼容性破坏

  • 由于 C++ 序列化增加了 opname 字段,导致老版本不能加载新版本序列化文件。
  • 废弃 set/get_conv_execution_strategy ,请使用新接口 set/get_execution_strategy 。

其他说明

  • funtional.nn 模块中 interpolate/roi_pooling/roi_align/nms/remap/warp_affine/warp_perspective/cvt_color 移动到 funtional.vision 模块。
  • functional.elemwsie 模块中 sigmoid/hsigmoid/relu/relu6/hswish 移动到 funtional.nn 模块。
  • functional.utils 模块中 topk_accuracy 被移动到 funtional.metric 模块。
  • functional.utils 模块中 copy 被移动到 funtional.tensor 模块。

问题修复

通用组件

  • 修复 reshape 推导 shape 错误导致 trace 报错的问题。
  • 修复 trace 内存泄漏的问题。
  • 修复 linspace 造成 trace 报错的问题。
  • 修复 scalar 参数经过求导后变成 1 维 tensor 的问题。
  • 修复图优化中 NCHW 转 NCHW4 出错的问题。
  • 修复异步执行下发任务过快导致内存泄漏问题。
  • 修复 pyobject 引用计数问题引起的段错误。
  • 修复 roialign 越界访存的问题。
  • 修复 CompNode reuse 某些情况下 load 错误。
  • 修复 NormalizeArithChainPass 和 WarpFusion 的图优化错误。
  • 修复 linspace 中 device 参数。

Python API

  • 修复 F.full/F.ones/F.zeros 输入 shape 是 scalar 类型的 tensor 会报错的问题。

量化

  • 修复量化类型在某些 case 下判等会报错的问题。
  • 修复量化训练 checkpoint 加载出错的问题。
  • 修复 TQT 量化训练参数不更新的问题。
  • 修复 TQT 量化训练反向求导计算的问题。
  • 修复量化训练未转换自定义量化 Module 的问题。

其他 

  • 修复 set_mgb_log_level 不生效的问题。
  • 修复 batch normalization 中的 freeze 参数的问题。

新功能

通用组件

  • 支持小 tensor 在 host 上的计算以减少 host-device 同步。
  • fastrun 添加 fast profile 模式。
  • fast-run 支持递归搜索。
  • Matmul Opr 支持 fast-run 搜参。
  • load_and_run 增加 disable-optimize-for-inference 参数。
  • 增加 trace 时根据 module 结构自动命名 op name 的功能。
  • Reshape 增加静态 shape 推导。

Python API

  • 增加 TensorRT/Atalas/Cambricon (三方硬件)、cvt_color、matinv、resize、warp_affine、deformable_conv2d、deformable_psroi_pooling、repeat、tile 等新算子。
  • 增加给 tensor 命名的功能。

分布式训练

  • 增加分布式通信算子对 scalar 的支持。

周边工具

  • 在 cgtools 中增加 GraphInference 并支持指定输出节点。
  • 增加基于 .mge 文件的可视化、统计参数量计算量的工具。
  • 增加 python 版 load_and_run 工具。

Dataloader

  • stream dataloader 支持设置 timeout 以及设置 timeout 后的回调函数。

ARM 

  • 自动检测 ARM 平台特征并开启相应优化。
  • 添加 ARM64 CUDA 推理支持。

改进

通用组件

  • 被 trace 的函数增加支持返回dict的功能。
  • Python API
  • module 支持用复杂 key 来做 getattr。
  • module repr 支持 list/dict。

分布式训练

  • 分布式训练增加返回值功能。

量化

  • 调整了假量化 bias 的策略,只有在 weight 和 activation 都被量化时才对 bias 做假量化。
  • 优化量化数据类型结构使量化框架支持第三方量化数据类型。

ARM

  • 增加了 Matmul 的分块实现,优化某些 shape 下的性能。

Thanks to our Contributors

本次 release 非常感谢 @jia-kai 提交 PR ,期待更多的开发者一起共建 MegEngine!

Compatibility violation

  • Since C++ serialization adds new opname filed, C++ serialization file dumped by this version can not be loaded by earlier releases.
  • set/get_conv_execution_strategy is deprecated and set/get_execution_strategy is suggested to use.

Additional Note

  • Some functionals are moved to new modules for better orgnization. Backward compatibility is also gurrettened so the change is not expected to affact original usage. The moved functionals include:interpolate/roi_pooling/roi_align/nms/remap/warp_affine/warp_perspective/cvt_color are moved from funtional.nn to funtional.vision.
  • sigmoid/hsigmoid/relu/relu6/hswish are moved from functional.elemwsie to funtional.nn.
  • topk_accuracy is moved from functional.utils to funtional.metric copy is moved from functional.utils to funtional.tensor.
  • copy is moved from functional.utils to funtional.tensor.

Bug Fixes

General components

  • Fix shape inference in reshape which may lead to error in trace.
  • Fix the problem of trace memory leak.
  • Fix trace error caused by linspace.
  • Fix the bug in automatic differentiation which turns a scalar into an 1-dim tensor.
  • Fix NCHW-to-NCHW4 layout transform in gopt.
  • Fix memory leak when python frontend runs much faster without synchronization to the device.
  • Fix segfault caused by pyobject reference counting error.
  • Fix the illegal memory access in ROIAlign operator.
  • Fix CompNode reuse load error in some cases.
  • Fix the graph optimization error of NormalizeArithChainPass and WarpFusion.
  • Fix the device parameter in linspace.

Python API

  • Fix scalar as the input shape of F.full/F.ones/F.zeros.

Quantization

  • Fix comparision error of quantized data type.
  • Fix checkpoint loading error in quantized training.
  • Fix parameters which cannot be updated in TQT.
  • Fix gradient calculation in TQT.
  • FIx bug in user-defined TQT module.

Others

  • Fix set_mgb_log_level malfunction.
  • Fix freeze parameter in batch normalization.

New Features

General components

  • Support host computation for small tensors to reduce synchronization between host and device.
  • Add fast profile mode for fastrun.
  • Support recursive search in fastrun.
  • Add matmul support in fastrun.
  • Add disable-optimize-for-inference parameter to load_and_run.
  • Add automatic naming of op's based on module structure.
  • Add static shape inference for reshape operator.

Python API

  • Add new operators: TensorRT/Atalas/Cambricon(third party hardwares), cvt_color, matinv, resize, warp_affine, deformable_conv2d, deformable_psroi_pooling、repeat、tile.
  • Enable tensor naming.

Distributed training

  • Support scalar tensors for distributed operators.

Tools

  • Add GraphInference in cgtools and support specifying output nodes.
  • Support model visualization and parameter statistics from .mge files.
  • Add python load_and_run.

Dataloader

  • Support setting timeout and callback function after timeout in stream dataloader.

ARM

  • Automatically detect ARM platform calculation characteristics and enable corresponding optimization.
  • Support inference on ARM64 with CUDA.

Improvements

General components

  • Support dict as returned value for traced function.

Python API

  • Add get/set_expand_structure to deal with complex key.
  • Support list and dict in module repr methods.

Distributed training

  • Add return values for distributed training.

Quantization

  • Adjust fake quantization method such that bias is quantized only both weight and activation are quantized.
  • Support user-defined quantized data type in quantized training.

ARM

  • Add more tiled kernels of Matmul to improve performance.

Thanks to our Contributors

A kind acknowledgement to PR lodged by @jia-kai , and we are genuinely welcoming more developers to co-build MegEngine!

MegEngine - MegEngine v1.2.0

Published by megvii-mge almost 4 years ago

问题修复

  • 修复asan报错的问题
  • 修复寒武纪跨计算节点拷贝的问题
  • 修复profile导致的显存爆炸
  • 修复寒武纪环境下显存未能正确回收
  • 修复由于CUDA环境变量没有正确设置而导致分布式训练卡0显存爆炸的问题
  • 修复tensor split
  • 修复 ARM testcase 内存占用过多的问题
  • 修复 Fastrun 占用显存过多的问题
  • 修复 Atlas dump 模型指定的 batch size 大于模型最大 batch size 的问题
  • 修复 MLIR 不能正确处理不同的 shape 的问题
  • 修复 MLIR 执行 CUDA 时出现 Dangling Pointer 的问题
  • 修复 Weight 前处理时没有考虑无 bias 的 ConvBias 的问题
  • 修复打印错误堆栈过程中再次crash导致 log 混乱的问题

新功能

  • python退出时做full sync
  • MegEngine中添加subpackages
  • pooling window size 小于 padding size 时输出警告信息
  • 添加 Atlas Stub, 支持在 X86 平台上 dump Atlas 模型
  • 为 JITExecutor opr 添加 memory forwarding 功能
  • 为 load_and_run 添加将结果输出到 stdout/stderr 的功能
  • 增加EasyQuant量化方法
  • 支持Tensor换入/换出重计算功能
  • Optimizer支持inplace add_update

性能优化

  • 添加常见 Video Detection 网络前处理融合优化
  • 添加 DimShuffle, Reformat 与 ConvBias 的融合优化
  • 添加 WarpPerspective 和 DimShuffle 的融合优化
  • 将tensor,求导以及trace从python实现改到cpp实现,提高了性能
  • 修改部分opr的求导规则以节省显存
  • 优化QAT和TQT量化训练性能和显存
  • 调整 CUDA chanwise Convolution 算法选择策略
  • 优化 NCHW32 的 pooling 算子性能
  • 优化 CallbackCaller 算子的性能
  • 优化 CUDA IO 通信

兼容性破坏

Bug Fixes

  • Fix errors reported by ASAN
  • Fix the problem of cross compute node copy in Cambricon
  • Fix out of memory error caused by profiling
  • Fix memory leak in the Cambrian
  • Fix out of memory error during distributed training due to the incorrect setting of CUDA environment variables
  • Fix tensor split
  • Reduce the memory usage of ARM testcase
  • Reduce the memory usage of Fastrun
  • Fix the issue that the batch size specified when dumping the Atlas model exceeds the maximum batch size of the model
  • Fix the problem that MLIR cannot handle different shapes correctly
  • Fix the problem of Dangling Pointer when MLIR executes CUDA
  • Fix the weight pre-processing to handle ConvBias without bias correctly
  • Fix the broken log caused by crash again in the process of printing error stack

New Features

  • Full sync when exits in Python
  • Add sub-packages to MegEngine
  • Print warning message when pooling window size is smaller than padding size
  • Add Atlas Stub, enabling R dump Atlas model on X86 platform
  • Add memory forwarding to JITExecutor operator
  • Make load_and_run print the result to stdout/stderr not just files
  • Add EasyQuant quantification method
  • Support tensor swap-in/swap-out recalculation
  • Optimizer supports inplace add_update

Optimization

  • Optimize common Video Detection network by pre-processing fusion
  • Optimize performance by fusing DimShuffle and Reformat with Convolution
  • Fuse WarpPerspective with DimShuffle
  • Improve performance by rewriting tensor, derivation and trace in cpp
  • Refactor some opr derivation rules to save memory usage
  • Optimize QAT and TQT quantitative training in terms of both performance and  memory usage
  • Adjust the CUDA chanwise Convolution algorithm selection strategy
  • Optimize the performance of NCHW32 pooling operator
  • Optimize the performance of CallbackCaller operator
  • Optimize CUDA IO communication

Compatibility violation

  • No
MegEngine - MegEngine v1.1.0

Published by megvii-mge almost 4 years ago

问题修复

  • 修复 trace 中的静态推导
  • 修复 trace 中io和opr的执行顺序避免死锁
  • 修复cd4在convolution中group=1时候转换错误以及elemwise转换错误
  • 修复fuse conv bias optpass中bias shape固定时,inference时shape匹配不上问题
  • 修复 mkl elemwise计算 LOG是异常
  • 修复load_and_run --input对于单输入未指定正确输入名字时的错误处理

新功能

  • 支持 scalar 类型的 Tensor
  • 使用async_level来控制异步执行中错误检查
  • 增加 group_norm、 instance_norm、layer_norm、conv1d、remap等算子
  • GradManger.attach 对 Tensor 使用 weak reference
  • 支持分布式量化训练
  • 支持inference weight-preprocess 释放原来weight的内存
  • jit mlir后端全面支持Elemwise, DimShuffle
  • 增加cv DCT 算子支持

性能优化

  • 减少了 batch normalization、elementwise、broadcast等算子在host CPU上的耗时
  • 优化了 optimizer 的 step() 性能
  • 优化量化训练性能
  • 优化arm64 int8X8X16_mk4_k8x8x8 matmul 算子

兼容性破坏

Bug Fixes

  • Fixed static shape inference in trace to allow training larger models
  • Link io-opr in trace to avoid deadlock
  • Fixed cd4 conversion error when group=1 in convolution and some cases in elemwise
  • Fixed the problem of shape matching when the bias shape is fixed in fuse conv bias optpass
  • Fixed LOG mode of elemwise in MKL calculation abnormal
  • Fix the error processing when load_and_run --input does not specify the correct input name for a single input

New Features

  • Support representation of scalar-type tensor
  • Enable users to control error check during asynchronous execution by parameter async_level
  • Add operators including group_norm, instance_norm and layer_norm, conv1d and remap
  • Use weakref for GradManger.attach
  • Support distributed quantize aware training
  • After weight preprocessing, release the original weight memory during inference
  • Support Elemwise and DimShuffle operators in JIT of mlir backend
  • Support DCT operator in cv

Optimization

  • Reduce host overhead for operators including batch normalization, elementwise, and broadcast
  • Improve performance of the step function in optimizers
  • Improve performance of quantization training
  • Optimize arm64 int8X8X16_mk4_k8x8x8 matmul operator

Compatibility violation

  • No
MegEngine - MegEngine v1.0.0

Published by megvii-mge about 4 years ago

新功能

  • IndexingMultiAxisVec添加bool类型支持
  • 添加windows和macOS打包功能
  • 添加adaptive pooling算子
  • mlir jit添加llvm-lit支持
  • 添加weights preprocess开关控制是否在inference阶段缓存weights 预处理后的结果提升性能
  • 添加MGB_USE_ATLAS_ASYNC_API宏控制开启异步API调用
  • 按用户使用习惯 更新 dtype promotion的规则
  • 在broadcast增加参数检查
  • device的__repr__方法增加物理单元信息

问题修复

  • 修复cpuinfo在arm linux下的编译warning
  • 修复Imperative Runtime在出错情况下由于没有正确set exception导致卡住的问题
  • 修复dump_with_testcase脚本在打开--output-strip-info选项时如果文件不存在会crash的问题
  • 修复NCHW->NCHW4的pass对float类型的处理
  • 在float转io16c32的pass中添加对deconv的处理
  • 由于xcode的问题,在ios下关闭thread_local的支持
  • 修复多机训练中,ParamPackSplit出现的refcnt计数问题
  • 修复多线程下多个模型使用同一个compnode且开启record功能导致出错的问题
  • 修复NCHW→NCHWxx的pass在处理conv_bias 且bias为空情况下的问题
  • 修复jit.trace发生错误后使得后续trace完全不可用的问题
  • 修复bool.sum()
  • 修复graph binding 错误处理导致graph被错误回收的问题
  • 修复jit.trace 对topk/warp/nms等op的处理
  • 修复LocalConv2d算子对group的支持
  • 修复 dump 中使用 optimize_for_inference 时的bug
  • 修复NMSKeep、topk 、warp_perspective 被 trace 时的 bug

兼容性破坏

  • 调整部分Function API的命名、参数或 import 路径,删除重复API

New Features

  • Add bool dtype support for IndexingMultiAxisVec
  • Add windows and macOS packaging capabilities
  • Add adaptive pooling opr
  • Add llvm-lit support for jit mlir
  • Add the weights preprocess option to control whether the results of weights preprocessing are cached in the inference phase to improve performance
  • Add macro MGB_USE_ATLAS_ASYNC_API to control whether enables asynchronous API calls
  • Update dtype promotion rule
  • Add parameter check in tensor broadcast method
  • Update device repr method to show physical placement

Bug Fixes

  • Fix cpuinfo compiling warning under arm Linux
  • Fix the stuck problem due to incorrect set exception in case of error
  • Fix crash when enabling --output-strip-info in dump_with_testcase if the file does not exist
  • Fix nchw → nchw4 pass when handling float type
  • Handle deconv opr in the pass from float to io16c32
  • remove thread_local support in ios due to Xcode problem
  • Fix refcnt counting problem in ParamPackSplit during multi-machine training
  • Fix the crash problem that multiple models use the same compnode and enable record function under multithreading
  • Fix nchw → nchwxx pass in processing conv_bias opr in the case of bias being empty
  • Fix jit.trace when an error occurs that may make subsequent trace completely unavailable
  • Fix bool.sum()
  • Fix graph binding error handling that caused the graph to be malcollected
  • Fix topk/warp/nms op when using jit.trace
  • Fix group support for local conv2d operator
  • Fix bug of optimize_for_inference in dump
  • Fix bugs of NMSKeep, topk, warp_perspetive during trace

Compatibility violation

  • Adjust names, paramters or import path of some functional API; delete dumplicated API
MegEngine - MegEngine v1.0.0-rc1

Published by megvii-mge about 4 years ago

Highlights

  • 全新的 Imperative Runtime,通过重写动态执行引擎,将过去几个版本中动态图的限制打破,解决了一系列资源释放问题,并大幅提升了动态自由度,让使用 GPU 计算就像 NumPy 一样方便自如;在提高自由度的同时,配合更强的动静转换功能,让增强能力的动态训练代码仍然可以静态化训练,方便高效;提供了更强的 trace 能力,每次仍然运行 python 代码,让 trace 的启用更加顺畅透明;实现了更可靠的 dump 功能,提供验证功能,确保没有多余的分支逻辑被误记录到序列化格式中,让用户可以低成本的兼得动态训练与静态推理的好处。
    midout 代码裁剪功能,让用户可以全自动的针对自己网络使用的算子进行代码裁剪,免除手工配置就能最小化推理时的代码体积,极大的提升端侧推理效率。
  • 一系列推理性能和功能优化。具体的推理优化包括代码编译速度优化、Winograd 算法优化提速、A7 / A55 / A53 等 ARM小核心GEMM的性能优化、NCHW44 下 8x8x16 channel-wise Conv和8x8x16 direct Conv 的性能优化、NCHW44 下 First Conv 的性能优化、修正了 Atlas H2D 拷贝时的问题、恢复对 CUDA9 的支持、添加了NCHW44下Winograd F(7,3) 实现、添加 cpuinfo 进行 CPU 架构的判断,让用户无需提前指定CPU架构、对框架代码进行了更细粒度的裁剪设计,配合midout功能,可以大幅度降低 binary size、Cmake 重构优化、修复了 shuffleShuffleRemovePass 在特定输入时的 segfault 问题。
  • 更多国产硬件支持:支持主流国产芯片和ROCm的接入,方便在国产 NPU 芯片上进行推理工作。
  • MLIR 的接入:接入了 MLIR 做为静态图 JIT fusing 引擎,对于连续的访存算子进行融合加速;利用 MLIR 做为工具,提高框架代码的可维护性。
  • 全新设计的 API,更加 Pythonic,控制更加清晰可靠。
  • 对 Windows / Mac 提供了原生支持,同时发布Linux / Windows / Mac 的 PYPI 安装包。
  • 尝鲜体验通道
    pip3 install megengine==1.0.0rc1 -f https://megengine.org.cn/whl/mge.html -i https://pypi.douban.com/simple/

Improvements

  • 通过添加cuda pinned memory内存池减少cudaHostAlloc调用次数降低host端的开销提升性能。
  • 进一步优化A7/A53/A55等小核上int8和int8x8x16的性能。
  • 添加Winograd F(7,3),在一些网络有10%-30%性能提升(目前由于精度问题默认关闭)。
  • 优化单stream下cuda device 内存分配器性能。

Bug Fixes

  • 修复megengine 交叉编译。
  • 修复conv NCHW88在fastrun搜索winograd算法未正确设置format导致的问题。
  • 修复部分arm kernel内存越界问题。
  • 修复cpuinfo在uclibc下的编译问题。
  • 修复部分后端对于一些特殊的shape未优化导致选到naive算法的问题(通过optpass中将nchwxx → dimshuffle + nchw)。
  • 修复寒武纪编译问题。
  • 修复由于x86 im2col算法不支持非对称量化导致模型无法dump的问题。
  • 修复fastrun写cache时由于snprintf使用不对导致崩溃的问题。
  • 修复某些testcase在某些平台(EV300)爆栈导致无法执行的问题。
  • 修复相同group组相同名字的多机opr频繁注册导致的冲突。
MegEngine - MegEngine v0.6.0

Published by megvii-mge about 4 years ago

新功能

  • NHWC的warpperspective添加matidx支持。
  • 添加CUDA版本的remap算子支持。
  • 支持编译ios whl包。
  • megengine模型支持TensorCore加速。
  • Parameter 中增加 replica_mode来指定是否需要同步。
  • collective_comm算子添加local_grad参数。

性能优化

  • 持续优化CPU下NCHW44性能,在业务线模型有5%-30%性能提升。
  • 添加更多midout支持,进一步减少binary size体积。

问题修复

  • 修复使用vs2015 编译后megbrain执行速度慢的问题。
  • 修复CPU端偶尔出现free < total的内存分配问题。
  • 修复arm linux下GCC编译器无法inline小函数导致的性能问题。
  • 修复cuda warpperspective算子在batch * img_size 超过INT_MAX时的计算错误。
  • 修复cuda elemwise 在int8 broadcast情况下的计算错误,不影响NCHW4模型。
  • 修复psroi_pooling 算子的indexing计算逻辑。
  • 修复若干个JIT求导时的错误。
  • 修复GCC7下编译问题。
  • 修复部分NCHW→NCHWxx的转换器问题。
  • 修复reduce和gather的求导问题。
  • 修复fbs模型格式下无法正确加载含有多个graph的情况(不影响内部mdl模型格式)。
  • 修复warpperspective在开midout时可能存在的undefined reference问题。
  • 修复开exception引入的敏感词问题。
  • 修复标注中由于categories乱序导致生成的contiguous id错误。
  • 修复了当一个进程中存在多个 dataloader 实例时,MGE_PLASMA_STORE_MANAGER销毁行为不正确的问题。
  • 修复无法加载量化int8 pkl模型的问题。
  • 修复nn.flatten的API 说明。@ChaiMind

Thanks to our Contributors

  • 本次release非常感谢@ChaiMind 提交PR,期待更多的开发者一起共建MegEngine!

New Features

  • Add matidx support to warp perspective operator of NHWC.
  • Add remap operator support for CUDA.
  • Support compile whl package of IOS.
  • MegEngine quantized model supports tensorcore acceleration.
  • Add replica_mode to Parameter to specify whether synchronization is required.
  • Add local_grad parameter to collective_ comm operators.

Optimization

  • Continue to optimize the performance of NCHW44 under CPU, and improve the performance of online model by 5% - 30%.
  • Add more midout support to further reduce the size of binary.

Bug Fixes

  • Fixed slow execution of megbrain compiled with vs2015.
  • Fix the memory allocation problem of free < total on CPU side occasionally.
  • Fix the performance problem caused by GCC compiler unable to inline small functions in arm Linux.
  • Fix CUDA warp perspective operator in batch * img_ size exceeds INT_MAX.
  • Fix CUDA elemwise's calculation error in int8 broadcast without affecting current CUDA nchw4 model.
  • Fix psroi_ Indexing computational logic of pooling operators.
  • Fixed several JIT grad errors.
  • Fix compilation problem under gcc7.
  • Fix some converter bugs of NCHW → NCHW4.
  • Fix the derivation problem of reduce and gather.
  • Fix the situation that FBS model format cannot load multiple graphs correctly (It does not affect the internal MDL model format).
  • Fix possible undefined reference issue with warp perspective operator when using midout.
  • Fix sensitive words introduced by exception.
  • Fix the generated contiguous id error due to the disorder of categories in the annotation.
  • Fix incorrect destruction behavior of MGE_PLASMA_STORE_MANAGER when multiple instances of dataloader exist in a process.
  • Fix the problem of loading quantified int8 pkl model.
  • fix the msgstr for nn.flatten.@ChaiMind

Thanks to our Contributors

  • A kind acknowledgement to PR lodged by @ChaiMind , and we are genuinely welcoming more developers to co-build MegEngine!
MegEngine - MegEngine v0.5.1

Published by megvii-mge over 4 years ago

New Features

  • 在有tensorcore的pass前添加nchw->nchw4的pass
  • NCHW→NCHW4转换pass增加对Pooling/WarpPerspective/Resize等op的支持
  • 增加加载pretrained的int8模型,再dump的支持

Bug Fix

  • 修复当一个进程中存在多个 dataloader 实例时,MGE_PLASMA_STORE_MANAGER销毁行为不正确的问题
  • 让FakeQuantize和Observer能够针对weight和activation使用不同的qmin,避免极端情况下出现数值溢出
  • 修复mgb.opr.deformable_psroi_pooling 实现错误
  • 修复cuda int8 nchw4支持channel小于4的问题
  • 修复网络搭建文档中的拼写错误 @ztjryg4

Thanks to our Contributors

  • 本次release非常感谢@ztjryg4 提交PR,期待更多的开发者一起共建MegEngine!

New Features

  • Insert nchw->nchw4 pass before tensorcore pass.
  • NCHW→NCHW4 pass supports ops such as Pooling/WarpPerspective/Resize.
  • Pretrained int8 models can now firstly be loaded and then be dumped.

Bug Fix

  • Fix MGE_PLASMA_STORE_MANAGER was destroyed incorrectly when there were multiple dataloader instances in a process.
  • Allow FakeQuantize and Observer to use different qmin in terms of different weights and activation to avoid numerical overflow in extreme cases
  • fix implementation mistakes in mgb.opr.deformable_psroi_pooling
  • Fix cuda int8 nchw4 support channel less than 4
  • Fix typo in network_build @ztjryg4

Thanks to our Contributors

  • A kind acknowledgement to PR lodged by @ztjryg4 , and we are genuinely welcoming more developers to co-build MegEngine!
MegEngine - MegEngine v0.5.0

Published by megvii-mge over 4 years ago

New Features

  • 增加cuda对nchw quantized数据的计算支持。
  • conv1x1中添加对gemv的支持。
  • CPU(X86,ARM)上增加NCHW4 layout 计算方式的支持。
  • 针对Armv8.2-a+dotprod指令集增加 nchw44-dot layout的优化支持。
  • 增加nchw44来优化float的计算,包括直接卷积,channel wise卷积,混合layout的卷积,winograd,mk4-matmul,以及pooling和elemwise等algo的优化。
  • 整理图优化,将一些通用转换能同时支持runtime和dump阶段。
  • 增加 Calibration 量化训练接口。
  • QAT量化训练优化:ConvBn 添加支持BN和fake quantization/observer的复合操作、添加Conv的量化操作、添加Linear的量化操作、quantize_qat支持自定义跳过Module。
  • 多卡训练增加同步 BN 统计量的支持。
  • 多卡训练在图优化中增加 PackAllReducePass,打包需要AllReduce的参数,减少卡间通信次数。
  • API的一些优化调整:F.eye原本放在functional/nn.py里,现在挪到了core/tensor_factory.py里;F.add_axis和F.remove_axis里强行限制只能传入int的axis,而不再允许传入list。

Bug Fix

  • 在FuseConvBiasWithZ的pass里添加HSwish激活函数的支持,将QFUSE_ADD_H_SWISH折叠进conv bias算子,提升性能。
  • 修复cuda-TopK算法在batch超过65535时会导致grid的y维超出限制,而报出invalid parameter的cuda错误。
  • 解除 cuda-stub 中对 libcuda.so 的路径限制。
  • 修复conv1x1错误使用了基类的is_prefered方法导致的性能问题。
  • ConvDirectUnrollBuffer算法中,在load src时取出的数据会变成0,加入printf语句或者去掉循环的unroll优化可以避免这个问题。
  • 修复paramfuse在处理midconst时,endpoint导致endpoint被replace两次的问题。
  • 修复自8.3.0(包括)gopt中的ReorderArithChainPass BUG fix reorder arith chain pass。
  • 修复cond op不支持空shape的问题。
  • 修复SetMeshIndexing使用多个axis做indexing时的问题。
  • 修复CompNode中assert locator.device < sd.MAX_NR_DEVICE 的书写错误 @zjd1988 。
  • 修复voc和objects365的书写错误。
  • 修复voc中错误的类名。
  • 修复Tensor 的default_comp_graph 使用 。
  • 修复Function中saved_tensors在静态图下无法copy而导致图优化失败的问题 。
  • 修复 scatter 的API文档,避免在GPU上报错。
  • 修复unused var ins的问题。
  • 修复Module中字段的非str键错误。
  • 修复QAT训练完的模型在eval模式下依然会更新scale和zero_point 的问题。
  • 在所有mali系列机器上都关闭 image算法。

Thanks to our Contributors

  • 本次release非常感谢@zjd1988 提交PR,期待更多的开发者一起共建MegEngine!

New Features

  • Enable cuda algos for nchw quantized.
  • Update conv1x1 to support gemv.
  • NCHW4 layout is now supported on CPU(X86,ARM).
  • Optimized nchw44-dot layout is available in Armv8.2-a+dotprod instruction set.
  • nchw44 is incorporated to optimize float-typed calculation, including but not limited to direct convolution, channel wise convolution, hybrid layout convolution, winograd, mk4-matmul, along with algorithm optimization of pooling and elemwise.
  • Graph optimization. Generalized conversion is supported both in runtime and dump phase.
  • Synchronized BN statistics are now available on multi-device training tasks.
  • PackAllReducePass is introduced into graph optimization on multi-device training.
  • Calibration quantization training interface is now available.
  • QAT quantization training updates: ConvBn is now able to conduct composed operation of BN and fake quantization/observer; enable quantization on Conv and Linear; quantize_qat is now allowed to skip Module on your needs
  • API adjustments: F.eye is moved to core/tensor_factory.py from the previous location functional/nn.py. F.add_axis and F.remove_axis are now restricted to accept axis of int type only, which disables axis of list type.

Bug Fix

  • HSwish activation function is enabled in pass of FuseConvBiasWithZ, and QFUSE_ADD_H_SWISH is wrapped into conv bias operator to enhance performance.
  • Fix cuda error‘invalid parameter’raised from cuda-TopK when batch exceeds 65535 which violates the y dimension limit of grid.
  • Drop path restriction of libcuda.so in cuda-stub.
  • Fix impacted performance for conv1x1 mistakenly adopts is_prefered from its base class.
  • Insert printf statements or removing looped unroll optimization to avoid the issue that data fetched through load src in ConvDirectUnrollBuffer are unexpectedly casted to 0.
  • Fix issue that endpoint would be replaced twice when paramfuse was processing midconst.
  • Fix ReorderArithChainPass in gopt raised since 8.3.0 (inclusive).
  • Fix empty shape not recognized by cond op.
  • Fix SetMeshIndexing uses multiple axes for indexing.
  • Fix typo assert locator.device < sd.MAX_NR_DEVICE in CompNode @zjd1988 .
  • Fix typo in voc and objects365.
  • Fix incorrect class name in voc.
  • Fix default_comp_graph of Tensor.
  • Fix graph optimization failure on occasion that saved_tensors in Function is unable to copy in a static graph.
  • Fix API documentation of scatter to circumvent exception on GPU environment.
  • Fix issues of unused var ins.
  • Fix none-str key exception in Module fields.
  • Fix unexpected eval-mode scale and zero_point updates in models trained by QAT.
  • Disable image algorithm on all of mali-series machines.

Thanks to our Contributors

  • A kind acknowledgement to PR lodged by @zjd1988 , and we are genuinely welcoming more developers to co-build MegEngine!
MegEngine - MegEngine v0.4.0

Published by megvii-mge over 4 years ago

New Features

  • 支持 ARM 交叉编译
  • 添加多线程 CompNode
  • 支持 从 CPU 到 CUDA设备的 DeviceTensorND copy
  • 动态图 profilng 功能
  • 暴露 sublinear 参数 API
  • 新增 objects365 数据集
  • voc 数据集支持 detection
  • 添加 arange, conv_transpose2d, isnan, isinf, normalize 算子
  • axis 参数支持负值
  • 均匀采样支持上界下届
  • LeakyReLU 支持 negative slope 参数
  • 支持根据用户定义 key 进行参数打包
  • 增加量化训练接口
  • ARM添加NCHW44的layout,并优化对应算子性能, 性能相比NCHW有加速

Bug Fix

  • 修复 im2col 线程安全问题
  • 修复 gcc5 -O0 编译错误
  • create_mm_server 失败时返回 -1
  • 修复 reduce mean 的求导函数
  • 修复 F.clamp 的边界问题
  • 修复 coco 数据集中的 NaN 问题
  • 修复 batch_norm2d, linspace 的文档问题
  • 释放老参数的显存
  • F.where 支持 x 或 y 参数是空值的情况
  • one_hot 移除 num_classes 参数默认值
  • 修复voc中错误的类名
  • 修复batchnorm docstring的momentum更新公式

致谢开源社区贡献者

截至目前,也收到了很多的宝贵的反馈和建议,感谢: clhne、cydiachen、daa233、DaHaiHuha、junjie18、KaiyuYue、mgno32、xiaoguai0992。部分反馈和建议在本次发版中解决,其余的反馈和建议将陆续在接下来的发版中解决
衷心感谢每一个提问的开发者

New Features

  • Add cmake cross build ci
  • Add inference cross build support
  • Add compnode multithread in python
  • Support copy DeviceTensorND from cpu to cuda
  • Add profiler for dynamic graph
  • Expose sublinear related parameters at mge api level
  • Add objects365 dataset
  • Voc dataset supports detection
  • Add arange, conv_transpose2d, isnan, isinf, normalize opr
  • Support negative axis in math.py
  • Add lower bound and higher bound for uniform sampling
  • Add negative slope attribute for LeakyReLU module
  • Add user-defined key to pack params
  • Add quantization interface
  • Support NCHW44 layout for ARM

Bug Fix

  • Fix cublas matmul on sm60
  • Fix im2col thread safe problem
  • Fix gcc5 -O0 compiler error
  • Return -1 when create_mm_server failed
  • Fix grad function of reduce mean
  • Fix F.clamp
  • Fix an nan bug in coco dataset
  • Fix batch_norm2d, linspace doc
  • Add the more warnings in load_state_dict
  • Release old parameters
  • F.where support x or y is empty
  • Fix one_hot: no default value for num_classes
  • Fix wrong class name in voc
  • Fix momentum equation in batch norm doc

Thanks to our Contributors

many feedbacks from developers : clhne、cydiachen、daa233、DaHaiHuha、junjie18、KaiyuYue、mgno32、xiaoguai0992
We would also like to thank everyone who reported questions

MegEngine - MegEngine v0.3.4

Published by megvii-mge over 4 years ago

Enhancement

  • 公开发布sublinear API,并增加使用示例

Bug Fix

  • 修复多卡无法使用问题

Enhancement

  • expose sublinear related parameters at mge api level
  • add example to use modified sublinear API

Bug Fix

  • fix multi-machine macro and add test_distributed
MegEngine - MegEngine v0.3.2

Published by megvii-mge over 4 years ago

Enhancement

  • 使用 MegEngine 的随机分布生成函数替换 numpy,加速参数初始化

Bug Fix

  • element-wise 函数增加数值输入参数的支持
  • collator挪到data_collection_process里,在divide模式下不用额外写collate的逻辑
  • 移除_ParallelDataLoaderIter内部的strict属性,在任意worker发生异常时可直接抛出异常
  • 内部的随机数由np.random.RandomState替换成megengine.randon.rng模块生成,保证数据供给的可复现性
  • 修改 load_and run README.md 的内部代码,提供 xornet.py 示例
  • 修复 ImageNet 解压错误
  • 修复 python3.7下多进程报错的问题[TypeError: can’t pickle weakref objects]
  • 修复 InternalGraphGenerator 拼写错误
  • 修复 batchnorm、loss、tranform、tensor API文档问题

Enhancement

  • Speed up parameter initialization by using MegEngine's random distribution generator function instead of NumPy.

BugFix

  • support scalar inputs in element-wise functions
  • Remove internal codes in README.md and add missed example file xornet.py
  • Move collator to data_collection_process, no need to write additional collate in divide mode
  • Remove the strict attribute inside _ParallelDataLoaderIter, and throw an exception directly when any worker exception occurs
  • The random number generation module is replaced by np.random.RandomState to megengine.randon.rng to ensure the reproducibility of data supply
  • Fix imagenet extraction error
  • Fix DataLoader error for Multi-process under python3.7
  • Fix typo InternalGraphGenerator
  • Fix docstring for batchnorm、loss、tranform、tensor
MegEngine - MegEngine v0.3.1: Hello World!

Published by windreamer over 4 years ago

新特性:

  • 同时支持动态(Imperative)、静态(Tracing) 模式的 Tensor 计算引擎,内建自动求导机制
    • 实现了各类基础 Tensor 操作
    • 通过装饰器 @jit.trace,Imperative 和 Tracing 模式下的代码可以高度一致
  • 实现了基于 Module 的神经网络构建方式,并支持通过 save / load 持久化权重
    • 在 megengine.functional 中提供了常见的计算函数
    • 在 megengine.module 中提供了常见层的实现
  • 提供了 X86 和 CUDA 下的高性能计算算子
    • 支持 SSE4, VNNI 等指令集
    • 广泛支持各种 NVIDIA GPU
    • 内置测速模式实现自动算法选择
  • 实现基本的数据加载机制(DataLoader)用于模型数据加载与预处理
  • 实现 hub 协议支持,可以拉取在线模型和预训练模型
  • 实现了 trace.dump() 对模型进行序列化,并提供 C++ 读取模型并运行的样例代码

实验性功能:

  • 支持直接导入 PyTorch Module

已知问题:

  • 动态模式显存占用和性能尚待进一步优化
    • 动态模式下的显存占用较高
    • 当前实现导致动态创建的 Tensor 显存不能自动回收,目前需要使用 set_value() 方法手动复用 Tensor 来避免显存持续增加
    • PyTorch 子图,megengine.Funtion 等算子占用显存会持续增加
  • 静态图相关
    • trace 后的函数无法继续求导
    • jit.trace 和 jit.sideeffect 不支持复杂嵌套
  • 性能问题
    • 当前 Adam 优化器的 step 性能不佳
    • 模型参数随机初始化性能不佳

下阶段计划:

  • 进一步提升动态模式的显存占用和性能
  • 提供对 ARM CPU 等更多后端的支持
  • 提供更多算子
  • 完善文档、CI 和 构建工具等周边基础设施

New Features:

  • An auto-differential numerical framework for Tensors, with Imperative and Tracing modes.
    • Various Tensor-based operators.
    • Unified code for both Imperative and Tracing modes via @jit.trace decorator.
  • Module-based APIs to build neural networks, with save/load methods for parameters.
    • Common mathematical functions in megengine.functional package.
    • Basic modules in megengine.module package
  • High performance operators for X86 and CUDA:
    • Support instruction sets such as SSE4, VNNI, etc.
    • Support NVIDIA GPUs.
    • Automatic kernel selection by profiling.
  • A DataLoader to provide support for loading and processing data.
  • A hub module for load models and pre-trained models.
  • trace.dump() for module serialization, and sample code for load module and do inference.

Experimental Features:

  • Import PyTorch Modules.

Known Issues:

  • Memory usage and performance need to be optimized for Imperative mode.
    • Memory consumption might be high in the Imperative mode.
    • Dynamically created Tensors in Imperative mode can not be automatically released for now. The user has to call set_value() method to reuse Tensors.
    • Some operators such as PyTorchModule and megengine.Function will increasingly alloc more memory.
  • Tracing related issues.
    • Traced functions can not execute or perform backward().
    • Multiple nested jit.trace and jit.sideeffect may result in undefined behaviors.
  • Performance issues.
    • Step() in Adam optimizer is slow.
    • Random initialization for parameters is slow.

Next Plans:

  • Improving memory consumption and speed for Imperative mode.
  • Supporting more devices, e.g., ARM.
  • More operators.
  • Providing more docs and tools.