TL;DR
As low-bit matrix multiplications become standard on modern AI hardware, the non-linear softmax operation has emerged as a major inference bottleneck, consuming up to 39% of execution time. EXAQ (Exponent-Aware Quantization) solves this by analytically deriving optimal clipping thresholds for sub-4-bit softmax inputs to minimize error after exponentiation. By quantizing softmax inputs down to 2 bits, EXAQ shrinks exponentiation to a tiny 4-entry lookup table (LUT) and packs four inputs into a single byte to accelerate denominator accumulation by 4×, cutting overall softmax latency by 36.9% with negligible loss in downstream accuracy.
What Problem Does This Paper Address?
Quantization typically targets General Matrix Multiplications (GEMMs) by compressing weights and activations to 8-bit or 4-bit precision. With dedicated accelerator support (such as FP8 on Intel Gaudi2 and NVIDIA H100), GEMM compute time has plummeted.
Consequently, the non-linear softmax layer inside the multi-head attention mechanism has become the new performance bottleneck—accounting for nearly 39% of total runtime in models like LLaMA-2-7B on Gaudi2. Softmax involves three steps:
- Exponent calculation ($e^{x_i}$)
- Denominator accumulation ($\sum_j e^{x_j}$)
- Normalization ($e^{x_i} / \sum_j e^{x_j}$)
Previous attempts to accelerate softmax relied on 8-bit or 16-bit fixed-point formats or multi-cycle approximations. The authors tackle the challenge of pushing softmax input precision below 4 bits (down to 2 or 3 bits) without collapsing model accuracy, unlocking hardware-friendly lookup tables for both exponentiation and accumulation.
Methods
EXAQ combines an analytical error formulation with table-driven arithmetic:
-
Exponent-Aware Clipping (EXAQ): Standard quantization minimizes mean squared error (MSE) directly on the input tensor $x$. However, softmax operates on $e^x$ (with inputs normalized so $x \le 0$). Small errors in larger, less-negative inputs explode exponentially, while large errors on deeply negative inputs are completely suppressed by $e^x \to 0$. EXAQ formulates total MSE after exponentiation: $$\text{MSE} = \text{MSE}_{\text{clip}} + \text{MSE}_{\text{quant}} = \int_{-\infty}^C (e^C - e^x)^2 f(x)dx + \frac{\Delta^2}{12} \int_C^0 e^{2x} f(x)dx$$ Assuming a Gaussian input distribution $f(x) \sim \mathcal{N}(\mu, \sigma^2)$, the optimal clipping threshold $C^*$ is solved numerically and mapped to a simple runtime linear function of the input standard deviation $\sigma$:
-
2-bit: $C^* = -1.66\sigma - 1.85$
- 3-bit: $C^* = -1.75\sigma - 2.06$
- Single-Cycle Exponentiation via Compact LUT: For 2-bit quantization, all exponent values are pre-computed in a tiny 4-entry table ($\text{LUT}_{\text{exp}}$), turning multi-cycle transcendental math into a single-cycle lookup.
- 4× Accelerated Denominator Accumulation: Since each value requires only 2 bits, four consecutive values fit into a single 8-bit byte. The authors deploy a 256-entry table ($\text{LUT}_{\text{sum}}$) indexed by that byte, which directly outputs the pre-computed sum of the four exponentiated values ($\sum_{k=0}^3 e^{q[k]}$). This shrinks the accumulation loop from $N$ iterations to $N/4$.
Datasets
The authors evaluated EXAQ using the lm-evaluation-harness across seven standard zero/few-shot natural language understanding and reasoning benchmarks:
- BoolQ (Boolean question answering)
- HellaSwag (sentence completion)
- PIQA (physical interaction QA)
- WinoGrande (commonsense reasoning)
- ARC Challenge & ARC Easy (science exam questions)
- OpenBookQA (open-domain question answering)
No new datasets were introduced. Evaluations were run using pre-trained LLaMA-1 (7B, 13B, 30B, 65B) and LLaMA-2 (7B, 13B, 70B) checkpoints.
Key Insights and Ideas
- Target the output of the non-linearity, not the input: By minimizing $\text{MSE}(e^x, e^{Q(x)})$ rather than $\text{MSE}(x, Q(x))$, the analytical model aggressively clips the negative tail where values contribute almost nothing to the partition function $\sum e^x$. This frees up quantization resolution for the values that actually matter.
- Low bit-width enables byte-level parallel summation: Moving to 2-bit integer representations does more than save memory—it allows packing multiple vector elements into standard byte-wide datatypes. A single 256-entry LUT can simultaneously perform 4 exponentiations and 3 additions in 1 clock cycle.
- Decoupling arithmetic: Unlike standard softmax, where accumulation depends directly on individual exponent outputs, EXAQ decouples exponentiation from the denominator sum, enabling parallel execution of both pipelines.
Key Results
- End-to-End Softmax Speedup: Softmax kernel execution time dropped from 3.274 ms to 2.066 ms, delivering an overall 36.9% speedup for the softmax layer on Gaudi2 hardware.
- Preserved Model Accuracy:
- 3-bit EXAQ: Within 0.65% of the full BF16 baseline across tasks, with 43% of benchmark runs matching or outperforming baseline accuracy.
- 2-bit EXAQ: Within 1.9% on average across tasks. For example, on LLaMA-1-30B evaluated on PIQA, 2-bit EXAQ achieved 81.3% accuracy (beating the BF16 baseline of 81.2%).
- Outperforming Prior Art: Compared against the prior state-of-the-art approximation method ($A^3$), which uses 16-bit fixed-point tables, EXAQ drastically outperformed it at 2-bit precision (e.g., LLaMA-1-7B average score: 64.6% with EXAQ vs. 49.8% with $A^3$).
Limitations and Future Work
- Objective Function Scope: The method minimizes error at the output of the exponential function ($e^x$), rather than the final normalized softmax distribution or the complete attention block output ($PV$).
- Inference-Only Evaluation: EXAQ was derived and evaluated strictly for post-training inference; the authors did not explore its applicability or stability during model training or fine-tuning.
- Hardware-Specific LUT Implementation: While conceptually simple, deployment benefits depend on hardware that allows fast byte-indexed table lookups without cache-line contention or bank conflicts.
Summary updated