Appearance
Mixed Precision & Quantization
Super-resolution networks operate on dense high-resolution feature maps where memory bandwidth dominates latency. Reducing numerical precision unlocks substantial speedups, but restoration models are notoriously sensitive to quantization noise in shallow and reconstruction layers.
Automatic Mixed Precision (AMP)
During training and GPU inference, SoraSR supports both BF16 and FP16:
| Format | Exponent Bits | Mantissa Bits | Dynamic Range | Recommendation |
|---|---|---|---|---|
fp32 | 8 | 23 | Reference accuracy & loss scaling baseline | |
bf16 | 8 | 7 | Preferred on Ampere / Hopper / Ada GPUs (no GradScaler needed) | |
fp16 | 5 | 10 | Preferred for TensorRT inference on Turing / Ampere / Ada |
Attention Accumulation in FP16
Keep softmax normalization and LayerNorm statistics in fp32. SoraSR automatically forces fp32 inside attention score scaling and residual accumulation when precision: fp16 is selected to prevent NaN divergence on high-contrast patches.
Post-Training Quantization (PTQ)
INT8 quantization compresses weights and activations by 4x relative to FP32, cutting DRAM traffic significantly. However, uniform INT8 quantization across all layers typically costs 0.4–0.9 dB PSNR on Set14/Urban100.
SoraSR mitigates this drop using Sensitivity-Guided Mixed-Precision PTQ:
- Calibration Set — Run 128 diverse high-resolution crops (covering sharp text, foliage, skin tones, and low-light gradients) through an entropy/percentile observer (
99.99%clipping). - Per-Layer Sensitivity Profiling — Measure PSNR delta when quantizing each module independently while holding the rest in FP16.
- Selective FP16 Fallback — Keep the top 10% most sensitive layers in FP16, always including:
- Entry shallow feature convolution (
conv_first) - Final sub-pixel reconstruction head (
upsampler,conv_last) - Residual skip additions with wide activation variance
- Entry shallow feature convolution (
Quantization-Aware Training (QAT)
When strict INT8 throughput is required with < 0.15 dB PSNR degradation, insert fake-quantization observers and fine-tune for 20k–40k steps at a reduced learning rate (1e-5):
bash
sorasr train \
--config configs/qat_sorasr_s_x4.yaml \
--resume checkpoints/sorasr_s_x4_fp32.pt \
--work-dir runs/sorasr_s_x4_qatObserved Accuracy vs. Latency (SoraSR-S x4, 720p → 4K on RTX 4090)
| Precision Mode | Urban100 PSNR (dB) | Latency (ms) | VRAM (GB) |
|---|---|---|---|
| PyTorch FP32 | 26.84 | 118.2 | 3.9 |
| PyTorch BF16 | 26.83 | 54.6 | 2.3 |
| TensorRT FP16 | 26.82 | 29.4 | 1.6 |
| TensorRT INT8 (Uniform PTQ) | 26.19 | 19.8 | 1.1 |
| TensorRT INT8 (Mixed PTQ + QAT) | 26.74 | 21.5 | 1.2 |