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

fastforks 0.1.0

Browse files
Files changed (2) hide show
  1. .gitattributes +35 -0
  2. README.md +107 -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,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: "fastforks"
3
+ pipeline_tag: "image-classification"
4
+ license: "other"
5
+ license_name: "bsd-3-clause-code-weights-unstated"
6
+ license_link: "https://github.com/pytorch/vision/blob/1f1a920d685d46dfbe187934b785b7ecb7a182f2/LICENSE"
7
+ tags:
8
+ - "classification"
9
+ - "image-classification"
10
+ - "cuda"
11
+ - "pytorch"
12
+ - "fastforks"
13
+ ---
14
+ # EfficientNet (fastforks)
15
+
16
+ EfficientNet (Tan and Le 2019): compound-scaled MBConv networks with squeeze-excite.
17
+
18
+ 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/pytorch/vision> at `1f1a920d685d`.
19
+
20
+ Task: classification. Tier: stable. Outputs: `logits`. Backends: `portable`, `kernels`.
21
+
22
+ Input: one RGB image. Output: ImageNet-1k class logits.
23
+
24
+ ## Variants
25
+
26
+ 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/classification/models/efficientnet/card.toml).
27
+
28
+ | variant | weights (author link) | SHA-256 | weights licence | commercial use |
29
+ |---|---|---|---|---|
30
+ | `efficientnet_b0.tv_in1k@1` | [efficientnet_b0_rwightman-7f5810bc.pth](https://download.pytorch.org/models/efficientnet_b0_rwightman-7f5810bc.pth) | `7f5810bc96de` | BSD-3-Clause (assumed from code) | yes |
31
+ | `efficientnet_b4.tv_in1k@1` | [efficientnet_b4_rwightman-23ab8bcd.pth](https://download.pytorch.org/models/efficientnet_b4_rwightman-23ab8bcd.pth) | `23ab8bcd5bdb` | BSD-3-Clause (assumed from code) | yes |
32
+
33
+ ## Licence
34
+
35
+ Original-code strings, recorded as they are (research-use package; check them before any other use). Code: BSD-3-Clause. Files: .
36
+
37
+ Code licence: BSD-3-Clause; the authors do not state a separate weights licence.
38
+
39
+ Training data: ImageNet-1k (ILSVRC 2012 classification).
40
+
41
+ Licence evidence: <https://github.com/pytorch/vision/blob/1f1a920d685d46dfbe187934b785b7ecb7a182f2/LICENSE>
42
+
43
+ ## Input size
44
+
45
+ - `efficientnet_b0.tv_in1k`: fixed 224x224: the input is resized (short side 256) and centre-cropped to it
46
+ - `efficientnet_b4.tv_in1k`: fixed 380x380: the input is resized (short side 384) and centre-cropped to it
47
+ Tested up to (portable, fp16, RTX 5060 Ti 16 GB): `efficientnet_b0.tv_in1k` 224x224 (0.0 GiB peak allocated, 0.1 reserved); `efficientnet_b4.tv_in1k` 380x380 (0.1 GiB peak allocated, 0.1 reserved)
48
+
49
+ ## Speed and memory
50
+
51
+ ### Classification, synthetic, 224x224
52
+
53
+ | model | time (ms): original fp32 | original | portable | kernels | kernels speed-up: vs original | vs portable | peak memory (MiB, allocated / reserved): original | portable | kernels |
54
+ | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
55
+ | `efficientnet_b0.tv_in1k` | 5.64 | 7.91 | 4.98 | 0.769 | 7.3x | 6.5x | 64 / 84 | 48 / 96 | 78 / 118 |
56
+ | `efficientnet_b4.tv_in1k` | 11.1 | 15.7 | 10.0 | 2.00 | 5.5x | 5.0x | 147 / 174 | 89 / 114 | 111 / 180 |
57
+
58
+ ### Startup and first call
59
+
60
+ | model | load (s): original | portable | kernels | first call (s): original | portable | kernels |
61
+ | --- | --- | --- | --- | --- | --- | --- |
62
+ | `efficientnet_b0.tv_in1k` | 1.25 | 0.17 | 1.53 | 2.86 | 0.38 | 0.06 |
63
+ | `efficientnet_b4.tv_in1k` | 0.41 | 0.37 | 1.94 | 1.72 | 0.06 | 0.07 |
64
+
65
+ ### torch.compile and TensorRT
66
+
67
+ | 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) |
68
+ | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
69
+ | `efficientnet_b0.tv_in1k` | 224x224 | 4.98 | 2.9 | 9.1 | 0.5 | 26 | 0.769 | 48 / 96 | 80 / 96 | 38 |
70
+
71
+ ### Fixed-size speed and peak memory, all models
72
+
73
+ | model | mode | 224x224 |
74
+ | --- | --- | --- |
75
+ | `efficientnet_b0.tv_in1k` | portable | 5.0 ms / 48 / 84 |
76
+ | `efficientnet_b0.tv_in1k` | kernels | 0.9 ms / 81 / 164 |
77
+ | `efficientnet_b4.tv_in1k` | portable | 9.9 ms / 92 / 120 |
78
+ | `efficientnet_b4.tv_in1k` | kernels | 2.2 ms / 125 / 200 |
79
+
80
+ Fixed-size cells: time (ms) / peak allocated / peak reserved memory (MiB).
81
+
82
+ 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.
83
+
84
+ ## Accuracy
85
+
86
+ ### Parity with the original code
87
+
88
+ Every variant is checked against reference outputs of the original code at its pinned commit. CPU, float32: max |diff| <= 0.002 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 0.02 and p99 <= 0.08 (absolute error of the output `logits`).
89
+
90
+ ## Usage
91
+
92
+ ```python
93
+ from fastforks import classification
94
+
95
+ model = classification.load("efficientnet_b0.tv_in1k") # mode="auto": the preferred backend from recorded measurements
96
+ result = model("photo.jpg")
97
+ result.top(5) # top-5 classes
98
+ result.backend # what ran, e.g. Backend(mode='portable', device='cuda:0', dtype='float16')
99
+ ```
100
+
101
+ Install with `pip install fastforks` (see <https://github.com/kleinicke/fastforks>). Other variants: `efficientnet_b0.tv_in1k`, `efficientnet_b4.tv_in1k`.
102
+
103
+ ## Kernels backend
104
+
105
+ `classification.load("efficientnet_b0.tv_in1k", mode="kernels")` runs our CUDA kernels (`cudnn_hacc`, `fvm_conv`, `fvm_extra`, `fvm_mb`, `fvm_r3`). 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.
106
+
107
+ <!-- staged from fastforks feccac41 (2026-11-06) -->