Models · Classification

DaViT

DaViT (Ding et al. 2022; tiny, small and base, ImageNet-1k): a vision transformer with spatial and channel attention. Apache-2.0.

experimental Fork of huggingface/pytorch-image-models@0df212b · backends: portable, kernels

Checkpoint

Paper 2022 Added in 0.2.0 Evaluated with 0.2.0

Portable, RTX 5060 Ti 16 GB 6.33 ms 224x224, fp16
vs the faster original 1.1× original fp32: 6.93 ms
Peak memory 96 MiB original: 158 MiB
Accuracy vs original fp32 ±0.00 portable top-1 %, ImageNet-1k val (83.94 original)

Use it

pip install fastforks

Lean install with only what this model needs: pip install "fastforks-core[timm]"

from fastforks import classification

model = classification.load("davit_tiny.msft_in1k")  # kernels on a supported GPU, else portable PyTorch
result = model(image)
result.logits
result.backend  # what ran: mode, device, dtype, kernels
fastforks bench davit_tiny.msft_in1k

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, 224x224 (the task’s standard size)

BackenddtypeTime per call (ms)vs original fp32Peak memory
allocated / reserved
Load (s)First call (s)
Original fp32fp32 6.93–158 MiB/174 MiB1.60.44
Original fp16torch.autocast(float16) around the callfp16 9.880.70×196 MiB/204 MiB0.40.85
Portable fp32fp32not measured ––––
Portablefp16 6.331.1×96 MiB/116 MiB1.50.25
Kernelsnot measured ––––
Portable + torch.compile 3.102.2×125 MiB/136 MiB15 (build)–
TensorRT fp16fp16 1.036.7×72 MiBenginenot comparable54 (build)–

Measured on RTX 5060 Ti 16 GB, torch 2.14.1+cu130, 2026-11-11. 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

DeviceBackenddtypems / callPeak memoryOutput vs referenceInput
Apple M1 Pro 16 GB MPS, torch 2.14.1, 2026-11-14Originalfp3215.0 738 MiB process–224x224
Portablefp1614.2 741 MiB processmatches224x224
Portablefp3214.7 701 MiB processmatches224x224
Kernelsfp32not implemented–224x224

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
Weights
Apache-2.0 source
Training data

Our reading of the licences, not legal advice.

Weights

davit_tiny.msft_in1k.safetensors 113 MB· hosted on Hugging Face

fastforks downloads and checks these files on first use (fastforks download davit_tiny.msft_in1k).

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.

ImageNet-1k val

5000 random images, top-1 / top-5 %

Rundtypetop-1 % ↑top-5 % ↑Δ top-1 % vs fp32 originalimagesms / image
Original fp32fp3283.9496.50 reference 5000 1.73
Original fp16fp1683.9296.50 −0.02 5000 0.982
Portable fp32fp3283.9296.60 −0.02 5000 2.13
Portablefp1683.9496.56 ±0.00 5000 0.840
Kernelsnot measured

fastforks: the model's own resize / crop on the GPU; original: the library's pretrained loader and its PIL eval transform. Original = the authors’ code, same checkpoint and protocol. Measured on original fp32, original fp16: RTX 5060 Ti, torch 2.14.1+cu130, 2026-11-11; portable fp32: RTX 5060 Ti, torch 2.14.1+cu130, fastforks 6f0a70e1, 2026-11-17; portable: RTX 5060 Ti, torch 2.14.1+cu130, fastforks 7ba7307f, 2026-11-11.

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.3e-06 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 0.0026 and p99 <= 0.011 (absolute error of the output logits).

CheckToleranceMeasured
CPU fp32, max |diff|≤ 0.0000033 not recorded
GPU default dtypes, mean |diff|≤ 0.0026 0.00196
GPU default dtypes, p99 |diff|≤ 0.011 0.00753

Recorded for davit_tiny.msft_in1k on RTX 5060 Ti, torch 2.10.0+cu130, 2026-11-17, with these kernels: cudnn_haccfvm_convfvm_extrafvm_mbfvm_r3

Details

DaViT (Ding et al. 2022): a hierarchical vision transformer that alternates window (spatial) attention and channel-group attention.

Input / output
Input: one RGB image. Output: ImageNet-1k class logits.
Input size
fixed 224x224: the input is resized (short side 235) and centre-cropped to it; tested up to 224x224 (96 MiB allocated)
Outputs
logits
Checkpoint
arch="davit_tiny.msft_in1k"
CUDA kernels
  • cudnn_haccconvolutions with fp16 accumulation (cuDNN)
  • fvm_convfused convolutions for image classifiers
  • fvm_extrafused transformer row operations (rotary split, SwiGLU with LayerNorm)
  • fvm_mbfused MBConv blocks (MobileNet and EfficientNet families)
  • fvm_r3further fused classifier blocks
Apple (MPS)
fp32, fp16
Full reference, generated from the repository

DaViT (Ding et al. 2022; tiny, small and base, ImageNet-1k): a vision transformer with spatial and channel attention. Apache-2.0.

Commercial use: yes.

variantinputbackendtime (ms)peak memory (MiB, allocated / reserved)
davit_tiny.msft_in1ksynthetic (224x224)original (fp32)
original
portable
kernels
portable + torch.compile
TensorRT fp16
6.93
9.88
6.33
–
3.10
1.03
158 / 174
196 / 204
96 / 116
–
125 / 136
159 / 166
davit_small.msft_in1ksynthetic (224x224)original (fp32)
original
portable
kernels
portable + torch.compile
TensorRT fp16
13.0
18.8
12.8
–
5.54
1.92
239 / 262
319 / 324
136 / 150
–
166 / 190
234 / 254
davit_base.msft_in1ksynthetic (224x224)original (fp32)
original
portable
kernels
portable + torch.compile
TensorRT fp16
13.4
20.0
11.7
–
5.48
2.28
390 / 416
537 / 548
212 / 224
–
242 / 262
403 / 422
Details
  • Original code: https://github.com/huggingface/pytorch-image-models at 0df212b369a5
  • Code licence: Apache-2.0 (permissive); files:
  • Weights licence: Apache-2.0
  • Licence evidence: https://huggingface.co/timm/davit_tiny.msft_in1k/blob/982f32c73d98f9966df4a7178b32b820bed3c1b1/README.md
  • Training data: ImageNet-1k (ILSVRC 2012 classification)
  • Kernel libraries: cudnn_hacc, fvm_conv, fvm_extra, fvm_mb, fvm_r3
  • Variants: davit_tiny.msft_in1k (default of davit_tiny), davit_small.msft_in1k (default of davit_small), davit_base.msft_in1k (default of davit_base)
  • Outputs: logits; label_set: imagenet-1k
  • Input size: fixed 224x224: the input is resized (short side 235) and centre-cropped to it
  • Tested up to (portable, fp16, RTX 5060 Ti 16 GB): davit_tiny.msft_in1k 224x224 (0.1 GiB peak allocated, 0.1 reserved); davit_small.msft_in1k 224x224 (0.1 GiB peak allocated, 0.1 reserved); davit_base.msft_in1k 224x224 (0.2 GiB peak allocated, 0.2 reserved)
  • davit_tiny.msft_in1k 224x224, first call: portable + torch.compile 15 s (cold Inductor cache), TensorRT fp16 54 s (ONNX + engine).
  • davit_small.msft_in1k 224x224, first call: portable + torch.compile 22 s (cold Inductor cache), TensorRT fp16 66 s (ONNX + engine).
  • davit_base.msft_in1k 224x224, first call: portable + torch.compile 22 s (cold Inductor cache), TensorRT fp16 71 s (ONNX + engine).
  • davit_tiny.msft_in1k original 224x224: torch.autocast(float16) around the call
  • davit_small.msft_in1k original 224x224: torch.autocast(float16) around the call
  • davit_base.msft_in1k original 224x224: torch.autocast(float16) around the call
  • davit_tiny.msft_in1k load / first call: original 0.39 s / 0.85 s, portable 1.47 s / 0.254 s
  • davit_small.msft_in1k load / first call: original 0.53 s / 0.021 s, portable 1.6 s / 0.235 s
  • davit_base.msft_in1k load / first call: original 0.99 s / 0.565 s, portable 1.84 s / 0.265 s
  • Protocol, first call, 3 warm-up, peak reset, median of 3 rounds x median of 5

Measured

fastforks: the model's own resize / crop on the GPU; original: the library's pretrained loader and its PIL eval transform. Original = the original code named under Details, same checkpoint and protocol.

variantdatasetoriginal fp32original fp16portableportable fp32note
davit_tiny.msft_in1kImageNet-1k val, 5000 random images, top-1 / top-5 %83.94 / 96.5083.92 / 96.5083.94 / 96.5683.92 / 96.60
davit_small.msft_in1kImageNet-1k val, 5000 random images, top-1 / top-5 %85.18 / 97.2085.16 / 97.2085.24 / 97.1885.22 / 97.20
davit_base.msft_in1kImageNet-1k val, 5000 random images, top-1 / top-5 %85.58 / 97.1085.58 / 97.1085.66 / 97.1285.70 / 97.12

Measured on portable: NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks 7ba7307f, 2026-11-11; portable32: NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks 6f0a70e1, 2026-11-17.

Parity

CPU, float32: max |diff| <= 3.3e-06 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 0.0026 and p99 <= 0.011 (absolute error of the output logits).

variantkernels error vs original, mean / p99GPU, torchkernels used
davit_tiny.msft_in1k0.00196 / 0.00753RTX 5060 Ti, torch 2.10.0+cu130cudnn_hacc@cudnn91501, fvm_conv@f1d064e539e1:sm_120, fvm_extra@3208ce525a91:sm_120, fvm_mb@720dd3f29bf7:sm_120, fvm_r3@f54eb890e23c:sm_120
davit_small.msft_in1k0.00171 / 0.00613RTX 5060 Ti, torch 2.10.0+cu130cudnn_hacc@cudnn91501, fvm_conv@f1d064e539e1:sm_120, fvm_extra@3208ce525a91:sm_120, fvm_mb@720dd3f29bf7:sm_120, fvm_r3@f54eb890e23c:sm_120
davit_base.msft_in1k0.00125 / 0.00535RTX 5060 Ti, torch 2.10.0+cu130cudnn_hacc@cudnn91501, fvm_conv@f1d064e539e1:sm_120, fvm_extra@3208ce525a91:sm_120, fvm_mb@720dd3f29bf7:sm_120, fvm_r3@f54eb890e23c:sm_120

Example output

One fixed input through this checkpoint, the same for every model of the task (portable · float16 · NVIDIA GeForce RTX 5060 Ti).

Input

Top 5

  1. Egyptian cat 68%
  2. tiger cat 7.9%
  3. tabby 4.7%
  4. lynx 0.3%
  5. Angora <0.1%
Chelsea the cat, input
Input · 100%

Input: Chelsea the cat, Stéfan van der Walt (CC0).