通过Python调用Rust提升张量计算的运行时性能
Improving Runtime Performance of Tensor Computations using Rust From Python
AI总结:
本研究针对Python张量工具包pyttb的计算性能问题,采用通过Python C API构建扩展模块调用Rust的方法,在不同规模合成张量的多类内核实验中,相较纯Python、Numba、NumPy方案均实现稳定性能提升。
摘要:
本研究旨在提升Python Tensor Toolbox(pyttb,一款适用于多类应用的张量数据分析工具包)中核心计算内核的运行时性能。已有研究表明,通过借助Python C API构建扩展模块,从Python端调用编译型语言Rust,可在Web应用、数据解析、数据校验等场景中实现运行时性能提升。本研究沿用该方法,针对复杂度递增的核心张量内核开展性能研究,覆盖从涉及单循环、嵌套循环访问数据的乘积求和类简单内核,到低秩张量分解与张量回归算法中的核心高级张量乘法内核。在针对不同规模的合成张量数据与上述张量内核开展的数值实验中,我们证实,相较于三种基线方案:1)纯Python实现;2)Python搭配Numba即时Python编译器(针对基于循环的内核);3)Python搭配科学计算包NumPy(针对pyttb内核),从Python调用Rust的方案可实现持续稳定的运行时性能提升。
英文摘要:
In this work, we investigate improving the runtime performance of key computational kernels in the Python Tensor Toolbox (pyttb), a package for analyzing tensor data across a wide variety of applications. Recent runtime performance improvements have been demonstrated using Rust, a compiled language, from Python via extension modules leveraging the Python C API -- e.g., web applications, data parsing, data validation, etc. Using this same approach, we study the runtime performance of key tensor kernels of increasing complexity, from simple kernels involving sums of products over data accessed through single and nested loops to more advanced tensor multiplication kernels that are key in low-rank tensor decomposition and tensor regression algorithms. In numerical experiments involving synthetically generated tensor data of various sizes and these tensor kernels, we demonstrate consistent improvements in runtime performance when using Rust from Python over 1) using Python alone, 2) using Python and the Numba just-in-time Python compiler (for loop-based kernels), and 3) using the NumPy Python package for scientific computing (for pyttb kernels).
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。