QUARK: Quantization-Enabled Circuit Sharing for Transformer Acceleration by Exploiting Common Patterns in Nonlinear Operations

Zhixiong Zhao, Haomin Li, Fangxin Liu, Yuncheng Lu, Zongwu Wang, Tao Yang, Li Jiang, Haibing Guan

TL;DR

QUARK is a hardware/software co-design framework that significantly accelerates Transformer inference on FPGAs by optimizing and sharing hardware circuits for nonlinear operations like Softmax, GELU, and LayerNorm. By replacing expensive floating-point operations with integer-only shift-and-add math and introducing a novel offline channel-reordering quantization strategy, QUARK achieves up to a 1.96× end-to-end speedup over GPUs while cutting hardware resource overhead by more than half.

What Problem Does This Paper Address?

As Transformer models dominate computer vision and natural language processing, deploying them efficiently on edge hardware is a major priority. Standard optimization techniques focus heavily on quantizing linear operations (like matrix multiplications) from 32-bit floating-point (FP32) down to 8-bit or 4-bit integers (INT8/INT4).

However, this creates a new bottleneck. As linear layers become faster, the relative latency contribution of nonlinear operations—specifically Softmax, GELU, and LayerNorm—skyrockets. As shown in Figure 1, nonlinear operators account for only ~18% of latency in FP32, but jump to nearly 50% in an INT8 quantized model.

Latency breakdown of nonlinear operators across different precisions.

Accelerating these nonlinear functions in hardware is notoriously difficult because they involve complex mathematical operations like exponents, logarithms, square roots, and divisions. Existing solutions either target only one operator at a time or rely on expensive Quantization-Aware Training (QAT), which requires retraining the entire model—a luxury many cannot afford with today's massive model scales.

Methods

The authors introduce QUARK, a framework consisting of two primary pillars: Sub-Operator-Sharing Quantitative Approximations (software) and a Group Quantization Unit (hardware).

Overview of the QUARK software framework.

1. Integer-Only Nonlinear Approximations

QUARK mathematically reformulates complex transcendental functions into lightweight, hardware-friendly shift-and-add operations:

  • Softmax: Transformed from base-$e$ to base-2, allowing the integer parts of exponents to be calculated using simple bit-shifters and adders, while fractional parts are approximated using low-order polynomials.
  • GELU: Reformulated as a combination of a binary Softmax and a standard ReLU, allowing it to directly reuse the Softmax hardware.
  • LayerNorm: The variance calculation is simplified to require only a single data access pass instead of two. Division and square root operations are replaced with an iterative, shift-based logarithmic method.

2. Hardware Circuit Sharing via TDM

Because these nonlinear functions are invoked at different stages of the Transformer pipeline (attention, activation, normalization), QUARK utilizes Time-Division Multiplexing (TDM). Instead of building separate, dedicated circuits for each function, QUARK unifies common sub-operators (like exponents and logs) into a single reusable hardware block that sequentially processes data across pipeline stages.

3. Reorder-Based Group Quantization

Post-nonlinear activations have highly irregular, non-uniform distributions (e.g., power-law distributions in Softmax, heavy tails in GELU). To handle this without massive accuracy loss, QUARK analyzes channel distributions offline during calibration and reorders them so that channels with similar statistical properties are grouped together. This allows efficient, hardware-friendly group-wise quantization using simple bit-shifting for cross-group alignment.

Datasets

The authors evaluated QUARK across both vision and language domains using mainstream Transformer architectures:

  • Computer Vision (CV): Evaluated on the ImageNet dataset using ViT-S, ViT-B, DeiT-T, DeiT-S, DeiT-B, Swin-T, Swin-S, and Swin-B.
  • Natural Language Processing (NLP): Evaluated on the GLUE benchmark using BERT-Base and RoBERTa-Base models.

Key Insights and Ideas

  • The GELU-Softmax Connection: A key "aha" moment is realizing that the Sigmoid function inherent in GELU's approximation shares an identical mathematical form with a binary Softmax. This insight allows the hardware to reuse the exact same exponential computation module for both operators.
  • Zero-Cost Online Reordering: Grouping channels by statistical similarity is great for quantization accuracy, but sorting channels during live inference adds unacceptable latency. QUARK solves this by computing a trainable permutation matrix offline and fusing it directly into the weights of the preceding linear layers, achieving the benefits of dynamic grouping with zero runtime overhead.

Key Results

  • End-to-End Speedup: When deployed on a Xilinx ZCU102 FPGA, QUARK achieved an end-to-end speedup of 1.48× to 1.96× compared to an NVIDIA RTX A5000 GPU implementation.
  • Hardware Savings: Compared to prior state-of-the-art FPGA implementations, QUARK cut Look-Up Table (LUT) utilization by 20% to 80% and Flip-Flop (FF) consumption by roughly 70% due to its aggressive circuit-sharing architecture.
Shared hardware components and reuse pathways in QUARK.
  • High Accuracy at Ultra-Low Bitwidths: Under standard 8-bit (W8A8) quantization, QUARK matched the accuracy of models requiring expensive retraining. Under ultra-low 4-bit (W4A4) settings, it set a new state-of-the-art, boosting accuracy on ViT-B by 6.08% and improving BERT's average GLUE score by 20.41% over conventional Post-Training Quantization (PTQ) methods.

Limitations and Future Work

Not discussed in the paper.

Summary updated

BibTeX
@inproceedings{zhao2025quark,
  author = {Zhixiong Zhao and Haomin Li and Fangxin Liu and Yuncheng Lu and Zongwu Wang and Tao Yang and Li Jiang and Haibing Guan},
  title = {{QUARK: Quantization-Enabled Circuit Sharing for Transformer Acceleration by Exploiting Common Patterns in Nonlinear Operations}},
  booktitle = {ICCAD},
  year = {2025},
  url = {https://openreview.net/forum?id=TENJi8PhFZ},
}
Figure