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.
Paper 2025 Added in 0.1.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 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)
| Backend | dtype | Time per call (ms) | vs original fp16 | Peak memory allocated / reserved | Load (s) | First call (s) |
|---|---|---|---|---|---|---|
| Original fp32 | fp32 | 6.47 | 1.00× | 119 MiB/132 MiB | 0.1 | 0.22 |
| Original fp16Transformers FP16 weights, FP16 inputs; original adapter casting hooks; full kNN accuracy checked | fp16 | 6.45 | – | 76 MiB/118 MiB | 0.1 | 0.01 |
| Portable fp32 | fp32 | not measured | – | – | – | – |
| Portable | fp16 | 3.40 | 1.9× | 76 MiB/104 MiB | 0.2 | 0.23 |
| Kernels | fp16 | 0.793 | 8.1× | 44 MiB/68 MiB | 0.2 | 0.14 |
| Portable + torch.compile | 2.18 | 3.0× | 109 MiB/138 MiB | 9 (build) | – | |
| TensorRT fp16 | fp16 | 0.564 | 11× | 64 MiBenginenot comparable | 25 (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
| Device | Backend | dtype | ms / call | Peak memory | Output vs reference | Input |
|---|---|---|---|---|---|---|
| Apple M1 Pro 16 GB MPS, torch 2.14.1, 2026-11-12 | Original | fp32 | 13.4 | 446 MiB process | matches | 224x224 |
| Portable | fp16 | 11.5 | 354 MiB process | matches | 224x224 | |
| Portable | fp32 | 11.9 | 389 MiB process | matches | 224x224 | |
| Kernels | fp16 | not implemented | – | 224x224 | ||
| NVIDIA L4 CUDA, torch 2.14.1+cu130, 2026-11-07 | Portable | fp16 | 7.95 | 52 MiB/58 MiB | – | 224x224 |
| Kernels | fp16 | 1.02 | 53 MiB/84 MiB | – | 224x224 | |
| NVIDIA L40S CUDA, torch 2.14.1+cu130, 2026-11-07 | Portable | fp16 | 5.69 | 52 MiB/58 MiB | – | 224x224 |
| Kernels | fp16 | 0.727 | 53 MiB/84 MiB | – | 224x224 | |
| NVIDIA A10 CUDA, torch 2.14.1+cu130, 2026-11-07 | Portable | fp16 | 4.71 | 52 MiB/58 MiB | – | 224x224 |
| Kernels | fp16 | 1.02 | 53 MiB/84 MiB | – | 224x224 | |
| NVIDIA A100-SXM4-40GB CUDA, torch 2.14.1+cu130, 2026-11-07 | Portable | fp16 | 5.80 | 53 MiB/58 MiB | – | 224x224 |
| Kernels | fp16 | 1.47 | 53 MiB/104 MiB | – | 224x224 | |
| NVIDIA RTX PRO 6000 CUDA, torch 2.14.1+cu130, 2026-11-08 | Portable | fp16 | 1.87 | 76 MiB/78 MiB | – | 224x224 |
| Kernels | fp16 | 0.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 Facefastforks 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)
| Run | dtype | top-1 % ↑ | Δ top-1 % vs fp32 original | images | ms / image |
|---|---|---|---|---|---|
| Original fp32 | fp32 | 55.38 | reference | 5000 | 1.33 |
| Original fp16 | fp16 | 55.42 | +0.04 | 5000 | 0.605 |
| Portable fp32 | fp32 | 55.36 | −0.02 | 5000 | 1.36 |
| Portable | fp16 | 55.42 | +0.04 | 5000 | 0.491 |
| Kernels | fp16 | 55.36 | −0.02 | 5000 | 0.279 |
| Original .half() | fp16 | 55.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).
| Check | Tolerance | Measured |
|---|---|---|
| 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 backbonesdpt_fusedfused fp16 matrix multiplies and convolutions for DINOv2 backbones and DPT depth headsswiglu
- 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.
| variant | input | backend | time (ms) | peak memory (MiB, allocated / reserved) |
|---|---|---|---|---|
dinov3-vits16 | synthetic (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-vitb16 | synthetic (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-vitl16 | synthetic (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-vith16plus | synthetic (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-vits163000x4000 (1.0 GiB peak allocated, 1.2 reserved);dinov3-vitb163000x4000 (1.6 GiB peak allocated, 2.0 reserved);dinov3-vitl163000x4000 (2.4 GiB peak allocated, 2.9 reserved);dinov3-vith16plus3000x4000 (4.2 GiB peak allocated, 4.9 reserved) dinov3-vits16224x224, first call: portable + torch.compile 9 s (cold Inductor cache), TensorRT fp16 25 s (ONNX + engine).dinov3-vitb16224x224, first call: portable + torch.compile 10 s (cold Inductor cache), TensorRT fp16 25 s (ONNX + engine).dinov3-vitl16224x224, first call: portable + torch.compile 17 s (cold Inductor cache), TensorRT fp16 34 s (ONNX + engine).dinov3-vith16plus224x224, first call: portable + torch.compile 21 s (cold Inductor cache), TensorRT fp16 99 s (ONNX + engine).dinov3-vits16original 224x224: Transformers FP16 weights, FP16 inputs; original adapter casting hooks; full kNN accuracy checkeddinov3-vitb16original 224x224: Transformers FP16 weights, FP16 inputs; original adapter casting hooks; full kNN accuracy checkeddinov3-vitl16original 224x224: Transformers BF16 weights and inputs (not IEEE FP16); full kNN accuracy checked; timing uses direct load without adapter hooksdinov3-vith16plusoriginal 224x224: Transformers BF16 weights and inputs (not IEEE FP16); full kNN accuracy checked; timing uses direct load without adapter hooksdinov3-vits16load / first call: original 0.48 s / 0.947 s, portable 0.07 s / 0.271 s, kernels 0.06 s / 0.259 sdinov3-vitb16load / first call: original 0.68 s / 0.012 s, portable 0.38 s / 0.198 s, kernels 0.16 s / 0.291 sdinov3-vitl16load / first call: original 2.37 s / 0.023 s, portable 0.54 s / 0.18 s, kernels 0.52 s / 0.246 sdinov3-vith16plusload / 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.
| variant | dataset | original fp32 | original fp16 | original half | portable | portable fp32 | kernels | note |
|---|---|---|---|---|---|---|---|---|
dinov3-vits16 | ImageNet-1k val, kNN top-1 % (k = 20, 10000 labelled / 5000 test images) | 55.38 | 55.42 | 55.42 | 55.42 | 55.36 | 55.36 | |
dinov3-vitb16 | ImageNet-1k val, kNN top-1 % (k = 20, 10000 labelled / 5000 test images) | 66.54 | 66.54 | 66.50 | 66.52 | 66.54 | 66.54 | |
dinov3-vitl16 | ImageNet-1k val, kNN top-1 % (k = 20, 10000 labelled / 5000 test images) | 75.94 | 75.92 | 75.78 | 75.80 | 75.94 | 75.88 | |
dinov3-vith16plus | ImageNet-1k val, kNN top-1 % (k = 20, 10000 labelled / 5000 test images) | 79.50 | 79.50 | 79.54 | 79.52 | 79.50 | 79.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).
| variant | kernels error vs original, mean / p99 | GPU, torch | kernels used |
|---|---|---|---|
dinov3-vits16 | 0.00573 / 0.01974 | RTX 5060 Ti, torch 2.10.0+cu130 | dpt_fused@48e0065bb7cf:sm_120, fastbb@7d058322634d:sm_120, swiglu@25fe34a2d389:sm_120 |
dinov3-vitb16 | 0.00548 / 0.01964 | RTX 5060 Ti, torch 2.10.0+cu130 | dpt_fused@48e0065bb7cf:sm_120, fastbb@7d058322634d:sm_120, swiglu@25fe34a2d389:sm_120 |
dinov3-vitl16 | 0.00794 / 0.03182 | RTX 5060 Ti, torch 2.10.0+cu130 | dpt_fused@48e0065bb7cf:sm_120, fastbb@7d058322634d:sm_120, swiglu@25fe34a2d389:sm_120 |
dinov3-vith16plus | 0.00635 / 0.03203 | RTX 5060 Ti, torch 2.10.0+cu130 | dpt_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: Chelsea the cat, Stéfan van der Walt (CC0).