Repository navigation
Conversation
This was referenced Oct 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
本 PR 用于在 xuxl1008/hyper-parallel 的 master 保存并评审当前版本,目标不是上游仓库。
当前私仓 master 为
b6346859,源分支为feat/kda-ascendc-tnd-ulysses,head 为a46195d1。因为前置 KDA/GDN TND CP PR #1263 尚未合入,此处保留其提交e93792be和其上的 Ascend C 增量提交,共两个提交;diff 中的通用 TND/GDN 改动来自前置,本次新增 Ascend C 后端只针对 KDA 本地/纯 Ulysses。后续正式向上游提交时,待前置合入再 rebase。在前置 TND CP 的数据流上,为 KDA 本地计算和纯 Ulysses 增加显式
backend="ascendc",直接支持 dense BSND 与 packed TND。复用模型投影、packed ShortConv/halo、文档 reset、Ulysses 布局和参数归约;不新增一套 CP 协议。本分支依赖上述 TND CP,保持已验收代码与提交关系。默认 Triton 后端保持不变。
实现
raw Q/K、beta/gate进入fla-npu公开Prepare→FwdH→Finalize;反向使用公开完整KDA Backward。A2尚未融合的Q/K L2Norm和beta sigmoid求导调用FLA Triton辅助,保留native FP32上游梯度。缺少必要依赖/接口直接报错。
TND沿用PackedSequenceInfo,U后恢复完整文档,向native前后各阶段传递相同CPU offsets和chunk顺序;packed backward显式适配NTD和chunk-major状态布局,避免每层设备元数据回传。
每次调用独占autograd保存量,前向专用u/qg_scaled不跨前反向保留;norm复用native辅助量,sigmoid保存raw beta。小型gate参数分片clone修正NPU storage descriptor。
范围
chunk_kda_bwd检测到 packed 文档中存在非64对齐长度后,会在库内按文档切片、补齐尾块并调用 Ascend C backward,再拼回 token 梯度并累加参数梯度。这不是退回 Triton 注意力主体,但会增加逐文档调用、padding 与拼接成本;文档很多或很短时,不能套用 dense 的吞吐数据。全64对齐 packed 使用整包原生反向。验证
验收环境为910B3、Torch/Torch-NPU2.10.0、CANN9.1.0-beta.3、Triton-Ascend3.2.2;native源码8762b613、FLA6b6f546f。主仓CI需提供匹配native wheel/OPP和FLA辅助接口。本轮没有TND吞吐宣称;此前dense性能证据不直接外推到大量短文档。