[Paper Review] FBGEMM: Enabling High-Performance Low-Precision Deep Learning Inference
FBGEMM is a high-performance, CPU-optimized library for low-precision deep learning inference, enabling >2× speedup over production baselines by fusing quantization operations with shape-specific, highly optimized GEMM kernels for INT8 and INT16. It achieves this through dynamic kernel generation, efficient memory access patterns, and support for accuracy-preserving techniques like row-wise and outlier-aware quantization.
Deep learning models typically use single-precision (FP32) floating point data types for representing activations and weights, but a slew of recent research work has shown that computations with reduced-precision data types (FP16, 16-bit integers, 8-bit integers or even 4- or 2-bit integers) are enough to achieve same accuracy as FP32 and are much more efficient. Therefore, we designed fbgemm, a high-performance kernel library, from ground up to perform high-performance quantized inference on current generation CPUs. fbgemm achieves efficiency by fusing common quantization operations with a high-performance gemm implementation and by shape- and size-specific kernel code generation at runtime. The library has been deployed at Facebook, where it delivers greater than 2x performance gains with respect to our current production baseline.
Motivation & Objective
- Address the performance bottleneck in low-precision deep learning inference on modern CPUs by optimizing matrix multiplication for reduced-precision data types.
- Overcome the inefficiencies of conventional linear algebra libraries that are not designed for low-precision inference workloads.
- Minimize accuracy loss in quantized inference through techniques like row-wise and outlier-aware quantization.
- Achieve high performance across diverse matrix shapes commonly found in real-world deep learning models (e.g., in NMT, CV, and recommendation systems).
- Enable efficient deployment of quantized models at scale in production environments by integrating with existing deep learning frameworks.
Proposed method
- Fuses common quantization operations—such as scaling, zero-point adjustment, and requantization—with high-performance GEMM kernels to reduce memory bandwidth and computation overhead.
- Employs shape- and size-specific kernel code generation at runtime, dynamically selecting or generating optimized kernels for non-square and small-matrix dimensions.
- Uses a modular pipeline architecture allowing flexible composition of input packing, core GEMM kernels (INT16, INT32, FP32 accumulation), and post-GEMM operations.
- Applies a quantization framework where real-valued matrices are mapped to quantized representations via scale factors and zero points: $ X_{i,j} = \alpha_X (X^{q}_{i,j} - \theta_X) $.
- Implements optimized low-precision GEMM using AVX-512 instructions, including vpbroadcastd, vpmaddubsw, vpmaddwd, and vpaddd for INT8 FMA operations.
- Supports both compute-bound and bandwidth-bound scenarios by dynamically selecting accumulation precision (INT16 vs. INT32) based on workload characteristics.
Experimental results
Research questions
- RQ1How can low-precision matrix multiplication be optimized on modern CPUs to achieve high performance without sacrificing model accuracy?
- RQ2What are the most effective strategies for fusing quantization operations with GEMM kernels to reduce memory bandwidth and computational overhead?
- RQ3How can shape-specific optimizations improve performance across diverse matrix dimensions commonly found in deep learning models?
- RQ4To what extent can low-precision inference outperform FP32 in terms of performance and bandwidth efficiency on CPU architectures?
- RQ5What role does dynamic kernel generation play in achieving high performance across irregular and small matrix shapes?
Key findings
- FBGEMM achieves greater than 2× performance gain over the production baseline on modern CPUs for low-precision inference workloads.
- For compute-bound shapes, FBGEMM achieves up to 153.6 GOPS with INT8 GEMM and INT16 accumulation, reaching 2× the theoretical FP32 peak performance on the Broadwell CPU.
- For bandwidth-bound shapes, FBGEMM achieves better-than-FP32 theoretical roofline performance by reducing memory bandwidth usage through lower-precision data types.
- The library reduces DRAM bandwidth usage by 40% in Facebook’s recommendation system, demonstrating significant efficiency gains in real-world deployment.
- FBGEMM accelerates English-to-Spanish translation by 1.3× and character detection by 2.4× in Rosetta, a production-scale NLP system.
- Dynamic kernel generation and shape-specific optimization allow FBGEMM to efficiently handle small and irregular matrix dimensions common in models like Faster-RCNN, ResNet50, and NMT.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.