本项目是CANN提供的transformer类大模型算子库,实现网络在NPU上加速计算。
Access rate limit exceeded. Please log in to continue.
🔥Latest News
- [2026/08] The repository integrates the pre-commit code check framework. After configuration,
git commitautomatically checks and fixes format issues, intercepting specification issues at the commit stage and improving code merge efficiency. For details, see the pre-commit configuration guide. - [2026/07] The quant_flash_attn operator is newly supported on A5, dedicated to the fully quantized Dense Attention scenario. The experimental directory adds an operator with the same name that supports MxFP4 full quantization on A5. The chunk_gated_delta_rule operator supports A5. A5 adds the DSV4 dense training-stage TopK filtering backward operators dense_lightning_indexer_grad_kl_loss and dense_lightning_indexer_softmax_lse. mc2 newly supports the engram_fetch_grad operator.
- [2026/06] sparse_flash_mla, mixed_quant_sparse_flash_mla, and the corresponding metadata operators are newly supported on A5 for sparse Attention computation in the DSV4 scenario. lightning_indexer_v2, quant_lightning_indexer_v2, and the corresponding metadata operators are added for TopK filtering in the DSV4 scenario. A5 adds the DSV4 sparse training-stage Attention backward operators sparse_flash_mla_grad and sparse_lightning_indexer_kl_loss_grad. mc2 newly supports the engram_fetch and engram_fetch_wait operators.
- [2026/05] The fused_infer_attention_score operator supports MxFP8 full quantization on A5. The flash_attn operator is newly supported on A5, dedicated to the non-quantized Dense Attention scenario.
- [2026/04] mc2 newly supports the mega_moe operator.
- [2026/03] The recurrent_gated_delta_rule operator supports A5.
- [2026/02] Newly supported operators: mhc_post, mhc_pre, and mhc_res.
- [2026/01] Added the grouped_matmul<<<>>> invocation example for convenient customized use.
- [2026/01] Newly supported operators: fused_floyd_attention, fused_floyd_attention_grad, and matmul_allto_all.
- [2025/12] Added QuickStart, which guides beginners with zero experience through operator project deployment (Docker environment supported), operator development, and the contribution process.
- [2025/12] Optimized the guide documents, focusing on the Operator Development Guide, clarifying the minimal deliverables and key sample code, and providing guidance on migrating operators from the Ascend/samples repository to this project.
- [2025/12] Supports transformer-type ONNX operator plugins, including NPUMultiHeadAttention, NPUMoeComputeExpertTokens, and so on.
- [2025/12] Newly supported operators: kv_rms_norm_rope_cache, attention_update, attention_worker_scheduler, gather_pa_kv_cache, kv_quant_sparse_flash_attention, lightning_indexer_grad, mla_preprocess, mla_preprocess_v2, grouped_matmul_swiglu_quant_v2, attention_to_ffn, and ffn_to_attention.
- [2025/12] Open-source operators support development and debugging with the NPU Simulator simulation tool.
- [2025/12] Open-source operators support the Ascend 950PR&950DT products/KirinX90 products.
- [2025/11] Newly supported operators: kv_quant_sparse_flash_attention, lightning_indexer, quant_lightning_indexer, and sparse_flash_attention.
- [2025/11] Added the sample operators rope_matrix and all_gather_add.
- [2025/11] Added the operator development project template NpuOpsTransformerExt, which seamlessly integrates PyTorch tensor operations and supports automatic differentiation and a unified GPU/NPU interface.
- [2025/10] Added the experimental directory and improved the Contribution Guide, allowing developers to debug and contribute custom operators.
- [2025/09] The ops-transformer project goes online for the first time, with open-source operators supporting Atlas A2/A3 products.
🚀Overview
ops-transformer is an advanced operator library in the CANN (Compute Architecture for Neural Networks) operator library that provides computation for transformer-type large models. It includes the attention, moe, and mc2 operator categories, covering various scenarios such as attention computation, MoE computation, and communication-computation fusion. The position of the operator library in the architecture diagram is as follows.

📌Version Compatibility
The source code of this project is released along with CANN software versions. For the mapping between CANN software versions and tags of this project, refer to the corresponding version descriptions in the release repository. Note that to ensure smooth customized development of your source code, select a compatible CANN version and the source code of the corresponding Gitcode tag. Using the master branch may cause version mismatch risks.
🛠️Environment Preparation
Environment deployment is the prerequisite for experiencing the capabilities of this project. Complete the NPU driver and CANN package installation first to ensure that the environment works properly.
⬇️Source Code Download
After the environment is ready, download the branch source code that matches the CANN version. The general command is as follows, where ${tag_version} is replaced with the branch tag name. The following uses downloading the 9.0.0 branch source code as an example:
# General command: git clone -b ${tag_version} https://atomgit.com/cann/ops-transformer.git
git clone -b 9.0.0 https://atomgit.com/cann/ops-transformer.git
Description: If the compatible branch source code already exists in the environment, you can skip this step. For example, CANNLab provides the source code corresponding to the latest CANN version by default.
📖Learning Tutorials
- Quick Start: Quickly experience the core basic capabilities of the project from scratch, covering source code compilation, operator invocation, development, debugging, and other operations.
- Advanced Tutorials: If you need to learn more about project compilation and deployment, operator invocation, development, debugging and tuning, and other capabilities, see the documentation center for detailed guidance.
💬Related Information
- Directory Structure
- Operator Index
- aclnn API Index
- torch API Index
- Contribution Guide
- Security Statement
- License
- SIG
- [Contact Us] WeChat: Clark_Dan
PS: The features and documentation of this project are continuously being updated and improved. Stay tuned for the latest version.
- Issue feedback: Submit issues through GitCode Issues.
- Community interaction: Join discussions through GitCode Discussions.
- Technical column: Get technical articles (such as serialized tutorials and best practices) through GitCode Wiki.