| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
update: rename blocksparseattention -> adablocksparseattention Co-authored-by: hyh_hh<huyinghong1@huawei.com> Co-authored-by: Abeon<wangbofan@huawei.com> # message auto-generated for no-merge-commit merge: !251 merge dev into dev update: rename blocksparseattention -> adablocksparseattention Created-by: hyh_hh Commit-by: Abeon;hyh_hh Merged-by: ascend-robot Description: # Purpose 文件重命名(31个文件 + 1个目录): - csrc/plugin/block_sparse_attention.{h,cpp} → ada_block_sparse_attention.{h,cpp} - csrc/ops/ascendc/op_host/block_sparse_attention*.{cpp,h} → ada_block_sparse_attention*.*(9个文件) - csrc/ops/ascendc/op_kernel/block_sparse_attention*.{cpp,h} → ada_block_sparse_attention*.*(5个文件) - 目录 csrc/ops/block_sparse_attention/ → csrc/ops/ada_block_sparse_attention/(含内部14个文件同步重命名) - tests/plugin/test_blocksparseattention.py → test_adablocksparseattention.py 内容替换(涉及所有相关文件): - BlockSparseAttention → AdaBlockSparseAttention - block_sparse_attention → ada_block_sparse_attention - BLOCK_SPARSE_ATTENTION → ADA_BLOCK_SPARSE_ATTENTION(头文件 include guard) - blocksparseattention → adablocksparseattention # Test Plan > 设计了哪些测试内容,指导他人如何对你的PR进行测试\ > Apply information to show others your test design and how to test your Pull Request # Test Report UT通过  profiling确认算子名已更新  See merge request: Ascend/MindIE-SD!251 | 3 个月前 | |
update: rename blocksparseattention -> adablocksparseattention Co-authored-by: hyh_hh<huyinghong1@huawei.com> Co-authored-by: Abeon<wangbofan@huawei.com> # message auto-generated for no-merge-commit merge: !251 merge dev into dev update: rename blocksparseattention -> adablocksparseattention Created-by: hyh_hh Commit-by: Abeon;hyh_hh Merged-by: ascend-robot Description: # Purpose 文件重命名(31个文件 + 1个目录): - csrc/plugin/block_sparse_attention.{h,cpp} → ada_block_sparse_attention.{h,cpp} - csrc/ops/ascendc/op_host/block_sparse_attention*.{cpp,h} → ada_block_sparse_attention*.*(9个文件) - csrc/ops/ascendc/op_kernel/block_sparse_attention*.{cpp,h} → ada_block_sparse_attention*.*(5个文件) - 目录 csrc/ops/block_sparse_attention/ → csrc/ops/ada_block_sparse_attention/(含内部14个文件同步重命名) - tests/plugin/test_blocksparseattention.py → test_adablocksparseattention.py 内容替换(涉及所有相关文件): - BlockSparseAttention → AdaBlockSparseAttention - block_sparse_attention → ada_block_sparse_attention - BLOCK_SPARSE_ATTENTION → ADA_BLOCK_SPARSE_ATTENTION(头文件 include guard) - blocksparseattention → adablocksparseattention # Test Plan > 设计了哪些测试内容,指导他人如何对你的PR进行测试\ > Apply information to show others your test design and how to test your Pull Request # Test Report UT通过  profiling确认算子名已更新  See merge request: Ascend/MindIE-SD!251 | 3 个月前 | |
[feature]新增adaLayernormv2的plugin Co-authored-by: chensiyu47<chensiyu49@huawei.com> # message auto-generated for no-merge-commit merge: !172 merge dev into dev [feature]新增adaLayernormv2的plugin Created-by: chensiyu47 Commit-by: chensiyu47 Merged-by: ascend-robot Description: <!-- PR描述模板更新日期:20251224 --> # Purpose 新增adaLayernormv2的plugin # Test Plan 单算子测试 # Test Report  See merge request: Ascend/MindIE-SD!172 | 5 个月前 | |
[feature]新增adaLayernormv2的plugin Co-authored-by: chensiyu47<chensiyu49@huawei.com> # message auto-generated for no-merge-commit merge: !172 merge dev into dev [feature]新增adaLayernormv2的plugin Created-by: chensiyu47 Commit-by: chensiyu47 Merged-by: ascend-robot Description: <!-- PR描述模板更新日期:20251224 --> # Purpose 新增adaLayernormv2的plugin # Test Plan 单算子测试 # Test Report  See merge request: Ascend/MindIE-SD!172 | 5 个月前 | |
[Bugfix][SLA]Fallback to BlockSparseAttention V1 when V2 aclnn is unavailable Co-authored-by: yujunyu2<yujunyu3@huawei.com> # message auto-generated for no-merge-commit merge: !403 merge dev into dev [Bugfix][SLA]Fallback to BlockSparseAttention V1 when V2 aclnn is unavailable Created-by: yjy_ac Commit-by: yujunyu2 Merged-by: ascend-robot Description: # Which issue(s) this PR fixes or accomplishes Fixes #199 关联 Issue:https://gitcode.com/Ascend/MindIE-SD/issues/199 # Purpose 修复 BSA PyTorch 插件在**仅含 V1 aclnn 符号的老版本 CANN** 上无法运行的问题。 部分 CANN 环境(如 CANN 9.0.0)的 libopapi.so 只交付 aclnnBlockSparseAttention(V1),不包含 aclnnBlockSparseAttentionV2。若插件硬绑 V2,运行期会在 dlsym 阶段直接失败,导致 SLA 等依赖 block_sparse_attention 的推理路径完全不可用。 **本 PR 改动:** | 模块 | 文件 | 说明 | |------|------|------| | PyTorch 插件 | csrc/plugin/block_sparse_attention.cpp | 运行时通过 GetOpApiFuncAddr 探测 aclnnBlockSparseAttentionV2 是否存在于 libopapi.so;存在则走 V2(支持 BF16/FP16/FP8),不存在则回退 aclnnBlockSparseAttention(V1,仅 BF16/FP16) | | 单元测试 | tests/plugin/test_rf_v3_attention.py | 增加 _is_bsa_v2_available() 探测;老 CANN 无 V2 时自动 skip FP8 用例,避免误报失败 | **行为说明:** - V2 可用:优先调用 aclnnBlockSparseAttentionV2,保持 FP8 等新特性路径 - V2 不可用、V1 可用:回退 V1,BF16/FP16 输入可正常推理 - V2 不可用且输入为 FP8:显式 TORCH_CHECK 报错,提示需升级 CANN 或改用 BF16/FP16 # Test Plan 1. **编译验证** - 编译 PyTorch 插件(build/build_plugin.sh 或 python setup.py bdist_wheel) - 确认 libPTAExtensionOPS.so 正常生成 2. **老 CANN(仅 V1 BSA)环境验证** - 确认 libopapi.so 无 V2 符号: nm -D $ASCEND_HOME_PATH/aarch64-linux/lib64/libopapi.so | grep -E 'aclnnBlockSparseAttention(V2)?(GetWorkspaceSize)?$' - 运行 SLA 层测试: python3 -m pytest tests/layers/flash_attn/test_sparse_linear_attn.py -v - 运行 RF-V3 attention 插件测试(无 V2 时 FP8 用例应被 skip,不应出现 not in libopapi.so 失败): python3 -m pytest tests/plugin/test_rf_v3_attention.py -v 3. **新 CANN(含 V2 BSA)回归(可选)** - 同上两条 pytest,确认 V2 路径与 FP8 用例仍正常 # Test Report **测试环境:** CANN 9.0.0(libopapi.so 仅含 V1 BSA 符号),Ascend 950 NPU,Python 3.11.15,pytest 8.3.2,aarch64 | 测试项 | 命令 | 结果 | |--------|------|------| | SLA SparseLinearAttention 层测试 | pytest tests/layers/flash_attn/test_sparse_linear_attn.py | ✅ 35 passed in 33.93s | | RF-V3 BSA 插件测试(老 CANN 无 V2) | pytest tests/plugin/test_rf_v3_attention.py | ✅ 9 skipped in 9.73s(无 failed/error;FP8 相关用例在无 V2 环境下 skip) | **SLA 测试通过截图(V1 回退路径,35 passed):**  **RF-V3 测试截图(老 CANN 无 V2,FP8 用例 skip):**  See merge request: Ascend/MindIE-SD!403 | 29 天前 | |
[feature][bsa] support fp8 bsa Co-authored-by: hyh_hh<huyinghong1@huawei.com> # message auto-generated for no-merge-commit merge: !337 merge bsa into dev [feature][bsa] support fp8 bsa Created-by: hyh_hh Commit-by: hyh_hh Merged-by: ascend-robot Description: # Purpose 支持 FP8 BSA(Block Sparse Attention),包括: - block_sparse_attention.cpp 算子接口更新,aclnnBlockSparseAttention -> aclnnBlockSparseAttentionV2,后者兼容前者BF16实现 - sparse_flash_attn_rf_v3.py 新增 FP8 量化路径的稀疏注意力实现,模型侧通过传入q_rot、k_rot使能FP8量化稀疏,block_size支持q=128,kv=256或512 - csrc/plugin/pytorch_npu_helper.h新增 FP8 类型 # Test Plan 1. UT:pytest tests/plugin/test_rf_v3_attention.py 和 pytest tests/plugin/test_block_sparse_attention.py 2. Wan2.2模型接入验证 # Test Report 1. UT:  2. Wan2.2模型接入验证:功能和精度正常 See merge request: Ascend/MindIE-SD!337 | 1 个月前 | |
【docs】文档修改-增加API参考&加速API Co-authored-by: xiao-qing123<xiaoqing14@h-partners.com> # message auto-generated for no-merge-commit merge: !263 merge dev into dev 【docs】文档修改-增加API参考&加速API Created-by: xiao-qing123 Commit-by: xiao-qing123 Merged-by: ascend-robot Description: fixes [#86](https://gitcode.com/Ascend/MindIE-SD/issues/86) 1、新增API参考(社区API接口) 2、新增加速API(原社区layer层) 3、删除readme中的快速入门和单多卡并行示例内容(有单独的quick_start承载) 4、算子融合单独拆分出来,在特性章节独立存在 5、删除特性章节目录名称中的“加速特性” 6、黄区大模型检测问题修改 See merge request: Ascend/MindIE-SD!263 | 3 个月前 | |
aclnn算子op plugin 公共接口 Co-authored-by: changetheway<guotaoyuan1@h-partners.com> # message auto-generated for no-merge-commit merge: !30 merge dev_1203_pta into dev aclnn算子op plugin 公共接口 Created-by: changetheway Commit-by: changetheway Merged-by: ascend-robot Description: aclnn算子op plugin 公共接口  See merge request: Ascend/MindIE-SD!30 | 7 个月前 | |
[Feature][ops]Add frequency regulator operator Co-authored-by: w00955629<wangruonan14@huawei.com> # message auto-generated for no-merge-commit merge: !395 merge feature/frequency-optimization-op into dev [Feature][ops]Add frequency regulator operator Created-by: w00955629 Commit-by: w00955629 Merged-by: ascend-robot Description: # Which issue(s) this PR fixes or accomplishes # Purpose Add MindIE-SD plugin support for the CANN frequency optimization operator. This change adds: - C++ wrapper and registration for the two-stage aclnn operator flow. - BackendSelect registration for scalar-only dispatch. - Python API export from mindiesd. - Lightweight wrapper tests for parameter validation and torch op forwarding. - Incremental test mapping for the new plugin files. # Test Plan - Build MindIE-SD from source with the CANN package that contains the operator. - Install with editable mode. - Verify Python import and torch op registration. - Run a smoke test on supported hardware and confirm the operator returns success status. - Run wrapper unit tests for Python-side parameter validation. # Test Report - git diff --check: passed. - Python py_compile for modified Python files: passed. - GitCode remote hook: passed. - Source build and runtime smoke test on target environment: passed by local validation. See merge request: Ascend/MindIE-SD!395 | 30 天前 | |
[Feature][ops]Add frequency regulator operator Co-authored-by: w00955629<wangruonan14@huawei.com> # message auto-generated for no-merge-commit merge: !395 merge feature/frequency-optimization-op into dev [Feature][ops]Add frequency regulator operator Created-by: w00955629 Commit-by: w00955629 Merged-by: ascend-robot Description: # Which issue(s) this PR fixes or accomplishes # Purpose Add MindIE-SD plugin support for the CANN frequency optimization operator. This change adds: - C++ wrapper and registration for the two-stage aclnn operator flow. - BackendSelect registration for scalar-only dispatch. - Python API export from mindiesd. - Lightweight wrapper tests for parameter validation and torch op forwarding. - Incremental test mapping for the new plugin files. # Test Plan - Build MindIE-SD from source with the CANN package that contains the operator. - Install with editable mode. - Verify Python import and torch op registration. - Run a smoke test on supported hardware and confirm the operator returns success status. - Run wrapper unit tests for Python-side parameter validation. # Test Report - git diff --check: passed. - Python py_compile for modified Python files: passed. - GitCode remote hook: passed. - Source build and runtime smoke test on target environment: passed by local validation. See merge request: Ascend/MindIE-SD!395 | 30 天前 | |
[Feature][ops]Add frequency regulator operator Co-authored-by: w00955629<wangruonan14@huawei.com> # message auto-generated for no-merge-commit merge: !395 merge feature/frequency-optimization-op into dev [Feature][ops]Add frequency regulator operator Created-by: w00955629 Commit-by: w00955629 Merged-by: ascend-robot Description: # Which issue(s) this PR fixes or accomplishes # Purpose Add MindIE-SD plugin support for the CANN frequency optimization operator. This change adds: - C++ wrapper and registration for the two-stage aclnn operator flow. - BackendSelect registration for scalar-only dispatch. - Python API export from mindiesd. - Lightweight wrapper tests for parameter validation and torch op forwarding. - Incremental test mapping for the new plugin files. # Test Plan - Build MindIE-SD from source with the CANN package that contains the operator. - Install with editable mode. - Verify Python import and torch op registration. - Run a smoke test on supported hardware and confirm the operator returns success status. - Run wrapper unit tests for Python-side parameter validation. # Test Report - git diff --check: passed. - Python py_compile for modified Python files: passed. - GitCode remote hook: passed. - Source build and runtime smoke test on target environment: passed by local validation. See merge request: Ascend/MindIE-SD!395 | 30 天前 | |
[Feature][plugin]Add fused infer attention score plugin Co-authored-by: lanwangli<lanwangli@huawei.com> # message auto-generated for no-merge-commit merge: !427 merge 0704_mig_fia_to_mindiesd_plugin into dev [Feature][plugin]Add fused infer attention score plugin Created-by: lanwangli Commit-by: lanwangli Merged-by: ascend-robot Description: # Which issue(s) this PR fixes or accomplishes TODO: Fixes #ISSUE ID # Purpose Add the MindIE-SD plugin-side migrated implementation for FusedInferAttentionScore. This PR provides the custom operator registration support and output metadata inference required by the follow-up Python quantization path that calls torch.ops.mindiesd.fused_infer_attention_score_v2. This PR only changes the plugin module: - Add csrc/plugin/fused_infer_attention_score.cpp for FIA output shape, LSE shape, and output dtype inference. - Add csrc/plugin/fused_infer_attention_score.h for the plugin-side FIA declarations. - Keep Python wrapper, docs, and tests out of this PR so the change remains module-scoped. # Test Plan - Run pre-commit on the diff between this branch and origin/dev. - Cover base formatting checks, secret detection, spelling checks, typos, and C/C++ clang-format. - Use the MR static rule asset as quality-gate reference for C++ code, including formatting, const usage, null pointer usage, macro/name constraints, and resource handling rules. # Test Report Executed and passed: bash pre-commit run --from-ref origin/dev --to-ref HEAD Result: Passed Not executed in this split PR: bash bash tests/ops/fused_infer_attention_score/run_fia_arch35_ut.sh Reason: the UT script is submitted in the test PR. Run it after the split plugin/core/test PRs are combined or merged. See merge request: Ascend/MindIE-SD!427 | 1 个月前 | |
[Feature][plugin]Add fused infer attention score plugin Co-authored-by: lanwangli<lanwangli@huawei.com> # message auto-generated for no-merge-commit merge: !427 merge 0704_mig_fia_to_mindiesd_plugin into dev [Feature][plugin]Add fused infer attention score plugin Created-by: lanwangli Commit-by: lanwangli Merged-by: ascend-robot Description: # Which issue(s) this PR fixes or accomplishes TODO: Fixes #ISSUE ID # Purpose Add the MindIE-SD plugin-side migrated implementation for FusedInferAttentionScore. This PR provides the custom operator registration support and output metadata inference required by the follow-up Python quantization path that calls torch.ops.mindiesd.fused_infer_attention_score_v2. This PR only changes the plugin module: - Add csrc/plugin/fused_infer_attention_score.cpp for FIA output shape, LSE shape, and output dtype inference. - Add csrc/plugin/fused_infer_attention_score.h for the plugin-side FIA declarations. - Keep Python wrapper, docs, and tests out of this PR so the change remains module-scoped. # Test Plan - Run pre-commit on the diff between this branch and origin/dev. - Cover base formatting checks, secret detection, spelling checks, typos, and C/C++ clang-format. - Use the MR static rule asset as quality-gate reference for C++ code, including formatting, const usage, null pointer usage, macro/name constraints, and resource handling rules. # Test Report Executed and passed: bash pre-commit run --from-ref origin/dev --to-ref HEAD Result: Passed Not executed in this split PR: bash bash tests/ops/fused_infer_attention_score/run_fia_arch35_ut.sh Reason: the UT script is submitted in the test PR. Run it after the split plugin/core/test PRs are combined or merged. See merge request: Ascend/MindIE-SD!427 | 1 个月前 | |
[Feature][ops]aclnn编译工程适配 Co-authored-by: guowenna1<guowenna1@huawei.com> # message auto-generated for no-merge-commit merge: !201 merge aclnn_compil into dev [Feature][ops]aclnn编译工程适配 Created-by: guowenna1 Commit-by: guowenna1 Merged-by: ascend-robot Description: Purpose 1、算子接入方式从aclop改为aclnn,aclnn编译工程适配 2、移除rope的plugin定义,对外接口保留,但路由到torch npu实现 Test Plan A2、A3、A5编译工程测试 A2、A3全量测试用例验证 A2、A3模型整网验证 Test Report  See merge request: Ascend/MindIE-SD!201 | 4 个月前 | |
[dev]同步最新代码 Co-authored-by: mazhixin00_00<mazhixin7@huawei.com> | 8 个月前 | |
[Bugfix][ops] Fix la_preprocess buffer allocation mismatch with infer-shape contract Co-authored-by: changetheway<guotaoyuan1@h-partners.com> # message auto-generated for no-merge-commit merge: !307 merge la_preprocess into dev [Bugfix][ops] Fix la_preprocess buffer allocation mismatch with infer-shape contract Created-by: changetheway Commit-by: changetheway Merged-by: ascend-robot Description: # Which issue(s) this PR fixes or accomplishes Fixes #<142> # Purpose 1. **C++ 插件** ( csrc/plugin/la_preprocess.cpp):调整实现细节。 2. **Python 实现** (mindiesd/layers/flash_attn/ascend_laser_preprocess.py): - 移除 AttentionParam 依赖,简化 forward_preprocess 逻辑; - 新增 query/key/value 的 4D 维度校验; - 将 head dimensions 联合校验拆分为 key/value 两个独立条件,分别抛出带上下文的 ParametersInvalid 异常,提升可调试性。 3. **测试** (tests/plugin/test_la_preprocess.py): - 重构并大幅扩充测试覆盖,新增 shape、consistency、align_len、dtype、layout、memory、device 等多维度测试; - 补齐 test_python_entry_value_head_*_mismatch 的异常消息断言,消除假阴性; - 同步更新 key 测试的断言以匹配新的独立错误消息。 4. **代码规范** (pre-commit/pyproject.toml): - 为 tests/**/* 添加 per-file-ignores,跳过 F401/I/E402,避免测试代码因 import 风格阻塞提交。 # Test Plan 1. 编译验证:cd build && bash build.sh 2. 回归验证:python3 tests/plugin/test_la_preprocess.py # Test Report - bash build.sh 编译通过 - python3 tests/plugin/test_la_preprocess.py -v 通过(18/18)  See merge request: Ascend/MindIE-SD!307 | 1 个月前 | |
[dev]同步最新代码 Co-authored-by: mazhixin00_00<mazhixin7@huawei.com> | 8 个月前 | |
[Bugfix][ops]Add dimension validation to prevent size_t underflow in layernorm Co-authored-by: changetheway<guotaoyuan1@h-partners.com> # message auto-generated for no-merge-commit merge: !305 merge layernorm into dev [Bugfix][ops]Add dimension validation to prevent size_t underflow in layernorm Created-by: changetheway Commit-by: changetheway Merged-by: ascend-robot Description: # Which issue(s) this PR fixes or accomplishes > Fix #<141> # Purpose 修复 csrc/plugin/layernorm.cpp 中 size_t 下溢导致越界迭代与潜在内存破坏的安全漏洞。 具体修复: 1. **C++ 算子层**:在 beginAxis = inputNdim - normNdim 计算前增加 TORCH_CHECK(normNdim <= inputNdim),当 normalized_shape 维数大于输入张量维数时直接抛出 RuntimeError,阻断无符号下溢路径。 2. **Python 入口层**:在 mindiesd/layers/norm.py::check_input_params() 中增加 len(layernorm.normalized_shape) > x.dim() 前置校验,使公开 API 路径在调用 C++ 算子前即被拒绝。 3. **Fake Op 层**:在 mindiesd/layers/_custom_ops.py::layernorm_fake() 中同步增加相同维数校验,保持测试 fake 模式与真实算子行为一致。 4. **边界用例测试**:在 tests/layers/test_layernorm.py 和 tests/plugin/test_layernorm.py 中补充 normalized_shape 过大、等于、小于输入维数三类边界测试。 # Test Plan 1. 编译验证:cd build && bash build.sh 2. 运行 layers 层测试:pytest tests/layers/test_layernorm.py -v 3. 运行 plugin 层测试:pytest tests/plugin/test_layernorm.py -v # Test Report - 编译:build.sh 成功 - tests/layers/test_layernorm.py:6 passed(含新增 3 个边界用例)  - tests/plugin/test_layernorm.py:4 passed(含新增 2 个边界用例)  See merge request: Ascend/MindIE-SD!305 | 2 个月前 | |
[Bugfix][ops]Add dimension validation to prevent size_t underflow in layernorm Co-authored-by: changetheway<guotaoyuan1@h-partners.com> # message auto-generated for no-merge-commit merge: !305 merge layernorm into dev [Bugfix][ops]Add dimension validation to prevent size_t underflow in layernorm Created-by: changetheway Commit-by: changetheway Merged-by: ascend-robot Description: # Which issue(s) this PR fixes or accomplishes > Fix #<141> # Purpose 修复 csrc/plugin/layernorm.cpp 中 size_t 下溢导致越界迭代与潜在内存破坏的安全漏洞。 具体修复: 1. **C++ 算子层**:在 beginAxis = inputNdim - normNdim 计算前增加 TORCH_CHECK(normNdim <= inputNdim),当 normalized_shape 维数大于输入张量维数时直接抛出 RuntimeError,阻断无符号下溢路径。 2. **Python 入口层**:在 mindiesd/layers/norm.py::check_input_params() 中增加 len(layernorm.normalized_shape) > x.dim() 前置校验,使公开 API 路径在调用 C++ 算子前即被拒绝。 3. **Fake Op 层**:在 mindiesd/layers/_custom_ops.py::layernorm_fake() 中同步增加相同维数校验,保持测试 fake 模式与真实算子行为一致。 4. **边界用例测试**:在 tests/layers/test_layernorm.py 和 tests/plugin/test_layernorm.py 中补充 normalized_shape 过大、等于、小于输入维数三类边界测试。 # Test Plan 1. 编译验证:cd build && bash build.sh 2. 运行 layers 层测试:pytest tests/layers/test_layernorm.py -v 3. 运行 plugin 层测试:pytest tests/plugin/test_layernorm.py -v # Test Report - 编译:build.sh 成功 - tests/layers/test_layernorm.py:6 passed(含新增 3 个边界用例)  - tests/plugin/test_layernorm.py:4 passed(含新增 2 个边界用例)  See merge request: Ascend/MindIE-SD!305 | 2 个月前 | |
[Feature][ops]Add mul_add fused operator support Co-authored-by: wangwei<daviwang2026@qq.com> # message auto-generated for no-merge-commit merge: !481 merge feature/mul_add_ops_dev into dev [Feature][ops]Add mul_add fused operator support Created-by: daviwang Commit-by: wangwei Merged-by: ascend-robot Description: # Purpose 新增 mul_add 融合算子,支持在昇腾 NPU 上执行融合乘加计算: - 算子接口:mindiesd::mul_add(a, b, c) -> y - 计算公式:y = a + b * c - 输入 shape:a/b = [batch, seq_len, hidden_size],c = [batch, 1, hidden_size] - 支持数据类型:FP16、BF16 - 支持计算平台:ascend910b、ascend910_93、ascend950 主要变更: 1. 在 csrc/ops/mul_add/ 下新增算子定义(OpDef)、shape/dtype 推导(proto)、tiling 计算及 AscendC kernel 实现。 2. 在 csrc/plugin/ 下新增 mul_add PTA plugin,并在 register_ops.cpp 中注册到 mindiesd torch 库。 3. 更新 csrc/CMakeLists.txt,将 mul_add.cpp 加入 PTAExtensionOPS 编译。 4. 更新 build/build_ops.sh 默认算子列表,确保默认构建包含 mul_add。 5. 在 tests/ops/mul_add/ 下新增单元测试,覆盖基础 shape、典型 LLM shape、小 shape 边界及 FP16 精度场景。 # Test Plan > 设计了哪些测试内容,指导他人如何对你的PR进行测试\ > Apply information to show others your test design and how to test your Pull Request 1. 编译 AscendC 算子: bash cd build bash build_ops.sh 2. 编译 PTA plugin: bash cd build bash build_plugin.sh 3. 运行 mul_add 单元测试(需在 NPU 环境): bash cd tests/ops/mul_add python test_mul_add.py 4. 可选:通过环境变量指定 NPU 卡号: ``bash MINDIESD_TEST_NPU_ID=7 python test_mul_add.py # Test Report • 测试覆盖: • 基础小 shape:(1, 4, 128) • 典型 LLM shape:(1, 7200, 4608)、(1, 256, 4608)、(1, 7200, 3072)、(1, 256, 3072) • 多组小 shape 边界:(1, 1, 64) ~ (1, 64, 1024) • FP16 精度:(1, 256, 3072) • 参考实现:ref = a.float() + b.float() * c.float() • 精度阈值:rtol=1e-2, atol=1e-2 - 运行环境:CANN 9.1.T560, Ascend950PR NPU, Python 3.11, aarch64 - 所有新增测试用例均通过: - test_mul_add_basic PASSED - test_mul_add_typical PASSED - test_mul_add_small_shapes PASSED - test_mul_add_fp16` PASSED - 最大误差:BF16 < 1e-2,FP16 < 1e-2 See merge request: Ascend/MindIE-SD!481 | 8 天前 | |
[Feature][ops]Add mul_add fused operator support Co-authored-by: wangwei<daviwang2026@qq.com> # message auto-generated for no-merge-commit merge: !481 merge feature/mul_add_ops_dev into dev [Feature][ops]Add mul_add fused operator support Created-by: daviwang Commit-by: wangwei Merged-by: ascend-robot Description: # Purpose 新增 mul_add 融合算子,支持在昇腾 NPU 上执行融合乘加计算: - 算子接口:mindiesd::mul_add(a, b, c) -> y - 计算公式:y = a + b * c - 输入 shape:a/b = [batch, seq_len, hidden_size],c = [batch, 1, hidden_size] - 支持数据类型:FP16、BF16 - 支持计算平台:ascend910b、ascend910_93、ascend950 主要变更: 1. 在 csrc/ops/mul_add/ 下新增算子定义(OpDef)、shape/dtype 推导(proto)、tiling 计算及 AscendC kernel 实现。 2. 在 csrc/plugin/ 下新增 mul_add PTA plugin,并在 register_ops.cpp 中注册到 mindiesd torch 库。 3. 更新 csrc/CMakeLists.txt,将 mul_add.cpp 加入 PTAExtensionOPS 编译。 4. 更新 build/build_ops.sh 默认算子列表,确保默认构建包含 mul_add。 5. 在 tests/ops/mul_add/ 下新增单元测试,覆盖基础 shape、典型 LLM shape、小 shape 边界及 FP16 精度场景。 # Test Plan > 设计了哪些测试内容,指导他人如何对你的PR进行测试\ > Apply information to show others your test design and how to test your Pull Request 1. 编译 AscendC 算子: bash cd build bash build_ops.sh 2. 编译 PTA plugin: bash cd build bash build_plugin.sh 3. 运行 mul_add 单元测试(需在 NPU 环境): bash cd tests/ops/mul_add python test_mul_add.py 4. 可选:通过环境变量指定 NPU 卡号: ``bash MINDIESD_TEST_NPU_ID=7 python test_mul_add.py # Test Report • 测试覆盖: • 基础小 shape:(1, 4, 128) • 典型 LLM shape:(1, 7200, 4608)、(1, 256, 4608)、(1, 7200, 3072)、(1, 256, 3072) • 多组小 shape 边界:(1, 1, 64) ~ (1, 64, 1024) • FP16 精度:(1, 256, 3072) • 参考实现:ref = a.float() + b.float() * c.float() • 精度阈值:rtol=1e-2, atol=1e-2 - 运行环境:CANN 9.1.T560, Ascend950PR NPU, Python 3.11, aarch64 - 所有新增测试用例均通过: - test_mul_add_basic PASSED - test_mul_add_typical PASSED - test_mul_add_small_shapes PASSED - test_mul_add_fp16` PASSED - 最大误差:BF16 < 1e-2,FP16 < 1e-2 See merge request: Ascend/MindIE-SD!481 | 8 天前 | |
[Feature][ops]Add norm_rope_concat fused operator Co-authored-by: zhangtian6691844<zhangtiantian5@huawei.com> # message auto-generated for no-merge-commit merge: !455 merge feat/norm_rope_concat_dev into dev [Feature][ops]Add norm_rope_concat fused operator Created-by: zhangtian6691844 Commit-by: zhangtian6691844 Merged-by: ascend-robot Description: <!-- PR描述模板更新日期:20251224 --> # Which issue(s) this PR fixes or accomplishes > **如问题已解决,按照下方示例附上ISSUE单号 / Apply bug or request issue as follow if the solved**\ > Fixes #ISSUE ID\ > **Fixes关键字会自动关闭issue,如问题部分解决请不要使用Fixes,可以用下方标签替代\ > Fixes will automatically close issue, please use the following tag if only part of the issue is solved**\ > Fix part of #ISSUE ID N/A — 新增特性,非问题修复。 # Purpose 为 MindIE-SD 新增 **NormRopeConcat 融合算子**,将三个高频操作(LayerNorm/RMSNorm、RoPE 旋转位置编码、KV Concat)融合为一个 AscendC 自定义算子,减少显存访问次数和 kernel launch 开销,提升大模型推理性能。 **算子功能:** - 对 Query/Key 输入执行 LayerNorm 或 RMSNorm(可选 affine) - 对 Query/Key 执行 RoPE 旋转位置编码(支持 interleave / half 两种模式) - 将 encoder KV 与当前 KV concat 拼接(支持 encoder 在前或在后) - 支持训练模式,输出 norm 的 mean/rstd 用于反向传播 - 支持 16 个输入、11 个输出,全部可选张量自动处理 **变更范围(18 files, +3819/-6 lines):** | 模块 | 文件 | 说明 | |------|------|------| | AscendC Host | csrc/ops/norm_rope_concat/op_host/ (6 files) | 算子定义、Shape/Dtype 推导、Tiling 策略 | | AscendC Kernel | csrc/ops/norm_rope_concat/op_kernel/ (4 files) | NPU 核函数实现 | | PyTorch 插件 | csrc/plugin/norm_rope_concat.{cpp,h} (2 files) | 插件适配层,调用 ACLNN 接口 | | 构建集成 | build/build_ops.sh, csrc/CMakeLists.txt, csrc/plugin/register_ops.cpp | 算子注册与编译 | | 单元测试 | tests/ops/norm_rope_concat/ (3 files) | Python 功能测试 + C++ Kernel UT | # Test Plan > 设计了哪些测试内容,指导他人如何对你的PR进行测试\ > Apply information to show others your test design and how to test your Pull Request 1. **编译验证** - AscendC 算子编译(ascend910_93 / ascend910b / ascend950 三芯片) - PyTorch 插件编链(libPTAExtensionOPS.so) - 构建环境:CANN 9.1.T560 + bisheng + PyTorch 2.x 2. **单元测试(Python)** - test_norm_rope_concat.py:覆盖 norm_type (NONE/LAYER_NORM/RMS_NORM)、rope_type (NONE/INTERLEAVE/HALF)、concat_order (BEFORE/AFTER)、训练模式等组合 - run_simple_test.py:快速冒烟测试 3. **C++ Kernel UT** - test_norm_rope_concat_kernel.cpp:验证 Tiling 数据传递与 kernel 逻辑正确性 4. **回归验证** - 已有算子(LA、AdaLA、RainFusionAttention 等)编译不受影响 - build_ops.sh 中 norm_rope_concat 作为 ascendc_ops 之一参与构建 # Test Report | 测试项 | 芯片 | 结果 | |--------|------|------| | AscendC 编译 (op_host_aclnn) | - | ✅ PASS | | AscendC 编译 (opsproto) | - | ✅ PASS | | AscendC 编译 (optiling) | - | ✅ PASS | | AscendC Kernel 生成 | ascend910_93 | ✅ PASS | | AscendC Kernel 生成 | ascend910b | ✅ PASS | | AscendC Kernel 生成 | ascend950 | ✅ PASS | | CANN-custom_ops .run 打包 | - | ✅ PASS | | PyTorch 插件编译链接 | - | ✅ PASS (100%) | | 已有算子兼容性 | - | ✅ 无影响 | **测试环境:** CANN 9.1.T560, Ascend950PR NPU, Python 3.11, aarch64 See merge request: Ascend/MindIE-SD!455 | 12 天前 | |
[Feature][ops]Add norm_rope_concat fused operator Co-authored-by: zhangtian6691844<zhangtiantian5@huawei.com> # message auto-generated for no-merge-commit merge: !455 merge feat/norm_rope_concat_dev into dev [Feature][ops]Add norm_rope_concat fused operator Created-by: zhangtian6691844 Commit-by: zhangtian6691844 Merged-by: ascend-robot Description: <!-- PR描述模板更新日期:20251224 --> # Which issue(s) this PR fixes or accomplishes > **如问题已解决,按照下方示例附上ISSUE单号 / Apply bug or request issue as follow if the solved**\ > Fixes #ISSUE ID\ > **Fixes关键字会自动关闭issue,如问题部分解决请不要使用Fixes,可以用下方标签替代\ > Fixes will automatically close issue, please use the following tag if only part of the issue is solved**\ > Fix part of #ISSUE ID N/A — 新增特性,非问题修复。 # Purpose 为 MindIE-SD 新增 **NormRopeConcat 融合算子**,将三个高频操作(LayerNorm/RMSNorm、RoPE 旋转位置编码、KV Concat)融合为一个 AscendC 自定义算子,减少显存访问次数和 kernel launch 开销,提升大模型推理性能。 **算子功能:** - 对 Query/Key 输入执行 LayerNorm 或 RMSNorm(可选 affine) - 对 Query/Key 执行 RoPE 旋转位置编码(支持 interleave / half 两种模式) - 将 encoder KV 与当前 KV concat 拼接(支持 encoder 在前或在后) - 支持训练模式,输出 norm 的 mean/rstd 用于反向传播 - 支持 16 个输入、11 个输出,全部可选张量自动处理 **变更范围(18 files, +3819/-6 lines):** | 模块 | 文件 | 说明 | |------|------|------| | AscendC Host | csrc/ops/norm_rope_concat/op_host/ (6 files) | 算子定义、Shape/Dtype 推导、Tiling 策略 | | AscendC Kernel | csrc/ops/norm_rope_concat/op_kernel/ (4 files) | NPU 核函数实现 | | PyTorch 插件 | csrc/plugin/norm_rope_concat.{cpp,h} (2 files) | 插件适配层,调用 ACLNN 接口 | | 构建集成 | build/build_ops.sh, csrc/CMakeLists.txt, csrc/plugin/register_ops.cpp | 算子注册与编译 | | 单元测试 | tests/ops/norm_rope_concat/ (3 files) | Python 功能测试 + C++ Kernel UT | # Test Plan > 设计了哪些测试内容,指导他人如何对你的PR进行测试\ > Apply information to show others your test design and how to test your Pull Request 1. **编译验证** - AscendC 算子编译(ascend910_93 / ascend910b / ascend950 三芯片) - PyTorch 插件编链(libPTAExtensionOPS.so) - 构建环境:CANN 9.1.T560 + bisheng + PyTorch 2.x 2. **单元测试(Python)** - test_norm_rope_concat.py:覆盖 norm_type (NONE/LAYER_NORM/RMS_NORM)、rope_type (NONE/INTERLEAVE/HALF)、concat_order (BEFORE/AFTER)、训练模式等组合 - run_simple_test.py:快速冒烟测试 3. **C++ Kernel UT** - test_norm_rope_concat_kernel.cpp:验证 Tiling 数据传递与 kernel 逻辑正确性 4. **回归验证** - 已有算子(LA、AdaLA、RainFusionAttention 等)编译不受影响 - build_ops.sh 中 norm_rope_concat 作为 ascendc_ops 之一参与构建 # Test Report | 测试项 | 芯片 | 结果 | |--------|------|------| | AscendC 编译 (op_host_aclnn) | - | ✅ PASS | | AscendC 编译 (opsproto) | - | ✅ PASS | | AscendC 编译 (optiling) | - | ✅ PASS | | AscendC Kernel 生成 | ascend910_93 | ✅ PASS | | AscendC Kernel 生成 | ascend910b | ✅ PASS | | AscendC Kernel 生成 | ascend950 | ✅ PASS | | CANN-custom_ops .run 打包 | - | ✅ PASS | | PyTorch 插件编译链接 | - | ✅ PASS (100%) | | 已有算子兼容性 | - | ✅ 无影响 | **测试环境:** CANN 9.1.T560, Ascend950PR NPU, Python 3.11, aarch64 See merge request: Ascend/MindIE-SD!455 | 12 天前 | |
[Feature][ops]迁移 fused infer attention score 算子到 MindIE-SD Co-authored-by: HAAZZZEEEE<wang-taicheng@qq.com> # message auto-generated for no-merge-commit merge: !407 merge haze/mig_fia_to_mindiesd into dev [Feature][ops]迁移 fused infer attention score 算子到 MindIE-SD Created-by: HAAZZZEEEE Commit-by: HAAZZZEEEE Merged-by: lanwangli Description: # Which issue(s) this PR fixes or accomplishes Fix part of #ISSUE 198 # Purpose 本 PR 将 fused infer attention score 算子迁移到 MindIE-SD。 主要变更: - 新增 csrc/ops/fused_infer_attention_score/ 下的算子实现,包括 op api、op host tiling/checker、op kernel、fallback graph 路径和 UT 框架。 - 新增 csrc/ops/common/、csrc/ops/incre_flash_attention/、csrc/ops/prompt_flash_attention/ 下的 FIA/flash-attention 公共 host 与 kernel 工具。 - 接入 fused infer attention score plugin,并更新相关 CMake/build 脚本。 - 新增 Python 层入口 mindiesd/layers/flash_attn/fused_infer_attention_score.py。 - 新增 tests/ops/fused_infer_attention_score/ 下的测试入口和 UT 脚本。 - 同步更新中英文 quantization 文档。 # Test Plan - 编译算子组件: - bash build/build_ops.sh - bash build/build_ascendc_ops.sh - 运行 fused infer attention score UT: - bash tests/ops/fused_infer_attention_score/run_fia_arch35_ut.sh - 运行 Python 侧 fused infer attention score 测试: - pytest tests/ops/fused_infer_attention_score/test_fused_infer_attention_score_v2.py - Wan2.2 5B TI2V w8a8f8推理测试 # Test Report 待补充: - bash build/build_ops.sh: ok - bash build/build_ascendc_ops.sh: ok - bash tests/ops/fused_infer_attention_score/run_fia_arch35_ut.sh: passed - pytest tests/ops/fused_infer_attention_score/test_fused_infer_attention_score_v2.py: passed - Wan2.2 5B TI2V w8a8f8推理测试正常 See merge request: Ascend/MindIE-SD!407 | 1 个月前 | |
feat: quant_flash_attn and quant_flash_attn_metadata operators Co-authored-by: lijinxi<lijinxi2@huawei.com> # message auto-generated for no-merge-commit merge: !313 merge dev into dev feat: quant_flash_attn and quant_flash_attn_metadata operators Created-by: weixin_44144262 Commit-by: lijinxi Merged-by: ascend-robot Description: # Which issue(s) this PR fixes or accomplishes > Fix part of #136 # Purpose 新增mxfp4的fa算子,配套的还有一个aicpu的metadata算子 # Test Plan 运行tests/ops/quant_flash_attn/quant_flash_attn_golden.py测试单算子精度 # Test Report  See merge request: Ascend/MindIE-SD!313 | 2 个月前 | |
feat: quant_flash_attn and quant_flash_attn_metadata operators Co-authored-by: lijinxi<lijinxi2@huawei.com> # message auto-generated for no-merge-commit merge: !313 merge dev into dev feat: quant_flash_attn and quant_flash_attn_metadata operators Created-by: weixin_44144262 Commit-by: lijinxi Merged-by: ascend-robot Description: # Which issue(s) this PR fixes or accomplishes > Fix part of #136 # Purpose 新增mxfp4的fa算子,配套的还有一个aicpu的metadata算子 # Test Plan 运行tests/ops/quant_flash_attn/quant_flash_attn_golden.py测试单算子精度 # Test Report  See merge request: Ascend/MindIE-SD!313 | 2 个月前 | |
feat: quant_flash_attn and quant_flash_attn_metadata operators Co-authored-by: lijinxi<lijinxi2@huawei.com> # message auto-generated for no-merge-commit merge: !313 merge dev into dev feat: quant_flash_attn and quant_flash_attn_metadata operators Created-by: weixin_44144262 Commit-by: lijinxi Merged-by: ascend-robot Description: # Which issue(s) this PR fixes or accomplishes > Fix part of #136 # Purpose 新增mxfp4的fa算子,配套的还有一个aicpu的metadata算子 # Test Plan 运行tests/ops/quant_flash_attn/quant_flash_attn_golden.py测试单算子精度 # Test Report  See merge request: Ascend/MindIE-SD!313 | 2 个月前 | |
feat: quant_flash_attn and quant_flash_attn_metadata operators Co-authored-by: lijinxi<lijinxi2@huawei.com> # message auto-generated for no-merge-commit merge: !313 merge dev into dev feat: quant_flash_attn and quant_flash_attn_metadata operators Created-by: weixin_44144262 Commit-by: lijinxi Merged-by: ascend-robot Description: # Which issue(s) this PR fixes or accomplishes > Fix part of #136 # Purpose 新增mxfp4的fa算子,配套的还有一个aicpu的metadata算子 # Test Plan 运行tests/ops/quant_flash_attn/quant_flash_attn_golden.py测试单算子精度 # Test Report  See merge request: Ascend/MindIE-SD!313 | 2 个月前 | |
【docs】文档修改-增加API参考&加速API Co-authored-by: xiao-qing123<xiaoqing14@h-partners.com> # message auto-generated for no-merge-commit merge: !263 merge dev into dev 【docs】文档修改-增加API参考&加速API Created-by: xiao-qing123 Commit-by: xiao-qing123 Merged-by: ascend-robot Description: fixes [#86](https://gitcode.com/Ascend/MindIE-SD/issues/86) 1、新增API参考(社区API接口) 2、新增加速API(原社区layer层) 3、删除readme中的快速入门和单多卡并行示例内容(有单独的quick_start承载) 4、算子融合单独拆分出来,在特性章节独立存在 5、删除特性章节目录名称中的“加速特性” 6、黄区大模型检测问题修改 See merge request: Ascend/MindIE-SD!263 | 3 个月前 | |
[feature]新增RainFusionAttention算子的plugin Co-authored-by: mazhixin00_00<mazhixin7@huawei.com> # message auto-generated for no-merge-commit merge: !54 merge dev into dev [feature]新增RainFusionAttention算子的plugin Created-by: mazhixin00_00 Commit-by: mazhixin00_00 Merged-by: ascend-robot Description: [feature]新增RainFusionAttention算子的plugin 背景: CANN中已有稀疏算子RainFusionAttention,但是未提供python的调用方式。 方案: MindIE-SD通过注册torch算子的方式,提供算子调用方式 m.def("rainfusionattention_mindie_sd(Tensor query, Tensor key, Tensor value, Tensor select_idx, \ Tensor select_num_idx, int[] blockshape, Tensor? attn_mask=None, int[]? actual_seq_qlen=None, \ int[]? actual_seq_kvlen=None, Tensor? block_table=None, str q_input_layout='TND', str kv_input_layout='TND', \ int head_num=1, int mask_type=0, float scale=1.0, \ int inner_precise=1, int block_size=0) -> (Tensor, Tensor)"); 测试结果: 全量UT:  约束: - query,key和value目前只支持shape为(batch\*seqlen, head, headdim)的tensor - q_input_layout和kv_input_layout目前只支持TND - 该接口依赖的CANN包暂未发布,暂不支持外部调用 See merge request: Ascend/MindIE-SD!54 | 7 个月前 | |
[Feature][ops]Add mul_add fused operator support Co-authored-by: wangwei<daviwang2026@qq.com> # message auto-generated for no-merge-commit merge: !481 merge feature/mul_add_ops_dev into dev [Feature][ops]Add mul_add fused operator support Created-by: daviwang Commit-by: wangwei Merged-by: ascend-robot Description: # Purpose 新增 mul_add 融合算子,支持在昇腾 NPU 上执行融合乘加计算: - 算子接口:mindiesd::mul_add(a, b, c) -> y - 计算公式:y = a + b * c - 输入 shape:a/b = [batch, seq_len, hidden_size],c = [batch, 1, hidden_size] - 支持数据类型:FP16、BF16 - 支持计算平台:ascend910b、ascend910_93、ascend950 主要变更: 1. 在 csrc/ops/mul_add/ 下新增算子定义(OpDef)、shape/dtype 推导(proto)、tiling 计算及 AscendC kernel 实现。 2. 在 csrc/plugin/ 下新增 mul_add PTA plugin,并在 register_ops.cpp 中注册到 mindiesd torch 库。 3. 更新 csrc/CMakeLists.txt,将 mul_add.cpp 加入 PTAExtensionOPS 编译。 4. 更新 build/build_ops.sh 默认算子列表,确保默认构建包含 mul_add。 5. 在 tests/ops/mul_add/ 下新增单元测试,覆盖基础 shape、典型 LLM shape、小 shape 边界及 FP16 精度场景。 # Test Plan > 设计了哪些测试内容,指导他人如何对你的PR进行测试\ > Apply information to show others your test design and how to test your Pull Request 1. 编译 AscendC 算子: bash cd build bash build_ops.sh 2. 编译 PTA plugin: bash cd build bash build_plugin.sh 3. 运行 mul_add 单元测试(需在 NPU 环境): bash cd tests/ops/mul_add python test_mul_add.py 4. 可选:通过环境变量指定 NPU 卡号: ``bash MINDIESD_TEST_NPU_ID=7 python test_mul_add.py # Test Report • 测试覆盖: • 基础小 shape:(1, 4, 128) • 典型 LLM shape:(1, 7200, 4608)、(1, 256, 4608)、(1, 7200, 3072)、(1, 256, 3072) • 多组小 shape 边界:(1, 1, 64) ~ (1, 64, 1024) • FP16 精度:(1, 256, 3072) • 参考实现:ref = a.float() + b.float() * c.float() • 精度阈值:rtol=1e-2, atol=1e-2 - 运行环境:CANN 9.1.T560, Ascend950PR NPU, Python 3.11, aarch64 - 所有新增测试用例均通过: - test_mul_add_basic PASSED - test_mul_add_typical PASSED - test_mul_add_small_shapes PASSED - test_mul_add_fp16` PASSED - 最大误差:BF16 < 1e-2,FP16 < 1e-2 See merge request: Ascend/MindIE-SD!481 | 8 天前 | |
[dev]同步最新代码 Co-authored-by: mazhixin00_00<mazhixin7@huawei.com> | 8 个月前 | |
[dev]同步最新代码 Co-authored-by: mazhixin00_00<mazhixin7@huawei.com> | 8 个月前 | |
[Bugfix][SparseEstimate]Fix uninitialized variables on invalid input_layout and align fake op with C++ plugin Co-authored-by: changetheway<guotaoyuan1@h-partners.com> # message auto-generated for no-merge-commit merge: !356 merge sparse_block_estimate into dev [Bugfix][SparseEstimate]Fix uninitialized variables on invalid input_layout and align fake op with C++ plugin Created-by: changetheway Commit-by: changetheway Merged-by: ascend-robot Description: # Which issue(s) this PR fixes or accomplishes > Fixes #186 # Purpose 修复 sparse_block_estimate C++ plugin 中的 input_layout 校验缺陷。 **问题根因:** - csrc/plugin/sparse_block_estimate.cpp 中,当 input_layout 不属于 BNSD/BSND/BSH 时,else 分支仅打印 std::cerr 日志,不 return 也不抛异常,导致 b/nq/s/d 四个局部变量保持未初始化状态,后续用这些随机值计算 tensor shape 并分配 NPU 内存。 - Python fake op (mindiesd/layers/_custom_ops.py) 不支持 BSH layout,与 C++ plugin 支持范围不一致;且非法 layout 的错误语义不一致(fake op 抛异常,C++ 不抛)。 **本次修改内容:** 1. **C++ Plugin (csrc/plugin/sparse_block_estimate.cpp)** - 将 int64_t b/nq/s/d 初始化为 0,消除未初始化变量风险 - 将 else 分支中的 std::cerr 替换为 TORCH_CHECK(false, ...),非法 layout 立即抛出 RuntimeError 2. **Python Fake Op (mindiesd/layers/_custom_ops.py)** - 新增 elif input_layout == "BSH" 分支,与 C++ plugin 的 BSH 支持对齐 - 统一错误消息为 supports 'BNSD', 'BSND', 'BSH' 3. **测试 (tests/plugin/test_sparseblockestimate.py)** - 新增 test_bsh_layout_output_shape:验证 BSH layout 正常工作且输出 shape 正确 - 新增 test_invalid_layout_empty_string:验证空字符串 layout 抛出 RuntimeError - 原有 test_invalid_layout 补充 docstring # Test Plan 1. C++ 编译验证: ```bash cd build && bash build_plugin.sh 预期:libPTAExtensionOPS.so 编译成功,无编译错误或警告。 NPU 功能测试: MINDIE_TEST_MODE=ALL python -m pytest tests/plugin/test_sparseblockestimate.py -v 预期:全部测试通过,包括新增的 test_bsh_layout_output_shape 和 test_invalid_layout_empty_string。 CPU 模式 fake op 测试(无需 NPU 设备): MINDIE_TEST_MODE=CPU python -m pytest tests/plugin/test_sparseblockestimate.py -v -k "test_invalid" 验证非法 layout 在 fake op 路径也能正确抛出异常。 Test Report  See merge request: Ascend/MindIE-SD!356 | 1 个月前 | |
[feature]新增SparseBlockEstimate算子以及plugin和UT Co-authored-by: lanwangli<lanwangli@huawei.com> # message auto-generated for no-merge-commit merge: !67 merge bsa_op1 into dev [feature]新增SparseBlockEstimate算子以及plugin和UT Created-by: mazhixin00_00 Commit-by: lanwangli Merged-by: ascend-robot Description: [feature]新增SparseBlockEstimate算子  **调用该算子plugin** import torch torch.ops.load_library("mindiesd/plugin/libPTAExtensionOPS.so") stride = 8 scale_value=query.shape[-1] ** -0.5 / stride smask, sct = torch.ops.mindie.sparse_block_estimate_mindie_sd( query=query, key=key, actual_seq_lengths=None, actual_seq_lengths_kv=None, input_layout="BNSD", stride=stride, sparse_size=128, num_heads=query.shape[1], num_key_value_heads=key.shape[1], scale_value=scale_value, threshold=1.0, causal=False, keep_sink=True, keep_recent=True, row_sparse=1.0 ) - query:支持fp16和bf16 - key:支持fp16和bf16 - actual_seq_lengths:目前只接受None - actual_seq_lengths_kv:目前只接受None - input_layout:目前只支持“BNSD”、“BSND”、“BSH” - stride:目前只支持8 - sparse_size:目前只支持128 - num_heads:query的head - num_key_value_heads:key和value的head - scale_value:headdim ** -0.5 / stride - threshold:1.0 时表示计算完整的注意力(完全不稀疏)。 - causal:为 True 时只计算 Attention Map 矩阵下三角部分,否则计算完整 Attention Map,默认值为True。 - keep_sink:为 True 时 Attention Map 矩阵的第一列必选,默认值为True。 - keep_recent:为 True 时 Attention Map 矩阵对角线上的 block 必选,默认值为True。 - row_sparse:取值为 0-1 之间的小数,用以强制保证每个 block 行的稀疏率大于 (1-row_sparse),当 TopCDF 选择的稀疏率小于 (1-row_sparse) 时,使用 Topk进行选取,默认值为1。 **单算子测试结果:**  See merge request: Ascend/MindIE-SD!67 | 7 个月前 |
| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
| 3 个月前 | ||
| 3 个月前 | ||
| 5 个月前 | ||
| 5 个月前 | ||
| 29 天前 | ||
| 1 个月前 | ||
| 3 个月前 | ||
| 7 个月前 | ||
| 30 天前 | ||
| 30 天前 | ||
| 30 天前 | ||
| 1 个月前 | ||
| 1 个月前 | ||
| 4 个月前 | ||
| 8 个月前 | ||
| 1 个月前 | ||
| 8 个月前 | ||
| 2 个月前 | ||
| 2 个月前 | ||
| 8 天前 | ||
| 8 天前 | ||
| 12 天前 | ||
| 12 天前 | ||
| 1 个月前 | ||
| 2 个月前 | ||
| 2 个月前 | ||
| 2 个月前 | ||
| 2 个月前 | ||
| 3 个月前 | ||
| 7 个月前 | ||
| 8 天前 | ||
| 8 个月前 | ||
| 8 个月前 | ||
| 1 个月前 | ||
| 7 个月前 |