Models · Feature backbones

DINOv3 ViT

Meta's DINOv3 vision transformers: self-supervised image features with register tokens and RoPE. Needs the gated DINOv3 licence.

stable Fork of huggingface/[email protected] · backends: portable, kernels

  • Paper DINOv3 arXiv · first released 13 Aug 2025
  • Authors’ code facebookresearch/dinov3 (PyTorch), not the code forked here: The checkpoints are used in Hugging Face transformers format, so the transformers implementation is vendored.
Checkpoint

Paper 2025 Added in 0.1.0 Evaluated with 0.2.0

Kernels, RTX 5060 Ti 16 GB 0.793 ms 224x224, fp16
vs the faster original 8.1× original fp16: 6.45 ms
Peak memory 44 MiB original: 76 MiB
Accuracy vs original fp32 −0.02 kernels top-1 %, ImageNet-1k val (55.38 original)

Use it

pip install fastforks

Lean install with only what this model needs: pip install fastforks-core

from fastforks import features

model = features.load("dinov3-vits16")  # kernels on a supported GPU, else portable PyTorch
result = model(image)
result.last_hidden_state  # also: pooler_output, hidden_states
result.backend  # what ran: mode, device, dtype, kernels
fastforks bench dinov3-vits16

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 fp16Peak memory
allocated / reserved
Load (s)First call (s)
Original fp32fp32 6.471.00×119 MiB/132 MiB0.10.22
Original fp16Transformers FP16 weights, FP16 inputs; original adapter casting hooks; full kNN accuracy checkedfp16 6.45–76 MiB/118 MiB0.10.01
Portable fp32fp32not measured ––––
Portablefp16 3.401.9×76 MiB/104 MiB0.20.23
Kernelsfp16 0.7938.1×44 MiB/68 MiB0.20.14
Portable + torch.compile 2.183.0×109 MiB/138 MiB9 (build)–
TensorRT fp16fp16 0.56411×64 MiBenginenot comparable25 (build)–

Measured on RTX 5060 Ti 16 GB, torch 2.14.1+cu130, 2026-11-03 to 2026-11-17. 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-12Originalfp3213.4 446 MiB processmatches224x224
Portablefp1611.5 354 MiB processmatches224x224
Portablefp3211.9 389 MiB processmatches224x224
Kernelsfp16not implemented–224x224
NVIDIA L4 CUDA, torch 2.14.1+cu130, 2026-11-07Portablefp167.95 52 MiB/58 MiB–224x224
Kernelsfp161.02 53 MiB/84 MiB–224x224
NVIDIA L40S CUDA, torch 2.14.1+cu130, 2026-11-07Portablefp165.69 52 MiB/58 MiB–224x224
Kernelsfp160.727 53 MiB/84 MiB–224x224
NVIDIA A10 CUDA, torch 2.14.1+cu130, 2026-11-07Portablefp164.71 52 MiB/58 MiB–224x224
Kernelsfp161.02 53 MiB/84 MiB–224x224
NVIDIA A100-SXM4-40GB CUDA, torch 2.14.1+cu130, 2026-11-07Portablefp165.80 53 MiB/58 MiB–224x224
Kernelsfp161.47 53 MiB/104 MiB–224x224
NVIDIA RTX PRO 6000 CUDA, torch 2.14.1+cu130, 2026-11-08Portablefp161.87 76 MiB/78 MiB–224x224
Kernelsfp160.654 77 MiB/104 MiB–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
LicenseRef-DINOv3-License LICENSE.md
Weights
LicenseRef-DINOv3-License source
Training data
LVD-1689M: 1.689B images curated from 17B public Instagram images by retrieval / clustering, self-supervised (no labels), per the paper; not released
  • Code and weights use the DINOv3 License (Meta: attribution and conditions apply); read it before commercial use.

Our reading of the licences, not legal advice.

Weights

dinov3-vits16-pretrain-lvd1689m/model.safetensors 86.4 MB· hosted on Hugging Face

fastforks downloads and checks these files on first use (fastforks download dinov3-vits16).

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

kNN top-1 % (k = 20, 10000 labelled / 5000 test images)

Rundtypetop-1 % ↑Δ top-1 % vs fp32 originalimagesms / image
Original fp32fp3255.38 reference 5000 1.33
Original fp16fp1655.42 +0.04 5000 0.605
Portable fp32fp3255.36 −0.02 5000 1.36
Portablefp1655.42 +0.04 5000 0.491
Kernelsfp1655.36 −0.02 5000 0.279
Original .half()fp1655.42 +0.04 5000 0.478

Two disjoint seeded subsets of the val folders; each image shorter side 256 (bicubic), centre crop 224, the CLS / pooled feature; cosine kNN, vote weighted by similarity. Original = the authors’ code, same checkpoint and protocol. Measured on original fp32, original fp16: RTX 5060 Ti, torch 2.14.1+cu130, 2026-11-06; portable fp32: RTX 5060 Ti, torch 2.14.1+cu130, fastforks 7c91993, 2026-10-31; portable, kernels: RTX 5060 Ti, torch 2.14.1+cu130, fastforks 939adfe8, 2026-11-06; original .half(): RTX 5060 Ti, torch 2.14.1+cu130, 2026-11-17.

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| <= 0.0001 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 1.5 % and p99 <= 6 % of the reference's median |value| (absolute error of the output last_hidden_state).

CheckToleranceMeasured
CPU fp32, max |diff|≤ 0.0001 (relative)not recorded
cpu_rtol≤ 0.000001 (relative)not recorded
GPU default dtypes, mean |diff|≤ 0.015 (relative)0.00573 (relative)
GPU default dtypes, p99 |diff|≤ 0.06 (relative)0.01974 (relative)

Recorded for dinov3-vits16 on RTX 5060 Ti, torch 2.10.0+cu130, 2026-11-17, with these kernels: dpt_fusedfastbbswiglu

Details

DINOv3 ViT (Meta, 2025): self-supervised ViT backbones with 4 register tokens and RoPE; dense patch + cls features at any size (Hugging Face format checkpoints). Gated weights: accept the DINOv3 licence on each model's Hugging Face page, download model.safetensors yourself and put it under FASTFORKS_WEIGHTS_PATH (path and SHA-256 in the load error); fastforks does not send HF_TOKEN there.

Input / output
Input: one RGB image. Output: dense patch features and a pooled image feature.
Input size
any H x W >= 1, resized or padded inside the model; tested up to 3000x4000 (1,006 MiB allocated)
Options
  • fp16_accumulate=false
Outputs
last_hidden_state, pooler_output, hidden_states
Checkpoint
arch="vits16"
CUDA kernels
  • fastbbfast backbone kernels: flash attention, window attention, instance norm and rotary embeddings for ViT and similar backbones
  • dpt_fusedfused fp16 matrix multiplies and convolutions for DINOv2 backbones and DPT depth heads
  • swiglu
Apple (MPS)
fp32, fp16

Limitations

  • kernels replays a CUDA graph per small input shape and layer set (up to 512 px, ViT-S 1024 px), captured on the shape's second call; at most 8 per model holding at most 256 MB of outputs (a full cache replaces only graphs unused for 64 calls, other new shapes run eagerly).
  • The graphs' shared memory pool (intermediates) comes on top of that limit and stays reserved: up to about 470 MB more PyTorch cache than eager for ViT-H+ at 512 px with all layers, usually under 75 MB; `model.release_graphs()` frees it on the device.
Full reference, generated from the repository

Meta's DINOv3 vision transformers: self-supervised image features with register tokens and RoPE. Needs the gated DINOv3 licence.

Commercial use: yes.

variantinputbackendtime (ms)peak memory (MiB, allocated / reserved)
dinov3-vits16synthetic (224x224)original (fp32)
original
portable
kernels
portable + torch.compile
TensorRT fp16
6.47
6.45
3.40
0.793
2.18
0.564
119 / 132
76 / 118
76 / 104
44 / 68
109 / 138
107 / 120
dinov3-vitb16synthetic (224x224)original (fp32)
original
portable
kernels
portable + torch.compile
TensorRT fp16
6.95
6.72
3.59
1.26
2.35
1.14
367 / 390
200 / 206
200 / 226
168 / 210
236 / 306
393 / 480
dinov3-vitl16synthetic (224x224)original (fp32)
original
portable
kernels
portable + torch.compile
TensorRT fp16
19.2
11.2
6.52
3.04
4.91
2.98
1199 / 1212
617 / 640
616 / 646
616 / 650
655 / 846
1226 / 1418
dinov3-vith16plussynthetic (224x224)original (fp32)
original
portable
kernels
portable + torch.compile
TensorRT fp16
48.0
16.0
12.5
8.45
11.6
7.86
3255 / 3276
1645 / 1816
1646 / 1666
1645 / 1672
1699 / 2008
3280 / 3628
Details
  • Original code: https://github.com/huggingface/transformers at v5.19.0
  • Code licence: LicenseRef-DINOv3-License (permissive); files: LICENSE.md
  • Weights licence: LicenseRef-DINOv3-License
  • Licence evidence: https://huggingface.co/facebook/dinov3-vits16-pretrain-lvd1689m/blob/114c1379950215c8b35dfcd4e90a5c251dde0d32/LICENSE.md (DINOv3 License, the same file in every model repo; gated: accept on Hugging Face to download)
  • Training data: LVD-1689M: 1.689B images curated from 17B public Instagram images by retrieval / clustering, self-supervised (no labels), per the paper; not released
  • Licence note: Code and weights use the DINOv3 License (Meta: attribution and conditions apply); read it before commercial use.
  • Options: fp16_accumulate = False (precision only)
  • Kernel libraries: fastbb, dpt_fused, swiglu
  • Variants: dinov3-vits16, dinov3-vitb16, dinov3-vitl16, dinov3-vith16plus
  • Outputs: last_hidden_state, pooler_output, hidden_states
  • Input size: any H x W >= 1, resized or padded inside the model
  • Tested up to (portable, fp16, RTX 5060 Ti 16 GB): dinov3-vits16 3000x4000 (1.0 GiB peak allocated, 1.2 reserved); dinov3-vitb16 3000x4000 (1.6 GiB peak allocated, 2.0 reserved); dinov3-vitl16 3000x4000 (2.4 GiB peak allocated, 2.9 reserved); dinov3-vith16plus 3000x4000 (4.2 GiB peak allocated, 4.9 reserved)
  • dinov3-vits16 224x224, first call: portable + torch.compile 9 s (cold Inductor cache), TensorRT fp16 25 s (ONNX + engine).
  • dinov3-vitb16 224x224, first call: portable + torch.compile 10 s (cold Inductor cache), TensorRT fp16 25 s (ONNX + engine).
  • dinov3-vitl16 224x224, first call: portable + torch.compile 17 s (cold Inductor cache), TensorRT fp16 34 s (ONNX + engine).
  • dinov3-vith16plus 224x224, first call: portable + torch.compile 21 s (cold Inductor cache), TensorRT fp16 99 s (ONNX + engine).
  • dinov3-vits16 original 224x224: Transformers FP16 weights, FP16 inputs; original adapter casting hooks; full kNN accuracy checked
  • dinov3-vitb16 original 224x224: Transformers FP16 weights, FP16 inputs; original adapter casting hooks; full kNN accuracy checked
  • dinov3-vitl16 original 224x224: Transformers BF16 weights and inputs (not IEEE FP16); full kNN accuracy checked; timing uses direct load without adapter hooks
  • dinov3-vith16plus original 224x224: Transformers BF16 weights and inputs (not IEEE FP16); full kNN accuracy checked; timing uses direct load without adapter hooks
  • dinov3-vits16 load / first call: original 0.48 s / 0.947 s, portable 0.07 s / 0.271 s, kernels 0.06 s / 0.259 s
  • dinov3-vitb16 load / first call: original 0.68 s / 0.012 s, portable 0.38 s / 0.198 s, kernels 0.16 s / 0.291 s
  • dinov3-vitl16 load / first call: original 2.37 s / 0.023 s, portable 0.54 s / 0.18 s, kernels 0.52 s / 0.246 s
  • dinov3-vith16plus load / first call: original 5.95 s / 0.046 s, portable 2.02 s / 0.099 s, kernels 1.4 s / 0.202 s
  • Protocol, first call, 3 warm-up, peak reset, median of 3 rounds x median of 5

Measured

Two disjoint seeded subsets of the val folders; each image shorter side 256 (bicubic), centre crop 224, the CLS / pooled feature; cosine kNN, vote weighted by similarity. Original = the original code named under Details, same checkpoint and protocol.

variantdatasetoriginal fp32original fp16original halfportableportable fp32kernelsnote
dinov3-vits16ImageNet-1k val, kNN top-1 % (k = 20, 10000 labelled / 5000 test images)55.3855.4255.4255.4255.3655.36
dinov3-vitb16ImageNet-1k val, kNN top-1 % (k = 20, 10000 labelled / 5000 test images)66.5466.5466.5066.5266.5466.54
dinov3-vitl16ImageNet-1k val, kNN top-1 % (k = 20, 10000 labelled / 5000 test images)75.9475.9275.7875.8075.9475.88
dinov3-vith16plusImageNet-1k val, kNN top-1 % (k = 20, 10000 labelled / 5000 test images)79.5079.5079.5479.5279.5079.52

Measured on portable: NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks 939adfe8, 2026-11-06; portable32: NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks 7c91993, 2026-10-31; kernels: NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks 939adfe8, 2026-11-06.

Parity

CPU, float32: max |diff| <= 0.0001 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 1.5 % and p99 <= 6 % of the reference's median |value| (absolute error of the output last_hidden_state).

variantkernels error vs original, mean / p99GPU, torchkernels used
dinov3-vits160.00573 / 0.01974RTX 5060 Ti, torch 2.10.0+cu130dpt_fused@48e0065bb7cf:sm_120, fastbb@7d058322634d:sm_120, swiglu@25fe34a2d389:sm_120
dinov3-vitb160.00548 / 0.01964RTX 5060 Ti, torch 2.10.0+cu130dpt_fused@48e0065bb7cf:sm_120, fastbb@7d058322634d:sm_120, swiglu@25fe34a2d389:sm_120
dinov3-vitl160.00794 / 0.03182RTX 5060 Ti, torch 2.10.0+cu130dpt_fused@48e0065bb7cf:sm_120, fastbb@7d058322634d:sm_120, swiglu@25fe34a2d389:sm_120
dinov3-vith16plus0.00635 / 0.03203RTX 5060 Ti, torch 2.10.0+cu130dpt_fused@48e0065bb7cf:sm_120, fastbb@7d058322634d:sm_120, swiglu@25fe34a2d389:sm_120

Limitations

  • kernels replays a CUDA graph per small input shape and layer set (up to 512 px, ViT-S 1024 px), captured on the shape's second call; at most 8 per model holding at most 256 MB of outputs (a full cache replaces only graphs unused for 64 calls, other new shapes run eagerly).
  • The graphs' shared memory pool (intermediates) comes on top of that limit and stays reserved: up to about 470 MB more PyTorch cache than eager for ViT-H+ at 512 px with all layers, usually under 75 MB; model.release_graphs() frees it on the device.

Example output

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

Input
Output
Chelsea the cat, input
Input · 100%

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