RPFQ-ViT: Rotated Phase-Frame Quantization for Extremely Low-Bit Weights in Vision Transformers
Organizations: Peking University
Abstract
Vision Transformers (ViTs) achieve strong performance on image recognition and mobile vision applications, but their high-dimensional linear projections and attention computations still impose substantial storage and inference costs. Extremely low-bit quantization is a promising solution, yet ViTs often suffer severe accuracy degradation because conventional real-valued scalar codebooks are poorly matched to the directional geometry of Transformer projections. We present RPFQ-ViT, a Rotated Phase-Frame Quantization method that quantizes paired channels in two-dimensional phase planes, enabling low-bit codes to better preserve projection directions while recovering magnitude with lightweight scaling. RPFQ-ViT serves as a drop-in QAT replacement for nn.Linear and does not modify the standard real-valued attention, normalization, or activation computation graph. On ImageNet-1K, RPFQ-ViT-B/16 reaches 79.33% Top-1 / 94.48% Top-5 under W2/A4, Swin-T reaches 79.30% Top-1 / 94.79% Top-5 under W2/A8, and DeiT-S reaches 77.41% Top-1 / 93.11% Top-5 under W2/A8. Ablations, phase-geometry analysis, and direction-preservation metrics show that channel pairing, learnable rotation, phase-anchor learning, and residual phase refinement each improve quantization quality. We further deploy RPFQ-ViT image-classification models on native iOS and Android runtime stacks; with 2-bit packed weights, model size shrinks by roughly - relative to FP32 and end-to-end on-device latency drops by -. All ImageNet results trained in our codebase use a matched 300-epoch recipe and are reported as mean accuracies over three independent runs. These results show that RPFQ-ViT provides a favorable trade-off among accuracy, compression, and practical mobile deployment for extremely low-bit ViTs.
Figures & tables
| Backbone | Method | Source | Eff. weight bits | Epochs | Top-1 | Top-5 |
|---|---|---|---|---|---|---|
| ViT-B/16 | FP32 | reproduced | 32 | 300 | 77.888 | 93.388 |
| Q-ViT | reproduced | 2 | 300 | 62.378 | 83.840 | |
| LSQ++KD | reproduced | 2 | 300 | 75.10 | 92.18 | |
| RPFQ | ours | 2 | 300 | 79.326 | 94.476 | |
| DeiT-S | FP32 | reproduced | 32 | 300 | 78.364 | 93.738 |
| Q-ViT | reported | 2 | 300 | 72.10 | 90.30 |
| Variant | Pairing | Residual | Rotation | Anchors | Scale fit | Top-1 | Top-5 |
|---|---|---|---|---|---|---|---|
| Real scalar LSQ | real LSQ | 74.89 | 91.28 | ||||
| Fixed phase frame | ✓ | none | fixed | mean | 76.56 | 92.83 | |
| + residual refinement | ✓ | ✓ | none | fixed | mean | 78.74 | 93.61 |
| + pre-aligned frame | ✓ | ✓ | pre-aligned | fixed | LS | 78.79 | 93.78 |
| RPFQ w/o anchor learning | ✓ | ✓ | learned | fixed | LS | 79.06 | 94.21 |
| RPFQ full | ✓ | ✓ | learned | learnable | LS | 79.33 | 94.48 |
| Quantizer | Weight MSE | Angular error | Attention score MSE | Feature cosine | Top-1 |
|---|---|---|---|---|---|
| Real LSQ W2/A4 | 1.00 | 1.00 | 1.00 | 0.931 | 74.89 |
| Real ternary + KD | 0.82 | 0.91 | 0.84 | 0.947 | 76.20 |
| Fixed phase frame | 0.63 | 0.57 | 0.61 | 0.971 | 78.74 |
| RPFQ w/o residual | 0.58 | 0.51 | 0.55 | 0.976 | 78.90 |
| RPFQ full | 0.49 | 0.43 | 0.46 | 0.983 | 79.33 |
| Hardware profile | Runtime | Model | W/A | Size (MB) | Load (ms) | Latency p50 / p90 (ms) | Speedup |
|---|---|---|---|---|---|---|---|
| Recent Apple A-series iOS phone | MLX Swift | ViT-B/16 FP32 | 32/32 | 338.6 | 742 | 86.4 / 95.1 | 1.00 |
| MLX Swift | RPFQ-ViT-B/16 | 2/4 | 47.7 | 213 | 54.9 / 61.3 | 1.57 | |
| MLX Swift | Swin-T FP32 | 32/32 | 110.2 | 318 | 39.8 / 44.5 | 1.00 | |
| MLX Swift | RPFQ-Swin-T | 2/8 | 20.4 | 91 | 27.4 / 31.0 | 1.45 | |
| Recent Android flagship phone | JNI/C++ | ViT-B/16 FP32 | 32/32 | 338.6 | 918 | 123.6 / 139.2 | 1.00 |
| JNI/C++ | RPFQ-ViT-B/16 | 2/4 | 47.7 | 302 | 78.1 / 88.4 | 1.58 |
Appendix figures & tables5 assets
Supplementary material from the paper’s appendix.
Appendix
| Backbone | Comparison | Ours 95% CI | Baseline 95% CI | Gap (pt) | Gap 95% CI (pt) |
|---|---|---|---|---|---|
| ViT-B/16 | RPFQ vs FP32 | [78.97, 79.68] | [77.52, 78.25] | +1.44 | [0.93, 1.95] |
| ViT-B/16 | RPFQ vs LSQ++KD | [78.97, 79.68] | [74.72, 75.48] | +4.23 | [3.71, 4.75] |
| DeiT-S | RPFQ vs OFQ | [77.04, 77.78] | [75.34, 76.10] | +1.69 | [1.17, 2.21] |
| Swin-T | RPFQ vs OFQ | [78.94, 79.65] | [78.16, 78.88] | +0.78 | [0.27, 1.28] |
| Pairing rule | Layout-preserving | Top-1 | Top-5 |
|---|---|---|---|
| Half-split | yes | 79.33 | 94.48 |
| Adjacent | yes | 79.08 | 94.24 |
| Random fixed pairing | no | 78.81 | 94.05 |
| Method | Backbone / setting | Protocol | Aux. branch | Iter (s) | 300-epoch total |
|---|---|---|---|---|---|
| RPFQ | ViT-B/16 W2/A4 | single-stage QAT | none | 0.223 | 46.55 h / 1.94 d |
| RPFQ | DeiT-S W2/A8 | single-stage QAT | none | 0.191 | 39.75 h / 1.66 d |
| RPFQ | Swin-T W2/A8 | single-stage QAT | none | 0.216 | 45.06 h / 1.88 d |
| Q-ViT | ViT-B/16 W2/A4 | single-stage QAT | teacher + DGD attention distill. | 0.768 | 160.21 h / 6.68 d |
| OFQ | DeiT-S / Swin-T (no ViT-B recipe) | QAT + CGA fine-tune | teacher + QKR + CGA | – | epochs |