torchtitan-npu:基于昇腾(Ascend)的PyTorch训练后端扩展插件项目

Ascend Extension for torchtitan

分支2Tags3
文件最后提交记录最后更新时间
[refactor] Remove the code related to the legacy converter mechanism Co-authored-by: zhaiyukun<zhaiyukun@huawei.com> # message auto-generated for no-merge-commit merge: !249 merge remove_base_converter into master [refactor] Remove the code related to the legacy converter mechanism Created-by: zhaiyukun Commit-by: zhaiyukun Merged-by: cann-robot Description: ## 描述 删除不再使用的旧Converter机制相关代码: 1. 删除不再使用的类BaseConverter、NPUConverter、ConverterRegistry 2. 移除文件(base_converter/npu_converter/registry) 3. npu_registry.py重命名为registry.py 4. 将has_npu_converter 移入 registry.py 并简化为仅匹配 ModelCustomConfig 模式 5. 更新所有 import 路径和相关注释、文档 ## 类型 - [ ] Bug 修复 - [ ] 新功能 - [x] 重构(即不是新增功能,也不是修改bug的代码变动) - [ ] 构建过程或辅助工具的变动 - [ ] 文档内容更新 ## Checklist: - [x] 我的代码遵循这个项目的代码风格 - [x] 我已经自己测试过我的代码 - [x] 我已经更新了相应的文档 - [x] 我已经在标题中正确使用了类型标签(例如:feat, fix, refactor, docs, test) ## 如何测试 测试DeepSeek-V3/DeepSeek-V32/DeepSeek-V4均正常。 See merge request: cann/torchtitan-npu!2491 天前
修改脚本cann包链接 Co-authored-by: liuyuanchen1<liuyuanchen1@huawei.com> # message auto-generated for no-merge-commit merge: !265 merge cann2 into master 修改脚本cann包链接 Created-by: liuyuanchen1 Commit-by: liuyuanchen1 Merged-by: cann-robot Description: ## 描述 请提供此Pull Request的预期功能,以方便检视。 ## 类型 - [ ] Bug 修复 - [ ] 新功能 - [ ] 重构(即不是新增功能,也不是修改bug的代码变动) - [ ] 构建过程或辅助工具的变动 - [x] 文档内容更新 ## Checklist: - [x] 我的代码遵循这个项目的代码风格 - [x] 我已经自己测试过我的代码 - [x] 我已经更新了相应的文档 - [x] 我已经在标题中正确使用了类型标签(例如:feat, fix, refactor, docs, test) ## 如何测试 不涉及 ## 其他信息 在这里可以添加任何与这个 Pull Request 相关的其他说明。 See merge request: cann/torchtitan-npu!2652 天前
[feat] Add hooks for Claude Code , OpenCode and CodeX to automatically load skills. Co-authored-by: 1Fire4<wangdingyi2@huawei.com> # message auto-generated for no-merge-commit merge: !165 merge dev_add_agent_hook into master [feat] Add hooks for Claude Code , OpenCode and CodeX to automatically load skills. Created-by: hitwdy Commit-by: 1Fire4 Merged-by: cann-robot Description: ## 描述 增加claude code和opencode及codex的hook以自动加载skill,无需手动执行setup_agent.sh ## 类型 - [ ] Bug 修复 - [x] 新功能 - [ ] 重构(即不是新增功能,也不是修改bug的代码变动) - [ ] 构建过程或辅助工具的变动 - [ ] 文档内容更新 ## Checklist: - [x] 我的代码遵循这个项目的代码风格 - [x] 我已经自己测试过我的代码 - [x] 我已经更新了相应的文档 - [x] 我已经在标题中正确使用了类型标签(例如:feat, fix, refactor, docs, test) See merge request: cann/torchtitan-npu!16510 天前
[feat] Add hooks for Claude Code , OpenCode and CodeX to automatically load skills. Co-authored-by: 1Fire4<wangdingyi2@huawei.com> # message auto-generated for no-merge-commit merge: !165 merge dev_add_agent_hook into master [feat] Add hooks for Claude Code , OpenCode and CodeX to automatically load skills. Created-by: hitwdy Commit-by: 1Fire4 Merged-by: cann-robot Description: ## 描述 增加claude code和opencode及codex的hook以自动加载skill,无需手动执行setup_agent.sh ## 类型 - [ ] Bug 修复 - [x] 新功能 - [ ] 重构(即不是新增功能,也不是修改bug的代码变动) - [ ] 构建过程或辅助工具的变动 - [ ] 文档内容更新 ## Checklist: - [x] 我的代码遵循这个项目的代码风格 - [x] 我已经自己测试过我的代码 - [x] 我已经更新了相应的文档 - [x] 我已经在标题中正确使用了类型标签(例如:feat, fix, refactor, docs, test) See merge request: cann/torchtitan-npu!16510 天前
修改脚本cann包链接 Co-authored-by: liuyuanchen1<liuyuanchen1@huawei.com> # message auto-generated for no-merge-commit merge: !265 merge cann2 into master 修改脚本cann包链接 Created-by: liuyuanchen1 Commit-by: liuyuanchen1 Merged-by: cann-robot Description: ## 描述 请提供此Pull Request的预期功能,以方便检视。 ## 类型 - [ ] Bug 修复 - [ ] 新功能 - [ ] 重构(即不是新增功能,也不是修改bug的代码变动) - [ ] 构建过程或辅助工具的变动 - [x] 文档内容更新 ## Checklist: - [x] 我的代码遵循这个项目的代码风格 - [x] 我已经自己测试过我的代码 - [x] 我已经更新了相应的文档 - [x] 我已经在标题中正确使用了类型标签(例如:feat, fix, refactor, docs, test) ## 如何测试 不涉及 ## 其他信息 在这里可以添加任何与这个 Pull Request 相关的其他说明。 See merge request: cann/torchtitan-npu!2652 天前
[docs] add PR/Issue template Co-authored-by: depeng1994<zhangdepeng2@huawei.com> # message auto-generated for no-merge-commit merge: !11 merge master into master [docs] add PR/Issue template Created-by: depeng1994 Commit-by: depeng1994 Merged-by: cann-robot Description: [docs] add PR/Issue template See merge request: cann/torchtitan-npu!113 个月前
[feat] add some github workflow: sync all branches from gitcode/deploy mkdocs Co-authored-by: mystri<hanboyou@huawei.com> # message auto-generated for no-merge-commit merge: !233 merge feat/deploy-docs-sync into master [feat] add some github workflow: sync all branches from gitcode/deploy mkdocs Created-by: mystri Commit-by: mystri Merged-by: cann-robot Description: ## 描述 - Sync all upstream branches — sync-upstream.yml now fetches and pushes every branch from cann/torchtitan-npu, not just master - Auto-deploy docs — new deploy-docs.yml builds mkdocs and deploys to torchtitan-npu.github.io/torchtitan-npu on push to master, manual dispatch, or after a successful upstream sync - mkdocs setup — config, image-path rewrite hook, and docs/index.md that pulls in README Notes - deploy-docs uses workflow_run to chain after Sync Upstream. - Badges inside the <div align="center"> block may render as text on mkdocs due to Python-Markdown not parsing markdown inside HTML blocks. Converted them to <a><img> tags ## 类型 - [ ] Bug 修复 - [ ] 新功能 - [ ] 重构(即不是新增功能,也不是修改bug的代码变动) - [x] 构建过程或辅助工具的变动 - [ ] 文档内容更新 ## Checklist: - [x] 我的代码遵循这个项目的代码风格 - [x] 我已经自己测试过我的代码 - [x] 我已经更新了相应的文档 - [x] 我已经在标题中正确使用了类型标签(例如:feat, fix, refactor, docs, test) ## 如何测试 Tried executing workflow on github and both worked. ## 其他信息 在这里可以添加任何与这个 Pull Request 相关的其他说明。 See merge request: cann/torchtitan-npu!2337 天前
[feat] Add hooks for Claude Code , OpenCode and CodeX to automatically load skills. Co-authored-by: 1Fire4<wangdingyi2@huawei.com> # message auto-generated for no-merge-commit merge: !165 merge dev_add_agent_hook into master [feat] Add hooks for Claude Code , OpenCode and CodeX to automatically load skills. Created-by: hitwdy Commit-by: 1Fire4 Merged-by: cann-robot Description: ## 描述 增加claude code和opencode及codex的hook以自动加载skill,无需手动执行setup_agent.sh ## 类型 - [ ] Bug 修复 - [x] 新功能 - [ ] 重构(即不是新增功能,也不是修改bug的代码变动) - [ ] 构建过程或辅助工具的变动 - [ ] 文档内容更新 ## Checklist: - [x] 我的代码遵循这个项目的代码风格 - [x] 我已经自己测试过我的代码 - [x] 我已经更新了相应的文档 - [x] 我已经在标题中正确使用了类型标签(例如:feat, fix, refactor, docs, test) See merge request: cann/torchtitan-npu!16510 天前
[docs] add user_guide.md Co-authored-by: CjianForBetter<2318164299@qq.com> # message auto-generated for no-merge-commit merge: !116 merge user_guide into master [docs] add user_guide.md Created-by: CjianForBetter Commit-by: CjianForBetter Merged-by: cann-robot Description: ## 描述 1.修改readme.md文档,并增加安装说明和快速入门文档,方便用户上手。 2.多机脚本scripts/run_train_multinodes.sh文件的config,由于toml文件名更改了,直接运行会显示toml文件找不到,因此需要同步更改 ## 类型 - [ ] Bug 修复 - [ ] 新功能 - [ ] 重构(即不是新增功能,也不是修改bug的代码变动) - [ ] 构建过程或辅助工具的变动 - [x] 文档内容更新 ## Checklist: - [ ] 我的代码遵循这个项目的代码风格 - [ ] 我已经自己测试过我的代码 - [x] 我已经更新了相应的文档 - [x] 我已经在标题中正确使用了类型标签(例如:feat, fix, refactor, docs, test) ## 如何测试 简要描述测试方案,并附上自验证记录。 ## 其他信息 在这里可以添加任何与这个 Pull Request 相关的其他说明。 See merge request: cann/torchtitan-npu!1161 个月前
[docs]补充文档中版本信息 Co-authored-by: liuyuanchen1<liuyuanchen1@huawei.com> # message auto-generated for no-merge-commit merge: !279 merge cann_fix into master [docs]补充文档中版本信息 Created-by: liuyuanchen1 Commit-by: liuyuanchen1 Merged-by: cann-robot Description: ## 描述 修改https://gitcode.com/cann/torchtitan-npu/issues/42中文本错误信息。 ## 类型 - [ ] Bug 修复 - [ ] 新功能 - [ ] 重构(即不是新增功能,也不是修改bug的代码变动) - [ ] 构建过程或辅助工具的变动 - [x] 文档内容更新 ## Checklist: - [x] 我的代码遵循这个项目的代码风格 - [x] 我已经自己测试过我的代码 - [x] 我已经更新了相应的文档 - [x] 我已经在标题中正确使用了类型标签(例如:feat, fix, refactor, docs, test) ## 如何测试 不涉及代码修改 ## 其他信息 在这里可以添加任何与这个 Pull Request 相关的其他说明。 See merge request: cann/torchtitan-npu!2799 小时前
修改脚本cann包链接 Co-authored-by: liuyuanchen1<liuyuanchen1@huawei.com> # message auto-generated for no-merge-commit merge: !265 merge cann2 into master 修改脚本cann包链接 Created-by: liuyuanchen1 Commit-by: liuyuanchen1 Merged-by: cann-robot Description: ## 描述 请提供此Pull Request的预期功能,以方便检视。 ## 类型 - [ ] Bug 修复 - [ ] 新功能 - [ ] 重构(即不是新增功能,也不是修改bug的代码变动) - [ ] 构建过程或辅助工具的变动 - [x] 文档内容更新 ## Checklist: - [x] 我的代码遵循这个项目的代码风格 - [x] 我已经自己测试过我的代码 - [x] 我已经更新了相应的文档 - [x] 我已经在标题中正确使用了类型标签(例如:feat, fix, refactor, docs, test) ## 如何测试 不涉及 ## 其他信息 在这里可以添加任何与这个 Pull Request 相关的其他说明。 See merge request: cann/torchtitan-npu!2652 天前
[fix] fix mtp hf mapping strategy for master Co-authored-by: zhangjianshe<1603088851@qq.com> # message auto-generated for no-merge-commit merge: !263 merge mtp-master into master [fix] fix mtp hf mapping strategy for master Created-by: zhangjianshe Commit-by: zhangjianshe Merged-by: cann-robot Description: ## 描述 - 修复了deepseek_v4模型MTP模块的hf权重转换逻辑,确保与官方hf权重分布保持一致。 ## 类型 - [x] Bug 修复 - [ ] 新功能 - [ ] 重构(即不是新增功能,也不是修改bug的代码变动) - [ ] 构建过程或辅助工具的变动 - [ ] 文档内容更新 ## Checklist: - [x] 我的代码遵循这个项目的代码风格 - [x] 我已经自己测试过我的代码 - [x] 我已经更新了相应的文档 - [x] 我已经在标题中正确使用了类型标签(例如:feat, fix, refactor, docs, test) ## 如何测试 4层减层模型+MTP层 hf转换前后key值统计对比 | Module | Sub-module | original hf | saved by titan | |--|--|--|--| | embed | embed.weight | 1 | 1 | | hc_head | hc_head_base/fn/scale | 3 | 3 | | head | head.weight (lm_head) | 1 | 1 | | norm | norm.weight | 1 | 1 | | layers.0-3 | attn.* (wq_a/b, wkv, wo_a/b, q_norm, kv_norm, attn_sink) | 各4 | 各4 | | layers.0-3 | attn.compressor | 8 | 8 | | layers.0-3 | attn.indexer | 6 | 6 | | layers.0-3 | attn_norm.weight | 4 | 4 | | layers.0-3 | ffn.experts.*.w1 | 1024 | 1024 | | layers.0-3 | ffn.experts.*.w2 | 1024 | 1024 | | layers.0-3 | ffn.experts.*.w3 | 1024 | 1024 | | layers.0-3 | ffn.gate | 8 | 8 | | layers.0-3 | ffn.shared_experts.w1/w2/w3 | 各4 | 各4 | | layers.0-3 | ffn_norm.weight | 4 | 4 | | layers.0-3 | hc_attn_base/fn/scale | 各4 | 各4 | | layers.0-3 | hc_ffn_base/fn/scale | 各4 | 各4 | | mtp.0 | attn.* (wq_a/b, wkv, wo_a/b, q_norm, kv_norm, attn_sink) | 各1 | 各1 | | mtp.0 | attn_norm | 1 | 1 | | mtp.0 | ffn.experts.*.w1/w2/w3 | 各256 | 各256 | | mtp.0 | ffn.gate | 2 | 2 | | mtp.0 | ffn.shared_experts.w1/w2/w3 | 各1 | 各1 | | mtp.0 | ffn_norm / norm / hnorm | 各1 | 各1 | | mtp.0 | e_proj / emb.tok_emb / enorm / h_proj | 各1 | 各1 | | mtp.0 | hc_attn_* / hc_ffn_* / hc_head_* | 各1 | 各1 | | mtp.0 | head | 1 | 1 | ## 其他信息 在这里可以添加任何与这个 Pull Request 相关的其他说明。 See merge request: cann/torchtitan-npu!2635 小时前
[fix] fix mtp hf mapping strategy for master Co-authored-by: zhangjianshe<1603088851@qq.com> # message auto-generated for no-merge-commit merge: !263 merge mtp-master into master [fix] fix mtp hf mapping strategy for master Created-by: zhangjianshe Commit-by: zhangjianshe Merged-by: cann-robot Description: ## 描述 - 修复了deepseek_v4模型MTP模块的hf权重转换逻辑,确保与官方hf权重分布保持一致。 ## 类型 - [x] Bug 修复 - [ ] 新功能 - [ ] 重构(即不是新增功能,也不是修改bug的代码变动) - [ ] 构建过程或辅助工具的变动 - [ ] 文档内容更新 ## Checklist: - [x] 我的代码遵循这个项目的代码风格 - [x] 我已经自己测试过我的代码 - [x] 我已经更新了相应的文档 - [x] 我已经在标题中正确使用了类型标签(例如:feat, fix, refactor, docs, test) ## 如何测试 4层减层模型+MTP层 hf转换前后key值统计对比 | Module | Sub-module | original hf | saved by titan | |--|--|--|--| | embed | embed.weight | 1 | 1 | | hc_head | hc_head_base/fn/scale | 3 | 3 | | head | head.weight (lm_head) | 1 | 1 | | norm | norm.weight | 1 | 1 | | layers.0-3 | attn.* (wq_a/b, wkv, wo_a/b, q_norm, kv_norm, attn_sink) | 各4 | 各4 | | layers.0-3 | attn.compressor | 8 | 8 | | layers.0-3 | attn.indexer | 6 | 6 | | layers.0-3 | attn_norm.weight | 4 | 4 | | layers.0-3 | ffn.experts.*.w1 | 1024 | 1024 | | layers.0-3 | ffn.experts.*.w2 | 1024 | 1024 | | layers.0-3 | ffn.experts.*.w3 | 1024 | 1024 | | layers.0-3 | ffn.gate | 8 | 8 | | layers.0-3 | ffn.shared_experts.w1/w2/w3 | 各4 | 各4 | | layers.0-3 | ffn_norm.weight | 4 | 4 | | layers.0-3 | hc_attn_base/fn/scale | 各4 | 各4 | | layers.0-3 | hc_ffn_base/fn/scale | 各4 | 各4 | | mtp.0 | attn.* (wq_a/b, wkv, wo_a/b, q_norm, kv_norm, attn_sink) | 各1 | 各1 | | mtp.0 | attn_norm | 1 | 1 | | mtp.0 | ffn.experts.*.w1/w2/w3 | 各256 | 各256 | | mtp.0 | ffn.gate | 2 | 2 | | mtp.0 | ffn.shared_experts.w1/w2/w3 | 各1 | 各1 | | mtp.0 | ffn_norm / norm / hnorm | 各1 | 各1 | | mtp.0 | e_proj / emb.tok_emb / enorm / h_proj | 各1 | 各1 | | mtp.0 | hc_attn_* / hc_ffn_* / hc_head_* | 各1 | 各1 | | mtp.0 | head | 1 | 1 | ## 其他信息 在这里可以添加任何与这个 Pull Request 相关的其他说明。 See merge request: cann/torchtitan-npu!2635 小时前
[refactor] Adapted torchtitan's pre-commit workflow Co-authored-by: mystri<hanboyou@huawei.com> # message auto-generated for no-merge-commit merge: !63 merge add-static-check into master [refactor] Adapted torchtitan's pre-commit workflow Created-by: mystri Commit-by: mystri Merged-by: cann-robot Description: ## 描述 新增代码检查工具: 格式/import sort - ufmt codestyle - flake8 pre-commit 用于启动代码检查。 使用pre-commit run --all 以全量检查仓库内文件。 执行 pre-commit install 以安装 git hooks,自动在commit时对修改文件执行检察。 当前不影响代码开发,后续补充贡献流程时启用 ## 类型 - [ ] Bug 修复 - [ ] 新功能 - [x] 重构(即不是新增功能,也不是修改bug的代码变动) - [x] 构建过程或辅助工具的变动 - [ ] 文档内容更新 ## Checklist: - [ ] 我的代码遵循这个项目的代码风格 - [ ] 我已经自己测试过我的代码 - [ ] 我已经更新了相应的文档 - [x] 我已经在标题中正确使用了类型标签(例如:feat, fix, refactor, docs, test) ## 如何测试 简要描述测试方案,并附上自验证记录。 ## 其他信息 在这里可以添加任何与这个 Pull Request 相关的其他说明。 See merge request: cann/torchtitan-npu!632 个月前
[refactor] adapt dsv32 model Co-authored-by: 1Fire4<wangdingyi2@huawei.com> Co-authored-by: mystri<hanboyou@huawei.com> # message auto-generated for no-merge-commit merge: !195 merge refactor/adapt_dsv32 into master [refactor] adapt dsv32 model Created-by: hitwdy Commit-by: 1Fire4;mystri Merged-by: cann-robot Description: ## 描述 基于更新配置系统后的主线代码适配deepseek-v3.2模型。 1. 模型结构重构 — 从旧版平铺 ModelArgs(model/args.py)迁移到上游新的内嵌 Config dataclass 体系,目录扁平化(合并 model/ infra/ train_configs/ 子目录到单层)。 2. npu_dsa融合算子重构适配 — npu_dsa 改造为 ModelConverter 经 registry 注入,适配 Module 子类机制;修复 block_causal mask 与 ScaledDotProductAttention 不兼容的问题。 3. MTP 功能恢复— 修复 MTP layer 创建 bug:update_from_config 在 num_mtp_modules>0 时动态扩展 config.layers 补齐 MTP layer config(registry 默认 0 → trainer 设 N)。 4. 并行策略修复 — 修复 TP / PP / CP 三类并行 bug;修复 PP 下 grad_norm 打印偏大(PP 路径 loss 未按 global_valid_tokens 归一化,导致 log 值偏大约 token 数倍)。 5. RMSNorm Converter 修复 — 修复 NPURMSNorm 替换时误写 self.Config.eps 破坏 dataclass slot 的 bug,改为实例属性 self.eps,v32 model中RMSNorm继承上游以正确替换。 6. 测试与配置 — 新增 dsv32 smoke test 并迁移至 tests/。 ## 类型 - [ ] Bug 修复 - [ ] 新功能 - [x] 重构(即不是新增功能,也不是修改bug的代码变动) - [ ] 构建过程或辅助工具的变动 - [ ] 文档内容更新 ## Checklist: - [x] 我的代码遵循这个项目的代码风格 - [x] 我已经自己测试过我的代码 - [x] 我已经更新了相应的文档 - [x] 我已经在标题中正确使用了类型标签(例如:feat, fix, refactor, docs, test) ## 如何测试 对比系统配置重构前和重构后loss曲线(开启所有融合算子): ![dsv32_loss_compare.png](https://raw.gitcode.com/user-images/assets/9028822/72fdb8b2-b2b5-4ebf-880c-bfd0d17ced4f/dsv32_loss_compare.png 'dsv32_loss_compare.png') 切分测试: - tp 2 vs tp 1 ![dsv32_tp_compare.png](https://raw.gitcode.com/user-images/assets/9028822/efb39d3c-6fe8-4834-a07d-3e8a033ee089/dsv32_tp_compare.png 'dsv32_tp_compare.png') - pp1 vs pp 2 ![pp1_vs_pp2_fixed.png](https://raw.gitcode.com/user-images/assets/9028822/6e81bb27-f00c-4a7b-8a43-51ae1eca0abc/pp1_vs_pp2_fixed.png 'pp1_vs_pp2_fixed.png') - cp 2 vs cp 1 ![cp1_tp1_vs_cp2_compare.png](https://raw.gitcode.com/user-images/assets/9028822/163f4f6f-d314-4876-a5b5-4d544a8eb61c/cp1_tp1_vs_cp2_compare.png 'cp1_tp1_vs_cp2_compare.png') See merge request: cann/torchtitan-npu!1959 天前
增加aclnn接口封装层去除对MindSpeed依赖 Co-authored-by: lrwei0709<weijinyi3@huawei.com> # message auto-generated for no-merge-commit merge: !231 merge br_remove_mindspeed into master 增加aclnn接口封装层去除对MindSpeed依赖 Created-by: lrwei0709 Commit-by: lrwei0709 Merged-by: cann-robot Description: ## 描述 引入aclnn接口封装层用于生成对应的python binding,用于临时处理torch_npu尚未提供的算子接口调用。去除对MindSpeed的依赖。 ## 类型 - [ ] Bug 修复 - [ ] 新功能 - [x] 重构(即不是新增功能,也不是修改bug的代码变动) - [ ] 构建过程或辅助工具的变动 - [ ] 文档内容更新 ## Checklist: - [ ] 我的代码遵循这个项目的代码风格 - [x] 我已经自己测试过我的代码 - [ ] 我已经更新了相应的文档 - [ ] 我已经在标题中正确使用了类型标签(例如:feat, fix, refactor, docs, test) ## 如何测试 ![图片.png](https://raw.gitcode.com/user-images/assets/9028822/fe3eacf1-5ff8-4926-8c1e-7393ba9ebaa1/图片.png '图片.png') ## 其他信息 在这里可以添加任何与这个 Pull Request 相关的其他说明。 See merge request: cann/torchtitan-npu!2314 天前
[docs] Updated contributing.md Co-authored-by: mystri<hanboyou@huawei.com> # message auto-generated for no-merge-commit merge: !69 merge update-contributing into master [docs] Updated contributing.md Created-by: mystri Commit-by: mystri Merged-by: cann-robot Description: ## 描述 新增 Contributing.md 新增 lint_guide.md ## 类型 - [ ] Bug 修复 - [ ] 新功能 - [ ] 重构(即不是新增功能,也不是修改bug的代码变动) - [ ] 构建过程或辅助工具的变动 - [x] 文档内容更新 ## Checklist: - [ ] 我的代码遵循这个项目的代码风格 - [ ] 我已经自己测试过我的代码 - [ ] 我已经更新了相应的文档 - [ ] 我已经在标题中正确使用了类型标签(例如:feat, fix, refactor, docs, test) ## 如何测试 简要描述测试方案,并附上自验证记录。 ## 其他信息 在这里可以添加任何与这个 Pull Request 相关的其他说明。 See merge request: cann/torchtitan-npu!692 个月前
[fix] modify standard license&copyright sample Co-authored-by: depeng1994<zhangdepeng2@huawei.com> # message auto-generated for no-merge-commit merge: !13 merge license into master [fix] modify standard license&copyright sample Created-by: depeng1994 Commit-by: depeng1994 Merged-by: cann-robot Description: ## 描述 屏蔽BSD copyright告警 ## 类型 - [ ] Bug 修复 - [ ] 新功能 - [ ] 重构(即不是新增功能,也不是修改bug的代码变动) - [x] 构建过程或辅助工具的变动 - [ ] 文档内容更新 ## Checklist: - [x] 我的代码遵循这个项目的代码风格 - [ ] 我已经自己测试过我的代码 - [ ] 我已经更新了相应的文档 - [x] 我已经在标题中正确使用了类型标签(例如:feat, fix, refactor, docs, test) ## 如何测试 简要描述测试方案,并附上自验证记录。 ## 其他信息 在这里可以添加任何与这个 Pull Request 相关的其他说明。 See merge request: cann/torchtitan-npu!133 个月前
[ci] [refactor] Integrated lint and type checking to CI Co-authored-by: mystri<hanboyou@huawei.com> # message auto-generated for no-merge-commit merge: !72 merge add-static-check into master [ci] [refactor] Integrated lint and type checking to CI Created-by: mystri Commit-by: mystri Merged-by: cann-robot Description: ## 描述 参考torchtitan仓库增加基于的 pre-commit 静态检查,包括 - 格式检查 - 类型检查等 详细配置见.pre-commit-config.yaml和pyproject.toml 当前屏蔽了很多类型检查问题,待后续重构/更新时逐步修复。 ## 类型 - [ ] Bug 修复 - [ ] 新功能 - [ ] 重构(即不是新增功能,也不是修改bug的代码变动) - [x] 构建过程或辅助工具的变动 - [ ] 文档内容更新 ## Checklist: - [x] 我的代码遵循这个项目的代码风格 - [x] 我已经自己测试过我的代码 - [x] 我已经更新了相应的文档 - [x] 我已经在标题中正确使用了类型标签(例如:feat, fix, refactor, docs, test) ## 如何测试 简要描述测试方案,并附上自验证记录。 ## 其他信息 在这里可以添加任何与这个 Pull Request 相关的其他说明。 See merge request: cann/torchtitan-npu!722 个月前
Updated License/Copyright headers Co-authored-by: mystri<hanboyou@huawei.com> # message auto-generated for no-merge-commit merge: !109 merge codex/license-header-0403 into master Updated License/Copyright headers Created-by: mystri Commit-by: mystri Merged-by: cann-robot Description: ## 描述 根据OAT.xml的检查结果修复了License/Copyright header. ## 类型 - [ ] Bug 修复 - [ ] 新功能 - [ ] 重构(即不是新增功能,也不是修改bug的代码变动) - [ ] 构建过程或辅助工具的变动 - [ ] 文档内容更新 ## Checklist: - [ ] 我的代码遵循这个项目的代码风格 - [ ] 我已经自己测试过我的代码 - [ ] 我已经更新了相应的文档 - [ ] 我已经在标题中正确使用了类型标签(例如:feat, fix, refactor, docs, test) ## 如何测试 简要描述测试方案,并附上自验证记录。 ## 其他信息 在这里可以添加任何与这个 Pull Request 相关的其他说明。 See merge request: cann/torchtitan-npu!1091 个月前
[feat]Add VLM NPU training support Co-authored-by: panchao-gitcode<panchao13@huawei.com> # message auto-generated for no-merge-commit merge: !211 merge vlm_npu into master [feat]Add VLM NPU training support Created-by: panchao-gitcode Commit-by: panchao-gitcode Merged-by: cann-robot Description: ## 描述 - 新增 torchtitan_npu.models.vlm 的 VLM debug model 注册与 NPU 配置。 - 新增 torchtitan_npu.models.multimodal 通用 helper,用于 dense mask、视觉 embedding scatter 和 SDPA 替换适配。 - 在 NPU 入口中保留 VLM dense mask 路径,并使 VLM compile 走 NPU Inductor 后端。 - 新增 VLM 单元测试、最小冒烟验证所需测试资产与功能文档。 - 在 README 支持矩阵中补充 VLM debug model。 ## 类型 - [ ] Bug 修复 - [x] 新功能 - [ ] 重构(即不是新增功能,也不是修改 bug 的代码变动) - [ ] 构建过程或辅助工具的变动 - [x] 文档内容更新 ## Checklist: - [x] 我的代码遵循这个项目的代码风格 - [x] 我已经自己测试过我的代码 - [x] 我已经更新了相应的文档 - [x] 我已经在标题中正确使用了类型标签(例如:feat, fix, refactor, docs, test) ## 如何测试 以下命令均在仓库根目录执行: ```bash PYTHONPATH=$PWD python -m pytest tests/unit_tests/models/test_multimodal_helpers.py -q ``` ```bash PYTHONPATH=/path/to/torchtitan:$PWD:${PYTHONPATH:-} \ NGPU=1 \ MODULE=torchtitan_npu.models.vlm \ CONFIG=vlm_debugmodel_npu \ COMM_MODE=fake_backend \ bash scripts/run_train.sh \ --training.local_batch_size 1 \ --training.seq_len 256 \ --dataloader.max_patches_per_image 64 \ --dataloader.max_images_per_batch 4 ``` 与GPU对比的loss曲线: ![image.png](https://raw.gitcode.com/user-images/assets/9028822/77b9f5ce-e0e8-4d36-b15f-dbbb0af9c503/image.png 'image.png') See merge request: cann/torchtitan-npu!2111 天前
增加aclnn接口封装层去除对MindSpeed依赖 Co-authored-by: lrwei0709<weijinyi3@huawei.com> # message auto-generated for no-merge-commit merge: !231 merge br_remove_mindspeed into master 增加aclnn接口封装层去除对MindSpeed依赖 Created-by: lrwei0709 Commit-by: lrwei0709 Merged-by: cann-robot Description: ## 描述 引入aclnn接口封装层用于生成对应的python binding,用于临时处理torch_npu尚未提供的算子接口调用。去除对MindSpeed的依赖。 ## 类型 - [ ] Bug 修复 - [ ] 新功能 - [x] 重构(即不是新增功能,也不是修改bug的代码变动) - [ ] 构建过程或辅助工具的变动 - [ ] 文档内容更新 ## Checklist: - [ ] 我的代码遵循这个项目的代码风格 - [x] 我已经自己测试过我的代码 - [ ] 我已经更新了相应的文档 - [ ] 我已经在标题中正确使用了类型标签(例如:feat, fix, refactor, docs, test) ## 如何测试 ![图片.png](https://raw.gitcode.com/user-images/assets/9028822/fe3eacf1-5ff8-4926-8c1e-7393ba9ebaa1/图片.png '图片.png') ## 其他信息 在这里可以添加任何与这个 Pull Request 相关的其他说明。 See merge request: cann/torchtitan-npu!2314 天前
[docs]补充文档中版本信息 Co-authored-by: liuyuanchen1<liuyuanchen1@huawei.com> # message auto-generated for no-merge-commit merge: !279 merge cann_fix into master [docs]补充文档中版本信息 Created-by: liuyuanchen1 Commit-by: liuyuanchen1 Merged-by: cann-robot Description: ## 描述 修改https://gitcode.com/cann/torchtitan-npu/issues/42中文本错误信息。 ## 类型 - [ ] Bug 修复 - [ ] 新功能 - [ ] 重构(即不是新增功能,也不是修改bug的代码变动) - [ ] 构建过程或辅助工具的变动 - [x] 文档内容更新 ## Checklist: - [x] 我的代码遵循这个项目的代码风格 - [x] 我已经自己测试过我的代码 - [x] 我已经更新了相应的文档 - [x] 我已经在标题中正确使用了类型标签(例如:feat, fix, refactor, docs, test) ## 如何测试 不涉及代码修改 ## 其他信息 在这里可以添加任何与这个 Pull Request 相关的其他说明。 See merge request: cann/torchtitan-npu!2799 小时前
[docs]补充文档中版本信息 Co-authored-by: liuyuanchen1<liuyuanchen1@huawei.com> # message auto-generated for no-merge-commit merge: !279 merge cann_fix into master [docs]补充文档中版本信息 Created-by: liuyuanchen1 Commit-by: liuyuanchen1 Merged-by: cann-robot Description: ## 描述 修改https://gitcode.com/cann/torchtitan-npu/issues/42中文本错误信息。 ## 类型 - [ ] Bug 修复 - [ ] 新功能 - [ ] 重构(即不是新增功能,也不是修改bug的代码变动) - [ ] 构建过程或辅助工具的变动 - [x] 文档内容更新 ## Checklist: - [x] 我的代码遵循这个项目的代码风格 - [x] 我已经自己测试过我的代码 - [x] 我已经更新了相应的文档 - [x] 我已经在标题中正确使用了类型标签(例如:feat, fix, refactor, docs, test) ## 如何测试 不涉及代码修改 ## 其他信息 在这里可以添加任何与这个 Pull Request 相关的其他说明。 See merge request: cann/torchtitan-npu!2799 小时前

torchtitan-npu

基于 torchtitan 的昇腾全流程大模型训练适配插件

Documentation license contributing SIG pypi zread

简介


torchtitan-npu定位为torchtitan的昇腾(Ascend)后端扩展插件,通过即插即用的硬件亲和性优化,充分释放NPU算力,助力PyTorch native训练在昇腾平台无缝、高效、稳定地运行。

本插件基于社区 ModelConverter 拓展机制构建,已支持多维度训练优化,涵盖 NPU融合算子、图优化、图下沉、算子自动融合、显存管理、分布式并行以及调试维测能力等等。

社群

SIG

SIG 例会:sig-framework-adapter

最新消息


  • [May. 2026]: 🚀 DeepSeek-V4-Pro 模型续训练支持:基于纯FSDP + 大EP极简切分,使能AutoFuse特性,达成训练入图。
  • [May. 2026]: ⚠️ 配置系统重构: master 分支对齐 torchtitan main 的 config_registry.py / ConfigManager 机制,模型训练使用 --module--config 启动,不再通过 --job.config_file 加载 TOML。
  • [Apr. 2026]: 🚀 DeepSeek-V4-Flash 续训练 0day 支持:基于纯FSDP + 大EP极简切分,使能AutoFuse特性,达成训练入图,开箱即优。
  • [Apr. 2026]: 🚀 【重要特性支持】算子自动融合:基于AscendC AutoFuse的能力,支持torch.compile + Inductor后端的算子自动融合。
  • [Apr. 2026]: 🚀 torchtitan‑npu 正式开源:在 NPU 上支持 4D 并行等 torchtitan 原生特性,并引入 Swap Optimizer 等 NPU 亲和优化。

Roadmap


当前季度的规划见 torchtitan-npu Roadmap。欢迎访问。

安装

源码安装:

git clone https://gitcode.com/cann/torchtitan-npu.git
cd torchtitan-npu
pip install -e .

详情参见 安装教程

快速上手

快速启动大语言模型的训练任务,参见 快速上手文档

特性支持概览


场景 特性名称 原生支持 NPU支持
并行能力 4D 并行 (FSDP2/TP/CP/PP)
专家并行 (EP/ETP)
自定义 CP (DeepSeek V3.2 CP/SDPA Ulysses CP)
torch.compile torch.compile
训练精度 MxFP8 量化 ✅ (Ascend 950)
HiF8 量化 ✅ (Ascend 950)
训练调试与监控 分布式 Checkpoint
调试工具
性能优化 Swap Optimizer
NPU 融合算子适配
多模态模型 VLM debug model

项目结构

torchtitan-npu 充分利用了 torchtitan 提供的 ModelConverter 插件化机制。该机制介入模型定义之后、并行策略(如 TP/FSDP)应用之前,支持以非侵入式的方式,通过注册机制对特定模块进行替换或重写。基于此方案,我们实现了融合算子优化、量化支持以及优化器增强等功能。见以下项目结构:

torchtitan-npu/
├── torchtitan_npu/     # torchtitan_npu核心源代码
│   ├── config/         # NPU 扩展配置 dataclass
│   ├── converters/     # 基于torchtitan ModelConverter机制的补丁
│   ├── distributed/    # 自定义分布式代码
│   ├── models/         # 基于torchtitan-npu的模型 (如Deepseek-V3.2)
│   ├── patches/        # 其他补丁
│   ├── tools/          # 工具补丁
│   ├── entry.py        # 启动训练
│   ├── train.py        # 训练主流程补丁
│   └── __init__.py     # torchtitan-npu 插件修改注入点
├── docs/               # 文档

上下游软件栈架构图如下: Architecture

性能基准


2026.04

System: Atlas 800T A3

Model Number of NPUs Precision GBS Local BS Sequence Length FSDP TP PP CP EP Throughput (tokens/p/s) MFU
DeepSeek-V4-Flash 64 BF16 1024 1 4096 128 1 1 1 128 1056 27.67%
DeepSeek-V3.2-671B 64 BF16 128 1 32768 4 4 1 8 64 103 /
DeepSeek-V3.2-671B 64 BF16 512 1 4096 32 4 1 1 64 146 /
DeepSeek-V3-671B 64 BF16 1024 1 4096 32 4 1 1 128 546 /
DeepSeek-V3-671B + compile(Autofuse) 64 BF16 1024 1 4096 32 4 1 1 128 576 /

注:以上MoE模型的性能数据均开启负载均衡配置moe_force_load_balance=true。

免责声明


致 torchtitan‑npu 使用者

  1. torchtitan‑npu 提供的所有内容仅供您用于非商业目的。
  2. 对于 torchtitan‑npu 测试用例以及示例文件中所涉及的各模型和数据集,平台仅用于功能测试,华为不提供任何模型权重和数据集。如您使用这些数据进行训练,请您特别注意应遵守对应模型和数据集的 License,如您因使用这些模型和数据集而产生侵权纠纷,华为不承担任何责任。
  3. 如您在使用 torchtitan‑npu 过程中,发现任何问题(包括但不限于功能问题、合规问题),请在 GitCode 提交 issue,我们将及时审视并解决。

torchtitan‑npu 功能依赖的 PyTorch 等第三方开源软件,均由第三方社区提供和维护,因第三方开源软件导致的问题的修复依赖相关社区的贡献和反馈。您应理解,torchtitan‑npu 仓库不保证对第三方开源软件本身的问题进行修复,也不保证会测试、纠正所有第三方开源软件的漏洞和错误。

License 声明


  • torchtitan‑npu 产品的使用许可证,具体请参见 LICENSE
  • torchtitan‑npu 工具 docs 目录下的文档适用相应许可证,具体请根目录下的 LICENSE 文件。

🤝联系我们

本项目功能和文档正在持续更新和完善中,欢迎您关注最新版本。

  • 问题反馈:通过GitCode【Issues】提交问题。
  • 社区互动:通过GitCode【讨论】参与交流。
  • 经验分享:通过GitCode【Wiki】分享经验总结。
  • 加入交流群:通过扫描下方微信二维码添加torchtitan‑npu小助手微信,加入微信群与我们进一步交流。

contact us