DAT
DAT (Chen et al., ICCV 2023): a x4 upscaler for clean (bicubic) images that alternates spatial and channel attention, in three sizes (DAT, DAT-2, DAT-light). Apache-2.0 code and weights.
experimental Fork of zhengchen1999/DAT@1645c64 · backends: portable, kernels
- Paper Dual Aggregation Transformer for Image Super-Resolution ICCV 2023 · first released 7 Aug 2023
Paper 2023 Added in 0.2.0 Evaluated with 0.2.0
Use it
pip install fastforks Lean install with only what this model needs: pip install fastforks-core
from fastforks import restoration
model = restoration.load("dat-x4") # kernels on a supported GPU, else portable PyTorch
result = model(image)
result.image
result.backend # what ran: mode, device, dtype, kernels fastforks bench dat-x4 Times the model on this machine. load(…, mode="portable") or mode="kernels" picks a backend; usage guide.
Speed and memory
Every backend on one GPU (RTX 5060 Ti 16 GB) and the same input, the authors’ code included. Kernels runs fp16. Portable runs fp16 on CUDA.
Input: synthetic, 512x512 (the task’s standard size)
| Backend | dtype | Time per call (ms) | vs original fp16 | Peak memory allocated / reserved | Load (s) | First call (s) |
|---|---|---|---|---|---|---|
| Original fp32 | fp32 | not measured | – | – | – | – |
| Original fp16.half() on 1 modules, fp16 inputs; upstream dat_model.py test, float32, no chop | fp16 | 9564 | – | 2,443 MiB/2,528 MiB | 2.2 | 7.78 |
| Portable fp32 | fp32 | not measured | – | – | – | – |
| Portable | fp16 | 1565 | 6.1× | 2,552 MiB/2,624 MiB | 3.0 | 2.31 |
| Kernels | fp16 | 1391 | 6.9× | 2,282 MiB/2,384 MiB | 1.2 | 2.14 |
| Portable + torch.compile | 1063 | 9.0× | 2,552 MiB/2,606 MiB | 43 (build) | – | |
| TensorRT fp16 | fp16 | 1001 | 9.6× | 8,334 MiBenginenot comparable | 191 (build) | – |
Measured on RTX 5060 Ti 16 GB, torch 2.14.1+cu130, 2026-11-13 to 2026-11-15. First call, 3 warm-up, peak reset, median of 3 rounds x median of 5. Ratios divide two
times of this table (same GPU, same input). Original fp16 is the authors’ own precision option, else torch.autocast. torch.compile and TensorRT: build time instead of load time. TensorRT memory (engine, not comparable) is the GPU memory the engine took, read from the driver because TensorRT allocates outside PyTorch, so it can't be compared with the PyTorch peaks of the other rows.
Other devices
| Device | Backend | dtype | ms / call | Peak memory | Output vs reference | Input |
|---|---|---|---|---|---|---|
| Apple M1 Pro 16 GB MPS, torch 2.14.1, 2026-11-14 | Original | fp32 | 18351 | 13.2 GiB process | – | 512x512 |
| Portable | fp16 | 10512 | 10.4 GiB process | matches | 512x512 | |
| Portable | fp32 | 21047 | 12.9 GiB process | matches | 512x512 | |
| Kernels | fp16 | not implemented | – | 512x512 | ||
CUDA memory is torch’s peak allocated / reserved; Apple has no such counter, so the Mac rows show the process footprint (weights, Python and torch included). “Output vs reference” compares the device’s output with the stored golden output under the card’s tolerance; – = not checked on that device. Kernels “not implemented” = no kernels for this model on that backend yet: it runs portable there.
Licence and weights
Commercial use allowed
- Code
- Apache-2.0 LICENSE
- Weights
- Apache-2.0 source
- Training data
-
- DIV2K (NTIRE 2017 super-resolution, 1000 2K images) research-only, non-commercial
- Flickr2K (2650 2K Flickr images, EDSR) not stated
Our reading of the licences, not legal advice.
Weights
DAT_x4.pth 155 MB· hosted on Google Drivefastforks downloads and checks these files on first use (fastforks download dat-x4).
Accuracy
The test set through the authors’ code and through ours: same checkpoint, same protocol. The distance between the original’s fp32 and fp16 runs is what half precision alone costs; our runs should stay within it.
DIV2K validation (every 4th: 25 images)
bicubic x4 LR -> HR, PSNR / SSIM (Y)
| Run | dtype | psnr ↑ | ssim ↑ | Δ psnr vs fp32 original | images | ms / image |
|---|---|---|---|---|---|---|
| Original fp32 | fp32 | 31.03 | 0.8498 | reference | 25 | – |
| Original fp16 | not measured | |||||
| Portable fp32 | fp32 | 31.03 | 0.8498 | ±0.00 | 25 | – |
| Portable | fp16 | 31.03 | 0.8498 | ±0.00 | 25 | – |
| Kernels | fp16 | 31.01 | 0.8498 | −0.02 | 25 | – |
DIV2K validation HR images and the official bicubic LR images (x4 or x2, the model's scale), one pass without tiles; PSNR and SSIM (Gaussian 11 x 11, sigma 1.5) on the Y channel (BT.601) of the output rounded to uint8, `scale` px border cropped, averaged over the images. Real-ESRGAN is trained for real-world degradations, not bicubic, so its PSNR is low: the numbers compare our modes with the original, not with PSNR-oriented upscalers. Original = the authors’ code, same checkpoint and protocol. Measured on original fp32: RTX 5060 Ti, torch 2.14.1+cu130, 2026-11-13; portable fp32, portable, kernels: RTX 5060 Ti, torch 2.14.1+cu130, fastforks f33b2772, 2026-11-13.
Closeness to the original
Beyond the test-set scores: the raw output of ours against the original’s fp32 output on the same input, pixel by pixel. CPU, float32: max |diff| <= 3.6e-06 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 0.0012 and p99 <= 0.0044 (absolute error of the output image).
| Check | Tolerance | Measured |
|---|---|---|
| CPU fp32, max |diff| | ≤ 0.0000036 | not recorded |
| GPU default dtypes, mean |diff| | ≤ 0.0012 | 0.00051 |
| GPU default dtypes, p99 |diff| | ≤ 0.0044 | 0.00191 |
Recorded for dat-x4 on RTX 5060 Ti, torch 2.14.1+cu130, 2026-11-13, with these kernels: cudnn_hacc
Details
DAT (Chen et al., ICCV 2023): image super-resolution with residual groups that alternate spatial window attention (8 x 32 rectangle windows) and channel attention, each with a convolution branch and adaptive interaction, and a spatial-gate feed-forward network. `dat-x4` is the main x4 model, `dat-2-x4` its variant with a 2x feed-forward expansion, `dat-light-x4` the lightweight one (60 channels, one-step upsampler); all trained on DF2K, bicubic x4.
- Input / output
- Input: one RGB image. Output: the restored (upscaled) image,
model.scalex the input size, RGB in [0, 1].What the numbers mean, and which models need the camera focal length
tile=runs large images in overlapping tiles (as ComfyUI). - Input size
- any H x W >= 32, padded to a multiple of 32; tested up to 1024x1024 (10.1 GiB allocated)
- Outputs
image- CUDA kernels
cudnn_haccconvolutions with fp16 accumulation (cuDNN)
- Apple (MPS)
- fp32, fp16
Full reference, generated from the repository
DAT (Chen et al., ICCV 2023): a x4 upscaler for clean (bicubic) images that alternates spatial and channel attention, in three sizes (DAT, DAT-2, DAT-light). Apache-2.0 code and weights.
Commercial use: yes.
| variant | input | backend | time (ms) | peak memory (MiB, allocated / reserved) |
|---|---|---|---|---|
dat-x4 | synthetic (512x512) | original portable kernels portable + torch.compile TensorRT fp16 | 9564 1565 1391 1063 1001 | 2443 / 2528 2552 / 2624 2282 / 2384 2552 / 2606 9010 / 9056 |
dat-2-x4 | synthetic (512x512) | original portable kernels portable + torch.compile TensorRT fp16 | 4880 1312 1221 964 921 | 2436 / 2518 2276 / 2378 2276 / 2378 2546 / 2598 9001 / 9048 |
dat-light-x4 | synthetic (512x512) | original portable kernels portable + torch.compile TensorRT fp16 | 2204 268 264 158 136 | 1606 / 1656 1535 / 1552 1445 / 1472 1385 / 1412 4144 / 4192 |
Details
- Original code: https://github.com/zhengchen1999/DAT at
1645c64fad7c - Code licence: Apache-2.0 (permissive); files:
LICENSE - Weights licence: Apache-2.0
- Licence evidence: https://github.com/zhengchen1999/DAT/blob/1645c64fad7c94d94abd090bd1319eec1f26f7cc/LICENSE ; https://github.com/zhengchen1999/DAT/blob/1645c64fad7c94d94abd090bd1319eec1f26f7cc/README.md (pretrained models: https://drive.google.com/drive/folders/1iBdf_-LVZuz_PAbFtuxSKd_11RL1YKxM)
- Training data: DIV2K (NTIRE 2017 super-resolution, 1000 2K images), Flickr2K (2650 2K Flickr images, EDSR) (options/Train/train_DAT_x4.yml: DF2K (DIV2K + Flickr2K), bicubic-downsampled, fine-tuned from the x2 model.)
dat-2-x4: DIV2K (NTIRE 2017 super-resolution, 1000 2K images), Flickr2K (2650 2K Flickr images, EDSR) (options/Train/train_DAT_2_x4.yml: DF2K (DIV2K + Flickr2K), bicubic-downsampled, fine-tuned from the x2 model.)dat-light-x4: DIV2K (NTIRE 2017 super-resolution, 1000 2K images), Flickr2K (2650 2K Flickr images, EDSR) (options/Train/train_DAT_light_x4.yml: DF2K (DIV2K + Flickr2K), bicubic-downsampled, fine-tuned from the x2 model.)
- Kernel libraries:
cudnn_hacc - Variants:
dat-x4,dat-2-x4,dat-light-x4 - Outputs: image
- Input size: any H x W >= 32, padded to a multiple of 32
- Tested up to (portable, fp16, RTX 5060 Ti 16 GB):
dat-x41024x1024 (10.1 GiB peak allocated, 14.9 reserved);dat-2-x41024x1024 (10.1 GiB peak allocated, 14.1 reserved);dat-light-x41024x1024 (6.3 GiB peak allocated, 7.4 reserved) dat-x4512x512, first call: portable + torch.compile 43 s (cold Inductor cache), TensorRT fp16 191 s (ONNX + engine).dat-2-x4512x512, first call: portable + torch.compile 44 s (cold Inductor cache), TensorRT fp16 206 s (ONNX + engine).dat-light-x4512x512, first call: portable + torch.compile 37 s (cold Inductor cache), TensorRT fp16 75 s (ONNX + engine).dat-x4original 512x512: .half() on 1 modules, fp16 inputs; upstream dat_model.py test, float32, no chopdat-2-x4original 512x512: .half() on 1 modules, fp16 inputs; upstream dat_model.py test, float32, no chopdat-light-x4original 512x512: .half() on 1 modules, fp16 inputs; upstream dat_model.py test, float32, no chopdat-x4load / first call: original 2.2 s / 6.13 s, portable 2.99 s / 2.307 s, kernels 0.71 s / 2.149 sdat-2-x4load / first call: original 2.04 s / 5.516 s, portable 0.71 s / 2.136 s, kernels 0.72 s / 2.006 sdat-light-x4load / first call: original 3.48 s / 2.721 s, portable 0.21 s / 1.304 s, kernels 1.25 s / 1.152 s- Protocol, first call, 3 warm-up, peak reset, median of 3 rounds x median of 5
Measured
DIV2K validation HR images and the official bicubic LR images (x4 or x2, the model's scale), one pass without tiles; PSNR and SSIM (Gaussian 11 x 11, sigma 1.5) on the Y channel (BT.601) of the output rounded to uint8, scale px border cropped, averaged over the images. Real-ESRGAN is trained for real-world degradations, not bicubic, so its PSNR is low: the numbers compare our modes with the original, not with PSNR-oriented upscalers. Original = the original code named under Details, same checkpoint and protocol.
| variant | dataset | original fp32 | portable | portable fp32 | kernels | note |
|---|---|---|---|---|---|---|
dat-x4 | DIV2K validation (every 4th: 25 images), bicubic x4 LR -> HR, PSNR / SSIM (Y) | 31.03 / 0.8498 | 31.03 / 0.8498 | 31.03 / 0.8498 | 31.01 / 0.8498 | |
dat-2-x4 | DIV2K validation (every 4th: 25 images), bicubic x4 LR -> HR, PSNR / SSIM (Y) | 30.99 / 0.8492 | 30.99 / 0.8493 | 30.99 / 0.8492 | 30.97 / 0.8492 | |
dat-light-x4 | DIV2K validation (every 4th: 25 images), bicubic x4 LR -> HR, PSNR / SSIM (Y) | 30.48 / 0.8379 | 30.48 / 0.8379 | 30.48 / 0.8379 | 30.46 / 0.8375 |
Measured on NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks f33b2772, 2026-11-13.
Parity
CPU, float32: max |diff| <= 3.6e-06 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 0.0012 and p99 <= 0.0044 (absolute error of the output image).
| variant | kernels error vs original, mean / p99 | GPU, torch | kernels used |
|---|---|---|---|
dat-x4 | 0.00051 / 0.00191 | RTX 5060 Ti, torch 2.14.1+cu130 | cudnn_hacc@cudnn92400 |
dat-2-x4 | 0.00065 / 0.00241 | RTX 5060 Ti, torch 2.14.1+cu130 | cudnn_hacc@cudnn92400 |
dat-light-x4 | 0.00079 / 0.00288 | RTX 5060 Ti, torch 2.14.1+cu130 | cudnn_hacc@cudnn92400 |
Example output
No example rendered for this checkpoint yet.