SPA-Q: 4-Bit Post-Training Quantization for Monocular Depth
For 4-bit monocular depth estimation, per-projection reconstruction error is the wrong acceptance metric; you must check whether attention distributions and intermediate feature distributions survive, which is exactly what SPA-Q calibrates for.
On this page
A 4-bit quantized Depth Anything can post a respectable average error, yet the number a buyer actually needs is whether the depth map still holds at object boundaries. The usual advice is to look at reconstruction error: compress the floating-point weights into small integers, measure how far the restored values drift from the originals, and sign if the gap is small. SPA-Q argues that this default check misleads on depth estimation. When the authors pushed Depth Anything down to 4 bits, two things broke. First, making the two projections inside attention individually accurate does not keep the attention map they jointly produce intact. Second, quantization error accumulates layer by layer and pushes the distribution of intermediate features off course. Their fix aligns the attention map directly and then learns a per-channel correction. Across NYUv2 and KITTI, that yields an average 25.9% reduction in AbsRel (relative depth error, lower is better) and a 17.3% improvement in delta-1 (the share of pixels within 1.25x of the true depth, higher is better) [1].
What breaks first at 4 bits is the attention map between tokens
Two definitions first. Quantization means storing a model's decimal weights and activations as integers; at 4 bits each number has only 16 slots to land in. Post-training quantization (PTQ) means the model is already trained and is not retrained: a small calibration set is used to fix a scale and zero-point per tensor, which is cheap and fast to deploy. The paper contrasts this with quantization-aware training (QAT), which simulates quantization during training and is usually more accurate but needs data and compute [1].
The paper's entry point is that existing PTQ methods, including BRECQ, QDrop and RepQ-ViT, were designed for image classification, where the criterion is that the final class scores do not collapse. Depth estimation is different: it must output a distance per pixel, and it relies on a decoder that fuses intermediate features from several encoder stages, the DPT family of architectures. Classification needs one row of scores to stay right; depth needs every intermediate representation to arrive intact. A calibration objective that works on classification therefore does not automatically transfer [1].
The two failure points the paper names
The first is inside attention. Two projection matrices turn the input into a query and a key, the two are multiplied and normalized, and the result is a table of how much each token attends to each other token. Conventional PTQ minimizes the quantization error of query and key separately, each pulled toward its full-precision output. The paper shows this objective embeds a false assumption: that if both projections are individually accurate, their product will be accurate too. The attention map is determined by the interaction after softmax, not by the fidelity of either projection alone [1].
A controlled comparison makes the point concrete. Replacing the per-projection objective with an error term on the pre-softmax score matrix does reduce that matrix's mean squared error, but the post-softmax attention map does not consistently improve on either mean squared error or KL divergence. The reason is the nonlinearity of softmax: unnormalized real-valued scores and a normalized probability distribution are not the same object, so shrinking Euclidean distance on the first does not shrink the gap on the second [1].
The second failure point is across layers. Quantization error is not local: each layer's quantized output feeds the next, error accumulates, and the distribution of intermediate features drifts away from the full-precision version. The paper names an amplifier. Under tensor-wise quantization a single scale is shared across all channels, which makes the error more sensitive to inter-channel variation and can worsen the shift. This matters more for depth than for classification because the DPT decoder consumes stage-wise encoder features; once those are distorted, scene geometry and object boundaries degrade with them [1].
- Failure one: query and key are calibrated separately, so the attention map is not guaranteed to survive.
- Failure two: error accumulates across layers and the intermediate feature distribution shifts before the decoder sees it.
- Amplifier: tensor-wise quantization shares one scale across channels, magnifying inter-channel variation.
What SPA-Q's two components, APC and CWDA, actually fix
For the first failure, the paper proposes Attention-Preserving Calibration (APC). Since a pre-softmax objective is not enough, APC places the calibration target directly on the post-softmax attention map. Each row of that map is a normalized probability distribution over tokens, so KL divergence is a better discrepancy measure than Euclidean error; APC therefore minimizes the row-wise KL divergence between the full-precision and quantized attention maps and uses that objective to set the query and key quantization parameters [1].
For the second failure, the paper proposes Channel-Wise Distribution Alignment (CWDA). It learns a scaling factor and a shift per channel to pull dequantized activations toward their full-precision counterparts, optimized end to end with both a feature-level and a depth-level objective. Crucially, after training these parameters are folded into the weights, and the paper states this introduces no additional inference overhead [1]. Separately, because post-softmax activations concentrate near zero with a long tail, the paper switches that part to a log2 quantizer, which allocates more levels to small values.
| Stage | Conventional PTQ | SPA-Q | Extra inference cost |
|---|---|---|---|
| Query / key calibration | Minimize each projection's quantization error separately | Minimize row-wise KL between full-precision and quantized attention maps (APC) | None; only the calibration-derived quantizer parameters change |
| Intermediate feature drift | Not handled explicitly; eased indirectly by block-wise reconstruction | Learn per-channel scale and shift, folded into weights after training (CWDA) | Paper reports no extra parameters or compute |
| Post-softmax activation quantization | Uniform quantization | Log2 quantizer, more levels for small values | None |
What the 25.9% and 17.3% on NYUv2 and KITTI actually measure
First, the scope of these two figures. The 25.9% is an average reduction in AbsRel and the 17.3% is an average improvement in delta-1. The averaging spans two datasets, NYUv2 and KITTI, under 4-bit quantization with both weights and activations at 4 bits (W4A4), on Depth Anything v1 and v2, against existing PTQ methods [1].
The abstract's wording is that SPA-Q consistently outperforms existing PTQ methods under 4-bit quantization, meaning it wins across the evaluated settings rather than on a cherry-picked one. The baselines named in the paper are BRECQ, QDrop and RepQ-ViT, plus QSCA, a method built specifically for depth estimation that adds lightweight auxiliary modules for residual error compensation. QSCA works, but it brings extra parameters and compute, which is exactly the cost SPA-Q sets out to avoid [1].
One caveat worth stating plainly: the version I read is an excerpt, and the full per-dataset, per-model results table does not appear in the supplied text. The abstract gives only the average across the two datasets. Any specific figure for NYUv2 alone cannot be derived from this material. That is my own reading, not a number from the paper.
Five questions to ask before buying or accepting this kind of compression
- Where exactly is the bit-width applied: are both weights and activations at 4 bits (W4A4), or only weights, with activations still at 8 bits? The deployment payoff differs by roughly a factor of two.
- What is the calibration set: how many images, from what scene distribution? If it does not match your own collected data, the PTQ scales are simply wrong for you.
- Which metrics are reported: AbsRel only, or delta-1 as well? The paper's appendix listing includes an evaluation on structural metrics, so ask for those too.
- What is the measured overhead: QSCA buys accuracy with auxiliary modules, while SPA-Q claims zero because parameters are folded into weights, but that claim needs measured latency and memory to back it.
- Where does it fail: the paper has its own limitations section, so ask which image types degrade most. That is more useful than an average.
The first two questions decide whether you are validating on someone else's scenes. The last three decide whether you are validating against someone else's average. The 25.9% and 17.3% are academic averages, not averages inside your vehicle's compute box [1].
When this method does not apply
SPA-Q is not a general-purpose PTQ scheme, and its scope is stated clearly: it targets architectures whose decoder aggregates multi-stage encoder features to produce dense depth, the DPT line, with Depth Anything v1 and v2 as its instances [1]. Point it at a model that does not fuse features that way and the premises behind APC and CWDA no longer hold.
The evidence coverage is the second limit. Evaluation lands on NYUv2 and KITTI, both standard relative-depth benchmarks, and the model side covers only Depth Anything v1 and v2. Large-scale outdoor driving logs, rain, fog, night, and cluttered indoor scenes have no corresponding results in the abstract or the excerpt. It also remains PTQ, which needs a small calibration set; if compliance rules forbid handing over even a handful of images, this route is closed.
Bit-width is the third limit. The paper's claim is anchored at 4 bits. Pushing to 3 or 2 bits, or going the other way to 8 bits, has no evidence of holding equally, and extending 4-bit conclusions downward is your inference, not the paper's finding. The method fails when your architecture is not a multi-stage-feature decoder, when you cannot supply representative calibration data, or when your target bit-width sits outside the tested 4-bit setting [1].
