Parallel Scan on Ascend AI accelerators
We design and implement parallel prefix sum (scan) algorithms using Ascend AI accelerators. Ascend accelerators feature specialized computing units—the Cube units for efficient matrix multiplication and the Vector units for optimized vector operations. A key feature of the proposed scan algorithms is their extensive use of matrix multiplications and accumulations enabled by the Cube unit. Our single-core results demonstrate substantial performance improvements, with speedups ranging from 5 × to 9.6 × compared to vector-only implementations for sufficiently large input lengths. Additionally, we present a multi-core scan algorithm that efficiently utilizes both the Cube and Vector units of Ascend, reaching up to 74.9% of the memory bandwidth achieved by memory copy. To showcase the effectiveness of matrix-multiplication-based scans as a fast primitive in AI workloads, we implemented several scan-based operators like split, compress, radix sort, and top- k / top- p sampling, obtaining up to 3.3 × and 2.3 × speedup compared to the vector-only kernels on radix-sort and top- p respectively. Finally, we show how these optimized kernels can impact Large Language Models on the Ascend NPUs obtaining 2.02 × speed-up on state-space neural networks like Mamba, and up to 1.47 × on LLMs with large vocabulary sizes thanks to more efficient top-p token sampling. The source code is available at https://github.com/huawei-csl/pytorch-tcuscan.
Authors
- Anastasios Zouzias (ORCID: https://orcid.org/0000-0002-3743-3489)
- Bartłomiej Wróblewski (ORCID: https://orcid.org/0000-0001-6242-2733)
- Gioele Gottardo (ORCID: https://orcid.org/0009-0009-9103-1403)
Institutions
- Huawei Technologies (China) (CN)
- Huawei Technologies (United States) (US)
- Huawei Technologies (United Kingdom) (GB)
Publication Details
- Journal
- ACM Transactions on Architecture and Code Optimization
- Published
- 2026-11-26
- DOI
- https://doi.org/10.1145/3872175
- Primary Topic
- Parallel Computing and Optimization Techniques
- Type
- article
- Field-Weighted Citation Impact
- 0.00