[{"data":1,"prerenderedAt":816},["ShallowReactive",2],{"content-query-AaeGq4QYnQ":3},{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":8,"description":9,"date":10,"cover":11,"type":12,"body":13,"_type":810,"_id":811,"_source":812,"_file":813,"_stem":814,"_extension":815},"/news/zh/3598","zh",false,"","训推全面支持、开箱即用！DeepSeek V3昇思MindSpore版本上线开源社区","昇思已支持在昇腾集群上训练和推理DeepSeek-V3 671B","2025-02-09","https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2025/02/09/a1b1c207d50d40f8a508250949e501f3.png","news",{"type":14,"children":15,"toc":795},"root",[16,24,30,35,40,49,54,65,70,79,87,97,102,110,115,124,129,134,139,144,149,154,159,164,169,174,179,189,194,199,207,212,217,225,234,239,244,249,258,263,272,277,282,287,295,304,309,314,322,327,335,340,348,353,361,366,371,379,384,392,401,406,414,419,427,432,440,445,454,459,464,472,477,485,490,498,503,511,516,521,529,534,545,553,573,584,589,654,663,673,686,699,707,715,723,734,744,754,765,773,784],{"type":17,"tag":18,"props":19,"children":21},"element","h1",{"id":20},"训推全面支持开箱即用deepseek-v3昇思mindspore版本上线开源社区",[22],{"type":23,"value":8},"text",{"type":17,"tag":25,"props":26,"children":27},"p",{},[28],{"type":23,"value":29},"近日，基于昇腾AI硬件与昇思MindSpore AI框架版本的DeepSeek-V3完成开发支持并上线昇思开源社区，面向开发者提供开箱即用的预训练和推理能力，并已成功在大规模集群上预训练和部署。",{"type":17,"tag":25,"props":31,"children":32},{},[33],{"type":23,"value":34},"应用昇思MindSpore大模型使能套件，依托昇思多维混合分布式能力、自动并行、Dryrun集群内存仿真等技术，天级快速适配DeepSeek V3新增模型结构和分布式并行训练能力。同时，昇思MindSpore通过深度优化MLA、DeepSeekMoE等网络结构的推理，实现了高效的推理部署性能。",{"type":17,"tag":25,"props":36,"children":37},{},[38],{"type":23,"value":39},"当前，通过获取昇思MindSpore版DeepSeek V3开源镜像，开发者可直接进行DeepSeek-V3的预训练和推理部署。",{"type":17,"tag":25,"props":41,"children":42},{},[43],{"type":17,"tag":44,"props":45,"children":46},"strong",{},[47],{"type":23,"value":48},"开源链接",{"type":17,"tag":25,"props":50,"children":51},{},[52],{"type":23,"value":53},"昇思MindSpore开源社区训练代码：",{"type":17,"tag":25,"props":55,"children":56},{},[57],{"type":17,"tag":58,"props":59,"children":63},"a",{"href":60,"rel":61},"https://gitee.com/mindspore/mindformers/tree/dev/research/deepseek3",[62],"nofollow",[64],{"type":23,"value":60},{"type":17,"tag":25,"props":66,"children":67},{},[68],{"type":23,"value":69},"魔乐社区推理代码：",{"type":17,"tag":25,"props":71,"children":72},{},[73],{"type":17,"tag":58,"props":74,"children":77},{"href":75,"rel":76},"https://modelers.cn/models/MindSpore-Lab/DeepSeek-V3",[62],[78],{"type":23,"value":75},{"type":17,"tag":25,"props":80,"children":81},{},[82],{"type":17,"tag":44,"props":83,"children":84},{},[85],{"type":23,"value":86},"以下是完整的手把手教程，助力开发者开箱即用",{"type":17,"tag":88,"props":89,"children":91},"h3",{"id":90},"预训练开箱流程",[92],{"type":17,"tag":44,"props":93,"children":94},{},[95],{"type":23,"value":96},"【预训练开箱流程】",{"type":17,"tag":25,"props":98,"children":99},{},[100],{"type":23,"value":101},"MindSpore Transformers支持对DeepSeek-V3进行预训练。仓库中提供了一份预训练配置文件供参考，该配置基于128台Atlas 800T A2 （64G），使用Wikitext-2数据集进行预训练，可参考多机教程进行使用：",{"type":17,"tag":25,"props":103,"children":104},{},[105],{"type":17,"tag":58,"props":106,"children":108},{"href":60,"rel":107},[62],[109],{"type":23,"value":60},{"type":17,"tag":25,"props":111,"children":112},{},[113],{"type":23,"value":114},"便于开发者上手体验，本章节基于此配置进行修改，缩小了DeepSeek-V3模型参数量，使其能够在单台Atlas 800T A2 （64G）上拉起预训练流程。",{"type":17,"tag":88,"props":116,"children":118},{"id":117},"一环境介绍",[119],{"type":17,"tag":44,"props":120,"children":121},{},[122],{"type":23,"value":123},"一、环境介绍",{"type":17,"tag":25,"props":125,"children":126},{},[127],{"type":23,"value":128},"准备一台Atlas 800T A2 （64G）训练服务器。MindSpore Transformers的环境依赖如下：",{"type":17,"tag":25,"props":130,"children":131},{},[132],{"type":23,"value":133},"Python",{"type":17,"tag":25,"props":135,"children":136},{},[137],{"type":23,"value":138},"MindSpore",{"type":17,"tag":25,"props":140,"children":141},{},[142],{"type":23,"value":143},"CANN",{"type":17,"tag":25,"props":145,"children":146},{},[147],{"type":23,"value":148},"固件与驱动",{"type":17,"tag":25,"props":150,"children":151},{},[152],{"type":23,"value":153},"3.10",{"type":17,"tag":25,"props":155,"children":156},{},[157],{"type":23,"value":158},"2.4.10",{"type":17,"tag":25,"props":160,"children":161},{},[162],{"type":23,"value":163},"8.0.RC3.beta1",{"type":17,"tag":25,"props":165,"children":166},{},[167],{"type":23,"value":168},"24.1.RC3",{"type":17,"tag":25,"props":170,"children":171},{},[172],{"type":23,"value":173},"提供了DeepSeek-V3预训练专用Docker镜像，通过如下步骤进行使用。",{"type":17,"tag":25,"props":175,"children":176},{},[177],{"type":23,"value":178},"1、下载Docker镜像",{"type":17,"tag":180,"props":181,"children":183},"pre",{"code":182}," docker pull swr.cn-central-221.ovaijisuan.com/mindformers/deepseek_v3_mindspore2.4.10-train:20250209\n",[184],{"type":17,"tag":185,"props":186,"children":187},"code",{"__ignoreMap":7},[188],{"type":23,"value":182},{"type":17,"tag":25,"props":190,"children":191},{},[192],{"type":23,"value":193},"2、基于镜像创建容器",{"type":17,"tag":25,"props":195,"children":196},{},[197],{"type":23,"value":198},"使用如下命令新建容器：",{"type":17,"tag":180,"props":200,"children":202},{"code":201}," image_name=swr.cn-central-221.ovaijisuan.com/mindformers/deepseek_v3_mindspore2.4.10-train:20250209\ndocker_name=deepseek_v3\ndocker run -itd -u root \\\n--ipc=host --net=host \\\n--privileged \\\n--device=/dev/davinci0 \\\n--device=/dev/davinci1 \\\n--device=/dev/davinci2 \\\n--device=/dev/davinci3 \\\n--device=/dev/davinci4 \\\n--device=/dev/davinci5 \\\n--device=/dev/davinci6 \\\n--device=/dev/davinci7 \\\n--device=/dev/davinci_manager \\\n--device=/dev/devmm_svm \\\n--device=/dev/hisi_hdc \\\n-v /etc/localtime:/etc/localtime \\\n-v /usr/local/Ascend/driver:/usr/local/Ascend/driver \\\n-v /usr/local/Ascend/driver/tools/hccn_tool:/usr/local/bin/hccn_tool \\\n-v /etc/ascend_install.info:/etc/ascend_install.info \\\n-v /var/log/npu:/usr/slog \\\n-v /usr/local/bin/npu-smi:/usr/local/bin/npu-smi \\\n-v /etc/hccn.conf:/etc/hccn.conf \\\n--name \"$docker_name\" \\\n\"$image_name\" \\\n/bin/bash\n",[203],{"type":17,"tag":185,"props":204,"children":205},{"__ignoreMap":7},[206],{"type":23,"value":201},{"type":17,"tag":25,"props":208,"children":209},{},[210],{"type":23,"value":211},"3、进入容器",{"type":17,"tag":25,"props":213,"children":214},{},[215],{"type":23,"value":216},"使用如下命令进入容器，并进入代码目录：",{"type":17,"tag":180,"props":218,"children":220},{"code":219}," docker exec -ti deepseek_v3 bash\n\n cd /home/work/mindformers\n",[221],{"type":17,"tag":185,"props":222,"children":223},{"__ignoreMap":7},[224],{"type":23,"value":219},{"type":17,"tag":88,"props":226,"children":228},{"id":227},"二-数据集准备",[229],{"type":17,"tag":44,"props":230,"children":231},{},[232],{"type":23,"value":233},"二、 数据集准备",{"type":17,"tag":25,"props":235,"children":236},{},[237],{"type":23,"value":238},"以Wikitext-2数据集为例，参考如下步骤将数据集处理成Megatron BIN式文件。",{"type":17,"tag":25,"props":240,"children":241},{},[242],{"type":23,"value":243},"1、下载数据集和分词模型文件",{"type":17,"tag":25,"props":245,"children":246},{},[247],{"type":23,"value":248},"数据集下载：WikiText2数据集",{"type":17,"tag":25,"props":250,"children":251},{},[252],{"type":17,"tag":58,"props":253,"children":256},{"href":254,"rel":255},"https://ascend-repo-modelzoo.obs.cn-east-2.myhuaweicloud.com/MindFormers/dataset/wikitext-2/wikitext-2-v1.zip",[62],[257],{"type":23,"value":254},{"type":17,"tag":25,"props":259,"children":260},{},[261],{"type":23,"value":262},"分词模型下载：DeepSeek-V3的tokenizer.json",{"type":17,"tag":25,"props":264,"children":265},{},[266],{"type":17,"tag":58,"props":267,"children":270},{"href":268,"rel":269},"https://huggingface.co/deepseek-ai/DeepSeek-V3/resolve/main/tokenizer.json?download=true",[62],[271],{"type":23,"value":268},{"type":17,"tag":25,"props":273,"children":274},{},[275],{"type":23,"value":276},"2、生成Megatron BIN格式文件",{"type":17,"tag":25,"props":278,"children":279},{},[280],{"type":23,"value":281},"将数据集文件wiki.train.tokens和分词模型文件tokenizer.json放置在/home/work/dataset下",{"type":17,"tag":25,"props":283,"children":284},{},[285],{"type":23,"value":286},"使用以下命令转换数据集文件",{"type":17,"tag":180,"props":288,"children":290},{"code":289},"cd /home/work/mindformers/research/deepseek3\n\n python wikitext_to_bin.py \\\n\n --input /home/work/dataset/wiki.train.tokens \\\n\n --output-prefix /home/work/dataset/wiki_4096 \\\n\n --vocab-file /home/work/dataset/tokenizer.json \\\n\n --seq-length 4096 \\\n\n --worker 1\n",[291],{"type":17,"tag":185,"props":292,"children":293},{"__ignoreMap":7},[294],{"type":23,"value":289},{"type":17,"tag":88,"props":296,"children":298},{"id":297},"三单机配置样例",[299],{"type":17,"tag":44,"props":300,"children":301},{},[302],{"type":23,"value":303},"三、单机配置样例",{"type":17,"tag":25,"props":305,"children":306},{},[307],{"type":23,"value":308},"基于预训练配置文件pretrain_deepseek3_671b.yaml按照如下步骤操作并保存为pretrain_deepseek3_1b.yaml。",{"type":17,"tag":25,"props":310,"children":311},{},[312],{"type":23,"value":313},"1、修改模型配置",{"type":17,"tag":180,"props":315,"children":317},{"code":316}," # model config\nmodel:\n  model_config:\n    type: DeepseekV3Config\n    auto_register: deepseek3_config.DeepseekV3Config\n    seq_length: 4096\n    hidden_size: 2048                                # 修改为2048\n    num_layers: &num_layers 3                       # 修改为3\n    num_heads: 8                                    # 修改为8\n    max_position_embeddings: 4096\n    intermediate_size: 6144                          # 修改为6144\n    offset: 0                                        # 修改为0\n    ……\n",[318],{"type":17,"tag":185,"props":319,"children":320},{"__ignoreMap":7},[321],{"type":23,"value":316},{"type":17,"tag":25,"props":323,"children":324},{},[325],{"type":23,"value":326},"2、修改MoE配置",{"type":17,"tag":180,"props":328,"children":330},{"code":329}," #moe\nmoe_config:\n  expert_num: &expert_num 16                      # 修改为16\n  first_k_dense_replace: 1                           # 修改为1\n  ……\n",[331],{"type":17,"tag":185,"props":332,"children":333},{"__ignoreMap":7},[334],{"type":23,"value":329},{"type":17,"tag":25,"props":336,"children":337},{},[338],{"type":23,"value":339},"3、修改并行配置",{"type":17,"tag":180,"props":341,"children":343},{"code":342}," # parallel config for devices num=8\nparallel_config:\n  data_parallel: 2                                   # 修改为2\n  model_parallel: 2                                 # 修改为2\n  pipeline_stage: 2                                 # 修改为2\n  expert_parallel: 2                                 # 修改为2\n  micro_batch_num: µ_batch_num 4           # 修改为4\n\n   parallel:\n\n     parallel_optimizer_config:\n\n       optimizer_weight_shard_size: 8                  # 修改为8\n  ……\n",[344],{"type":17,"tag":185,"props":345,"children":346},{"__ignoreMap":7},[347],{"type":23,"value":342},{"type":17,"tag":25,"props":349,"children":350},{},[351],{"type":23,"value":352},"4、修改学习率配置",{"type":17,"tag":180,"props":354,"children":356},{"code":355}," # lr schedule\n\n lr_schedule:\n\n   type: ConstantWarmUpLR\n\n   warmup_steps: 20                                    # 修改为20\n",[357],{"type":17,"tag":185,"props":358,"children":359},{"__ignoreMap":7},[360],{"type":23,"value":355},{"type":17,"tag":25,"props":362,"children":363},{},[364],{"type":23,"value":365},"5. 修改数据集配置",{"type":17,"tag":25,"props":367,"children":368},{},[369],{"type":23,"value":370},"配置数据集路径：",{"type":17,"tag":180,"props":372,"children":374},{"code":373},"# dataset\n\n train_dataset: &train_dataset\n\n   data_loader:\n type: BlendedMegatronDatasetDataLoader\n\n     config:\n\n       data_path:\n\n         - 1\n\n         - \"/home/work/dataset/wiki_4096_text_document\"  # 修改此项为数据集路径\n    ……\n",[375],{"type":17,"tag":185,"props":376,"children":377},{"__ignoreMap":7},[378],{"type":23,"value":373},{"type":17,"tag":25,"props":380,"children":381},{},[382],{"type":23,"value":383},"配置数据集并行通信配置路径：",{"type":17,"tag":180,"props":385,"children":387},{"code":386}," # mindspore context init config\n\n\n context:\n\n   ascend_config:\n\n     parallel_speed_up_json_path: \"/home/work/mindformers/research/deepseek3/parallel_speed_up.json\"  # 修改此项为数据集并行通信配置路径\n",[388],{"type":17,"tag":185,"props":389,"children":390},{"__ignoreMap":7},[391],{"type":23,"value":386},{"type":17,"tag":88,"props":393,"children":395},{"id":394},"四-拉起任务",[396],{"type":17,"tag":44,"props":397,"children":398},{},[399],{"type":23,"value":400},"四、 拉起任务",{"type":17,"tag":25,"props":402,"children":403},{},[404],{"type":23,"value":405},"进入代码根目录并执行以下命令拉起单台Atlas 800T A2（64G）预训练任务：",{"type":17,"tag":180,"props":407,"children":409},{"code":408},"cd /home/work/mindformers\nbash scripts/msrun_launcher.sh \"run_mindformer.py \\\n--register_path research/deepseek3 \\\n--config research/deepseek3/deepseek3_671b/pretrain_deepseek3_1b.yaml\"\n",[410],{"type":17,"tag":185,"props":411,"children":412},{"__ignoreMap":7},[413],{"type":23,"value":408},{"type":17,"tag":25,"props":415,"children":416},{},[417],{"type":23,"value":418},"启动脚本执行完毕会在后台拉起任务，日志保存在/home/work/mindformers/output/msrun_log下，使用以下命令查看训练日志（由于开启了流水并行pipeline_stage: 2，loss只显示在最后一张卡的日志worker_7.log中，其他日志显示loss为0）：",{"type":17,"tag":180,"props":420,"children":422},{"code":421},"tail -f /home/work/mindformers/output/msrun_log/worker_7.log\n",[423],{"type":17,"tag":185,"props":424,"children":425},{"__ignoreMap":7},[426],{"type":23,"value":421},{"type":17,"tag":25,"props":428,"children":429},{},[430],{"type":23,"value":431},"训练loss的曲线图如下",{"type":17,"tag":25,"props":433,"children":434},{},[435],{"type":17,"tag":436,"props":437,"children":439},"img",{"alt":7,"src":438},"https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2025/02/09/b093db6a9a684bf499d9f93d791c50b7.png",[],{"type":17,"tag":25,"props":441,"children":442},{},[443],{"type":23,"value":444},"训练过程中的权重checkpoint将会保存在/home/work/mindformers/output/checkpoint下。",{"type":17,"tag":88,"props":446,"children":448},{"id":447},"推理部署开箱流程",[449],{"type":17,"tag":44,"props":450,"children":451},{},[452],{"type":23,"value":453},"【推理部署开箱流程】",{"type":17,"tag":25,"props":455,"children":456},{},[457],{"type":23,"value":458},"采用BF16格式的模型权重文件，运行DeepSeek-V3推理服务，需要4台Atlas 800I A2（64G）服务器。为缩短开发部署周期，昇思MindSpore此次提供了docker容器镜像，供开发者快速体验。其主要操作步骤如下：",{"type":17,"tag":25,"props":460,"children":461},{},[462],{"type":23,"value":463},"执行以下Shell命令，下载昇思MindSpore DeepSeek-V3推理容器镜像：",{"type":17,"tag":180,"props":465,"children":467},{"code":466},"docker pull swr.cn-central-221.ovaijisuan.com/mindformers/deepseek_v3_mindspore2.5.0-infer:20250209\n",[468],{"type":17,"tag":185,"props":469,"children":470},{"__ignoreMap":7},[471],{"type":23,"value":466},{"type":17,"tag":25,"props":473,"children":474},{},[475],{"type":23,"value":476},"执行以下Shell命令，启动容器镜像，后续操作将均在容器内进行：",{"type":17,"tag":180,"props":478,"children":480},{"code":479},"docker run -itd --privileged  --name=deepseek-v3 --net=host \\\n\n   --shm-size 500g \\\n\n   --device=/dev/davinci0 \\\n\n   --device=/dev/davinci1 \\\n\n   --device=/dev/davinci2 \\\n\n   --device=/dev/davinci3 \\\n\n   --device=/dev/davinci4 \\\n\n   --device=/dev/davinci5 \\\n\n   --device=/dev/davinci6 \\\n\n   --device=/dev/davinci7 \\\n\n   --device=/dev/davinci_manager \\\n\n   --device=/dev/hisi_hdc \\\n\n   --device /dev/devmm_svm \\\n\n   -v /usr/local/Ascend/driver:/usr/local/Ascend/driver \\\n\n   -v /usr/local/Ascend/firmware:/usr/local/Ascend/firmware \\\n\n   -v /usr/local/sbin/npu-smi:/usr/local/sbin/npu-smi \\\n\n   -v /usr/local/sbin:/usr/local/sbin \\\n\n   -v /etc/hccn.conf:/etc/hccn.conf \\\n\n   deepseek_v3_mindspore2.5.0-infer:20250209 \\\n\n   bash\n",[481],{"type":17,"tag":185,"props":482,"children":483},{"__ignoreMap":7},[484],{"type":23,"value":479},{"type":17,"tag":25,"props":486,"children":487},{},[488],{"type":23,"value":489},"执行以下Shell命令，将用于下载存储DeepSeek-V3权重文件的路径（开箱示例中为./model_path），添加至白名单：",{"type":17,"tag":180,"props":491,"children":493},{"code":492},"export HUB_WHITE_LIST_PATHS=./model_path\n",[494],{"type":17,"tag":185,"props":495,"children":496},{"__ignoreMap":7},[497],{"type":23,"value":492},{"type":17,"tag":25,"props":499,"children":500},{},[501],{"type":23,"value":502},"使用以下Python脚本，从魔乐社区下载昇思MindSpore版本的DeepSeek-V3权重文件至指定路径。完整的权重文件约1.4TB，请确保指定路径下有充足的可用磁盘空间：",{"type":17,"tag":180,"props":504,"children":506},{"code":505},"from openmind_hub import snapshot_download\n\nsnapshot_download(\n\n    repo_id=\"MindSpore-Lab/DeepSeek-V3\",\n\n    local_dir=\"./model_path\",\n\n    local_dir_use_symlink=False\n\n)\n",[507],{"type":17,"tag":185,"props":508,"children":509},{"__ignoreMap":7},[510],{"type":23,"value":505},{"type":17,"tag":25,"props":512,"children":513},{},[514],{"type":23,"value":515},"将./model_path/examples/predict_deepseek3_671B.yaml文件中的load_checkpoint参数配置为权重文件夹绝对路径，并将tokenizer_file参数和vocab_file参数配置为tokenizer.json文件绝对路径。",{"type":17,"tag":25,"props":517,"children":518},{},[519],{"type":23,"value":520},"在第1台至第4台服务器上，分别执行以下Shell命令，通过msrun_launcher.sh启动单次推理测试脚本run_deepseekv3_predict.py，完成后将显示“生抽和老抽的区别是什么？ ”的问题回复。其中，master_ip需修改设置为第1台服务器的实际IP地址。",{"type":17,"tag":180,"props":522,"children":524},{"code":523},"# 第1台服务器（Node 0）\n\nexport PYTHONPATH=/root/mindformers/:$PYTHONPATH\n\nexport HCCL_OP_EXPANSION_MODE=AIV\nexport MS_ENABLE_LCCL=off\n\nmaster_ip=192.168.1.1\n\ncd model_path/DeepSeek-V3/examples\n\nbash msrun_launcher.sh \"run_deepseekv3_predict.py\" 32 8 $master_ip 8888 0 output/msrun_log False 300\n\n# 第2台服务器（Node 1）\n\nexport PYTHONPATH=/root/mindformers/:$PYTHONPATH\n\nexport HCCL_OP_EXPANSION_MODE=AIV\nexport MS_ENABLE_LCCL=off\n\nmaster_ip=192.168.1.1\n\ncd model_path/DeepSeek-V3/examples\n\nbash msrun_launcher.sh \"run_deepseekv3_predict.py\" 32 8 $master_ip 8888 1 output/msrun_log False 300\n\n# 第3台服务器（Node 2）\n\nexport PYTHONPATH=/root/mindformers/:$PYTHONPATH\n\nexport HCCL_OP_EXPANSION_MODE=AIV\nexport MS_ENABLE_LCCL=off\n\nmaster_ip=192.168.1.1\n\ncd model_path/DeepSeek-V3/examples\n\nbash msrun_launcher.sh \"run_deepseekv3_predict.py\" 32 8 $master_ip 8888 2 output/msrun_log False 300\n\n# 第4台服务器（Node 3）\n\nexport PYTHONPATH=/root/mindformers/:$PYTHONPATH\n\nexport HCCL_OP_EXPANSION_MODE=AIV\nexport MS_ENABLE_LCCL=off\n\nmaster_ip=192.168.1.1\n\ncd model_path/DeepSeek-V3/examples\n\nbash msrun_launcher.sh \"run_deepseekv3_predict.py\" 32 8 $master_ip 8888 3 output/msrun_log False 300\n",[525],{"type":17,"tag":185,"props":526,"children":527},{"__ignoreMap":7},[528],{"type":23,"value":523},{"type":17,"tag":25,"props":530,"children":531},{},[532],{"type":23,"value":533},"此外，还可参考魔乐社区MindSpore-Lab/DeepSeek-V3模型仓的ReadMe指引，进行推理服务化部署，然后通过访问与OpenAI兼容的RESTful服务端口，体验多轮对话服务。",{"type":17,"tag":88,"props":535,"children":537},{"id":536},"_1-mindspore支持deepseek-v3增量模块的快速开发",[538,540],{"type":23,"value":539},"1. ",{"type":17,"tag":44,"props":541,"children":542},{},[543],{"type":23,"value":544},"MindSpore支持DeepSeek V3增量模块的快速开发",{"type":17,"tag":25,"props":546,"children":547},{},[548],{"type":17,"tag":44,"props":549,"children":550},{},[551],{"type":23,"value":552},"DeepSeek V3的关键网络结构的支持：",{"type":17,"tag":554,"props":555,"children":556},"ul",{},[557,563,568],{"type":17,"tag":558,"props":559,"children":560},"li",{},[561],{"type":23,"value":562},"**MTP：**在MTP模块中，MindSpore通过shard()接口对MPT入口处的激活融合结构配置了序列并行，消除不必要的通讯重排。通过set_pipeline_stage()接口实现了embedding矩阵在first_stage和last_stage间的参数共享，即由first_stage负责维护embedding的参数更新，训练前向时发送给last_stage，训练反向时从last_stage回收梯度。",{"type":17,"tag":558,"props":564,"children":565},{},[566],{"type":23,"value":567},"**AuxFree Balance：**MindSpore的MoE模块中已支持全局的Expert负载统计, AuxFree Balance机制的实现是在callback中新增了根据全局专家负载而更新专家偏置的逻辑，从而达到在每个train step结束后做一次负载均衡调整的目的。",{"type":17,"tag":558,"props":569,"children":570},{},[571],{"type":23,"value":572},"**MoE Sigmoid激活：**在Router score后的激活函数部分新增了可配置项，用户可以通过yaml文件灵活选择softmax或sigmoid作为激活函数，支持开发者灵活选择。",{"type":17,"tag":88,"props":574,"children":576},{"id":575},"_2-mindspore对于deepseek-v3推理网络的实现和优化",[577,579],{"type":23,"value":578},"2. ",{"type":17,"tag":44,"props":580,"children":581},{},[582],{"type":23,"value":583},"MindSpore对于DeepSeek V3推理网络的实现和优化",{"type":17,"tag":25,"props":585,"children":586},{},[587],{"type":23,"value":588},"MindSpore针对DeepSeek V3的网络结构特点，高效地实现和优化了更高效的推理网络，最大化地压缩算子下发耗时和提升网络推理性能。",{"type":17,"tag":554,"props":590,"children":591},{},[592,597,604,620,627,642],{"type":17,"tag":558,"props":593,"children":594},{},[595],{"type":23,"value":596},"**MLA：**将FC、MatMul等超过10个小算子，融合成单个InferAttention-MLA算子，然后将其与已有的PageAttention算子，组合实现MLA模块功能。同时，在InferAttention-MLA算子内，设计了Key-Value张量存储复用机制，减少存储资源占用。",{"type":17,"tag":558,"props":598,"children":599},{},[600],{"type":17,"tag":436,"props":601,"children":603},{"alt":7,"src":602},"https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2025/02/09/06e15338574b49f9987f5ff2f74ade1b.png",[],{"type":17,"tag":558,"props":605,"children":606},{},[607,609,613,618],{"type":23,"value":608},"图1 MLA推理网络实现原理",{"type":17,"tag":610,"props":611,"children":612},"br",{},[],{"type":17,"tag":44,"props":614,"children":615},{},[616],{"type":23,"value":617},"DeepSeekMoE",{"type":23,"value":619},"：MindSpore优化精简了MoE的推理代码实现，并新增实现MoeUnpermuteToken、MoeInitRouting等多个融合大算子，用于组合实现DeepSeek-V3的MoE单元，降低了单个MoE单元的推理时延。",{"type":17,"tag":558,"props":621,"children":622},{},[623],{"type":17,"tag":436,"props":624,"children":626},{"alt":7,"src":625},"https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2025/02/09/5f6e435f9ee840a19429670949515ceb.png",[],{"type":17,"tag":558,"props":628,"children":629},{},[630,632,635,640],{"type":23,"value":631},"图2 DeepSeekMoE推理网络实现原理",{"type":17,"tag":610,"props":633,"children":634},{},[],{"type":17,"tag":44,"props":636,"children":637},{},[638],{"type":23,"value":639},"图编译",{"type":23,"value":641},"：MindSpore推理使用了图编译进行加速，通过对整图进行Pattern匹配，无需修改模型脚本，即可实现整图的通用融合。以DeepSeekV3为例，在图编译过程中实现了Add+RmsNorm、SplitWithSize+SiLU+Mul等众多Pattern的自动融合。",{"type":17,"tag":558,"props":643,"children":644},{},[645,649,652],{"type":17,"tag":436,"props":646,"children":648},{"alt":7,"src":647},"https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2025/02/09/5193a3dd768a43688c51193fe0d88ba1.png",[],{"type":17,"tag":610,"props":650,"children":651},{},[],{"type":23,"value":653},"图3 图编译原理",{"type":17,"tag":88,"props":655,"children":657},{"id":656},"_3-mindspore框架特性助力deepseek-v3训练性能提升",[658],{"type":17,"tag":44,"props":659,"children":660},{},[661],{"type":23,"value":662},"3. MindSpore框架特性助力DeepSeek V3训练性能提升",{"type":17,"tag":25,"props":664,"children":665},{},[666,671],{"type":17,"tag":44,"props":667,"children":668},{},[669],{"type":23,"value":670},"DeepSeek V3的训推适配过程中，通过MindSpore的",{"type":23,"value":672},"MoE模块优化、Dryrun仿真等技术**，在优化MoE的训练流程的同时，还实现了更高效的多维混合并行。**",{"type":17,"tag":25,"props":674,"children":675},{},[676],{"type":17,"tag":44,"props":677,"children":678},{},[679,684],{"type":17,"tag":44,"props":680,"children":681},{},[682],{"type":23,"value":683},"MoE模块优化",{"type":23,"value":685},"：在MoE模块中可支持多种主流结构可配置，如共享专家、路由专家个数、激活函数选择等，极大地提升了模型的灵活性。在MoE并行方面支持TP-extend-EP、路由序列并行、MoE计算通讯掩盖、分组AllToAll通讯等多种并行模式和并行优化，用户可在配置中更灵活地使用相关并行加速能力。",{"type":17,"tag":25,"props":687,"children":688},{},[689],{"type":17,"tag":44,"props":690,"children":691},{},[692,697],{"type":17,"tag":44,"props":693,"children":694},{},[695],{"type":23,"value":696},"Dryrun集群内存仿真与自动负载均衡",{"type":23,"value":698},"：MindSpore的Dryrun工具可以根据训练任务模拟出集群中每卡的内存占用情况，从而在不实际占用集群的情况下，为训练的分布式并行策略调优提供快捷反馈。自动负载均衡工具SAPP为DeepSeek V3通过精确建模内存和计算负载，在内存约束条件下，求解最优的流水线并行的各Stage层数与重计算量，分钟级开销内自动获得最优流水线配置。",{"type":17,"tag":25,"props":700,"children":701},{},[702],{"type":17,"tag":44,"props":703,"children":704},{},[705],{"type":23,"value":706},"下一步，昇思MindSpore开源社区将上线DeepSeek V3微调样例与R1版本镜像，为开发者提供开箱即用的模型。未来，昇思开源社区将依托丰富的技术能力，持续优化DeepSeek V3系列模型的性能，加速模型从训练到生产部署端到端的创新效率，为开源开发者进行大模型创新提供了高效易用的基础软件与技术生态，促进千行万业智能化转型升级。",{"type":17,"tag":25,"props":708,"children":709},{},[710],{"type":17,"tag":44,"props":711,"children":712},{},[713],{"type":23,"value":714},"在使用模型中，有任何疑问和建议，均可通过社区进行反馈。",{"type":17,"tag":25,"props":716,"children":717},{},[718],{"type":17,"tag":44,"props":719,"children":720},{},[721],{"type":23,"value":722},"昇思MindSpore开源社区DeepSeek V3使用问题讨论issue：",{"type":17,"tag":25,"props":724,"children":725},{},[726],{"type":17,"tag":44,"props":727,"children":728},{},[729],{"type":17,"tag":58,"props":730,"children":733},{"href":731,"rel":732},"https://gitee.com/mindspore/mindformers/issues/IBL0X5?from=project-issue",[62],[],{"type":17,"tag":25,"props":735,"children":736},{},[737],{"type":17,"tag":44,"props":738,"children":739},{},[740],{"type":17,"tag":58,"props":741,"children":743},{"href":731,"rel":742},[62],[],{"type":17,"tag":25,"props":745,"children":746},{},[747],{"type":17,"tag":44,"props":748,"children":749},{},[750],{"type":17,"tag":58,"props":751,"children":753},{"href":731,"rel":752},[62],[],{"type":17,"tag":25,"props":755,"children":756},{},[757],{"type":17,"tag":44,"props":758,"children":759},{},[760],{"type":17,"tag":58,"props":761,"children":763},{"href":731,"rel":762},[62],[764],{"type":23,"value":731},{"type":17,"tag":25,"props":766,"children":767},{},[768],{"type":17,"tag":44,"props":769,"children":770},{},[771],{"type":23,"value":772},"昇腾社区昇思论坛DeepSeek V3使用问题讨论帖：",{"type":17,"tag":25,"props":774,"children":775},{},[776],{"type":17,"tag":44,"props":777,"children":778},{},[779],{"type":17,"tag":58,"props":780,"children":783},{"href":781,"rel":782},"https://www.hiascend.com/forum/thread-02112174450796469017-1-1.html",[62],[],{"type":17,"tag":25,"props":785,"children":786},{},[787],{"type":17,"tag":44,"props":788,"children":789},{},[790],{"type":17,"tag":58,"props":791,"children":793},{"href":781,"rel":792},[62],[794],{"type":23,"value":781},{"title":7,"searchDepth":796,"depth":796,"links":797},4,[798,800,801,802,803,804,805,807,809],{"id":90,"depth":799,"text":96},3,{"id":117,"depth":799,"text":123},{"id":227,"depth":799,"text":233},{"id":297,"depth":799,"text":303},{"id":394,"depth":799,"text":400},{"id":447,"depth":799,"text":453},{"id":536,"depth":799,"text":806},"1. MindSpore支持DeepSeek V3增量模块的快速开发",{"id":575,"depth":799,"text":808},"2. MindSpore对于DeepSeek V3推理网络的实现和优化",{"id":656,"depth":799,"text":662},"markdown","content:news:zh:3598.md","content","news/zh/3598.md","news/zh/3598","md",1776506085909]