Everything K-culture — comebacks to K-beauty, straight to your inboxGet it in your inbox

METAL MEDIA

Efficient INT8 Inference of Small NLP Models on Server CPUs with PyTorch Native Stack

arXiv:2608.181822026-08-20

Intel engineers made BERT-style models run up to 5.8x faster on server CPUs, using only PyTorch's built-in tools

BERT-family models like BERT and DistilBERT are still heavily used in industry for tasks like classification and search, even though everyone talks about large language models now. This work plugs SmoothQuant, a technique that squeezes model numbers into 8-bit integers (INT8) without losing much accuracy, directly into PyTorch's own compiler stack instead of requiring separate third-party tools. The result is up to 5.8x faster processing on Intel Xeon server chips with barely any accuracy loss.

METAL MEDIA explanatory visual

Intel engineers made BERT-style models run up to 5.8x faster on server CPUs, using only PyTorch's built-in tools

  1. 01Integrated SmoothQuant (a method that shifts numerical 'difficulty' from activations to weights before compressing to INT8) into TorchAO, PyTorch's native quantization library, so users don't need external tools.
  2. 02Added fusion passes in TorchInductor (PyTorch's compiler backend) to merge INT8 matrix-multiplication operations with scaling and bias steps into a single efficient operator, avoiding wasted time converting data layouts at runtime.
  3. 03Built custom low-level kernels using AVX512_VNNI and AMX (special CPU instruction sets for fast integer math) so both older Ice Lake chips and newer Granite Rapids chips get the best available speed.
  4. 04Devised a workaround (s8s8-to-u8s8 transformation) so INT8 quantization still works efficiently on Ice Lake CPUs that lack certain instruction support.
  5. 05Benchmarked on BERT-large, DistilBERT, and XLM-RoBERTa: throughput improved 1.9x-2.6x on Ice Lake and 4.2x-5.8x on Granite Rapids versus FP32 (32-bit floating point, the default precision), with less than 1% accuracy loss on SQuAD and MultiNLI tasks.
An explanatory diagram made by METAL MEDIA, not a figure supplied by the paper's authors.

What they did

  1. Integrated SmoothQuant (a method that shifts numerical 'difficulty' from activations to weights before compressing to INT8) into TorchAO, PyTorch's native quantization library, so users don't need external tools.
  2. Added fusion passes in TorchInductor (PyTorch's compiler backend) to merge INT8 matrix-multiplication operations with scaling and bias steps into a single efficient operator, avoiding wasted time converting data layouts at runtime.
  3. Built custom low-level kernels using AVX512_VNNI and AMX (special CPU instruction sets for fast integer math) so both older Ice Lake chips and newer Granite Rapids chips get the best available speed.
  4. Devised a workaround (s8s8-to-u8s8 transformation) so INT8 quantization still works efficiently on Ice Lake CPUs that lack certain instruction support.
  5. Benchmarked on BERT-large, DistilBERT, and XLM-RoBERTa: throughput improved 1.9x-2.6x on Ice Lake and 4.2x-5.8x on Granite Rapids versus FP32 (32-bit floating point, the default precision), with less than 1% accuracy loss on SQuAD and MultiNLI tasks.
Figure 1: SmoothQuant workflow built on TorchAO and TorchInductor. TorchAO prepares and quantizes the model, TorchInductor fuses INT8 subgraphs, and the CPP backend selects between oneDNN and template-based GEMM kernels. C++ code is generated and compiled for deployment.
Figure 1: SmoothQuant workflow built on TorchAO and TorchInductor. TorchAO prepares and quantizes the model, TorchInductor fuses INT8 subgraphs, and the CPP backend selects between oneDNN and template-based GEMM kernels. C++ code is generated and compiled for deployment.
Table 1: Hardware platforms used for baseline collection.
Xeon GenerationCodenameModelPhysical CoresInstruction Support
3rd GenIce Lake835864AVX512F, AVX512_VNNI
6th GenGranite Rapids6980P256AVX512F, AVX512_VNNI, AMX
Table 2: Baseline collection setup.
ItemValue
ModelBERT-large
Input shapeBatch size 1, sequence length 256
Precision modesFP32 on both platforms; BF16 on Granite Rapids
Launch strategyMulti-instance with weight-sharing on each socket
Cores per instance4
Number of instancesNumber of physical cores / 4
Deployment pathAOTI enabled
Input dataSynthetic
Table 3: Baseline hotspot breakdown for the BERT-large analysis case under the same multi-instance setup used for throughput benchmarking. Operator shares are aggregated from representative profiler logs. The linear-block consists of GEMM and fused post-operations such as bias addition, activation, and residual addition.
BaselineLinear-BlockAttentionLayerNormOther
FP32 on Ice Lake88.5%10.4%0.6%0.5%
FP32 on Granite Rapids86.9%11.8%0.8%0.5%
BF16 on Granite Rapids72.70%19.75%5.99%1.56%
Table 4: Estimated peak compute and measured memory bandwidth per socket, balance point for different data types on the evaluated platforms.
PlatformFP32 Throughput (TFLOPS)BF16 Throughput (TFLOPS)INT8 Throughput (TOPS)Memory Bandwidth (GB/s)FP32 Balance Point (FLOPs/byte)BF16 Balance Point (FLOPs/byte)INT8 Balance Point (OPs/byte)
Ice Lake6.76N/A27.03175.0038.63N/A154.46
Granite Rapids19.66262.14524.29700.0028.09374.49748.99
Table 5: BERT-large GEMM shapes and their arithmetic intensity.
Arithmetic Intensity (ops/byte)
GEMM Shape M × K × NOccurrences per forward passFP32BF16INT8
256×1024×10249685.33146.29227.56
256×1024×40962497.52163.84248.24
256×4096×10242497.52186.18341.33
Table 6: Effective memory bandwidth and balance point for INT8 GEMM on Granite Rapids.
GEMM ShapeEffective Memory Bandwidth (GB/s)Arithmetic Intensity (OPs/byte)Balance Point (OPs/byte)
256×1024×1024807.69227.56649.12
256×1024×4096819.15248.24640.04
256×4096×1024875.00341.33599.19
Table 7: Estimated GEMM throughput and speedup on Granite Rapids.
GEMM ShapeFP32 Throughput (TFLOPS)BF16 Throughput (TFLOPS)INT8 Throughput (TOPS)INT8 vs FP32 SpeedupINT8 vs BF16 Speedup
256×1024×102419.66102.40183.799.35×1.79×
256×1024×409619.66114.69203.3510.34×1.77×
256×4096×102419.66130.33298.6715.19×2.29×
Weighted Average19.66114.69218.8711.13×1.91×
Table 8: Models used for the performance benchmark.
ModelModel ID
BERT-largebert-large-uncased
DistilBERTdistilbert-base-uncased
XLM-RoBERTaxlm-roberta-base
Table 9: Task-finetuned checkpoints used for accuracy evaluation. The model marked by * is finetuned on SQuAD 2.0 but still workable for the test on SQuAD 1.1.
DatasetModelModel ID
SQuAD 1.1BERT-largegoogle-bert/bert-large-uncased-whole-word-masking-finetuned-squad
SQuAD 1.1DistilBERTdistilbert/distilbert-base-cased-distilled-squad
SQuAD 1.1XLM-RoBERTadeepset/xlm-roberta-base-squad2*
MultiNLIBERT-largeyoshitomo-matsubara/bert-large-uncased-mnli
MultiNLIDistilBERTtypeform/distilbert-base-uncased-mnli
MultiNLIXLM-RoBERTasymanto/xlm-roberta-base-snli-mnli-anli-xnli
Table 10: Quantization methods used in the experiments.
MethodShort Name
No quantization, no AMPFP32
No quantization, with AMPBF16
SmoothQuant, static quantizationSmooth-Static
SmoothQuant, dynamic quantizationSmooth-Dynamic
Table 11: INT8 speedup over FP32 on Ice Lake.
ModelMethodThroughput SpeedupLinear-Block Speedup
BERT-largeSmooth-Dynamic2.22×3.59×
BERT-largeSmooth-Static2.58×3.87×
DistilBERTSmooth-Dynamic1.90×3.31×
DistilBERTSmooth-Static2.30×3.35×
XLM-RoBERTaSmooth-Dynamic1.86×3.05×
XLM-RoBERTaSmooth-Static2.17×3.71×
Table 12: INT8 speedup over FP32 on Granite Rapids.
ModelMethodThroughput SpeedupLinear-Block Speedup
BERT-largeSmooth-Dynamic5.02×9.92×
BERT-largeSmooth-Static5.82×8.67×
DistilBERTSmooth-Dynamic4.24×7.60×
DistilBERTSmooth-Static5.37×8.84×
XLM-RoBERTaSmooth-Dynamic4.17×7.58×
XLM-RoBERTaSmooth-Static5.41×8.71×
Table 13: INT8 speedup over BF16 on Granite Rapids.
ModelMethodThroughput SpeedupLinear-Block Speedup
BERT-largeSmooth-Dynamic1.37×1.84×
BERT-largeSmooth-Static1.59×1.61×
DistilBERTSmooth-Dynamic0.98×1.45×
DistilBERTSmooth-Static1.24×1.69×
XLM-RoBERTaSmooth-Dynamic0.99×1.50×
XLM-RoBERTaSmooth-Static1.29×1.67×
Table 14: Realized speedup of BERT-large over estimated speedup ceiling on both evaluated platforms.
Throughput SpeedupLinear-Block Speedup
PlatformMethodBaselineRealizedEstimatedGapRealizedEstimatedGap
Ice LakeSmooth-DynamicFP322.22×3.15×29.59%3.59×4.00×10.22%
Ice LakeSmooth-StaticFP322.58×3.15×18.17%3.87×4.00×3.21%
Granite RapidsSmooth-DynamicFP325.02×7.06×28.89%9.92×11.13×10.89%
Granite RapidsSmooth-StaticFP325.82×7.06×17.56%8.67×11.13×22.12%
Granite RapidsSmooth-DynamicBF161.37×1.53×10.41%1.84×1.91×3.58%
Granite RapidsSmooth-StaticBF161.59×1.53×-3.98%1.61×1.91×15.64%
Table 15: Accuracy results on Granite Rapids.
ModelMetricFP32BF16Smooth-StaticAlphaLossSmooth-DynamicAlphaLoss
BERT-largeSQuAD F192.6492.6792.660.60.0%92.630.60.0%
BERT-largeSQuAD EM86.4186.4586.490.6-0.1%86.440.60.0%
BERT-largeMultiNLI Accuracy64.5564.5864.730.7-0.3%64.520.60.0%
DistilBERTSQuAD F186.3986.4186.000.70.5%86.400.60.0%
DistilBERTSQuAD EM79.0279.0478.490.70.7%79.040.60.0%
DistilBERTMultiNLI Accuracy82.2182.1682.260.8-0.1%82.170.60.0%
XLM-RoBERTaSQuAD F176.4376.3476.470.55-0.1%76.590.6-0.2%
XLM-RoBERTaSQuAD EM69.9569.8970.040.55-0.1%70.300.6-0.5%
XLM-RoBERTaMultiNLI Accuracy82.2682.2382.310.7-0.1%82.260.60.0%

Why it matters

Many companies still rely on smaller, cheaper-to-run NLP models for everyday tasks like search ranking and text classification, and most of them deploy on ordinary CPUs rather than GPUs. Making these speedups available directly inside standard PyTorch, without extra plugins, lowers the barrier for any team to get several-times-faster, cheaper inference with almost no code changes.

Terms in this paper

  • INT8 quantization · Storing and computing numbers using 8-bit integers instead of 32-bit floats, which is faster and uses less memory but can reduce accuracy.
  • SmoothQuant · A technique that rebalances numerical scale between activations and weights so INT8 quantization causes less accuracy loss.
  • TorchAO · PyTorch's official library for applying quantization and other low-precision techniques to models.
  • TorchInductor · The compiler backend in PyTorch 2 that optimizes and generates fast code for a model's computation graph.
  • GEMM · General matrix multiplication, the core repeated calculation inside neural network layers.
  • AVX512_VNNI / AMX · Special instruction sets built into Intel Xeon CPUs that speed up integer math used in INT8 computation.
  • roofline model · A performance analysis method that predicts whether a computation is limited by processor speed or by memory bandwidth.

Original abstract (English)

Small NLP models, especially BERT-family encoders, remain important in industrial workloads such as classification, ranking, and retrieval even in the era of large language models. On server CPUs, INT8 quantization offers an attractive latency-throughput-cost trade-off, but users increasingly expect such acceleration to be available directly in the native PyTorch stack. We integrate SmoothQuant into TorchAO and optimize the resulting inference path for Intel Xeon CPUs through graph-level fusion in TorchInductor and efficient INT8 GEMM kernel selection across oneDNN-, AVX512_VNNI-, and AMX-based implementations. Across BERT, DistilBERT, and XLM-RoBERTa benchmarks, the approach delivers up to 5.8x end-to-end throughput speedup with negligible---and in some cases no measurable---accuracy loss relative to the FP32 baseline. We also validated our work by detailed performance analysis with roofline models. The implementation has been upstreamed to PyTorch and TorchAO, enabling out-of-the-box deployment with native PyTorch tooling

Authors · Weiwen Xia, Yuxin Cui, E Cao

Read on arXiv

Latest papers

All papers →

Latest from METAL MEDIA

Figures: Weiwen Xia et al., arXiv:2608.18182, CC BY 4.0