FastViT (fastforks)

FastViT (Vasu et al. 2023): reparameterisable RepMixer token mixing, attention in the last stage.

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/pytorch-image-models at 0df212b369a5.

Author weight repos: https://huggingface.co/timm/fastvit_sa24.apple_dist_in1k.

Task: classification. Tier: stable. Outputs: logits. Backends: portable, kernels.

Input: one RGB image. Output: ImageNet-1k class logits.

Variants

Weights are the authors' files (not hosted here). SHA-256 shortened to 12 hex digits; the full hashes are in card.toml.

variant weights (author link) SHA-256 weights licence commercial use
fastvit_sa24.apple_dist_in1k@1 fastvit_sa24.apple_dist_in1k.safetensors c38594c380a5 LicenseRef-Apple-Sample-Code yes

Licence

Original-code strings, recorded as they are (research-use package; check them before any other use). Code: Apache-2.0. Files: .

Training data: ImageNet-1k (ILSVRC 2012 classification).

  • Licence note: The weights are under Apple's sample-code licence (the timm Hugging Face card says only 'license: other'); that licence grants no patent rights.

Licence evidence: https://huggingface.co/timm/fastvit_sa24.apple_dist_in1k/blob/0b86f2b98f83274e9f03b6ddbcb3942b84efb839/README.md

Input size

fixed 256x256: the input is resized (short side 284) and centre-cropped to it Tested up to (portable, fp16, RTX 5060 Ti 16 GB): fastvit_sa24.apple_dist_in1k 256x256 (0.1 GiB peak allocated, 0.1 reserved)

Speed and memory

Classification, synthetic, 224x224

model time (ms): original fp32 original portable kernels kernels speed-up: vs original vs portable peak memory (MiB, allocated / reserved): original portable kernels
fastvit_sa24.apple_dist_in1k 11.92 16.53 6.88 1.49 8.0x 4.6x 157 / 176 81 / 108 111 / 168

Startup and first call

model load (s): original portable kernels first call (s): original portable kernels
fastvit_sa24.apple_dist_in1k 2.49 0.62 0.74โ€  1.67 0.17 0.00

Fixed-size speed and peak memory, all models

model mode 224x224
fastvit_sa24.apple_dist_in1k portable 6.9 ms / 81 / 118
fastvit_sa24.apple_dist_in1k kernels 1.5 ms / 113 / 194

Fixed-size cells: time (ms) / peak allocated / peak reserved memory (MiB).

Hardware, protocol and caveats: benchmarks (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.

Accuracy

Parity with the original code

Every variant is checked against golden 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 px and p99 <= 0.08 px.

Usage

from fastforks import classification

model = classification.load("fastvit_sa24.apple_dist_in1k")  # portable PyTorch on the GPU if there is one, else the CPU
result = model("photo.jpg")
result.top(5)  # top-5 classes
result.backend  # what ran, e.g. Backend(mode='portable', device='cuda:0', dtype='float16')

Install with pip install fastforks (see https://github.com/kleinicke/fastforks). Other variants: fastvit_sa24.apple_dist_in1k.

Kernels backend

classification.load("fastvit_sa24.apple_dist_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.

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support