RSR-core加速低比特矩阵-向量乘法,显著提升大模型推理速度。
RSR-core: A High-Performance Engine for Low-Bit Matrix-Vector Multiplication
- 将RSR算法转化为底层优化内核,支持二值/三值权重计算
- 在CPU上最高提速62倍,CUDA上生成令牌速度提升1.9倍
- 可直接集成到实际推理流程,适配HuggingFace生态
矩阵-向量乘法是神经网络、向量数据库和大语言模型推理中的核心操作。低比特量化(如1位二值或1.58位三值)能显著提升硬件层面计算效率。尽管冗余段压缩(RSR)算法理论上可加速此类乘法,但现有实现仅在应用层运行,难以高效嵌入硬件内核。为此,我们提出RSR-core,一个高性能引擎,将RSR算法以优化的底层内核形式部署于CPU与CUDA环境。该引擎支持二值与三值权重矩阵及通用向量的高效乘法,并实现真实推理流水线中的实用部署。通过HuggingFace集成,支持低比特模型预处理与加速推理。实验表明,相比基线PyTorch实现,其在CPU上最高提速62倍,在CUDA上生成令牌速度提升1.9倍,适用于主流三值大模型。代码已开源:https://github.com/UIC-InDeXLab/RSR-core。
原文摘要 · Abstract (English)
Matrix-vector multiplication is a fundamental building block in neural networks, vector databases, and large language models, particularly during inference. As a result, efficient matrix-vector multiplication engines directly translate into more efficient inference. Recent work has explored low-bit quantization of model weights, where matrices are represented using binary (1-bit) or ternary (1.58-bit) values while activation is kept in higher precision. These representations enable efficient hardware-level computation. In parallel, algorithms such as Redundant Segment Reduction (RSR) provide theoretical guarantees for accelerating low-bit matrix-vector multiplication. However, existing implementations operate at the application level and cannot be efficiently integrated into hardware kernels, limiting practical performance. To bridge this gap, we present RSR-core, a high-performance engine that implements the RSR algorithm as optimized low-level kernels for both CPU and CUDA environments. RSR-core supports efficient matrix-vector multiplication for binary and ternary weight matrices and general vectors while enabling practical deployment of RSR algorithm in real inference pipelines. RSR-core is provided as a production-ready engine with HuggingFace integration for preprocessing low-bit models and running accelerated inference. Experimental results demonstrate significant performance improvements over baseline HuggingFace PyTorch multiplication, achieving up to 62x speedup on CPU and up to 1.9x speedup for token generation on CUDA for popular ternary LLMs. The source code is publicly available at https://github.com/UIC-InDeXLab/RSR-core.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。