[论文解读] On the Performance Prediction of BLAS-based Tensor Contractions
本文提出了一种基于微基准测试的性能预测框架,用于基于 BLAS 的张量收缩运算,可在不执行算法的情况下,准确识别出数百种可能分解方式中最快的算法。通过模拟缓存条件并单独测量底层 BLAS 内核的执行时间,该方法实现了高精度的性能预测,并在直接执行算法时实现了高达 10^6× 的加速,尤其适用于具有细粒度 BLAS 调用的算法。
Tensor operations are surging as the computational building blocks for a variety of scientific simulations and the development of high-performance kernels for such operations is known to be a challenging task. While for operations on one- and two-dimensional tensors there exist standardized interfaces and highly-optimized libraries (BLAS), for higher dimensional tensors neither standards nor highly-tuned implementations exist yet. In this paper, we consider contractions between two tensors of arbitrary dimensionality and take on the challenge of generating high-performance implementations by resorting to sequences of BLAS kernels. The approach consists in breaking the contraction down into operations that only involve matrices or vectors. Since in general there are many alternative ways of decomposing a contraction, we are able to methodically derive a large family of algorithms. The main contribution of this paper is a systematic methodology to accurately identify the fastest algorithms in the bunch, without executing them. The goal is instead accomplished with the help of a set of cache-aware micro-benchmarks for the underlying BLAS kernels. The predictions we construct from such benchmarks allow us to reliably single out the best-performing algorithms in a tiny fraction of the time taken by the direct execution of the algorithms.
研究动机与目标
- 解决在数百种可能的基于 BLAS 的分解方式中选择最快算法的挑战。
- 实现在不执行完整算法的情况下,对张量收缩运算进行准确的性能预测。
- 克服由于高阶张量中缓存行为差异和维度偏移导致的性能波动。
- 为高性能计算工作负载提供一种可扩展、自动化的最优算法选择方法。
- 支持科学计算中张量收缩的高效执行,特别是在 BLAS-1 和 BLAS-2 内核占主导地位的情况下。
提出的方法
- 通过将张量收缩分解为 BLAS 内核(gemm、gemv、ger、axpy、dot)的序列,生成多种算法变体。
- 使用微基准测试,隔离并测量在受控内存和缓存条件下的单个 BLAS 操作的执行时间。
- 在微基准测试中建模并复现缓存状态和预取器行为,以模拟真实执行上下文。
- 从微基准测试的执行时间外推性能预测,估算所有算法变体的总执行时间。
- 该框架通过仅依赖代表性工作负载下低层内核的性能分析,避免了完整算法的执行。
- 该方法在多种张量收缩运算中得到验证,包括小维度张量和使用 10 个核心的多线程执行场景。
实验结果
研究问题
- RQ1在使用 BLAS 内核时,相同张量收缩的不同算法分解方式对性能有何影响?
- RQ2是否可以在不执行完整算法的情况下,对基于 BLAS 的张量收缩运算实现准确的性能预测?
- RQ3在维度偏移明显的张量收缩中,BLAS 内核的选择(例如 gemm 与 axpy)如何影响性能?
- RQ4对低层内核进行微基准测试,在多大程度上能够预测复杂高层张量操作的性能?
- RQ5与实际执行并测量完整算法所需的时间相比,该预测方法的开销如何?
主要发现
- 基于微基准测试的预测框架能够正确识别出数十种替代方案中最快的算法,即使性能差异超过 3 倍。
- 对于收缩运算 Cabc = AijaBjbic,i′c-gemm 和 i′b-gemm 算法的性能达到 60 次浮点运算/周期,而最慢的(jb′-gemm)仅达到 20 次浮点运算/周期,凸显了显著的性能差异。
- 该预测方法相较于直接执行算法,实现了高达 10^6× 的加速,尤其适用于具有细粒度操作的 BLAS-1 基础算法。
- 该框架在多种场景下保持了高精度,包括小维度张量和使用 10 个核心的多线程执行。
- 当 a = b = c = 1,000 时,预测速度仍比执行基于 gemm 的算法快 10^3×,而对于基于 BLAS-1 的算法,最快可快 10^6×。
- 该方法能以极短的时间可靠地区分性能组别,并识别出最优算法,所需时间仅为完整执行的极小部分。
更好的研究,从现在开始
从阅读论文到最终审阅,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。