How hicann/ops-transformer works
ops-transformer is a CANN library of transformer-oriented accelerator operators, spanning attention, MoE, grouped matrix multiplication, and communication/computation fusion. Users invoke operator APIs with tensors and receive computed tensor results; the repository also exposes PyTorch extensions for selected operators. The graph captures documented capability areas and sampled implementation layers. The tree and excerpts do not establish most operator-to-operator runtime calls, so those are not chained; unsampled capabilities are represented at their supported directory paths.
Main entry points: pipeline_builder.h Pipeline stage wiring · attention Attention operators · matmul_allto_all_pipeline.h Matmul all-to-all · allto_all_matmul_pipeline.h All-to-all matmul
Components 30
Attention operators
- Attention operators
attention - Block sparse attention
attention/block_sparse_attention/op_kernel/arch35/block_sparse_attention_kernel_arch35_regular.h - Attention update
attention/attention_update/op_kernel/attention_update.cpp - Attention worker scheduler
attention/attention_worker_scheduler/op_kernel_aicpu/attention_worker_scheduler_aicpu.cpp - Attention worker combine
attention/attention_worker_combine/op_kernel/attention_worker_combine.cpp - Block result preparation
attention/block_attn_res_prepare/op_kernel/block_attn_res_prepare_apt.cpp - Block result update
attention/block_attn_res_update/op_kernel/block_attn_res_update.cpp - MLA prolog
attention/mla_prolog/op_kernel/arch35/service_rotary_position_embedding_arch35.h
MoE operators
- MoE operators
moe - MoE routing init
moe/moe_init_routing_v3/op_host/moe_init_routing_v3_tiling_arch35.cpp - MoE routing finalize
moe/moe_finalize_routing/op_host/moe_finalize_routing_tiling.cpp
Grouped matmul
- Grouped matmul operators
gmm/grouped_matmul/op_kernel/grouped_matmul_kernel.h - A16W4 quant controller
gmm/grouped_matmul/op_kernel/a16w4_msd/grouped_matmul_weight_quant_a16w4_msd_controller.h - Quantized SwiGLU
gmm/grouped_matmul_swiglu_quant/op_kernel/grouped_matmul_swiglu_pipeline.h - Quantized SwiGLU v2
gmm/grouped_matmul_swiglu_quant_v2/op_kernel/grouped_matmul_swiglu_quant_v2_a8w4_msd_pipeline.h - GMM routing finalize
gmm/grouped_matmul_finalize_routing/op_kernel/arch35/weight_quant_basic_block/gmm_fr_weight_quant_resplit_controller.h
Communication fusion
- Collective operators
mc2 - Matmul all-to-all
mc2/matmul_allto_all/op_kernel/matmul_allto_all_pipeline.h - All-to-all matmul
mc2/allto_all_matmul/op_kernel/allto_all_matmul_pipeline.h - All-to-all-v quant GMM
mc2/allto_allv_quant_grouped_mat_mul/op_kernel/mc2_templates/communication/a2av_permute_engine.h - Reduce-scatter tiling
mc2/matmul_reduce_scatter_v2/op_host/op_tiling/arch22/matmul_reduce_scatter_v2_smallm_rank8_pipeline_rules.h - Pipeline stage wiring
mc2/common/op_kernel/mc2_templates/scheduler/pipeline_builder.h
Operator internals
- Attention buffer manager
attention/common/op_kernel/attn_buffer_manager.h - Attention buffer
attention/common/op_kernel/attn_buffer.h - Rotary embedding A2
attention/mla_prolog/op_kernel/arch22/service_rotary_position_embedding_arch22.h - Rotary embedding A5
attention/mla_prolog/op_kernel/arch35/service_rotary_position_embedding_arch35.h - Mix-core synchronization
mc2/3rd/weight_quant_batch_matmul_v2/op_kernel/arch35/catlass/pipeline/pipeline_stage_mixcore.h - SwiGLU pipeline helper
gmm/grouped_matmul_swiglu_quant/op_kernel/grouped_matmul_swiglu_pipeline.h - SwiGLU v2 helper
gmm/grouped_matmul_swiglu_quant_v2/op_kernel/grouped_matmul_swiglu_quant_v2_a8w4_msd_pipeline.h
Other components
- Model or caller
Connections 13
- Model or caller → Attention operators: invokes
- Model or caller → MoE operators: invokes
- Model or caller → Grouped matmul operators: invokes
- Model or caller → Collective operators: invokes
- Attention buffer manager → Attention buffer: uses
attention/common/op_kernel/attn_buffer_manager.h - Rotary embedding A2 → Attention operators: supports MLA
attention/mla_prolog/op_kernel/arch22/service_rotary_position_embedding_arch22.h - Rotary embedding A5 → Attention operators: supports MLA
attention/mla_prolog/op_kernel/arch35/service_rotary_position_embedding_arch35.h - SwiGLU pipeline helper → Quantized SwiGLU: stages computation
gmm/grouped_matmul_swiglu_quant/op_kernel/grouped_matmul_swiglu_pipeline.h - SwiGLU v2 helper → Quantized SwiGLU v2: stages computation
gmm/grouped_matmul_swiglu_quant_v2/op_kernel/grouped_matmul_swiglu_quant_v2_a8w4_msd_pipeline.h - Pipeline stage wiring → Matmul all-to-all: provides stages
mc2/common/op_kernel/mc2_templates/scheduler/pipeline_builder.h - Pipeline stage wiring → All-to-all matmul: provides stages
mc2/common/op_kernel/mc2_templates/scheduler/pipeline_builder.h - Matmul all-to-all → Pipeline stage wiring: uses stages
mc2/matmul_allto_all/op_kernel/matmul_allto_all_pipeline.h - All-to-all matmul → Pipeline stage wiring: uses stages
mc2/allto_all_matmul/op_kernel/allto_all_matmul_pipeline.h