Paper · 2018-05-16 · cs.CV, cs.AI
PACT: Parameterized Clipping Activation for Quantized Neural Networks
PACT replaces ReLU with a clipped activation whose clip level alpha is a learned, per-layer parameter trained by backpropagation with an L2 penalty. Activations are then uniformly quantized to k bits with a straight-through estimator. Author-reported: 4-bit weights and activations stay within about 1 point of full precision top-1 on CIFAR10, SVHN, AlexNet, ResNet18 and ResNet50.
Quantization-aware trainingLow-precision arithmeticHardware-aware trainingquantizationactivation-quantizationlow-precisioninference-efficiency
AI-compiled by claude-haiku-5-5 on 2026-10-19, not yet reviewed by a human. Every claim cites its source; check it when a detail matters.
In plain words
Neural networks run on numbers stored with many bits. Storing and multiplying those numbers with fewer bits makes a model smaller and faster, but the model usually gets worse. Most earlier work shrank the weights (the learned parameters). The activations (the values passed from layer to layer while the network runs) were harder to shrink, because a common activation function, ReLU, lets them grow without a limit, and a few-bit scale then fits them poorly.
PACT's idea is to cap each layer's activations at a threshold that the network learns during training. The threshold starts large, and training pulls it down to the range where the activations matter, so the few available levels are spent where they count. The rest of training then adjusts the network to the rounding. The authors report that this works with 4-bit weights and activations at roughly full-precision accuracy, and that the smaller number formats let a hardware accelerator pack in more compute units.
TL;DR
- PACT swaps ReLU for a clipped activation with one learned clip level alpha per layer. §4 eq. 1
- Clipped activations are rounded to k bits in the forward pass; gradients reach alpha through a straight-through estimator. §4 eq. 2 eq. 3
- Author-reported: with 4-bit weights (DoReFa) and 4-bit activations (PACT), top-1 accuracy is within about 1 point of full precision on the five networks tested. tab. 1
- The hardware analysis is a model estimate (14 nm MAC area, a performance simulator), not a measured chip. §6 fig. 6
Problem
Quantizing activations is harder than quantizing weights. ReLU outputs are unbounded, so quantizing them needs a high dynamic range, and accuracy is significantly degraded §3 fig. 1. Clipping activations with an upper bound helps, but the authors say it is hard to find one globally optimal clip value across layers and models §3. The Gaussian-based scale of HWGQ is set offline and stays fixed during training §3. The authors state that such schemes do not fully use back-propagation to learn the clip level §3.
Method
PACT is an activation function with one trainable parameter alpha. The forward pass is a truncation followed by a uniform k-bit quantizer. The backward pass uses a straight-through estimator (STE) for the rounding. §4
Activation (forward pass). The ReLU in each activation position is replaced by the function in eq. 1. It is 0 below zero, the identity on [0, alpha), and the constant alpha above alpha. §4 eq. 1
Quantization (forward pass). The truncated output y is mapped onto 2^k levels spaced alpha / (2^k - 1) apart, using the formula in eq. 2. The authors say the result is linearly quantized to k bits for the dot products. §4 eq. 2
Gradient for alpha (backward pass). The STE sets the derivative of the rounding to 1. The derivative of the output with respect to alpha is then 1 where the input is at or above alpha, and 0 elsewhere eq. 3. The paper therefore learns alpha by gradient descent through the loss. §4 eq. 3
Regularization of alpha. The loss includes an L2 penalty on alpha so that alpha shrinks during training and limits the dynamic range. The penalty uses the same coefficient as the weight decay §4.2 app. A.2, and the paper calls it lambda_alpha §4.1. The exact form of the penalty term in the loss is not written out in the paper. §4 app. A.2
Effect of alpha during training. In the ResNet20/CIFAR10 run of fig. 2 (lambda_alpha = 0.01), alpha falls from its initial value and settles at values much smaller than that start, which limits the dynamic range of the activations. §4 fig. 2
Sharing scope. The best scope for alpha was one value per layer. Sharing per layer also lets alpha be applied once after all multiply-accumulate operations of the layer §4.2 app. A.1 fig. 7.
Initialization. Starting alpha at a large value and then regularizing it down worked better than starting it small §4.2 app. A.2. The ResNet20 run uses an initial value of 10 §4 fig. 2.
Layers kept at full precision. The paper follows common practice and does not quantize the first and last layers in its main comparisons §4.2. Table 2 and Figure 9 show how quantizing those layers changes accuracy tab. 2 fig. 9.
Pseudocode. The two functions below restate eq. 1 to eq. 3. The paper gives no algorithm box.
# PACT forward pass [eq. 1] [eq. 2]
# Input: x (activation tensor), alpha (scalar clip level, one per layer),
# k (activation bit-width)
# Output: y_q (quantized activations, same shape as x)
def pact_forward(x, alpha, k):
# Truncate to [0, alpha] [eq. 1]
truncated = 0.5 * (abs(x) - abs(x - alpha) + alpha)
# Uniform k-bit grid with 2^k levels spaced alpha / (2^k - 1) [eq. 2]
step = alpha / (2 ** k - 1)
quantized = round(truncated / step) * step
return quantized# Gradient of the output with respect to alpha, with STE [eq. 3]
# Input: x (pre-activation tensor), alpha, upstream (dL/dy_q, same shape as x)
# Output: grad_alpha (scalar)
def pact_grad_alpha(x, alpha, upstream):
# 1 where x >= alpha, 0 where x < alpha [eq. 3]
inside_clip = (x >= alpha)
# Sum over every element that shares this alpha (one alpha per layer)
# [§4.2] [app. A.1]
grad_alpha = sum(upstream * inside_clip)
return grad_alphaHyperparameters
Values are as stated in the paper. Where the paper is silent, the cell says so. The full comparison tables are in the paper's appendix app. C.2.
| Name | Value | Where | Notes |
|---|---|---|---|
| Activation replacement | PACT replaces the ReLU that follows each convolution's BatchNorm; FC output uses Softmax | app. B | Baselines use ReLU |
| Activation bit-widths studied | 2, 3, 4, 5 bits | tab. 1 tab. 3–tab. 8 | |
| Weight bit-widths | DoReFa at the same bits as activations in tab. 1 | tab. 1 §5.2 | Weight precision in the activation-only runs (fig. 4, fig. 7–fig. 9) not stated |
| Scope of alpha | One per layer | §4.2 app. A.1 fig. 7 | Per channel and per neuron scopes were tried |
| Initial alpha | 10 (ResNet20/CIFAR10 run) | §4 fig. 2 | Other networks: not stated |
| lambda_alpha (L2 on alpha) | 0.01 in fig. 2 | fig. 2 fig. 8 | Sweep 1e-5 to 1e-1 in fig. 8; "same as weight lambda works well" app. A.2 |
| First and last layers | Not quantized in the main comparison | §4.2 | Table 1 setup for PACT not stated; tab. 2 tests 8-bit |
| Framework | TensorFlow with Tensorpack | §5 | |
| CIFAR10 model | ResNet20: conv, 3 ResNet blocks (16 conv, 3x3), FC | app. B | Trained from scratch |
| CIFAR10 optimizer | SGD, momentum 0.9 | app. B | |
| CIFAR10 learning rate | 0.1, scaled by 0.1 at epochs 60 and 120 | app. B | |
| CIFAR10 weight decay | 0.0002 on weights | app. B | |
| CIFAR10 batch size / epochs | 128 / 200 | app. B | |
| SVHN model | 7 conv layers, then 1 FC | app. B | Inputs resized to 40 x 40 |
| SVHN optimizer | ADAM, epsilon 1e-5 | app. B | |
| SVHN learning rate | 1e-3, scaled by 0.5 every 50 epochs | app. B | |
| SVHN weight decay | 1e-7 on weights | app. B | |
| SVHN batch size / epochs | 128 / 200 | app. B | |
| ImageNet preprocessing | Resize to 256 x 256, random crop 224 x 224 | app. B | |
| AlexNet | 5 parallel conv layers, then 3 FC; LRN replaced by BatchNorm | app. B | |
| AlexNet optimizer | ADAM, epsilon 1e-5; learning rate 1e-4 scaled by 0.2 at epochs 56 and 64 | app. B | |
| AlexNet weight decay / batch / epochs | 5e-6 / 128 / 100 | app. B | |
| ResNet18 | Conv, 8 ResNet blocks (16 conv 3x3), FC; pre-activation ResNet | app. B | |
| ResNet50 | Conv, 16 bottleneck blocks (48 conv), FC; pre-activation ResNet | app. B | |
| ResNet18/50 optimizer | SGD, momentum 0.9; learning rate 0.1 scaled by 0.1 at epochs 30, 60, 85, 95 | app. B | |
| ResNet18/50 weight decay / batch / epochs | 1e-4 / 256 / 110 | app. B | |
| Hardware model: MAC array | 8 rows x 64 columns, 2 GHz | fig. 6 | |
| Hardware model: cores and on-chip memory | 4 cores (16A-16W), 8 (8A-8W), 16 (4A-4W), 32 (2A-2W); 16 MB on-chip | fig. 6 | Iso-area across bit-widths |
| Hardware model: external bandwidth | Unconstrained, 32 GB/s, 64 GB/s | §6 fig. 6 |
Results
Author-reported. Setup: CIFAR10, SVHN, ImageNet (AlexNet, ResNet18, ResNet50), trained from scratch in TensorFlow §5 app. B. Baselines are DoReFa-Net for the same bit-widths §5.2 tab. 1 and the prior schemes of app. C.1 for ImageNet. "PACT" below means DoReFa weights with PACT activations, unless noted tab. 1 tab. 1 caption.
Top-1 accuracy on CIFAR10, SVHN, AlexNet, ResNet18, ResNet50 tab. 1
| Network | Full precision | DoReFa 2b | DoReFa 3b | DoReFa 4b | DoReFa 5b | PACT 2b | PACT 3b | PACT 4b | PACT 5b |
|---|---|---|---|---|---|---|---|---|---|
| CIFAR10 | 0.916 | 0.882 | 0.899 | 0.905 | 0.904 | 0.897 | 0.911 | 0.913 | 0.917 |
| SVHN | 0.978 | 0.976 | 0.976 | 0.975 | 0.975 | 0.977 | 0.978 | 0.978 | 0.979 |
| AlexNet | 0.551 | 0.536 | 0.550 | 0.549 | 0.549 | 0.550 | 0.556 | 0.557 | 0.557 |
| ResNet18 | 0.702 | 0.626 | 0.675 | 0.681 | 0.684 | 0.644 | 0.681 | 0.692 | 0.698 |
| ResNet50 | 0.769 | 0.671 | 0.699 | 0.714 | 0.714 | 0.722 | 0.753 | 0.765 | 0.767 |
Validation error (%) for CIFAR10-ResNet20 with first and last layers at different bit-widths tab. 2. Column groups are the bit-width of the other layers (BIT-M). Within each group the columns are the bit-width of the first and last layers (BIT-FL = 2, 4, 8, 32). FL/M/FL quantizes first, middle and last layers. FL/M/NQ leaves the last layer unquantized. NQ/M/FL leaves the first layer unquantized. NQ means no quantization.
| Config | BIT-M 2: 2 / 4 / 8 / 32 | BIT-M 3: 2 / 4 / 8 / 32 | BIT-M 4: 2 / 4 / 8 / 32 | BIT-M 5: 2 / 4 / 8 / 32 |
|---|---|---|---|---|
| FL/M/FL | 21.0 / 12.9 / 11.1 / 10.9 | 17.4 / 10.0 / 9.4 / 8.9 | 15.9 / 9.7 / 9.2 / 8.9 | 18.2 / 9.0 / 8.4 / 8.5 |
| FL/M/NQ | 21.3 / 11.5 / 11.5 / 10.7 | 17.6 / 9.7 / 9.2 / 9.0 | 16.5 / 9.7 / 8.7 / 8.7 | 16.3 / 9.3 / 8.6 / 8.5 |
| NQ/M/FL | 12.1 / 11.2 / 11.0 / 11.5 | 9.8 / 8.9 / 9.2 / 9.2 | 8.4 / 8.4 / 8.7 / 8.8 | 8.5 / 9.0 / 8.5 / 8.5 |
ImageNet, PACT rows only (full comparisons with DoReFa, BalancedQ, WRPN, FGQ, WEP, LPBN and HWGQ are in the cited tables app. C.2). The first row of each block is the bit configuration as BitW / BitA. The full-precision baseline is given per table.
AlexNet top-1, full precision 55.1 tab. 3:
| BitW | 32 | 32 | 32 | 32 | 32 | 2 | 2 | 2 | 3 | 3 | 3 | 4 | 4 | 4 | 5 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| BitA | 32 | 2 | 3 | 4 | 5 | 2 | 3 | 4 | 2 | 3 | 4 | 2 | 3 | 4 | 5 |
| PACT | 55.1 | 54.9 | 55.6 | 55.5 | 55.2 | 55.0 | 55.4 | 55.7 | 54.6 | 55.6 | 55.7 | 54.6 | 55.7 | 55.7 | 55.7 |
AlexNet top-5, full precision 77.0 tab. 4:
| BitW | 32 | 32 | 32 | 32 | 32 | 2 | 2 | 2 | 3 | 3 | 3 | 4 | 4 | 4 | 5 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| BitA | 32 | 2 | 3 | 4 | 5 | 2 | 3 | 4 | 2 | 3 | 4 | 2 | 3 | 4 | 5 |
| PACT | 77.0 | 77.2 | 77.8 | 77.6 | 77.2 | 77.7 | 77.9 | 78.0 | 77.1 | 78.0 | 78.0 | 77.1 | 78.0 | 78.0 | 77.8 |
ResNet18 top-1, full precision 70.4 tab. 5:
| BitW | 32 | 32 | 32 | 32 | 32 | 1 | 1 | 1 | 1 | 2 | 3 | 4 | 5 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| BitA | 32 | 2 | 3 | 4 | 5 | 32 | 2 | 3 | 4 | 2 | 3 | 4 | 5 |
| PACT | 70.4 | 67.5 | 69.2 | 70.0 | 70.0 | 65.8 | 62.9 | 65.3 | 65.0 | 64.4 | 68.1 | 69.2 | 69.8 |
ResNet18 top-5, full precision 89.6 tab. 6:
| BitW | 32 | 32 | 32 | 32 | 32 | 1 | 1 | 1 | 1 | 2 | 3 | 4 | 5 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| BitA | 32 | 2 | 3 | 4 | 5 | 32 | 2 | 3 | 4 | 2 | 3 | 4 | 5 |
| PACT | 89.6 | 87.6 | 88.9 | 89.3 | 89.3 | 86.7 | 84.7 | 85.9 | 85.9 | 85.6 | 88.2 | 89.0 | 89.3 |
ResNet50 top-1, full precision 76.9 tab. 7:
| BitW | 32 | 32 | 32 | 32 | 1 | 2 | 2 | 3 | 4 | 5 |
|---|---|---|---|---|---|---|---|---|---|---|
| BitA | 32 | 3 | 4 | 5 | 2 | 2 | 4 | 3 | 4 | 5 |
| PACT | 76.9 | 75.5 | 75.9 | 76.0 | 67.8 | 72.2 | 74.5 | 75.3 | 76.5 | 76.7 |
ResNet50 top-5, full precision 93.1 tab. 8:
| BitW | 32 | 32 | 32 | 1 | 2 | 2 | 3 | 4 | 5 |
|---|---|---|---|---|---|---|---|---|---|
| BitA | 3 | 4 | 5 | 2 | 2 | 4 | 3 | 4 | 5 |
| PACT | 92.6 | 92.9 | 92.9 | 87.9 | 90.5 | 91.9 | 92.6 | 93.2 | 93.3 |
Hardware (modelled). Over 16 to 2 bits, the MAC density improves by about 14x when weight and activation bit-widths are reduced together §6 fig. 6. With external bandwidth limited to 64 GB/s, going from 16 to 4 bits gives a 4x increase in peak FLOPs and about 4.5x in performance. The authors attribute the extra gain to data fitting in on-chip memory §6. The first and last layers stayed at 8 bits in these runs; the authors estimate about 1.24x more if they were also quantized to 4 or 2 bits §6.
Paper vs code
No official code. The arXiv source is a wrapper around the PDF, and the PDF has no code link [raw/src/1805.06085/main2.tex]. Searches with the GitHub API: "PACT quantization" returned six repositories, none owned by an author or by IBM; "pact ibm org:IBM" returned none; "parameterized clipping activation" returned none. The closest match, KwangHoonAn/PACT (Apache-2.0), is a third-party reimplementation and is not used.
Pitfalls
- Alpha's L2 penalty is unspecified. The paper says alpha has an L2 penalty with coefficient lambda_alpha §4 app. A.2, but does not write the term in the loss (for example whether it is lambda * alpha^2 or with a 1/2 factor). No official code is available to settle it.
- Gradient with respect to the input is not stated. eq. 3 covers only alpha. The gradient with respect to x, and the handling of the STE for the rounding in eq. 2, are not written out. An implementation has to choose them. The usual choice is the straight-through identity for rounding and the step of eq. 1 for the input; this is an inference, not stated.
- Initial alpha is only given for one run. The value 10 is from the ResNet20/CIFAR10 study §4 fig. 2. For other networks, the initial value is not stated. app. A.2 says a very small start puts activations where the gradient is nonzero, so alpha adapts unstably in early epochs. A very large start makes the gradient small, so alpha may stay large and quantization error suffers.
- Quantization of the first and last layers in Table 1 is not stated. The paper's default is to keep them full precision §4.2; tab. 2 shows that quantizing them to low bits costs accuracy. Whether the Table 1 PACT runs did so is not stated.
- Weight precision in the activation-only runs is not stated. Figure 4 and Figures 7 to 9 vary activation bit-width. Whether weights were full precision in those runs is not stated.
- "Full precision" versus "near full precision." The text says 4-bit runs reach "full-precision accuracy consistently across the networks tested", then says "near (<= 1%)" §5.2. In tab. 1, ResNet18 with 4-bit PACT is 1.0 point below full precision (0.692 against 0.702). Use the table numbers.
- Accuracy degradation curves are read from plots. Figures 5 and 4(f) give degradation values only as bar heights, so they are not reproduced here.
- Hardware numbers are a model. The area and performance results come from a 14 nm MAC area estimate and the DeepMatrix framework §6 fig. 6. They are not measured silicon. The memory bandwidth of the modelled system is set per configuration §6.
- Scope of alpha drives the hardware benefit. Per-layer scope lets alpha be applied once after all MAC operations §4.2. Per-channel and per-neuron scopes give different training and validation error app. A.1 fig. 7, and the paper prefers per-layer scope partly for hardware complexity app. A.1.
Lineage
- Used with: DoReFa-Net (arXiv:1606.06160) for weights in tab. 1 §5.2.
- Builds on: clipping activation functions with an upper bound (Hubara et al., Zhou et al., as cited in §3), with the clip level learned rather than set.
- Compared against: DoReFa, BalancedQ, WRPN, FGQ, WEP, LPBN, HWGQ, with their reported numbers and settings app. C.1 app. C.2.
- Superseded by: not stated.
Source and license
Adapted from “PACT: Parameterized Clipping Activation for Quantized Neural Networks” by Jungwook Choi, Zhuo Wang, Swagath Venkataramani, Pierce I-Jen Chuang, Vijayalakshmi Srinivasan, Kailash Gopalakrishnan (arXiv:1805.06085), used under CC BY 4.0. Changes: condensed and restructured for implementation, with tables, equations and algorithms taken from the paper and its code, each cited to its source. Not affiliated with or endorsed by the authors.