Flor commited on
Commit
a2fa01c
·
0 Parent(s):

fastforks 0.1.0

Browse files
Files changed (2) hide show
  1. .gitattributes +35 -0
  2. README.md +119 -0
.gitattributes ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz filter=lfs diff=lfs merge=lfs -text
33
+ *.zip filter=lfs diff=lfs merge=lfs -text
34
+ *.zst filter=lfs diff=lfs merge=lfs -text
35
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: "fastforks"
3
+ pipeline_tag: "image-feature-extraction"
4
+ license: "other"
5
+ license_name: "dinov3-license"
6
+ license_link: "https://huggingface.co/facebook/dinov3-convnext-tiny-pretrain-lvd1689m/blob/10d30274b4d445111e2d5bf75ac93bbd94db274b/LICENSE.md"
7
+ tags:
8
+ - "features"
9
+ - "backbone"
10
+ - "feature-extraction"
11
+ - "cuda"
12
+ - "pytorch"
13
+ - "fastforks"
14
+ ---
15
+ # DINOv3 ConvNeXt (fastforks)
16
+
17
+ DINOv3 ConvNeXt T/S/B/L (Meta, 2025), distilled from the DINOv3 ViT-7B: stride-32 grid features + pooled token (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.
18
+
19
+ This repo is the model card only: it holds no weights. fastforks downloads the authors' weights from the links below and checks them against the SHA-256 in the model card. Code: <https://github.com/kleinicke/fastforks>. Kernels for the `kernels` backend: <https://huggingface.co/fastforks/kernels>. Original code: <https://github.com/huggingface/transformers> at `v5.19.0`.
20
+
21
+ Author weight repos: <https://huggingface.co/facebook/dinov3-convnext-base-pretrain-lvd1689m>, <https://huggingface.co/facebook/dinov3-convnext-large-pretrain-lvd1689m>, <https://huggingface.co/facebook/dinov3-convnext-small-pretrain-lvd1689m>, <https://huggingface.co/facebook/dinov3-convnext-tiny-pretrain-lvd1689m>.
22
+
23
+ Task: features. Tier: experimental. Outputs: `last_hidden_state`, `pooler_output`. Backends: `portable`, `kernels`.
24
+
25
+ Input: one RGB image. Output: dense patch features and a pooled image feature.
26
+
27
+ ## Variants
28
+
29
+ Weights are the authors' files (not hosted here). SHA-256 shortened to 12 hex digits; the full hashes are in [`card.toml`](https://github.com/kleinicke/fastforks/blob/main/src/fastforks/features/models/dinov3_convnext/card.toml).
30
+
31
+ | variant | weights (author link) | SHA-256 | weights licence | commercial use |
32
+ |---|---|---|---|---|
33
+ | `dinov3-convnext-base@1` | [dinov3-convnext-base-pretrain-lvd1689m/model.safetensors](https://huggingface.co/facebook/dinov3-convnext-base-pretrain-lvd1689m/resolve/e619358a5fe272554f17d2fb6cc65a679326bac0/model.safetensors) | `ec90bd798b5f` | LicenseRef-DINOv3-License | yes |
34
+ | `dinov3-convnext-large@1` | [dinov3-convnext-large-pretrain-lvd1689m/model.safetensors](https://huggingface.co/facebook/dinov3-convnext-large-pretrain-lvd1689m/resolve/e959efa74c867491dcfe3ec3e4f97382e39025b3/model.safetensors) | `8bab82eaa133` | LicenseRef-DINOv3-License | yes |
35
+ | `dinov3-convnext-small@1` | [dinov3-convnext-small-pretrain-lvd1689m/model.safetensors](https://huggingface.co/facebook/dinov3-convnext-small-pretrain-lvd1689m/resolve/421020015aa4266363db803b6049a529999afb1e/model.safetensors) | `8182492b7334` | LicenseRef-DINOv3-License | yes |
36
+ | `dinov3-convnext-tiny@1` | [dinov3-convnext-tiny-pretrain-lvd1689m/model.safetensors](https://huggingface.co/facebook/dinov3-convnext-tiny-pretrain-lvd1689m/resolve/10d30274b4d445111e2d5bf75ac93bbd94db274b/model.safetensors) | `bd30a9459d61` | LicenseRef-DINOv3-License | yes |
37
+
38
+ ## Licence
39
+
40
+ Original-code strings, recorded as they are (research-use package; check them before any other use). Code: LicenseRef-DINOv3-License. Files: `LICENSE.md`.
41
+
42
+ Training data: distilled from the DINOv3 ViT-7B teacher on LVD-1689M (1.689B images curated from public Instagram images), self-supervised, per the paper; not released.
43
+
44
+ - Licence note: Code and weights use the DINOv3 License (Meta: attribution and conditions apply); read it before commercial use.
45
+
46
+ Licence evidence: https://huggingface.co/facebook/dinov3-convnext-tiny-pretrain-lvd1689m/blob/10d30274b4d445111e2d5bf75ac93bbd94db274b/LICENSE.md (DINOv3 License; gated: accept on Hugging Face to download)
47
+
48
+ ## Input size
49
+
50
+ any H x W >= 1, resized or padded inside the model
51
+ Tested up to (portable, fp16, RTX 5060 Ti 16 GB): `dinov3-convnext-base` 3000x4000 (2.5 GiB peak allocated, 3.5 reserved); `dinov3-convnext-large` 3000x4000 (3.7 GiB peak allocated, 5.1 reserved); `dinov3-convnext-small` 3000x4000 (1.9 GiB peak allocated, 2.6 reserved); `dinov3-convnext-tiny` 3000x4000 (1.9 GiB peak allocated, 2.6 reserved)
52
+
53
+ ## Speed and memory
54
+
55
+ ### Features, synthetic, 224x224
56
+
57
+ | model | time (ms): original fp32 | original | portable | kernels | kernels speed-up: vs original | vs portable | peak memory (MiB, allocated / reserved): original | portable | kernels |
58
+ | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
59
+ | `dinov3-convnext-base` | 7.38 | 8.24 | 5.71 | 2.18 | 3.4x | 2.6x | 535 / 552 | 208 / 232 | 200 / 214 |
60
+ | `dinov3-convnext-large` | 10.5 | 9.59 | 5.45 | 3.59 | 2.7x | 1.5x | 1163 / 1252 | 419 / 430 | 441 / 494 |
61
+ | `dinov3-convnext-small` | 5.97 | 8.09 | 5.42 | 1.99 | 3.0x | 2.7x | 328 / 348 | 134 / 150 | 127 / 152 |
62
+ | `dinov3-convnext-tiny` | 2.96 | 4.47 | 3.04 | 1.18 | 2.5x | 2.6x | 198 / 206 | 93 / 108 | 86 / 112 |
63
+
64
+ ### Startup and first call
65
+
66
+ | model | load (s): original | portable | kernels | first call (s): original | portable | kernels |
67
+ | --- | --- | --- | --- | --- | --- | --- |
68
+ | `dinov3-convnext-base` | 0.42 | 0.43 | 0.19 | 0.01 | 0.27 | 0.10 |
69
+ | `dinov3-convnext-large` | 1.64 | 0.85 | 0.38 | 0.02 | 0.24 | 0.20 |
70
+ | `dinov3-convnext-small` | 0.27 | 0.25 | 0.11 | 0.01 | 0.33 | 0.07 |
71
+ | `dinov3-convnext-tiny` | 0.43 | 0.48 | 0.08 | 1.03 | 0.42 | 0.12 |
72
+
73
+ ### torch.compile and TensorRT
74
+
75
+ | model | input | portable ms | compile ms | compile s (cold) | TensorRT fp16 ms | ONNX + build s | kernels ms | peak MiB (alloc / reserved): portable | compile | TensorRT (device) |
76
+ | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
77
+ | `dinov3-convnext-tiny` | 224x224 | 3.04 | 2.0 | 7.8 | 0.7 | 23 | 1.18 | 93 / 108 | 123 / 148 | 72 |
78
+
79
+ ### Fixed-size speed and peak memory, all models
80
+
81
+ | model | mode | 480x640 | 720x1280 | 1080x1920 | 12 MP 3000x4000 |
82
+ | --- | --- | --- | --- | --- | --- |
83
+ | `dinov3-convnext-base` | portable | 8.3 ms / 253 / 290 | 22.8 ms / 357 / 410 | 55.2 ms / 565 / 650 | 323.2 ms / 2310 / 2670 |
84
+ | `dinov3-convnext-base` | kernels | 6.5 ms / 279 / 360 | 15.1 ms / 372 / 572 | 33.5 ms / 502 / 548 | 190.9 ms / 1914 / 2048 |
85
+ | `dinov3-convnext-large` | portable | 14.8 ms / 484 / 510 | 42.5 ms / 633 / 766 | 99.9 ms / 932 / 1048 | 587.2 ms / 3435 / 4008 |
86
+ | `dinov3-convnext-large` | kernels | 11.0 ms / 505 / 642 | 26.7 ms / 635 / 950 | 61.0 ms / 837 / 926 | 357.8 ms / 2887 / 2946 |
87
+ | `dinov3-convnext-small` | portable | 5.9 ms / 169 / 188 | 15.6 ms / 250 / 266 | 37.9 ms / 413 / 486 | 220.9 ms / 1778 / 2106 |
88
+ | `dinov3-convnext-small` | kernels | 4.5 ms / 197 / 276 | 10.6 ms / 272 / 410 | 23.3 ms / 366 / 406 | 133.7 ms / 1474 / 1526 |
89
+ | `dinov3-convnext-tiny` | portable | 3.6 ms / 127 / 148 | 9.8 ms / 209 / 226 | 23.9 ms / 372 / 446 | 136.6 ms / 1737 / 2066 |
90
+ | `dinov3-convnext-tiny` | kernels | 2.7 ms / 156 / 236 | 6.5 ms / 231 / 368 | 14.6 ms / 324 / 366 | 82.1 ms / 1433 / 1484 |
91
+
92
+ Fixed-size cells: time (ms) / peak allocated / peak reserved memory (MiB).
93
+
94
+ Hardware, protocol and caveats: [benchmarks](https://github.com/kleinicke/fastforks/blob/main/docs/benchmarks.md) (RTX 5060 Ti 16 GB, sm_120). Original = the authors' code at the precision of portable (fp16, or `(fp32)` where fp16 is unsupported or not finite); original fp32 = its default fp32 run. Peak memory is the torch allocator's.
95
+
96
+ ## Accuracy
97
+
98
+ ### Parity with the original code
99
+
100
+ Every variant is checked against reference outputs of the original code at its pinned commit. CPU, float32: max |diff| <= 0.0001 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 1 % and p99 <= 4 % of the reference's median |value| (absolute error of the output `last_hidden_state`).
101
+
102
+ ## Usage
103
+
104
+ ```python
105
+ from fastforks import features
106
+
107
+ model = features.load("dinov3-convnext-base") # mode="auto": the preferred backend from recorded measurements
108
+ result = model("photo.jpg", size=518)
109
+ result.last_hidden_state # tokens [N, C], as Hugging Face's output
110
+ result.backend # what ran, e.g. Backend(mode='portable', device='cuda:0', dtype='float16')
111
+ ```
112
+
113
+ Install with `pip install fastforks` (see <https://github.com/kleinicke/fastforks>). Other variants: `dinov3-convnext-base`, `dinov3-convnext-large`, `dinov3-convnext-small`, `dinov3-convnext-tiny`.
114
+
115
+ ## Kernels backend
116
+
117
+ `features.load("dinov3-convnext-base", mode="kernels")` runs our CUDA kernels (`fvm_conv`, `fvm_seg`). It needs a prebuilt kernel for your GPU architecture (downloaded from <https://huggingface.co/fastforks/kernels> on first use) and a recent NVIDIA driver; if there is none it raises `BackendUnavailableError` with the reason and never falls back silently. `mode="auto"` picks `kernels` when it can run and logs the choice.
118
+
119
+ <!-- staged from fastforks feccac41 (2026-11-06) -->