文件最后提交记录最后更新时间
【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 个月前
匹配最新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 个月前
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!487022 天前
add kirin9030 ops Co-authored-by: zengjuan<zengjuan2@huawei.com> # message auto-generated for no-merge-commit merge: !1118 merge master into master add kirin9030 ops Created-by: zengjuan Commit-by: zengjuan Merged-by: cann-robot Description: ## 描述 add kirin9030 ops: attention/nsa_compress_with_cache attention/nsa_selected_attention_infer attention/ring_attention_update ffn/ffn ffn/swin_attention_ffn ffn/swin_transformer_ln_qkv ffn/swin_transformer_ln_qkv_quant gmm/grouped_matmul gmm/grouped_matmul_swiglu_quant moe/moe_compute_expert_tokens moe/moe_finalize_routing moe/moe_finalize_routing_v2 moe/moe_re_routing moe/moe_token_unpermute moe/moe_token_unpermute_with_ep moe/moe_token_unpermute_with_routing_map posembedding/apply_rotary_pos_emb posembedding/dequant_rope_quant_kvcache posembedding/interleave_rope posembedding/kv_rms_norm_rope_cache posembedding/rope_quant_kvcache posembedding/rope_with_sin_cos_cache posembedding/rotary_position_embedding ## 关联的Issue https://gitcode.com/cann/ops-transformer/issues/671 ## 测试 蓝区门禁、黄区门禁、算子二级冒烟 ## 文档更新 无 ## 类型标签 <!-- [x] 表示选中 --> - [ ] Bug修复 - [x] 新特性 - [ ] 性能优化 - [ ] 文档更新 - [ ] 其他,请描述: See merge request: cann/ops-transformer!11183 个月前
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!487022 天前
匹配最新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 个月前
wsl_transformer_readme修改 Co-authored-by: wang_shuli<wangshuli6@h-partners.com> # message auto-generated for no-merge-commit merge: !2329 merge master into master wsl_transformer_readme修改 Created-by: wang_shuli Commit-by: wang_shuli Merged-by: cann-robot Description: ## 描述 算子代码中数据类型跟readme文件中所支持的数据类型不一致 ## 关联的Issue https://gitcode.com/cann/ops-transformer/issues/1062 ## 测试 ## 文档更新 更新了README.md文件。 ## 类型标签 - [ ] Bug修复 - [ ] 新特性 - [ ] 性能优化 - [ x] 文档更新 - [ ] 其他,请描述: See merge request: cann/ops-transformer!23292 个月前
README.md

NsaCompressWithCache

产品支持情况

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

功能说明

  • 算子功能:用于Native-Sparse-Attention推理阶段的KV压缩,每次推理每个batch会产生一个新的token,每当某个batch的token数量凑满一个compress_block时,该算子会将该batch的后compress_block个token压缩成一个compress_token,算法流程如下:

    1. 检查act_seq_lens是否有满足s≥compressBlockSizes \ge compressBlockSize(s−compressBlockSize)%stride==0(s - compressBlockSize) \% stride ==0的序列长度;
    2. 找到满足序列长度的batchIdx,根据block_table找到该batch的后compress_block_size个token压缩;
    3. 执行压缩算法;
    4. 根据slot_mapping写回到output_cache中。
  • 计算公式:

compressIdx=(s−compressBlockSize)/strideoutputCacheRef[slotMapping[i]]=input[compressIdx∗stride:compressIdx∗stride+compressBlockSize]∗weight[:]compressIdx=(s-compressBlockSize)/stride\\ outputCacheRef[slotMapping[i]] = input[compressIdx*stride : compressIdx*stride+compressBlockSize]*weight[:]

参数说明

参数名 输入/输出/属性 描述 数据类型 数据格式
s 属性 当前batch的token长度。 INT64 -
compressBlockSize 属性 压缩滑窗大小。 INT64 -
stride 属性 两次压缩滑窗间隔大小。 INT64 -
weight 输入 k/v值的压缩weight。 BFLOAT16、FLOAT16 ND
input 输入 k/v值的cache。 BFLOAT16、FLOAT16 ND
slotMapping 输入 每个batch尾部压缩数据存储的位置的索引。 INT32 ND
outputCacheRef 输入/输出 输出的cache。 BFLOAT16、FLOAT16 ND
  • Kirin X90/Kirin 9030 处理器系列产品: 不支持BFLOAT16。

约束说明

  • input和weight满足broadcast关系,input的第三维大小与weight的第二维大小相等。
  • compressBlockSize、stride必须是16的整数倍,且compressBlockSize>=stride,compressBlockSize<=64。
  • actSeqLenType目前仅支持取值1。
  • layoutOptional取值可以是BSH、SBH、BSND、BNSD、TND,但是不会生效。
  • pageBlockSize只能是64或者128。
  • headDim是16的整数倍,且headDim<=256。
  • 不支持input/weight/outputCache为空输入。
  • slotMapping的值无重复,否则会导致计算结果不稳定。
  • blockTableOptional的值不超过blockNum,否则会发生越界。
  • actSeqLenOptional的值不应该超过序列最大长度。
  • headNum<=64,且headNum>50时headNum%2=0。

调用说明

调用方式 样例代码 说明
aclnn接口 test_aclnn_nsa_compress_with_cache 通过aclnnNsaCompressWithCache接口方式调用NsaCompressWithCache算子。