[{"data":1,"prerenderedAt":1062},["ShallowReactive",2],{"content-query-DYNsEkxCqr":3},{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":8,"description":9,"date":10,"cover":11,"type":12,"body":13,"_type":1056,"_id":1057,"_source":1058,"_file":1059,"_stem":1060,"_extension":1061},"/version-updates/zh/1721","zh",false,"","昇思MindSpore 1.8：丰富的算法集与套件，实现高性能训练，降低部署门槛","提供丰富的模型压缩算法，持续升级自定义算子能力，实现多平台的统一算子开发表达，不断提升易用性，方便开发者调用！","2022-08-16","https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2023/09/15/570ca0056466409f8abe38dc17b76fcd.png","version-updates",{"type":14,"children":15,"toc":1053},"root",[16,24,33,42,47,52,82,89,101,106,114,122,127,132,139,144,152,157,162,177,182,187,192,199,213,218,223,228,235,240,245,250,255,265,273,281,286,291,305,310,315,327,335,340,345,352,357,362,380,385,394,408,416,421,426,431,445,452,457,469,480,492,500,505,510,517,522,532,540,548,553,558,563,577,582,587,591,601,615,620,625,630,634,644,652,660,665,670,678,683,691,696,703,708,715,720,727,732,742,750,764,769,774,778,788,802,807,812,816,826,836,844,852,857,862,867,874,879,883,893,907,915,923,937,942,947,952,959,964,971,976,980,989,1003,1008,1015,1020,1025,1029,1038,1043,1048],{"type":17,"tag":18,"props":19,"children":21},"element","h1",{"id":20},"昇思mindspore-18丰富的算法集与套件实现高性能训练降低部署门槛",[22],{"type":23,"value":8},"text",{"type":17,"tag":25,"props":26,"children":27},"p",{},[28],{"type":17,"tag":29,"props":30,"children":32},"img",{"alt":7,"src":31},"https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2022/08/16/8a7cbaf8990949c3b1970731ca3b3a05.gif",[],{"type":17,"tag":25,"props":34,"children":35},{},[36],{"type":17,"tag":37,"props":38,"children":39},"strong",{},[40],{"type":23,"value":41},"新版本发布",{"type":17,"tag":25,"props":43,"children":44},{},[45],{"type":23,"value":46},"经过社区开发者们两个月来的不断努力，昇思MindSpore1.8版本现已发布。",{"type":17,"tag":25,"props":48,"children":49},{},[50],{"type":23,"value":51},"在此版本中，",{"type":17,"tag":53,"props":54,"children":55},"ul",{},[56,62,67,72,77],{"type":17,"tag":57,"props":58,"children":59},"li",{},[60],{"type":23,"value":61},"我们发布了MindSpore Golden Stick，提供丰富的模型压缩算法；",{"type":17,"tag":57,"props":63,"children":64},{},[65],{"type":23,"value":66},"开源大模型训练套件MindSpore Transformer、推荐网络训练套件MindSpore Recommender，帮助开发者实现高性能的模型并行训练和推荐网络大模型训练；",{"type":17,"tag":57,"props":68,"children":69},{},[70],{"type":23,"value":71},"持续升级自定义算子能力，实现多平台的统一算子开发表达；",{"type":17,"tag":57,"props":73,"children":74},{},[75],{"type":23,"value":76},"统一图像处理类接口、提供model.fit高阶API和早停功能，不断提升API接口易用性；",{"type":17,"tag":57,"props":78,"children":79},{},[80],{"type":23,"value":81},"新增180多个算子的functional接口，并支持NPU、GPU、CPU平台，方便开发者调用。",{"type":17,"tag":25,"props":83,"children":84},{},[85],{"type":17,"tag":29,"props":86,"children":88},{"alt":7,"src":87},"https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2022/08/16/c19929215bda40f6b5cbe71cec28a896.png",[],{"type":17,"tag":25,"props":90,"children":91},{},[92],{"type":17,"tag":93,"props":94,"children":98},"a",{"href":95,"rel":96},"https://mp.weixin.qq.com/s/3MHockEC_j6ywmBPOwbuKg",[97],"nofollow",[99],{"type":23,"value":100},"请在微信中打开进行观看",{"type":17,"tag":25,"props":102,"children":103},{},[104],{"type":23,"value":105},"下面就带大家详细了解下1.8版本的关键特性。",{"type":17,"tag":25,"props":107,"children":108},{},[109],{"type":17,"tag":37,"props":110,"children":111},{},[112],{"type":23,"value":113},"1 MindSpore Golden Stick",{"type":17,"tag":25,"props":115,"children":116},{},[117],{"type":17,"tag":37,"props":118,"children":119},{},[120],{"type":23,"value":121},"降低端侧AI部署门槛",{"type":17,"tag":25,"props":123,"children":124},{},[125],{"type":23,"value":126},"MindSpore Golden Stick是华为诺亚实验室和昇思MindSpore团队基于昇思研发的模型压缩算法集，通过提供剪枝、量化等丰富的模型压缩算法，达到缩减模型参数量等效果，降低模型在端侧部署的门槛；",{"type":17,"tag":25,"props":128,"children":129},{},[130],{"type":23,"value":131},"此外，面向开发者还提供一套简单易用的算法接口，可降低模型压缩算法的应用成本。",{"type":17,"tag":25,"props":133,"children":134},{},[135],{"type":17,"tag":29,"props":136,"children":138},{"alt":7,"src":137},"https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2022/08/16/811ba4d20bb54a7fa1b4354d2a920a0a.png",[],{"type":17,"tag":25,"props":140,"children":141},{},[142],{"type":23,"value":143},"MindSpore Golden Stick架构图",{"type":17,"tag":25,"props":145,"children":146},{},[147],{"type":17,"tag":37,"props":148,"children":149},{},[150],{"type":23,"value":151},"1.1 统一的算法接口和改图能力",{"type":17,"tag":25,"props":153,"children":154},{},[155],{"type":23,"value":156},"模型压缩算法种类繁多，不同算法的应用方式往往各不相同，这增加了应用算法的学习成本。MindSpore Golden Stick对算法应用流程做了梳理和抽象，提供了一套统一的算法应用接口，最大程度缩减算法应用的学习成本，同时这也方便了在各种算法的基础上，对自动模型压缩等高阶技术的探索。",{"type":17,"tag":25,"props":158,"children":159},{},[160],{"type":23,"value":161},"同时，MindSpore Golden Stick提供了通过接口修改前端网络的能力，算法开发者可以基于此能力制定通用的改图规则去实现算法逻辑，而不需要针对每个特定的网络都实现一遍算法逻辑，提升算法开发效率。",{"type":17,"tag":25,"props":163,"children":164},{},[165,170,172],{"type":17,"tag":37,"props":166,"children":167},{},[168],{"type":23,"value":169},"1.2",{"type":23,"value":171}," ",{"type":17,"tag":37,"props":173,"children":174},{},[175],{"type":23,"value":176},"剪枝算法：SCOP[1]，缩减模型功耗50%",{"type":17,"tag":25,"props":178,"children":179},{},[180],{"type":23,"value":181},"MindSpore Golden Stick当前提供的一个结构化剪枝算法是华为诺亚实验室自研的SCOP（Scientific Control for Reliable Neural Network Pruning，基于科学控制法的神经网络剪枝），在数据驱动下，设置了对照实验，通过引入对照特征来减少各种无关因素对剪枝过程的干扰，提高剪枝结果的可靠性。",{"type":17,"tag":25,"props":183,"children":184},{},[185],{"type":23,"value":186},"我们对ResNet50模型应用SCOP剪枝，并使用CIFAR-10数据集评估，实验结果如下表所示，在剪枝率45%的情况下，精度损失在0.5%以内，模型参数量下降超过50%，带来50%以上的部署功耗缩减和2倍以上的推理性能收益。",{"type":17,"tag":25,"props":188,"children":189},{},[190],{"type":23,"value":191},"表 SCOP剪枝算法用于ResNet50的CIFAR-10数据集结果",{"type":17,"tag":25,"props":193,"children":194},{},[195],{"type":17,"tag":29,"props":196,"children":198},{"alt":7,"src":197},"https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2022/08/16/90f7245c4a6b477382950b21611d8db6.png",[],{"type":17,"tag":25,"props":200,"children":201},{},[202,207,208],{"type":17,"tag":37,"props":203,"children":204},{},[205],{"type":23,"value":206},"1.3",{"type":23,"value":171},{"type":17,"tag":37,"props":209,"children":210},{},[211],{"type":23,"value":212},"量化算法：SLB[2]，压缩模型8-32倍",{"type":17,"tag":25,"props":214,"children":215},{},[216],{"type":23,"value":217},"MindSpore Golden Stick当前提供的一个量化算法是华为诺亚实验室自研的SLB（Searching for low-bit weights，基于权值搜索的低比特神经网络量化）。",{"type":17,"tag":25,"props":219,"children":220},{},[221],{"type":23,"value":222},"针对低比特网络量化，由于量化网络权值的有效解数量比较少，因此对网络的量化可以通过对权值搜索实现，也就是将量化过程转换成权值搜索的过程。与传统的量化算法相比，规避了不准确的梯度更新过程，能获得更好的准确率，在极低比特量化中更有优势。",{"type":17,"tag":25,"props":224,"children":225},{},[226],{"type":23,"value":227},"我们对SLB算法做了简单的实验，结果如下图所示，在当前任务中，与全精度模型相比，4bit权重量化后的模型大小缩减为原来的1/8，但top1精度没有损失，1bit权重量化的精度损失在0.6%以内，此时可以获得32倍的模型压缩效果。",{"type":17,"tag":25,"props":229,"children":230},{},[231],{"type":17,"tag":29,"props":232,"children":234},{"alt":7,"src":233},"https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2022/08/16/e98bda1d9392435da01a0d81ed771022.png",[],{"type":17,"tag":25,"props":236,"children":237},{},[238],{"type":23,"value":239},"SLB权重量化算法用于量化ResNet18的CIFAR-10数据集结果，",{"type":17,"tag":25,"props":241,"children":242},{},[243],{"type":23,"value":244},"W32表示全精度模型，",{"type":17,"tag":25,"props":246,"children":247},{},[248],{"type":23,"value":249},"W4，W2，W1分别对应4bit、2bit和1bit权重量化模型",{"type":17,"tag":25,"props":251,"children":252},{},[253],{"type":23,"value":254},"查看文档：",{"type":17,"tag":25,"props":256,"children":257},{},[258],{"type":17,"tag":93,"props":259,"children":262},{"href":260,"rel":261},"https://www.mindspore.cn/golden%5C_stick/docs/zh-CN/r0.1/index.html",[97],[263],{"type":23,"value":264},"https://www.mindspore.cn/golden\\_stick/docs/zh-CN/r0.1/index.html",{"type":17,"tag":25,"props":266,"children":267},{},[268],{"type":17,"tag":37,"props":269,"children":270},{},[271],{"type":23,"value":272},"2 高性能的大模型训练套件",{"type":17,"tag":25,"props":274,"children":275},{},[276],{"type":17,"tag":37,"props":277,"children":278},{},[279],{"type":23,"value":280},"MindSpore Transformer",{"type":17,"tag":25,"props":282,"children":283},{},[284],{"type":23,"value":285},"目前Transformer已经广泛地应用在深度学习的各个领域，为了结合昇思丰富的并行能力和高性能优化特性，让开发者能够轻松上手Transformer类网络训练，我们专门提供的MindSpore Transformer是一个开源的Transformer类网络训练和推理套件。",{"type":17,"tag":25,"props":287,"children":288},{},[289],{"type":23,"value":290},"套件提供了典型网络，例如GPT、T5、VIT等基础模型的训练能力，并结合昇思MindSpore丰富的并行训练能力，实现高性能的模型并行训练。通过实验得出，在相同的硬件条件下，昇思MindSpore比Megatron的性能要优越18%以上。",{"type":17,"tag":25,"props":292,"children":293},{},[294,299,300],{"type":17,"tag":37,"props":295,"children":296},{},[297],{"type":23,"value":298},"2.1",{"type":23,"value":171},{"type":17,"tag":37,"props":301,"children":302},{},[303],{"type":23,"value":304},"多维度混合并行与图算融合优化",{"type":17,"tag":25,"props":306,"children":307},{},[308],{"type":23,"value":309},"MindSpore Transformer主要应用了如下两种技术：",{"type":17,"tag":25,"props":311,"children":312},{},[313],{"type":23,"value":314},"1、**多维度混合并行，包含优化器并行、多副本并行等技术。**通过优化数据并行维度上的冗余参数和通信计算并发，可有效提升网络的训练性能。",{"type":17,"tag":25,"props":316,"children":317},{},[318,320,325],{"type":23,"value":319},"2、",{"type":17,"tag":37,"props":321,"children":322},{},[323],{"type":23,"value":324},"图算融合优化",{"type":23,"value":326},"：昇思的图算融合功能可以自动实现算子融合和编译优化，提升模型的内存效率和训练速度。在MindSpore Transformer的所有模型和数据/模型并行模式下，图算融合均已大范围应用并取得了显著效果。",{"type":17,"tag":25,"props":328,"children":329},{},[330],{"type":17,"tag":37,"props":331,"children":332},{},[333],{"type":23,"value":334},"2.2 性能对比",{"type":17,"tag":25,"props":336,"children":337},{},[338],{"type":23,"value":339},"我们分别在8p、16p和32p A100集群上测试了百亿规模GPT(hiddensize=5120, num_layers=35, num_heads=40)性能，模型并行路数设置为8，数据并行数分别为1、2、4，Global Batch为1024。",{"type":17,"tag":25,"props":341,"children":342},{},[343],{"type":23,"value":344},"Megatron配置Micro Batch Size=2（Megatron已达到上限），MindSpore配置Micro Batch Size=8（MindSpore已达到上限），相比Megatron，昇思MindSpore的内存利用率更高，可以训练更大的Batch Size。",{"type":17,"tag":25,"props":346,"children":347},{},[348],{"type":17,"tag":29,"props":349,"children":351},{"alt":7,"src":350},"https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2022/08/16/141ae67d01c645f3954a44c40e488d5e.png",[],{"type":17,"tag":25,"props":353,"children":354},{},[355],{"type":23,"value":356},"图 吞吐率对比",{"type":17,"tag":25,"props":358,"children":359},{},[360],{"type":23,"value":361},"如上图所示，",{"type":17,"tag":53,"props":363,"children":364},{},[365,370,375],{"type":17,"tag":57,"props":366,"children":367},{},[368],{"type":23,"value":369},"8P Megatron的最大吞吐率为7.4 k samples/s，MindSpore 最大吞吐率为9.3k samples/s，超过Megatron 25%；",{"type":17,"tag":57,"props":371,"children":372},{},[373],{"type":23,"value":374},"16P Megatron的最大吞吐率为13.6k samples/s，MindSpore最大吞吐率为16.9k samples/s，超过Megatron 24%；",{"type":17,"tag":57,"props":376,"children":377},{},[378],{"type":23,"value":379},"32P Megatron的最大吞吐率为20.1k samples/s，MindSpore最大吞吐率为23.8k samples/s，超过Megatron 18%。",{"type":17,"tag":25,"props":381,"children":382},{},[383],{"type":23,"value":384},"开源链接：",{"type":17,"tag":25,"props":386,"children":387},{},[388],{"type":17,"tag":93,"props":389,"children":392},{"href":390,"rel":391},"https://gitee.com/mindspore/transformer",[97],[393],{"type":23,"value":390},{"type":17,"tag":25,"props":395,"children":396},{},[397,402,403],{"type":17,"tag":37,"props":398,"children":399},{},[400],{"type":23,"value":401},"3",{"type":23,"value":171},{"type":17,"tag":37,"props":404,"children":405},{},[406],{"type":23,"value":407},"高性能的推荐网络训练套件",{"type":17,"tag":25,"props":409,"children":410},{},[411],{"type":17,"tag":37,"props":412,"children":413},{},[414],{"type":23,"value":415},"MindSpore Recommender",{"type":17,"tag":25,"props":417,"children":418},{},[419],{"type":23,"value":420},"推荐系统中部署了多种点击率（CTR）模型，为提高推荐点击率，需要对深度CTR模型进行高效的训练，推荐网络的训练性能是模型实时性的重要因素之一。",{"type":17,"tag":25,"props":422,"children":423},{},[424],{"type":23,"value":425},"昇思MindSpore 1.8版本提供了推荐网络大模型训练套件—MindSpore Recommender，结合昇思MindSpore自动并行、图算融合以及分布式Embedding Cache等基础能力，实现了推荐网络大模型的高性能训练。",{"type":17,"tag":25,"props":427,"children":428},{},[429],{"type":23,"value":430},"在套件中提供了主流推荐网络模型（如Wide&Deep）端到端的训练流程，包括数据集预处理、模型训练、Benchmark等，为开发者提供了一站式的推荐大模型训练能力。",{"type":17,"tag":25,"props":432,"children":433},{},[434,439,440],{"type":17,"tag":37,"props":435,"children":436},{},[437],{"type":23,"value":438},"3.1",{"type":23,"value":171},{"type":17,"tag":37,"props":441,"children":442},{},[443],{"type":23,"value":444},"推荐大模型训练架构",{"type":17,"tag":25,"props":446,"children":447},{},[448],{"type":17,"tag":29,"props":449,"children":451},{"alt":7,"src":450},"https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2022/08/16/450f966ee940421a87dc09fb2b02b90f.png",[],{"type":17,"tag":25,"props":453,"children":454},{},[455],{"type":23,"value":456},"技术架构图",{"type":17,"tag":25,"props":458,"children":459},{},[460,462,467],{"type":23,"value":461},"1、 ",{"type":17,"tag":37,"props":463,"children":464},{},[465],{"type":23,"value":466},"自动并行",{"type":23,"value":468},"：通过模型并行实现Sparse计算（Embedding）多卡自动切分，数据并行实现Dense计算与集合通信并发执行，有效提升网络的整体训练性能。",{"type":17,"tag":25,"props":470,"children":471},{},[472,473,478],{"type":23,"value":319},{"type":17,"tag":37,"props":474,"children":475},{},[476],{"type":23,"value":477},"分布式Embedding Cache",{"type":23,"value":479},"：采用多级Embedding Cache、多级计算流水等设计，实现了大规模特征向量的存储与高性能训练。",{"type":17,"tag":25,"props":481,"children":482},{},[483,485,490],{"type":23,"value":484},"3、",{"type":17,"tag":37,"props":486,"children":487},{},[488],{"type":23,"value":489},"分布式计算图",{"type":23,"value":491},"：通过分布式计算图切分与执行，实现了大规模特征向量的分布式存储与高性能本地计算。",{"type":17,"tag":25,"props":493,"children":494},{},[495],{"type":17,"tag":37,"props":496,"children":497},{},[498],{"type":23,"value":499},"3.2 统一的算法接口和改图能力",{"type":17,"tag":25,"props":501,"children":502},{},[503],{"type":23,"value":504},"基于GPU V100集群Wide&Deep模型训练（batch_size=16000, vocab_size=5860000）",{"type":17,"tag":25,"props":506,"children":507},{},[508],{"type":23,"value":509},"，如下图所示，单机八卡上昇思MindSpore的吞吐率优于HugeCTR 35%。",{"type":17,"tag":25,"props":511,"children":512},{},[513],{"type":17,"tag":29,"props":514,"children":516},{"alt":7,"src":515},"https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2022/08/16/d4e1b8e8b5bf40b9a701bd8873c82de9.png",[],{"type":17,"tag":25,"props":518,"children":519},{},[520],{"type":23,"value":521},"图 Wide&Deep训练吞吐率",{"type":17,"tag":25,"props":523,"children":524},{},[525,526],{"type":23,"value":384},{"type":17,"tag":93,"props":527,"children":530},{"href":528,"rel":529},"https://gitee.com/mindspore/recommender",[97],[531],{"type":23,"value":528},{"type":17,"tag":25,"props":533,"children":534},{},[535],{"type":17,"tag":37,"props":536,"children":537},{},[538],{"type":23,"value":539},"4 自定义算子持续升级,",{"type":17,"tag":25,"props":541,"children":542},{},[543],{"type":17,"tag":37,"props":544,"children":545},{},[546],{"type":23,"value":547},"统一表达支持高效添加算子",{"type":17,"tag":25,"props":549,"children":550},{},[551],{"type":23,"value":552},"年初发布昇思MindSpore1.6版本提供了多平台的统一算子开发接口Custom，能够快捷地进行不同类型自定义算子的定义和使用。",{"type":17,"tag":25,"props":554,"children":555},{},[556],{"type":23,"value":557},"为了进一步提升自定义算子的体验，昇思MindSpore1.8版本提供统一的MindSpore Hybrid DSL表达，支持包括Ascend，GPU和CPU在内多平台的统一算子开发表达，可以在全平台同时满足快速验证和实时编译的需求。",{"type":17,"tag":25,"props":559,"children":560},{},[561],{"type":23,"value":562},"此外，1.8版本提供接入Julia算子的自定义算子新模式，成为业界首个支持Julia语言的AI框架。",{"type":17,"tag":25,"props":564,"children":565},{},[566,571,572],{"type":17,"tag":37,"props":567,"children":568},{},[569],{"type":23,"value":570},"4.1",{"type":23,"value":171},{"type":17,"tag":37,"props":573,"children":574},{},[575],{"type":23,"value":576},"跨平台统一的MindSpore Hybrid DSL表达",{"type":17,"tag":25,"props":578,"children":579},{},[580],{"type":23,"value":581},"MindSpore Hybrid DSL支持在不同平台用统一的表达开发算子，一次开发便可以在所有后端使用。此外，开发的算子接入Custom接口时，既可以通过hybrid模式即时编译运行，亦可通过pyfunc模式解释运行方便快速验证。",{"type":17,"tag":25,"props":583,"children":584},{},[585],{"type":23,"value":586},"此外基于MindSpore Hybrid DSL提供新的调度原语，帮助hybrid类型自定义算子在Ascend后端使能多面体模型的专用处理器（DSA)调度器，实现手自一体的算子调度协助代码生成，帮助开发者基于Ascend后端加速科学计算任务。",{"type":17,"tag":25,"props":588,"children":589},{},[590],{"type":23,"value":254},{"type":17,"tag":25,"props":592,"children":593},{},[594],{"type":17,"tag":93,"props":595,"children":598},{"href":596,"rel":597},"https://www.mindspore.cn/tutorials/experts/zh-CN/r1.8/operation/op%5C_custom.html#mindspore-hybrid%E8%AF%AD%E6%B3%95%E8%A7%84%E8%8C%83",[97],[599],{"type":23,"value":600},"https://www.mindspore.cn/tutorials/experts/zh-CN/r1.8/operation/op\\_custom.html#mindspore-hybrid%E8%AF%AD%E6%B3%95%E8%A7%84%E8%8C%83",{"type":17,"tag":25,"props":602,"children":603},{},[604,609,610],{"type":17,"tag":37,"props":605,"children":606},{},[607],{"type":23,"value":608},"4.2",{"type":23,"value":171},{"type":17,"tag":37,"props":611,"children":612},{},[613],{"type":23,"value":614},"业界首个支持Julia语言的AI框架",{"type":17,"tag":25,"props":616,"children":617},{},[618],{"type":23,"value":619},"Julia是一种速度快且使用简单的高级通用编程语言，最初设计是用于科学计算领域，而由于其高效而实用的特性，近些年来越来越受到青睐，逐步迈向主流编程语言。",{"type":17,"tag":25,"props":621,"children":622},{},[623],{"type":23,"value":624},"昇思MindSpore 1.8版本在算子开发接口Custom提供Julia模式，把基于Julia语言开发的算子和基于昇思开发的模型有机地结合在一起。",{"type":17,"tag":25,"props":626,"children":627},{},[628],{"type":23,"value":629},"开发者可以采用Julia算子加速运算，也可以使用Julia生态高效地开发算子。如此，开发者在模型移植、快速验证以及模型加速等场景下使能Julia算子，在基于昇思MindSpore开发的模型中享受Julia语言对计算带来的收益。",{"type":17,"tag":25,"props":631,"children":632},{},[633],{"type":23,"value":254},{"type":17,"tag":25,"props":635,"children":636},{},[637],{"type":17,"tag":93,"props":638,"children":641},{"href":639,"rel":640},"https://www.mindspore.cn/tutorials/experts/zh-CN/r1.8/operation/op%5C_custom.html#julia%E7%B1%BB%E5%9E%8B%E7%9A%84%E8%87%AA%E5%AE%9A%E4%B9%89%E7%AE%97%E5%AD%90%E5%BC%80%E5%8F%91",[97],[642],{"type":23,"value":643},"https://www.mindspore.cn/tutorials/experts/zh-CN/r1.8/operation/op\\_custom.html#julia%E7%B1%BB%E5%9E%8B%E7%9A%84%E8%87%AA%E5%AE%9A%E4%B9%89%E7%AE%97%E5%AD%90%E5%BC%80%E5%8F%91",{"type":17,"tag":25,"props":645,"children":646},{},[647],{"type":17,"tag":37,"props":648,"children":649},{},[650],{"type":23,"value":651},"5 MindSpore Data统一图像处理类接口，",{"type":17,"tag":25,"props":653,"children":654},{},[655],{"type":17,"tag":37,"props":656,"children":657},{},[658],{"type":23,"value":659},"提升接口API易用性",{"type":17,"tag":25,"props":661,"children":662},{},[663],{"type":23,"value":664},"昇思MindSpore1.8版本中，MindSpore Data模块对于图像类数据预处理操作进行重新设计及改造，从原有的c_transforms和py_transforms两种类型操作合并为transforms统一接口，同时对其中包含的各类数据处理算子进行归一合并，减少开发者混用算子的转换操作，并基于算子上下文实现自动的算子输出格式转换，极简易用，同时对资深开发者仍然保留了手动选择算子策略的能力。",{"type":17,"tag":25,"props":666,"children":667},{},[668],{"type":23,"value":669},"为了方便大家构建自己的量子变分相关算法，我们公开了更多模拟器的接口。",{"type":17,"tag":25,"props":671,"children":672},{},[673],{"type":17,"tag":37,"props":674,"children":675},{},[676],{"type":23,"value":677},"5.1 实现方式",{"type":17,"tag":25,"props":679,"children":680},{},[681],{"type":23,"value":682},"将c_transforms和py_transforms相同的功能合并为同一个接口，内部保留两种底层实现，执行时优先使用C层实现，保证高效率；不同的功能分别保留C层和Python层底层实现，执行时只有唯一方式。",{"type":17,"tag":25,"props":684,"children":685},{},[686],{"type":17,"tag":37,"props":687,"children":688},{},[689],{"type":23,"value":690},"5.2 实现后总结",{"type":17,"tag":25,"props":692,"children":693},{},[694],{"type":23,"value":695},"1、包的导入方式统一，如下图所示。",{"type":17,"tag":25,"props":697,"children":698},{},[699],{"type":17,"tag":29,"props":700,"children":702},{"alt":7,"src":701},"https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2022/08/16/d67aa8139a054224aae465a600dc319d.png",[],{"type":17,"tag":25,"props":704,"children":705},{},[706],{"type":23,"value":707},"2、数据处理接口统一，如下图所示。",{"type":17,"tag":25,"props":709,"children":710},{},[711],{"type":17,"tag":29,"props":712,"children":714},{"alt":7,"src":713},"https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2022/08/16/c9545f5550c24ad091a2dc310906a20e.png",[],{"type":17,"tag":25,"props":716,"children":717},{},[718],{"type":23,"value":719},"3、运行方式举例，如下图所示。",{"type":17,"tag":25,"props":721,"children":722},{},[723],{"type":17,"tag":29,"props":724,"children":726},{"alt":7,"src":725},"https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2022/08/16/6ac2981f550b42a1996e27a923a432db.png",[],{"type":17,"tag":25,"props":728,"children":729},{},[730],{"type":23,"value":731},"详情参考：",{"type":17,"tag":25,"props":733,"children":734},{},[735],{"type":17,"tag":93,"props":736,"children":739},{"href":737,"rel":738},"https://www.mindspore.cn/docs/zh-CN/r1.8/api%5C_python/mindspore.dataset.vision.html",[97],[740],{"type":23,"value":741},"https://www.mindspore.cn/docs/zh-CN/r1.8/api\\_python/mindspore.dataset.vision.html",{"type":17,"tag":25,"props":743,"children":744},{},[745],{"type":17,"tag":37,"props":746,"children":747},{},[748],{"type":23,"value":749},"6 支持边训练边推理和早停功能",{"type":17,"tag":25,"props":751,"children":752},{},[753,758,759],{"type":17,"tag":37,"props":754,"children":755},{},[756],{"type":23,"value":757},"6.1",{"type":23,"value":171},{"type":17,"tag":37,"props":760,"children":761},{},[762],{"type":23,"value":763},"提供model.fit高阶API",{"type":17,"tag":25,"props":765,"children":766},{},[767],{"type":23,"value":768},"之前的训练及推理分别通过model.train和model.eval两个接口执行，如果在训练过程中需要查看验证集的评估指标来监控模型效果，需手动实现；",{"type":17,"tag":25,"props":770,"children":771},{},[772],{"type":23,"value":773},"而昇思MindSpore1.8提供model.fit高阶API，对model.train及model.eval进行了封装，保证原有功能的情况下简化了开发流程，开发者只需传入对应的参数，即可一行代码实现自动化训练及推理。",{"type":17,"tag":25,"props":775,"children":776},{},[777],{"type":23,"value":731},{"type":17,"tag":25,"props":779,"children":780},{},[781],{"type":17,"tag":93,"props":782,"children":785},{"href":783,"rel":784},"https://mindspore.cn/docs/zh-CN/r1.8/api%5C_python/mindspore/mindspore.Model.html#mindspore.Model.fit",[97],[786],{"type":23,"value":787},"https://mindspore.cn/docs/zh-CN/r1.8/api\\_python/mindspore/mindspore.Model.html#mindspore.Model.fit",{"type":17,"tag":25,"props":789,"children":790},{},[791,796,797],{"type":17,"tag":37,"props":792,"children":793},{},[794],{"type":23,"value":795},"6.2",{"type":23,"value":171},{"type":17,"tag":37,"props":798,"children":799},{},[800],{"type":23,"value":801},"实现EarlyStopping和ReduceLROnPlateau功能",{"type":17,"tag":25,"props":803,"children":804},{},[805],{"type":23,"value":806},"为及时掌握训练过程中模型的状态、实时观察模型各参数的变化情况和实现训练过程中自定义的一些操作，昇思提供了回调机制（Callback）来实现上述功能，对标业界框架，昇思MindSpore1.8版本新增EarlyStopping及ReduceLROnPlateau两个Callback，可用于model.train和model.fit中，实现指定指标的Epoch级别的验证：",{"type":17,"tag":25,"props":808,"children":809},{},[810],{"type":23,"value":811},"当指标值变差，超过可容忍阈值或等待时间超过可容忍Epoch数时，EarlyStopping将终止训练过程实现早停，而ReduceLROnPlateau将按照开发者指定的学习率衰减规则，改变学习率。",{"type":17,"tag":25,"props":813,"children":814},{},[815],{"type":23,"value":731},{"type":17,"tag":25,"props":817,"children":818},{},[819],{"type":17,"tag":93,"props":820,"children":823},{"href":821,"rel":822},"https://mindspore.cn/docs/zh-CN/r1.8/api%5C_python/mindspore/mindspore.EarlyStopping.html",[97],[824],{"type":23,"value":825},"https://mindspore.cn/docs/zh-CN/r1.8/api\\_python/mindspore/mindspore.EarlyStopping.html",{"type":17,"tag":25,"props":827,"children":828},{},[829],{"type":17,"tag":93,"props":830,"children":833},{"href":831,"rel":832},"https://mindspore.cn/docs/zh-CN/r1.8/api%5C_python/mindspore/mindspore.ReduceLROnPlateau.html",[97],[834],{"type":23,"value":835},"https://mindspore.cn/docs/zh-CN/r1.8/api\\_python/mindspore/mindspore.ReduceLROnPlateau.html",{"type":17,"tag":25,"props":837,"children":838},{},[839],{"type":17,"tag":37,"props":840,"children":841},{},[842],{"type":23,"value":843},"7 支持网络的常量输入可变，",{"type":17,"tag":25,"props":845,"children":846},{},[847],{"type":17,"tag":37,"props":848,"children":849},{},[850],{"type":23,"value":851},"提升编译效率",{"type":17,"tag":25,"props":853,"children":854},{},[855],{"type":23,"value":856},"当前图编译机制是除Tensor外所有顶层网络的输入都被当做常量值，如标量、tuple、list和dict。而常量值是不能求导的，而且在编译优化阶段会被常量折叠掉。",{"type":17,"tag":25,"props":858,"children":859},{},[860],{"type":23,"value":861},"另外，当网络的输入是tuple[Tensor]，list[Tensor]或dict[Tensor]时，即使里面Tensor的shape和dtype没有发生变化，在多次调用同一个网络去得到结果时，由于输入都被当做常量值去处理了，无法忽略掉里面Tensor的具体数值，所以导致网络每次都会被重新编译，降低训练效率。",{"type":17,"tag":25,"props":863,"children":864},{},[865],{"type":23,"value":866},"为解决以上的问题，昇思MindSpore1.8版本新增了mutable接口去设置网络的常量输入为“可变的”，也就是把这个输入当做像Tensor一样的变量，从而可以对其求梯度以及防止网络被重复编译。接口用法也比较简单，在传参时对网络输入用mutable接口进行包裹即可，如下图所示。",{"type":17,"tag":25,"props":868,"children":869},{},[870],{"type":17,"tag":29,"props":871,"children":873},{"alt":7,"src":872},"https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2022/08/16/905c8f6deb66471797209954fd85751e.png",[],{"type":17,"tag":25,"props":875,"children":876},{},[877],{"type":23,"value":878},"图 用例对tuple[Tensor]类型的输入进行包裹",{"type":17,"tag":25,"props":880,"children":881},{},[882],{"type":23,"value":731},{"type":17,"tag":25,"props":884,"children":885},{},[886],{"type":17,"tag":93,"props":887,"children":890},{"href":888,"rel":889},"https://www.mindspore.cn/docs/zh-CN/r1.8/api%5C_python/mindspore/mindspore.mutable.html#mindspore.mutable",[97],[891],{"type":23,"value":892},"https://www.mindspore.cn/docs/zh-CN/r1.8/api\\_python/mindspore/mindspore.mutable.html#mindspore.mutable",{"type":17,"tag":25,"props":894,"children":895},{},[896,901,902],{"type":17,"tag":37,"props":897,"children":898},{},[899],{"type":23,"value":900},"8",{"type":23,"value":171},{"type":17,"tag":37,"props":903,"children":904},{},[905],{"type":23,"value":906},"MindSpore Reinforcement，",{"type":17,"tag":25,"props":908,"children":909},{},[910],{"type":17,"tag":37,"props":911,"children":912},{},[913],{"type":23,"value":914},"提供高性能分布式训练",{"type":17,"tag":25,"props":916,"children":917},{},[918],{"type":17,"tag":37,"props":919,"children":920},{},[921],{"type":23,"value":922},"和****原生蒙特卡洛树搜索算法",{"type":17,"tag":25,"props":924,"children":925},{},[926,931,932],{"type":17,"tag":37,"props":927,"children":928},{},[929],{"type":23,"value":930},"8.1",{"type":23,"value":171},{"type":17,"tag":37,"props":933,"children":934},{},[935],{"type":23,"value":936},"通过Dataflow Fragment实现灵活，高性能的分布式训练。",{"type":17,"tag":25,"props":938,"children":939},{},[940],{"type":23,"value":941},"当前分布式强化学习框架主要以Python函数的方式实现强化学习算法，虽然具有直观的编程API，但在多机并行和异构加速上却很有挑战。",{"type":17,"tag":25,"props":943,"children":944},{},[945],{"type":23,"value":946},"MindSpore Reinforcement v0.5.0提供基于Dataflow Fragment的分布式策略（DP），支持将深度强化学习算法分割成多个数据流片段，并映射到异构设备上执行。相同的算法可以根据不同的分布式策略而部署到单机多卡或多机多卡上。",{"type":17,"tag":25,"props":948,"children":949},{},[950],{"type":23,"value":951},"下图中展示了基于Dataflow Fragment的分布式策略，以及对应的训练加速效果，在多机多卡分布式训练场景下可大幅缩短算法的训练时间。",{"type":17,"tag":25,"props":953,"children":954},{},[955],{"type":17,"tag":29,"props":956,"children":958},{"alt":7,"src":957},"https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2022/08/16/89349d506c394d988f8c68de933da957.png",[],{"type":17,"tag":25,"props":960,"children":961},{},[962],{"type":23,"value":963},"图 分布式策略示意图（左：分布式策略1; 右：分布式策略2）",{"type":17,"tag":25,"props":965,"children":966},{},[967],{"type":17,"tag":29,"props":968,"children":970},{"alt":7,"src":969},"https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2022/08/16/af83790174764eacaf345ca11d3c20f2.png",[],{"type":17,"tag":25,"props":972,"children":973},{},[974],{"type":23,"value":975},"图 不同分布式策略下的训练时间",{"type":17,"tag":25,"props":977,"children":978},{},[979],{"type":23,"value":731},{"type":17,"tag":25,"props":981,"children":982},{},[983],{"type":17,"tag":93,"props":984,"children":987},{"href":985,"rel":986},"https://gitee.com/mindspore/reinforcement/tree/master/example/ppo",[97],[988],{"type":23,"value":985},{"type":17,"tag":25,"props":990,"children":991},{},[992,997,998],{"type":17,"tag":37,"props":993,"children":994},{},[995],{"type":23,"value":996},"8.2",{"type":23,"value":171},{"type":17,"tag":37,"props":999,"children":1000},{},[1001],{"type":23,"value":1002},"蒙特卡洛树搜索（MCTS）",{"type":17,"tag":25,"props":1004,"children":1005},{},[1006],{"type":23,"value":1007},"蒙特卡洛树搜索（MCTS）是一种决策搜索算法，以MCTS为基础的强化学习算法（如AlphaGo）获得成功之后，MCTS在强化学习算法中的应用越来越广泛。",{"type":17,"tag":25,"props":1009,"children":1010},{},[1011],{"type":17,"tag":29,"props":1012,"children":1014},{"alt":7,"src":1013},"https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2022/08/16/dd3251f5825244caa8dbd8d8b63c7a09.png",[],{"type":17,"tag":25,"props":1016,"children":1017},{},[1018],{"type":23,"value":1019},"图 MSTC算法伪代码",{"type":17,"tag":25,"props":1021,"children":1022},{},[1023],{"type":23,"value":1024},"MindSpore Reinforcement v0.5.0提供了通用可扩展的MCTS算法。开发者可以使用Python在强化学习算法中直接调用框架内置的MCTS算法，也可以通过扩展来完成自定义逻辑，框架自动将算法编译成计算图，实现高效执行。",{"type":17,"tag":25,"props":1026,"children":1027},{},[1028],{"type":23,"value":731},{"type":17,"tag":25,"props":1030,"children":1031},{},[1032],{"type":17,"tag":93,"props":1033,"children":1036},{"href":1034,"rel":1035},"https://gitee.com/mindspore/reinforcement/tree/master/example/mcts",[97],[1037],{"type":23,"value":1034},{"type":17,"tag":25,"props":1039,"children":1040},{},[1041],{"type":23,"value":1042},"参考文献",{"type":17,"tag":25,"props":1044,"children":1045},{},[1046],{"type":23,"value":1047},"[1] Tang, Yehui, et al. \"Scop: Scientific control for reliable neural network pruning.\" NeurIPS 2020: 10936-10947.",{"type":17,"tag":25,"props":1049,"children":1050},{},[1051],{"type":23,"value":1052},"[2] Yang Z, Wang Y, Han K, et al. Searching for low-bit weights in quantized neural networks. NIPS, 2020.",{"title":7,"searchDepth":1054,"depth":1054,"links":1055},4,[],"markdown","content:version-updates:zh:1721.md","content","version-updates/zh/1721.md","version-updates/zh/1721","md",1776506143970]