ACM Transactions on Architecture and Code Optimization

Parallel Scan on Ascend AI accelerators

Gioele Gottardo, Bartlomiej Wroblewski, Anastasios Zouzias

Key points

From the paper's conclusion
  • We design and implement parallel prefix sum (scan) algorithms using Ascend AI accelerators.

Abstract

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.

Read the paper

Discussion

Science Skim's AI key points, plus readers' public thoughts

Readers' thoughts

No reader thoughts yet.

Related papers

Parallel Scan on Ascend AI accelerators — Science Skim