| fix(indexer_quant_cache): reject odd cache headDim for MX-FP4 mode Co-authored-by: wangxun21<wangxun21@huawei.com> # message auto-generated for no-merge-commit merge: !9613 merge fix/indexer-quant-cache-mxfp4-odd-headdim into master fix(indexer_quant_cache): reject odd cache headDim for MX-FP4 mode Created-by: wangxun21 Commit-by: wangxun21 Merged-by: cann-robot Description: ## 描述 修复 indexer_quant_cache 算子在 quantMode=3(MX-FP4)模式下,cache.headDim 为奇数时产生精度错误/数据错位的问题。 **根因**:MX-FP4 每字节打包 2 个 fp4 逻辑元素。当 headDim 为奇数时,相邻逻辑行的起始位置会交替落在字节的高 4 位 / 低 4 位。当前 kernel 把 cache 声明为 GlobalTensor<int8_t>,仅支持整字节地址的 CopyOut,无法表达这种半字节偏移,导致输出数据错位/精度错误。 **修复方案**:在 host tiling (indexer_quant_cache_tiling_arch35.cpp) 的 CalcOpTiling 中新增校验——quantMode=3 时要求 cache.headDim(连续场景)以及 cache 分页 view 的 row/block stride(分页场景)必须为偶数,不满足则直接返回 GRAPH_FAILED,从"跑出错误数据"变为"直接报错拒绝非法输入"。同步更新文档约束说明,并新增 host UT 拒绝用例。 该做法与 CANN 内其他 FP4/MX-FP4 打包量化算子(如 scatter_pa_kv_cache 对 k_head_size/v_head_size 的偶数校验、dynamic_mx_quant 对 input.shape[-1] 的偶数要求)保持一致——均选择在 host tiling 阶段拒绝奇数尾轴,而不是尝试支持半字节寻址。 ## 关联的Issue 关联 Issue #4137 ## 测试 - **端到端验证**:用 TTK aclnn 模式构造了 headDim=65(奇数)和 headDim=64(偶数)两个 MX-FP4 用例,前者 aclnnIndexerQuantCacheGetWorkspaceSize 阶段报错拒绝(ACLNN_ERR_INNER_NULLPTR),plog 确认报错发生在 indexer_quant_cache_tiling_arch35.cpp:332,未进入 kernel;后者正常执行,精度 PASS。 - **Host UT**:新增测试用例 indexer_quant_cache_tiling_mxfp4_odd_headdim_rejected,验证奇数 headDim(129)在 tiling 阶段返回 GRAPH_FAILED。(本机 host UT 框架本身有环境问题——TilingContext 构造为空指针、所有用例均 segfault,与本次改动无关,已用 gdb 确认崩溃点在框架代码 tiling_case_executor.cpp:316 而非算子逻辑) ## 文档更新 更新了 attention/indexer_quant_cache/docs/aclnnIndexerQuantCache.md 的约束说明,新增一条: > **MX-FP4(quantMode=3)模式下,cache.headDim 必须为偶数**。 ## 类型标签 - [x] 🐛 Bug修复 - [ ] ✨ 新特性 - [ ] ⚡ 性能优化 - [ ] ♻️ 重构 - [ ] 🧪 测试 - [ ] 📦 构建/CI - [ ] 🔧 配置变更 - [x] 📝 文档更新 - [ ] ⬆️ 依赖升级 - [ ] 🔒 安全修复 - [ ] 🧹 代码清理 - [ ] ❓ 其他,请描述: See merge request: cann/ops-transformer!9613 | 1 个月前 |
| fix(indexer_quant_cache): 修复GEIR内存泄漏并补充数值golden Co-authored-by: chendunyang<chendunyang1@huawei.com> # message auto-generated for no-merge-commit merge: !11302 merge fix/indexer-quant-cache-geir-leak-golden into master fix(indexer_quant_cache): 修复GEIR内存泄漏并补充数值golden Created-by: qq_37913898 Commit-by: chendunyang Merged-by: cann-robot Description: ## 背景 - 修复 #4792 反馈的 GEIR 示例成功路径中 Session 未释放问题。 - 补充 IndexerQuantCache kernel UT 的真实数值 golden 校验,避免仅判断输出非零而漏检数值错误。 ## 修改内容 - 在 RunGraph 成功完成后、GEFinalize 前释放 Session,与失败路径的资源释放行为保持一致。 - 新增 Normal 量化分支的独立 golden 测试,覆盖 roundScale=true/false。 - 校验完整 cache 字节、float32 scale 位模式,以及 slotMapping=-1 时目标行保持不变。 - golden 使用固定字面值,与被测 kernel 的计算逻辑独立。 ## 验证结果 - pre-commit 全部通过(含 clang-format、codespell、OAT)。 - ascend950 opkernel UT:16/16 通过。 - GEIR 示例编译通过。 Closes #4792 See merge request: cann/ops-transformer!11302 | 8 天前 |
| 修复kv_compress_epilog和indexer_quant_cache算子图模式 Co-authored-by: zhu-lei0614<zhulei113@huawei.com> # message auto-generated for no-merge-commit merge: !8030 merge master into master 修复kv_compress_epilog和indexer_quant_cache算子图模式 Created-by: zhu-lei0614 Commit-by: zhu-lei0614 Merged-by: cann-robot Description: ## 描述 修改kv_compress_epilog和indexer_quant_cache算子图模式 修复kv_compress_epilog和indexer_quant_cache算子找不到geir原型的问题 ## 关联的Issue https://gitcode.com/cann/ops-transformer/issues/3501 ## 测试 本地出包验证通过 ## 文档更新 <!--如果这个PR包含文档的更新,请在这里指出。例如:更新了README.md文件。--> ## 类型标签 <!-- [x] 表示选中 --> - [x] 🐛 Bug修复 - [ ] ✨ 新特性 - [ ] ⚡ 性能优化 - [ ] ♻️ 重构 - [ ] 🧪 测试 - [ ] 📦 构建/CI - [ ] 🔧 配置变更 - [ ] 📝 文档更新 - [ ] ⬆️ 依赖升级 - [ ] 🔒 安全修复 - [ ] 🧹 代码清理 - [ ] ❓ 其他,请描述: See merge request: cann/ops-transformer!8030 | 2 个月前 |
| pre-commit修复attention目录.h/.hpp历史格式问题(第2批) Co-authored-by: gitcode_lijd<lijiandong20@huawei.com> # message auto-generated for no-merge-commit merge: !10422 merge graph into master pre-commit修复attention目录.h/.hpp历史格式问题(第2批) Created-by: gitcode_lijd Commit-by: gitcode_lijd Merged-by: cann-robot Description: ## 关联的Issue 关联Issue https://gitcode.com/cann/ops-transformer/issues/4850 ## 描述 对仓内算子源码提前做 pre-commit 历史格式问题清理,为后续功能改动(如 Regbase API 替换等)扫清钩子障碍,避免后续 PR 因格式问题被大面积格式化污染 diff。 处理方式:find <目录> -type f \( -name '*.h' -o -name '*.hpp' \) | xargs pre-commit run --files,多轮执行直到所有 hook 收敛(无 Failed / 无自动修复)。 修复内容(仅格式,不改任何代码语义): - 尾随空白(trailing whitespace) - 文件末尾换行(end of file) - clang-format 代码重排(换行、缩进、对齐,遵循仓内 .clang-format) ### 排除范围(不做格式化) - *_def.cpp 算子定义文件(排版由开发者自行维护,另见 PR #11041) - */op_api/aclnn*.h、*/op_graph/*_proto.h、*/op_host/op_api/aclnn*.h 接口/原型头文件(排版由开发者自行维护) - mamba/ 目录(该目录 causal_conv1d 算子 UT 上游基线存在失败,见 Issue #4840,本批不涉及) - examples/、experimental/ 目录 ### PR 拆分说明 全仓 .h/.hpp 清理共 2362 个文件,按场景目录拆分为 6 个 PR(分支不同、内容互不重叠,可独立 review 合入): | PR | 分支 | 范围 | |---|---|---| | #4878 | compile | attention 第1批(按算子字母序前段) | | #10422 | graph | attention 第2批(按算子字母序中段) | | #9331 | test | attention 第3批(按算子字母序后段) | | #10991 | fix | mc2 | | #11020 | fix_2 | moe、gmm | | #11021 | fix_3 | posembedding、mhc、ffn、common、tests、torch_extension | ## 测试 - 纯格式化改动:不改变任何代码语义,逐文件 diff 均为空白/换行/clang-format 重排 - pre-commit 全量 hook 收敛验证:多轮执行后 trailing-whitespace / end-of-file-fixer / clang-format 均 Passed - 建议合入前对相关算子做一次编译验证 See merge request: cann/ops-transformer!10422 | 10 天前 |
| pre-commit修复attention目录.h/.hpp历史格式问题(第2批) Co-authored-by: gitcode_lijd<lijiandong20@huawei.com> # message auto-generated for no-merge-commit merge: !10422 merge graph into master pre-commit修复attention目录.h/.hpp历史格式问题(第2批) Created-by: gitcode_lijd Commit-by: gitcode_lijd Merged-by: cann-robot Description: ## 关联的Issue 关联Issue https://gitcode.com/cann/ops-transformer/issues/4850 ## 描述 对仓内算子源码提前做 pre-commit 历史格式问题清理,为后续功能改动(如 Regbase API 替换等)扫清钩子障碍,避免后续 PR 因格式问题被大面积格式化污染 diff。 处理方式:find <目录> -type f \( -name '*.h' -o -name '*.hpp' \) | xargs pre-commit run --files,多轮执行直到所有 hook 收敛(无 Failed / 无自动修复)。 修复内容(仅格式,不改任何代码语义): - 尾随空白(trailing whitespace) - 文件末尾换行(end of file) - clang-format 代码重排(换行、缩进、对齐,遵循仓内 .clang-format) ### 排除范围(不做格式化) - *_def.cpp 算子定义文件(排版由开发者自行维护,另见 PR #11041) - */op_api/aclnn*.h、*/op_graph/*_proto.h、*/op_host/op_api/aclnn*.h 接口/原型头文件(排版由开发者自行维护) - mamba/ 目录(该目录 causal_conv1d 算子 UT 上游基线存在失败,见 Issue #4840,本批不涉及) - examples/、experimental/ 目录 ### PR 拆分说明 全仓 .h/.hpp 清理共 2362 个文件,按场景目录拆分为 6 个 PR(分支不同、内容互不重叠,可独立 review 合入): | PR | 分支 | 范围 | |---|---|---| | #4878 | compile | attention 第1批(按算子字母序前段) | | #10422 | graph | attention 第2批(按算子字母序中段) | | #9331 | test | attention 第3批(按算子字母序后段) | | #10991 | fix | mc2 | | #11020 | fix_2 | moe、gmm | | #11021 | fix_3 | posembedding、mhc、ffn、common、tests、torch_extension | ## 测试 - 纯格式化改动:不改变任何代码语义,逐文件 diff 均为空白/换行/clang-format 重排 - pre-commit 全量 hook 收敛验证:多轮执行后 trailing-whitespace / end-of-file-fixer / clang-format 均 Passed - 建议合入前对相关算子做一次编译验证 See merge request: cann/ops-transformer!10422 | 10 天前 |
| test(indexer_quant_cache): add TTK golden asset Co-authored-by: chendunyang<chendunyang1@huawei.com> # message auto-generated for no-merge-commit merge: !11325 merge test/indexer-quant-cache-golden into master test(indexer_quant_cache): add TTK golden asset Created-by: qq_37913898 Commit-by: chendunyang Merged-by: cann-robot Description: ## 描述 为 IndexerQuantCache 补充仓库标准 TTK Python golden 入口 tests/assets/golden.py。通过 __spec__ 同时注册 kernel 名称和 aclnn 名称,CPU golden 覆盖 quantMode 0(MXFP8)、1(Normal)、2(HiFloat8)、3(MXFP4),包含 cache/scale 原地更新、slot 跳过、roundScale 开关、FP16/BF16 以及特殊值处理。 本 PR 只新增测试资产,不修改算子 kernel、host、API 或 GEIR 实现,也不改动此前 PR。 ## 测试 - pre-commit:全部通过(ruff-check、ruff-format、codespell、OAT 等) - 直接数值回归:quantMode 0/1/2/3 全部通过;Normal 模式关键字节与 scale 编码已核对;slot=-1 跳过逻辑已核对 - TTK CSV 校验:282/282 valid,0 invalid - TTK 小规模实跑:4 个代表用例(每种 quantMode 1 个)4/4 PASS ## 文档更新 无。 ## 类型标签 - [ ] 🐛 Bug修复 - [ ] ✨ 新特性 - [ ] ⚡ 性能优化 - [ ] ♻️ 重构 - [x] 🧪 测试 - [ ] 📦 构建/CI - [ ] 🔧 配置变更 - [ ] 📝 文档更新 - [ ] ⬆️ 依赖升级 - [ ] 🔒 安全修复 - [ ] 🧹 代码清理 - [ ] ❓ 其他,请描述: See merge request: cann/ops-transformer!11325 | 8 天前 |
| 修改IndexerQuantCache PTA接口dtype传递逻辑 Co-authored-by: echoes_00444757<luwei44@huawei.com> # message auto-generated for no-merge-commit merge: !11108 merge fix/indexer-quant-cache-pta-dtype-wrapper-copy into master 修改IndexerQuantCache PTA接口dtype传递逻辑 Created-by: qq_37913898 Commit-by: echoes_00444757 Merged-by: cann-robot Description: ## 变更背景 IndexerQuantCache 的 Torch/PTA 接口原先直接把 cache 和 cacheScale 传入 ACLNN。MXFP8、MXFP4 等场景允许使用 torch.uint8 保存底层比特数据,但 uint8 只是物理存储类型,不能表达数据实际对应的 FP8、FP4 或 E8M0 逻辑类型。直接传递原始 Tensor 会使 ACLNN 按 uint8 识别参数,导致 dtype 信息传递不准确。 ## 变更内容 - 在 indexer_quant_cache.cpp 中增加量化模式常量和 TensorRole,区分 cache 与 cacheScale。 - 新增 MakeTensorWrapper,根据 quantMode、Tensor 角色和 Torch dtype 校验输入,并向 ACLNN 显式传递对应的 ACL dtype。 - IndexerQuantCache 调用 aclnnIndexerQuantCache 前,使用 TensorWrapper 包装 cache 和 cacheScale。 - 在公共 aclnn_common.h 中增加 wrapper 类型识别,使 GetFirstTensor 能从 TensorWrapper 和 StorageShapeTensor 中提取底层 at::Tensor,保证设备和 Stream 等运行时信息能够正常获取。 - 优化非法 quantMode 的错误提示,使报错直接对应 mxfp8、fp8、hifloat8 和 mxfp4 四种模式。 ## dtype 映射 | quantMode | 模式 | cache 允许的 Torch dtype | 传递给 ACLNN 的 dtype | cacheScale 允许的 Torch dtype | 传递给 ACLNN 的 dtype | | --- | --- | --- | --- | --- | --- | | 0 | MXFP8 | uint8 / float8_e4m3fn | ACL_FLOAT8_E4M3FN | uint8 / float8_e8m0fnu | ACL_FLOAT8_E8M0 | | 1 | FP8 | uint8 / float8_e4m3fn / float8_e5m2 | ACL_FLOAT8_E4M3FN / ACL_FLOAT8_E5M2 | float32 | ACL_FLOAT | | 2 | HiFloat8 | uint8 | ACL_UINT8 | float32 | ACL_FLOAT | | 3 | MXFP4 | packed uint8 / float4_e2m1fn_x2 | ACL_FLOAT4_E2M1 | uint8 / float8_e8m0fnu | ACL_FLOAT8_E8M0 | ## 影响范围 - 修改范围仅涉及 IndexerQuantCache 的 Torch/PTA dtype 传递逻辑和 ACLNN 公共参数解析。 - 不修改 Arch35 算子核、tiling、ACLNN 接口签名以及量化计算公式。 - 对 dtype 不符合对应量化模式的输入,将在 Torch 接口层通过 TORCH_CHECK 提前报错。 ## 验证情况 - Torch/PTA 直接功能用例:11/11 通过。 - 泛化功能用例:196/197 通过;剩余 1 条为转换后特殊值输入不满足接口约束的无效用例,不是算子计算失败。 - 已在本 PR 下触发 compile,流水线结果以 CI 页面为准。 ## 变更类型 - [x] Bug 修复 - [ ] 新功能 - [ ] 性能优化 - [ ] 文档更新 - [ ] 代码清理 See merge request: cann/ops-transformer!11108 | 10 天前 |
| 新增kvCompressEpilog和indexerQunatCache算子 Co-authored-by: zhu-lei0614<zhulei113@huawei.com> # message auto-generated for no-merge-commit merge: !6519 merge master into master 新增kvCompressEpilog和indexerQunatCache算子 Created-by: zhu-lei0614 Commit-by: zhu-lei0614 Merged-by: cann-robot Description: ## 描述 新增kvCompressEpilog和indexerQunatCache算子 ## 关联的Issue 关联issue:https://gitcode.com/cann/ops-transformer/issues/3103 ## 测试 本地验证测试通过 ## 文档更新 <!--如果这个PR包含文档的更新,请在这里指出。例如:更新了README.md文件。--> ## 类型标签 <!-- [x] 表示选中 --> - [ ] 🐛 Bug 修复 - [x] ✨ 新特性 - [ ] ⚡ 性能优化 - [ ] ♻️ 重构 - [ ] 🧪 测试 - [ ] 📦 构建/CI - [ ] 🔧 配置变更 - [ ] 📝 文档更新 - [ ] ⬆️ 依赖升级 - [ ] 🔒 安全修复 - [ ] 🧹 代码清理 - [ ] ❓ 其他,请描述: See merge request: cann/ops-transformer!6519 | 2 个月前 |
| 修改torch_npu产品名称和doc tools修改 Co-authored-by: caiwenwen<caiwenwen6@h-partners.com> # message auto-generated for no-merge-commit merge: !9049 merge master into master 修改torch_npu产品名称和doc tools修改 Created-by: caiwenwen Commit-by: caiwenwen Merged-by: cann-robot Description: ## 描述 修改torch_npu产品、doctools和api手册名称修改 ## 关联的Issue 关联Issue [#3706](https://gitcode.com/cann/ops-transformer/issues/3706) <!-- 如果这个PR是为了解决特定的问题单,请在这里描述问题单单号。--> ## 测试 <!--描述进行了哪些测试来验证你的改动。包括但不限于二级冒烟、算子泛化等。--> ## 文档更新 README.md attention docs examples / mc2 / all_gather_add / docs experimental ## 类型标签 <!-- [x] 表示选中 --> - [ ] 🐛 Bug修复 - [ ] ✨ 新特性 - [ ] ⚡ 性能优化 - [ ] ♻️ 重构 - [ ] 🧪 测试 - [ ] 📦 构建/CI - [ ] 🔧 配置变更 - [x] 📝 文档更新 - [ ] ⬆️ 依赖升级 - [ ] 🔒 安全修复 - [ ] 🧹 代码清理 - [ ] ❓ 其他,请描述: See merge request: cann/ops-transformer!9049 | 1 个月前 |