HGNetV2
HGNetV2 (PaddlePaddle's PP-HGNetV2; B0 to B6, SSLD-distilled, fine-tuned on ImageNet-1k): a convolutional classifier built for GPU speed. Apache-2.0.
experimental Fork of huggingface/pytorch-image-models@0df212b · backends: portable, kernels
- Paper PP-HGNetV2 PaddleClas docs · first released 26 Sept 2023
- Authors’ code PaddlePaddle/PaddleClas (PaddlePaddle), not the code forked here: timm carries the architecture and the converted PaddleClas checkpoints in its own PyTorch API; the original is PaddlePaddle.
Paper 2023 Added in 0.2.0 Evaluated with 0.2.0
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("hgnetv2_b0.ssld_stage2_ft_in1k") # kernels on a supported GPU, else portable PyTorch
result = model(image)
result.logits
result.backend # what ran: mode, device, dtype, kernels fastforks bench hgnetv2_b0.ssld_stage2_ft_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)
| Backend | dtype | Time per call (ms) | vs original fp32 | Peak memory allocated / reserved | Load (s) | First call (s) |
|---|---|---|---|---|---|---|
| Original fp32 | fp32 | 4.45 | – | 65 MiB/70 MiB | 3.2 | 0.33 |
| Original fp16torch.autocast(float16) around the call | fp16 | 5.89 | 0.76× | 68 MiB/72 MiB | 0.2 | 1.36 |
| Portable fp32 | fp32 | not measured | – | – | – | – |
| Portable | fp16 | 3.46 | 1.3× | 48 MiB/70 MiB | 1.7 | 0.73 |
| Kernels | not measured | – | – | – | – | |
| Portable + torch.compile | 1.78 | 2.5× | 78 MiB/110 MiB | 7 (build) | – | |
| TensorRT fp16 | fp16 | 0.334 | 13× | 32 MiBenginenot comparable | 21 (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
| Device | Backend | dtype | ms / call | Peak memory | Output vs reference | Input |
|---|---|---|---|---|---|---|
| Apple M1 Pro 16 GB MPS, torch 2.14.1, 2026-11-14 | Original | fp32 | 11.6 | 480 MiB process | – | 224x224 |
| Portable | fp16 | 7.01 | 513 MiB process | matches | 224x224 | |
| Portable | fp32 | 6.34 | 503 MiB process | matches | 224x224 | |
| Kernels | fp32 | not 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
-
- ImageNet-21k / ImageNet-22k (full ImageNet, fall 2011 release) noncommercial, non-commercial
- ImageNet-1k (ILSVRC 2012 classification) noncommercial, non-commercial
Our reading of the licences, not legal advice.
Weights
hgnetv2_b0.ssld_stage2_ft_in1k.safetensors 24.1 MB· hosted on Hugging Facefastforks downloads and checks these files on first use (fastforks download hgnetv2_b0.ssld_stage2_ft_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 %
| Run | dtype | top-1 % ↑ | top-5 % ↑ | Δ top-1 % vs fp32 original | images | ms / image |
|---|---|---|---|---|---|---|
| Original fp32 | fp32 | 78.50 | 93.98 | reference | 5000 | 0.474 |
| Original fp16 | fp16 | 78.40 | 93.96 | −0.10 | 5000 | 0.492 |
| Portable fp32 | fp32 | 78.50 | 94.04 | ±0.00 | 5000 | 1.15 |
| Portable | fp16 | 78.50 | 94.04 | ±0.00 | 5000 | 0.535 |
| Kernels | not 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| <= 1.8e-05 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 0.008 and p99 <= 0.033 (absolute error of the output logits).
| Check | Tolerance | Measured |
|---|---|---|
| CPU fp32, max |diff| | ≤ 0.000018 | not recorded |
| GPU default dtypes, mean |diff| | ≤ 0.008 | 0.0054 |
| GPU default dtypes, p99 |diff| | ≤ 0.033 | 0.02154 |
Recorded for hgnetv2_b0.ssld_stage2_ft_in1k on RTX 5060 Ti, torch 2.10.0+cu130, 2026-11-17, with these kernels: cudnn_haccfvm_convfvm_extrafvm_mbfvm_r3
Details
HGNetV2 (PaddlePaddle, PP-HGNetV2): a convolutional classifier of aggregation blocks with light 5x5 convolutions, SSLD-distilled and fine-tuned on ImageNet-1k.
- Input / output
- Input: one RGB image. Output: ImageNet-1k class logits.
- Input size
- fixed 224x224: the input is resized (short side 232) and centre-cropped to it; tested up to 224x224 (48 MiB allocated)
- Outputs
logits- Checkpoint
arch="hgnetv2_b0.ssld_stage2_ft_in1k"- CUDA kernels
cudnn_haccconvolutions with fp16 accumulation (cuDNN)fvm_convfused convolutions for image classifiersfvm_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
HGNetV2 (PaddlePaddle's PP-HGNetV2; B0 to B6, SSLD-distilled, fine-tuned on ImageNet-1k): a convolutional classifier built for GPU speed. Apache-2.0.
Commercial use: yes.
| variant | input | backend | time (ms) | peak memory (MiB, allocated / reserved) |
|---|---|---|---|---|
hgnetv2_b0.ssld_stage2_ft_in1k | synthetic (224x224) | original (fp32) original portable kernels portable + torch.compile TensorRT fp16 | 4.45 5.89 3.46 – 1.78 0.334 | 65 / 70 68 / 72 48 / 70 – 78 / 110 77 / 100 |
hgnetv2_b1.ssld_stage2_ft_in1k | synthetic (224x224) | original (fp32) original portable kernels portable + torch.compile TensorRT fp16 | 4.57 6.17 3.47 – 1.84 0.307 | 66 / 94 70 / 92 50 / 68 – 80 / 108 81 / 104 |
hgnetv2_b2.ssld_stage2_ft_in1k | synthetic (224x224) | original (fp32) original portable kernels portable + torch.compile TensorRT fp16 | 6.25 7.98 4.55 – 2.33 0.383 | 89 / 114 98 / 118 59 / 94 – 89 / 134 91 / 128 |
hgnetv2_b3.ssld_stage2_ft_in1k | synthetic (224x224) | original (fp32) original portable kernels portable + torch.compile TensorRT fp16 | 7.16 9.30 5.22 – 2.55 0.436 | 112 / 134 127 / 140 76 / 114 – 99 / 152 100 / 150 |
hgnetv2_b4.ssld_stage2_ft_in1k | synthetic (224x224) | original (fp32) original portable kernels portable + torch.compile TensorRT fp16 | 7.06 8.41 4.53 – 2.66 0.463 | 131 / 140 147 / 166 82 / 116 – 107 / 134 139 / 182 |
hgnetv2_b5.ssld_stage2_ft_in1k | synthetic (224x224) | original (fp32) original portable kernels portable + torch.compile TensorRT fp16 | 11.4 13.8 7.04 – 4.13 0.758 | 213 / 222 260 / 280 114 / 150 – 146 / 190 209 / 250 |
hgnetv2_b6.ssld_stage2_ft_in1k | synthetic (224x224) | original (fp32) original portable kernels portable + torch.compile TensorRT fp16 | 16.5 17.9 9.44 – 5.44 1.42 | 354 / 376 465 / 490 198 / 224 – 217 / 264 347 / 394 |
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/hgnetv2_b0.ssld_stage2_ft_in1k/blob/9e0a904b210d65e4fcd6582f8ca6e0921fac2650/README.md
- Training data: ImageNet-21k / ImageNet-22k (full ImageNet, fall 2011 release), ImageNet-1k (ILSVRC 2012 classification)
- Kernel libraries:
cudnn_hacc,fvm_conv,fvm_extra,fvm_mb,fvm_r3 - Variants:
hgnetv2_b0.ssld_stage2_ft_in1k(default ofhgnetv2_b0),hgnetv2_b1.ssld_stage2_ft_in1k(default ofhgnetv2_b1),hgnetv2_b2.ssld_stage2_ft_in1k(default ofhgnetv2_b2),hgnetv2_b3.ssld_stage2_ft_in1k(default ofhgnetv2_b3),hgnetv2_b4.ssld_stage2_ft_in1k(default ofhgnetv2_b4),hgnetv2_b5.ssld_stage2_ft_in1k(default ofhgnetv2_b5),hgnetv2_b6.ssld_stage2_ft_in1k(default ofhgnetv2_b6) - Outputs: logits; label_set:
imagenet-1k - Input size: fixed 224x224: the input is resized (short side 232) and centre-cropped to it
- Tested up to (portable, fp16, RTX 5060 Ti 16 GB):
hgnetv2_b0.ssld_stage2_ft_in1k224x224 (0.0 GiB peak allocated, 0.1 reserved);hgnetv2_b1.ssld_stage2_ft_in1k224x224 (0.0 GiB peak allocated, 0.1 reserved);hgnetv2_b2.ssld_stage2_ft_in1k224x224 (0.1 GiB peak allocated, 0.1 reserved);hgnetv2_b3.ssld_stage2_ft_in1k224x224 (0.1 GiB peak allocated, 0.1 reserved);hgnetv2_b4.ssld_stage2_ft_in1k224x224 (0.1 GiB peak allocated, 0.1 reserved);hgnetv2_b5.ssld_stage2_ft_in1k224x224 (0.1 GiB peak allocated, 0.1 reserved);hgnetv2_b6.ssld_stage2_ft_in1k224x224 (0.2 GiB peak allocated, 0.2 reserved) hgnetv2_b0.ssld_stage2_ft_in1k224x224, first call: portable + torch.compile 7 s (cold Inductor cache), TensorRT fp16 21 s (ONNX + engine).hgnetv2_b1.ssld_stage2_ft_in1k224x224, first call: portable + torch.compile 7 s (cold Inductor cache), TensorRT fp16 20 s (ONNX + engine).hgnetv2_b2.ssld_stage2_ft_in1k224x224, first call: portable + torch.compile 8 s (cold Inductor cache), TensorRT fp16 23 s (ONNX + engine).hgnetv2_b3.ssld_stage2_ft_in1k224x224, first call: portable + torch.compile 8 s (cold Inductor cache), TensorRT fp16 25 s (ONNX + engine).hgnetv2_b4.ssld_stage2_ft_in1k224x224, first call: portable + torch.compile 8 s (cold Inductor cache), TensorRT fp16 20 s (ONNX + engine).hgnetv2_b5.ssld_stage2_ft_in1k224x224, first call: portable + torch.compile 10 s (cold Inductor cache), TensorRT fp16 24 s (ONNX + engine).hgnetv2_b6.ssld_stage2_ft_in1k224x224, first call: portable + torch.compile 11 s (cold Inductor cache), TensorRT fp16 27 s (ONNX + engine).hgnetv2_b0.ssld_stage2_ft_in1koriginal 224x224: torch.autocast(float16) around the callhgnetv2_b1.ssld_stage2_ft_in1koriginal 224x224: torch.autocast(float16) around the callhgnetv2_b2.ssld_stage2_ft_in1koriginal 224x224: torch.autocast(float16) around the callhgnetv2_b3.ssld_stage2_ft_in1koriginal 224x224: torch.autocast(float16) around the callhgnetv2_b4.ssld_stage2_ft_in1koriginal 224x224: torch.autocast(float16) around the callhgnetv2_b5.ssld_stage2_ft_in1koriginal 224x224: torch.autocast(float16) around the callhgnetv2_b6.ssld_stage2_ft_in1koriginal 224x224: torch.autocast(float16) around the callhgnetv2_b0.ssld_stage2_ft_in1kload / first call: original 0.19 s / 1.357 s, portable 1.67 s / 0.735 shgnetv2_b1.ssld_stage2_ft_in1kload / first call: original 0.31 s / 0.313 s, portable 1.87 s / 0.396 shgnetv2_b2.ssld_stage2_ft_in1kload / first call: original 0.23 s / 0.59 s, portable 1.79 s / 0.39 shgnetv2_b3.ssld_stage2_ft_in1kload / first call: original 0.27 s / 0.165 s, portable 1.81 s / 0.395 shgnetv2_b4.ssld_stage2_ft_in1kload / first call: original 0.32 s / 0.297 s, portable 1.74 s / 0.389 shgnetv2_b5.ssld_stage2_ft_in1kload / first call: original 0.49 s / 0.305 s, portable 1.95 s / 0.4 shgnetv2_b6.ssld_stage2_ft_in1kload / first call: original 0.86 s / 0.453 s, portable 2.21 s / 0.46 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.
| variant | dataset | original fp32 | original fp16 | portable | portable fp32 | note |
|---|---|---|---|---|---|---|
hgnetv2_b0.ssld_stage2_ft_in1k | ImageNet-1k val, 5000 random images, top-1 / top-5 % | 78.50 / 93.98 | 78.40 / 93.96 | 78.50 / 94.04 | 78.50 / 94.04 | |
hgnetv2_b1.ssld_stage2_ft_in1k | ImageNet-1k val, 5000 random images, top-1 / top-5 % | 80.08 / 94.40 | 80.00 / 94.46 | 80.12 / 94.38 | 80.16 / 94.42 | |
hgnetv2_b2.ssld_stage2_ft_in1k | ImageNet-1k val, 5000 random images, top-1 / top-5 % | 82.50 / 95.92 | 82.48 / 95.92 | 82.50 / 95.92 | 82.50 / 95.92 | |
hgnetv2_b3.ssld_stage2_ft_in1k | ImageNet-1k val, 5000 random images, top-1 / top-5 % | 83.68 / 96.08 | 83.68 / 96.08 | 83.66 / 96.02 | 83.64 / 96.06 | |
hgnetv2_b4.ssld_stage2_ft_in1k | ImageNet-1k val, 5000 random images, top-1 / top-5 % | 83.96 / 96.66 | 83.98 / 96.66 | 84.00 / 96.64 | 84.02 / 96.64 | |
hgnetv2_b5.ssld_stage2_ft_in1k | ImageNet-1k val, 5000 random images, top-1 / top-5 % | 85.50 / 97.14 | 85.52 / 97.14 | 85.52 / 97.18 | 85.52 / 97.16 | |
hgnetv2_b6.ssld_stage2_ft_in1k | ImageNet-1k val, 5000 random images, top-1 / top-5 % | 86.60 / 97.94 | 86.60 / 97.94 | 86.74 / 98.00 | 86.66 / 98.00 |
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| <= 1.8e-05 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 0.008 and p99 <= 0.033 (absolute error of the output logits).
| variant | kernels error vs original, mean / p99 | GPU, torch | kernels used |
|---|---|---|---|
hgnetv2_b0.ssld_stage2_ft_in1k | 0.0054 / 0.02154 | RTX 5060 Ti, torch 2.10.0+cu130 | cudnn_hacc@cudnn91501, fvm_conv@f1d064e539e1:sm_120, fvm_extra@3208ce525a91:sm_120, fvm_mb@720dd3f29bf7:sm_120, fvm_r3@f54eb890e23c:sm_120 |
hgnetv2_b1.ssld_stage2_ft_in1k | 0.00362 / 0.01274 | RTX 5060 Ti, torch 2.10.0+cu130 | cudnn_hacc@cudnn91501, fvm_conv@f1d064e539e1:sm_120, fvm_extra@3208ce525a91:sm_120, fvm_mb@720dd3f29bf7:sm_120, fvm_r3@f54eb890e23c:sm_120 |
hgnetv2_b2.ssld_stage2_ft_in1k | 0.00244 / 0.01084 | RTX 5060 Ti, torch 2.10.0+cu130 | cudnn_hacc@cudnn91501, fvm_conv@f1d064e539e1:sm_120, fvm_extra@3208ce525a91:sm_120, fvm_mb@720dd3f29bf7:sm_120, fvm_r3@f54eb890e23c:sm_120 |
hgnetv2_b3.ssld_stage2_ft_in1k | 0.00242 / 0.01019 | RTX 5060 Ti, torch 2.10.0+cu130 | cudnn_hacc@cudnn91501, fvm_conv@f1d064e539e1:sm_120, fvm_extra@3208ce525a91:sm_120, fvm_mb@720dd3f29bf7:sm_120, fvm_r3@f54eb890e23c:sm_120 |
hgnetv2_b4.ssld_stage2_ft_in1k | 0.00152 / 0.00782 | RTX 5060 Ti, torch 2.10.0+cu130 | cudnn_hacc@cudnn91501, fvm_conv@f1d064e539e1:sm_120, fvm_extra@3208ce525a91:sm_120, fvm_mb@720dd3f29bf7:sm_120, fvm_r3@f54eb890e23c:sm_120 |
hgnetv2_b5.ssld_stage2_ft_in1k | 0.00146 / 0.00686 | RTX 5060 Ti, torch 2.10.0+cu130 | cudnn_hacc@cudnn91501, fvm_conv@f1d064e539e1:sm_120, fvm_extra@3208ce525a91:sm_120, fvm_mb@720dd3f29bf7:sm_120, fvm_r3@f54eb890e23c:sm_120 |
hgnetv2_b6.ssld_stage2_ft_in1k | 0.00201 / 0.00906 | RTX 5060 Ti, torch 2.10.0+cu130 | cudnn_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).
Top 5
Input: Chelsea the cat, Stéfan van der Walt (CC0).