文件最后提交记录最后更新时间
【update】block_sparse_attention/fused_infer_attention_score等算子资料修改 Co-authored-by: wjc<wangjincheng14@huawei.com> # message auto-generated for no-merge-commit merge: !4071 merge personal/wjc/doc_updates into master 【update】block_sparse_attention/fused_infer_attention_score等算子资料修改 Created-by: Anthony0331 Commit-by: wjc Merged-by: cann-robot Description: ## 描述 <!--在这里详细描述你的改动,包括改动的原因和所采取的方法。--> 本次PR对block_sparse_attention、fused_infer_attention_score等算子的API文档进行了集中修正和优化。主要解决了文档中普遍存在的拼写错误、参数名不一致、术语不准确、约束条件描述模糊或过时、以及部分格式和示例代码错误等问题。这些修改旨在提升整个算子接口文档集的准确性、一致性和可读性,确保开发者能够正确理解和使用相关功能。 ## 关联的Issue <!-- 如果这个PR是为了解决特定的Issue,请在这里提供Issue链接。例如:关联Issue #000--> <!-- 如果这个PR是为了解决特定的问题单,请在这里描述问题单单号。--> 关联Issue [#1825](https://gitcode.com/cann/ops-transformer/issues/1825) ## 测试 <!--描述进行了哪些测试来验证你的改动。包括但不限于二级冒烟、算子泛化等。--> ## 文档更新 <!--如果这个PR包含文档的更新,请在这里指出。例如:更新了README.md文件。--> 更新了以下文件: attention/block_sparse_attention/docs/aclnnBlockSparseAttention.md attention/fused_infer_attention_score/docs/aclnnFusedInferAttentionScore.md attention/fused_infer_attention_score/docs/aclnnFusedInferAttentionScoreV2.md attention/fused_infer_attention_score/docs/aclnnFusedInferAttentionScoreV3.md attention/fused_infer_attention_score/docs/aclnnFusedInferAttentionScoreV4.md attention/fused_infer_attention_score/docs/aclnnFusedInferAttentionScoreV5.md attention/incre_flash_attention/docs/aclnnIncreFlashAttention.md attention/incre_flash_attention/docs/aclnnIncreFlashAttentionV2.md attention/incre_flash_attention/docs/aclnnIncreFlashAttentionV3.md attention/incre_flash_attention/docs/aclnnIncreFlashAttentionV4.md attention/nsa_compress_attention_infer/docs/aclnnNsaCompressAttentionInfer.md attention/nsa_compress_attention_infer/examples/test_aclnn_nsa_compress_attention_infer.cpp attention/nsa_compress_with_cache/docs/aclnnNsaCompressWithCache.md attention/nsa_selected_attention_infer/docs/aclnnNsaSelectedAttentionInfer.md attention/nsa_selected_attention_infer/examples/test_aclnn_nsa_selected_attention_infer.cpp attention/prompt_flash_attention/docs/aclnnPromptFlashAttention.md attention/prompt_flash_attention/docs/aclnnPromptFlashAttentionV2.md attention/prompt_flash_attention/docs/aclnnPromptFlashAttentionV3.md ## 类型标签 <!-- [x] 表示选中 --> - [ ] 🐛 Bug 修复 - [ ] ✨ 新特性 - [ ] ⚡ 性能优化 - [ ] ♻️ 重构 - [ ] 🧪 测试 - [ ] 📦 构建/CI - [ ] 🔧 配置变更 - [x] 📝 文档更新 - [ ] ⬆️ 依赖升级 - [ ] 🔒 安全修复 - [ ] 🧹 代码清理 - [ ] ❓ 其他,请描述: See merge request: cann/ops-transformer!40711 个月前
【update】block_sparse_attention/fused_infer_attention_score等算子资料修改 Co-authored-by: wjc<wangjincheng14@huawei.com> # message auto-generated for no-merge-commit merge: !4071 merge personal/wjc/doc_updates into master 【update】block_sparse_attention/fused_infer_attention_score等算子资料修改 Created-by: Anthony0331 Commit-by: wjc Merged-by: cann-robot Description: ## 描述 <!--在这里详细描述你的改动,包括改动的原因和所采取的方法。--> 本次PR对block_sparse_attention、fused_infer_attention_score等算子的API文档进行了集中修正和优化。主要解决了文档中普遍存在的拼写错误、参数名不一致、术语不准确、约束条件描述模糊或过时、以及部分格式和示例代码错误等问题。这些修改旨在提升整个算子接口文档集的准确性、一致性和可读性,确保开发者能够正确理解和使用相关功能。 ## 关联的Issue <!-- 如果这个PR是为了解决特定的Issue,请在这里提供Issue链接。例如:关联Issue #000--> <!-- 如果这个PR是为了解决特定的问题单,请在这里描述问题单单号。--> 关联Issue [#1825](https://gitcode.com/cann/ops-transformer/issues/1825) ## 测试 <!--描述进行了哪些测试来验证你的改动。包括但不限于二级冒烟、算子泛化等。--> ## 文档更新 <!--如果这个PR包含文档的更新,请在这里指出。例如:更新了README.md文件。--> 更新了以下文件: attention/block_sparse_attention/docs/aclnnBlockSparseAttention.md attention/fused_infer_attention_score/docs/aclnnFusedInferAttentionScore.md attention/fused_infer_attention_score/docs/aclnnFusedInferAttentionScoreV2.md attention/fused_infer_attention_score/docs/aclnnFusedInferAttentionScoreV3.md attention/fused_infer_attention_score/docs/aclnnFusedInferAttentionScoreV4.md attention/fused_infer_attention_score/docs/aclnnFusedInferAttentionScoreV5.md attention/incre_flash_attention/docs/aclnnIncreFlashAttention.md attention/incre_flash_attention/docs/aclnnIncreFlashAttentionV2.md attention/incre_flash_attention/docs/aclnnIncreFlashAttentionV3.md attention/incre_flash_attention/docs/aclnnIncreFlashAttentionV4.md attention/nsa_compress_attention_infer/docs/aclnnNsaCompressAttentionInfer.md attention/nsa_compress_attention_infer/examples/test_aclnn_nsa_compress_attention_infer.cpp attention/nsa_compress_with_cache/docs/aclnnNsaCompressWithCache.md attention/nsa_selected_attention_infer/docs/aclnnNsaSelectedAttentionInfer.md attention/nsa_selected_attention_infer/examples/test_aclnn_nsa_selected_attention_infer.cpp attention/prompt_flash_attention/docs/aclnnPromptFlashAttention.md attention/prompt_flash_attention/docs/aclnnPromptFlashAttentionV2.md attention/prompt_flash_attention/docs/aclnnPromptFlashAttentionV3.md ## 类型标签 <!-- [x] 表示选中 --> - [ ] 🐛 Bug 修复 - [ ] ✨ 新特性 - [ ] ⚡ 性能优化 - [ ] ♻️ 重构 - [ ] 🧪 测试 - [ ] 📦 构建/CI - [ ] 🔧 配置变更 - [x] 📝 文档更新 - [ ] ⬆️ 依赖升级 - [ ] 🔒 安全修复 - [ ] 🧹 代码清理 - [ ] ❓ 其他,请描述: See merge request: cann/ops-transformer!40711 个月前
common目录整改 Co-authored-by: hello_simida<wangyi206@huawei.com> # message auto-generated for no-merge-commit merge: !4870 merge feature/common_dir_fix_v2 into master common目录整改 Created-by: hello_simida Commit-by: hello_simida Merged-by: cann-robot Description: ## 描述 本次修改对 common/ 目录进行整理,分为两个阶段: - **Phase 1**: 将 common/include/kernel/ 重命名为 common/include/op_kernel/ - **Phase 2**: 将 common/include/tiling_base/common/src/tiling_base/ 合并到 common/include/op_host/common/src/op_host/ 相应的 CMake 配置和所有 #include 路径引用已同步更新。 影响范围: - 351 个文件修改(include 路径更新) - 8 个文件重命名(tiling_base → op_host) - 2 个 CMakeLists.txt 修改 + 多个 tests 目录 CMakeLists.txt 更新 ## 关联的Issue Closes #2246 ## 测试 - 编译验证通过:bash build.sh --pkg --soc=ascend910b --ops=all_gather_matmul_v2 -j16 - 编译产物成功生成 .run 包 ## 文档更新 无 ## 类型标签 - [x] ♻️ 重构 - [ ] 🐛 Bug 修复 - [ ] ✨ 新特性 - [ ] ⚡ 性能优化 - [ ] 🧪 测试 - [ ] 📦 构建/CI - [ ] 🔧 配置变更 - [ ] 📝 文档更新 - [ ] ⬆️ 依赖升级 - [ ] 🔒 安全修复 - [ ] 🧹 代码清理 - [ ] ❓ 其他,请描述: See merge request: cann/ops-transformer!487026 天前
匹配最新cann版本,上线新版本attention/ffn/moe/posembedding算子 Co-authored-by: huangchuhong<huangchuhong1@h-partners.com> # message auto-generated for no-merge-commit merge: !538 merge master into master 匹配最新cann版本,上线新版本attention/ffn/moe/posembedding算子 Created-by: huang-chuhong Commit-by: huangchuhong Merged-by: cann-robot Description: ## 描述 transformer 同步算子最新开发,涉及attention/ffn/moe/posembedding ## 关联的Issue https://gitcode.com/cann/ops-transformer/issues/315 ## 测试 <!--描述进行了哪些测试来验证你的改动。包括但不限于二级冒烟、算子泛化等。--> ## 文档更新 <!--如果这个PR包含文档的更新,请在这里指出。例如:更新了README.md文件。--> ## 类型标签 <!-- [x] 表示选中 --> - [ ] Bug修复 - [ ] 新特性 - [ ] 性能优化 - [ ] 文档更新 - [ ] 其他,请描述: See merge request: cann/ops-transformer!5385 个月前
fix: skip failing operator UT builds by commenting out error test CMakeLists.txt Co-authored-by: huang-chuhong<huangchuhong1@h-partners.com> # message auto-generated for no-merge-commit merge: !5823 merge fix/ut-build-skip-failing-ops into master fix: skip failing operator UT builds by commenting out error test CMakeLists.txt Created-by: huang-chuhong Commit-by: huang-chuhong Merged-by: cann-robot Description: ## 描述 部分算子 UT 在 ascend910b 平台上编译失败,导致整体 UT 构建阻塞。本 PR 通过注释失败算子的 tests CMakeLists.txt 代码部分(保留版权头),使 op_host/op_api UT 构建能顺利通过。 ## 改动 - build.sh: 在 set_ut_mode() 中新增逻辑,当 UT_TEST_ALL=TRUE 且 ENABLE_BUILT_CUSTOM!=TRUE 时自动拆分为 OP_HOST_UT + OP_API_UT + OP_GRAPH_UT,关闭 OP_KERNEL_UT - 注释以下算子的 tests CMakeLists.txt(保留版权头): - ffn/ffn, attention/fused_floyd_attention_grad, attention/lightning_indexer_grad, attention/nsa_compress_attention, attention/nsa_compress_attention_infer, attention/nsa_compress_with_cache, attention/nsa_selected_attention, attention/nsa_selected_attention_infer, gmm/quant_grouped_matmul_dequant, mc2/matmul_all_reduce, mhc/mhc_pre_sinkhorn, mhc/mhc_sinkhorn, moe/moe_gating_top_k_softmax_v2, posembedding/norm_rope_concat ## 关联的Issue https://gitcode.com/cann/ops-transformer/issues/2622 https://gitcode.com/cann/ops-transformer/issues/2594 ## 测试 - bash build.sh -u: 1198 tests, 1197 passed, 1 skipped - bash build.sh -u --ophost: 2904 tests, all passed - bash build.sh -u --opapi: 1198 tests, 1197 passed, 1 skipped ## 类型标签 - [x] 🧪 测试 - [x] 📦 构建/CI See merge request: cann/ops-transformer!582310 天前
匹配最新cann版本,上线新版本attention/ffn/moe/posembedding算子 Co-authored-by: huangchuhong<huangchuhong1@h-partners.com> # message auto-generated for no-merge-commit merge: !538 merge master into master 匹配最新cann版本,上线新版本attention/ffn/moe/posembedding算子 Created-by: huang-chuhong Commit-by: huangchuhong Merged-by: cann-robot Description: ## 描述 transformer 同步算子最新开发,涉及attention/ffn/moe/posembedding ## 关联的Issue https://gitcode.com/cann/ops-transformer/issues/315 ## 测试 <!--描述进行了哪些测试来验证你的改动。包括但不限于二级冒烟、算子泛化等。--> ## 文档更新 <!--如果这个PR包含文档的更新,请在这里指出。例如:更新了README.md文件。--> ## 类型标签 <!-- [x] 表示选中 --> - [ ] Bug修复 - [ ] 新特性 - [ ] 性能优化 - [ ] 文档更新 - [ ] 其他,请描述: See merge request: cann/ops-transformer!5385 个月前
doc tools工具扫描问题修改 Co-authored-by: gitee-yanglulu<yanglulul@h-partners.com> # message auto-generated for no-merge-commit merge: !3397 merge master into master doc tools工具扫描问题修改 Created-by: gitee-yanglulu Commit-by: gitee-yanglulu Merged-by: cann-robot Description: doc tools工具扫描问题修改 See merge request: cann/ops-transformer!33972 个月前
README.md

NsaCompressAttentionInfer

产品支持情况

产品 是否支持
Ascend 950PR/Ascend 950DT ×
Atlas A3 训练系列产品/Atlas A3 推理系列产品
Atlas A2 训练系列产品/Atlas A2 推理系列产品
Atlas 200I/500 A2 推理产品 ×
Atlas 推理系列产品 ×
Atlas 训练系列产品 ×

功能说明

  • 算子功能:Native Sparse Attention推理过程中,Compress Attention的计算。
  • 计算公式:

Pcmp=Softmax(scale∗query⋅keyT)attentionOut=Pcmp⋅valuePslc[j]=∑m=0l′/d−1∑n=0l/d−1Pcmp[l′/d∗j−m−n]Pslc′=∑g=1GPslcg,其中 G=GroupSize(分组大小),即:G=numHeadsnumKeyValueHeadstopkIndices=topk(Pslc′)P_{cmp}= Softmax(scale * query · key^T) \\ attentionOut = P_{cmp} · value\\ P_{slc}[j] = \sum\limits_{m=0}^{l'/d -1} \sum\limits_{n = 0}^{l/d -1} P_{cmp} [l'/d * j -m - n]\\ P_{slc'} = \sum\limits_{g=1}^{G} P_{slc} ^g,\quad \text{其中 } G = \text{GroupSize(分组大小),即:} G = \frac{\text{numHeads}}{\text{numKeyValueHeads}} \\ topkIndices = topk(P_{slc'})\\

参数说明

参数名 输入/输出/属性 描述 数据类型 数据格式
query 输入 公式中的输入query。 FLOAT16、BFLOAT16 ND
key 输入 公式中的输入key。 FLOAT16、BFLOAT16 ND
value 输入 公式中的输入value。 FLOAT16、BFLOAT16 ND
scale 输入 公式中的输入scale,代表attention计算的缩放系数。 DOUBLE -
l' 属性 公式中的输入l',代表select阶段的block大小。 INT64 -
l 属性 公式中的输入l,代表compress阶段的block大小。 INT64 -
d 属性 公式中的输入d,代表两次压缩间的滑窗间隔大小。 INT64 -
attentionOut 输出 公式中的attentionOut,attention计算的结果。 FLOAT16、BFLOAT16 ND
topkIndices 输出 公式中的topkIndices,重要性得分最高的几个block的索引。 INT32 -

约束说明

  • 参数query中的N和numHeads值相等,key、value的N和numKeyValueHeads值相等,并且numHeads是numKeyValueHeads的倍数关系。
  • 参数query中的D和key的D(H/numKeyValueHeads)值相等,value的D(H/numKeyValueHeads)和output的D值相等。
  • query,key,value输入,功能使用限制如下:
    • 支持B轴小于等于3072。
    • 支持key/value的N轴小于等于256。
    • 支持query的N轴与key/value的N轴(H/D)的比值(即GQA中的group大小)小于等于16。
    • 支持query与key的D轴等于192。
    • 支持value的D轴等于128。
    • 支持key与value的blockSize等于64或128。
    • 普通场景下仅支持query的S轴等于1。
    • 多token推理场景下,仅支持query的S轴最大等于4,并且此时要求每个batch单独的actualQSeqLen<=actualSelKvSeqLen。
    • 仅支持paged attention。
    • 仅支持selectBlockSize取值为16的整数倍,最大支持到128。
    • selectBlockCount上限满足selectBlockCount*selectBlockSize<=MaxKvSeqlen,MaxKvSeqlen=Max(actualSelKvSeqLenOptional)。

调用说明

调用方式 样例代码 说明
aclnn接口 test_aclnn_nsa_compress_attention_infer 通过aclnnNsaCompressAttentionInfer接口方式调用NsaCompressAttentionInfer算子。