vjepa2 / README.md
Flor's picture
Update model card for 0.4.0
309bd6d verified
|
Raw History Blame Contribute Delete
8.37 kB
metadata
library_name: fastforks
pipeline_tag: image-feature-extraction
license: other
license_name: mixed-see-variant-table
license_link: >-
  https://huggingface.co/facebook/vjepa2-vitg-fpc64-256/blob/875c192b7b704b87d1e1d99345769632dd5f739a/README.md
tags:
  - features
  - backbone
  - feature-extraction
  - cuda
  - pytorch
  - fastforks
  - fastforks-card

V-JEPA 2 (fastforks)

V-JEPA 2 (Assran et al. 2025, Meta): self-supervised video ViT encoders (3D rotary position embedding, 2-frame tubelets, no cls token) trained by latent prediction on over a million hours of video; clip features at any size. model.video(frames) encodes a clip (T a multiple of 2) to its token grid [T/2 * h * w, C]; an image is repeated to one tubelet. Encoder only: the predictor, the action-conditioned world model and the SSv2 / Diving48 classifier heads are not ported.

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/facebookresearch/vjepa2 at 204698b45b37.

Author weight repos: https://huggingface.co/facebook/vjepa2-vitg-fpc64-256, https://huggingface.co/facebook/vjepa2-vitl-fpc64-256.

Task: features. Tier: experimental. Outputs: last_hidden_state, pooler_output, hidden_states. Backends: portable, kernels.

Input: one RGB image. Output: dense patch features and a pooled image feature.

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
vjepa2-vitg-fpc64-256@1 vjepa2-vitg-fpc64-256/model.safetensors f205e77aa2ad Apache-2.0 yes
vjepa2-vitl-fpc64-256@1 vjepa2-vitl-fpc64-256/model.safetensors 25466aef8572 MIT yes

Licence

Original-code strings, recorded as they are (research-use package; check them before any other use). Code: MIT. Licence files: LICENSE.

Training data: VideoMix22M: Something-Something v2, Kinetics 400/600/700, HowTo100M, YT-Temporal-1B and ImageNet, self-supervised (no labels), per the paper.

Licence evidence: https://huggingface.co/facebook/vjepa2-vitl-fpc64-256/blob/b3c1679b7c34d3255ef3547f27c7b226aefab26f/README.md (metadata: license mit)

Input size

any H x W >= 1, resized or padded inside the model Tested up to (portable, fp16, RTX 5060 Ti 16 GB): vjepa2-vitg-fpc64-256 3000x4000 (4.4 GiB peak allocated, 4.9 reserved); vjepa2-vitl-fpc64-256 3000x4000 (2.5 GiB peak allocated, 2.8 reserved)

Speed and memory

Features, 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
vjepa2-vitg-fpc64-256 104 107 15.2 14.2 7.3x 1.1x 4196 / 4536 2081 / 2228 1969 / 1988
vjepa2-vitl-fpc64-256 64.6 82.1 9.63 5.13 12.6x 1.9x 1410 / 1428 717 / 746 617 / 626

Features, DAVIS 2017 bear, 64x256x256

model time (ms): original fp32 original portable peak memory (MiB, allocated / reserved): original portable
vjepa2-vitg-fpc64-256 5089 1156 796 4838 / 5392 2801 / 3106
vjepa2-vitl-fpc64-256 2651 549 298 2052 / 2282 1332 / 1464

Startup and first call

model load (s): original portable kernels first call (s): original portable kernels
vjepa2-vitg-fpc64-256 1.25 2.20 2.22 0.26 0.07 0.16
vjepa2-vitl-fpc64-256 1.37 1.02 1.50 0.29 0.09 0.16

torch.compile and TensorRT

model input time: portable compile TensorRT (fp16 unless shown) kernels preparation: compile (cold first call) ONNX + engine build peak MiB (alloc / reserved): portable compile kernels TensorRT (engine + torch)
vjepa2-vitg-fpc64-256 224x224 15.2 ms 13.7 ms 9.40 ms 14.2 ms 19.3 s 74.3 s 2081 / 2228 2017 / 2026 1969 / 1988 3931 / 3950
vjepa2-vitl-fpc64-256 224x224 9.63 ms 4.83 ms 2.98 ms 5.13 ms 12.1 s 37.1 s 717 / 746 656 / 666 617 / 626 1228 / 1238

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 original code named above 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

On public datasets

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 portable portable fp32 note
vjepa2-vitl-fpc64-256 ImageNet-1k val, kNN top-1 % (k = 20, 10000 labelled / 5000 test images) 33.28 33.34 33.24
vjepa2-vitg-fpc64-256 ImageNet-1k val, kNN top-1 % (k = 20, 10000 labelled / 5000 test images) 45.38 45.40 45.28

Measured on NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks c0606f892, 2026-11-30.

Parity with the original code

Every variant is checked against reference outputs of the original code at its pinned commit. CPU, float32: max |diff| <= 0.01 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 0.05 and p99 <= 0.5 (absolute error of the output last_hidden_state).

Limitations

  • Encoder only: the checkpoints also hold the pre-training predictor, which is not loaded; the action-conditioned world model (V-JEPA 2-AC) and the attentive-probe classifier heads are not ported.
  • No cls token and no pooler in the model: pooler_output is the mean of the final-LayerNorm tokens (this port's choice) and num_prefix_tokens is 0. An image call repeats the image to one 2-frame tubelet, as Hugging Face does for one frame.
  • Rotary position ids follow the actual (T/2, h, w) grid (Hugging Face fixes the square 256 x 256 grid; identical there), so other sizes run but lie outside the training distribution (256 px, 64 frames). Attention is global: 64 frames at 256 px are 8192 tokens.
  • Apple MLX (device="mlx") is hand-written, float32 or fp16, with no custom kernels; mode="kernels" is CUDA fp16 only (head dim 64) and has no exportable module().

Usage

from fastforks import features

model = features.load("vjepa2-vitg-fpc64-256")  # mode="auto": the preferred backend from recorded measurements
result = model("photo.jpg", size=518)
result.last_hidden_state  # tokens [N, C], as Hugging Face's output
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: vjepa2-vitg-fpc64-256, vjepa2-vitl-fpc64-256.

Kernels backend

features.load("vjepa2-vitg-fpc64-256", mode="kernels") runs our CUDA kernels (vjepa2_ops, fastbb, dpt_fused). 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.