混合精度计算k-means
Mixed-Precision Lloyd's Algorithm for k-means Clustering
AI总结:
针对现代硬件上低精度和混合精度算术的日益普及,提出混合精度的Lloyd算法变体用于k-means聚类,通过舍入误差分析指导的欧氏距离计算核,在保证精度和收敛性的同时显著提升性能。
摘要:
受现代硬件上低精度和混合精度算术日益普及的启发,我们开发了用于k-means聚类的Lloyd算法的混合精度变体。主要成分是一系列用于欧氏距离计算的混合精度核。这些核由舍入误差分析指导,并使用简单的可靠性测试来决定扩展距离公式是否可以安全地以低精度评估,或者是否需要通过直接距离公式进行更高精度的校正。因此,大多数距离计算可以以低精度进行,而高精度算术则选择性地用于可能因抵消导致精度损失的情况。我们在大规模距离计算基准、合成聚类问题和图像分割任务上评估了所提出的方法。实验验证了GPU上的混合精度核能够在保持高精度基线的精度和收敛行为的同时显著提升性能。特别是,我们的CUDA实现在NVIDIA A100 GPU上比 exttt{scikit-learn}中的CPU实现实现了数量级的加速,并且比 exttt{PyTorch}的IEEE双精度 exttt{cdist}例程快达4倍,同时在易发生抵消的区域提供了改进的数值鲁棒性。所得到的混合精度k-means方法对于聚类和图像分割是有效的,尽管观察到的增益取决于数据集、特征维度和聚类数量。这些结果表明,混合精度距离核可以为k-means聚类提供性能和精度之间的有用权衡,并表明类似的想法可能对其他基于距离的机器学习方法有益。
英文摘要:
As low-precision arithmetic becomes more widely available on modern hardware, we develop mixed-precision variants of Lloyd's algorithm for k-means clustering, with a family of mixed-precision kernels for Euclidean distance computation as the main ingredient. These kernels are guided by rounding-error analysis and use a simple reliability test to decide whether the expanded distance formula can be evaluated safely with low precision or a higher-precision correction by the direct distance formula is required. Thus, most distance computations can be carried out with low precision, while high-precision arithmetic is used selectively when cancellation may lead to a loss of accuracy. We evaluate the proposed methods on large-scale distance-computation benchmarks, synthetic clustering problems, and image-segmentation tasks. The experiments verify that the mixed-precision kernels on GPUs can substantially improve performance while retaining accuracy and convergence behavior of higher-precision baselines. In particular, our implemented distance computation in CUDA achieves speedups of up to $4\times$ over the \texttt{PyTorch} baseline that evaluates the expanded formula in FP64 on an NVIDIA A100 GPU, with overall maximum relative errors of order $10^{-3}$, while providing increased numerical robustness in cancellation-prone calculations. The resulting mixed-precision kernels show efficiency for clustering and image segmentation, although the observed gains depend on factors such as feature dimension, and number of clusters. The mixed-precision kernels offer a favorable trade-off between performance and accuracy for clustering, and suggest that similar ideas may be beneficial for other distance-based machine learning methods.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。