V-JEPA 2
V-JEPA 2 (Meta, 2025): a self-supervised video encoder that turns a clip (or one photo) into patch features capturing motion and scene content. Encoder only, no classifier head. MIT code and weights (Apache-2.0 for the giant).
experimental Fork of facebookresearch/vjepa2@204698b · backends: portable, kernels
- Paper V-JEPA 2: Self-Supervised Video Models Enable Understanding, Prediction and Planning arXiv · first released 11 Jun 2025
Paper 2025 Added in 0.4.0 Evaluated with 0.4.0
Use it
pip install fastforks Lean install with only what this model needs: pip install fastforks-core
from fastforks import features
model = features.load("vjepa2-vitl-fpc64-256") # fastest backend that runs here
result = model("photo.jpg")
# result fields: last_hidden_state, pooler_output, hidden_states
last_hidden_state = result.last_hidden_state # a torch tensor
arrays = result.numpy() # the tensor fields as NumPy arrays: arrays["last_hidden_state"]
result.backend # what ran: mode, device, dtype
Other ways to run it
- Backend:
features.load("vjepa2-vitl-fpc64-256", mode="kernels") # or "portable", "auto" (default) - Precision:
features.load("vjepa2-vitl-fpc64-256", dtype="float32") # full precision: slower, portable only
fastforks bench vjepa2-vitl-fpc64-256 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.
| Backend | dtype | Time per call (ms) | vs original fp32 | Peak memory allocated / reserved | Load (s) | First call (s) |
|---|---|---|---|---|---|---|
| Original fp32original default fp32 (HF transformers VJEPA2Model, sdpa) | fp32 | 64.6 | – | 1,410 MiB/1,428 MiB | 1.4 | 0.49 |
| Original fp16torch.autocast(float16) around the HF transformers VJEPA2Model forward (sdpa) | fp16 | 82.1 | 0.79× | 1,410 MiB/1,428 MiB | 1.4 | 0.29 |
| Portable fp32 | fp32 | not measured | – | – | – | – |
| Portable | 9.63 | 6.7× | 717 MiB/746 MiB | 1.0 | 0.09 | |
| Kernels | fp16 | 5.13 | 13× | 617 MiB/626 MiB | 1.5 | 0.16 |
| Portable + torch.compile | 4.83 | 13× | 656 MiB/666 MiB | 12 (build) | – | |
| TensorRT fp16 | fp16 | 2.98 | 22× | 614 MiBenginenot comparable | 37 (build) | – |
Measured on RTX 5060 Ti 16 GB, torch 2.14.1+cu130, 2026-11-28 to 2026-12-02. 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
Not measured on other devices yet.
Licence and weights
Commercial use allowed
- Code
- MIT LICENSE
- Weights
- MIT source
- Training data
- VideoMix22M: Something-Something v2, Kinetics 400/600/700, HowTo100M, YT-Temporal-1B and ImageNet, self-supervised (no labels), per the paper
Our reading of the licences, not legal advice.
Weights
vjepa2-vitl-fpc64-256/model.safetensors 1.3 GB· hosted on Hugging Facefastforks downloads and checks these files on first use (fastforks download vjepa2-vitl-fpc64-256).
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
kNN top-1 % (k = 20, 10000 labelled / 5000 test images)
| Run | dtype | top-1 % ↑ | Δ top-1 % vs fp32 original | images | ms / image |
|---|---|---|---|---|---|
| Original fp32 | fp32 | 33.28 | reference | 5000 | 17.7 |
| Original fp16 | not measured | ||||
| Portable fp32 | fp32 | 33.24 | −0.04 | 5000 | 13.6 |
| Portable | fp16 | 33.34 | +0.06 | 5000 | 3.86 |
| Kernels | not measured | ||||
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 authors’ code, same checkpoint and protocol. Measured on original fp32: RTX 5060 Ti, torch 2.14.1+cu130, 2026-11-30; portable fp32, portable: RTX 5060 Ti, torch 2.14.1+cu130, fastforks c0606f892, 2026-11-30.
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| <= 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).
| Check | Tolerance | Measured |
|---|---|---|
| CPU fp32, max |diff| | ≤ 0.01 | not recorded |
| GPU default dtypes, mean |diff| | ≤ 0.05 | 0.03809 |
| GPU default dtypes, p99 |diff| | ≤ 0.5 | 0.31906 |
Recorded for vjepa2-vitl-fpc64-256 on RTX 5060 Ti, torch 2.14.1+cu130, 2026-12-02, with these kernels: dpt_fusedfastbbvjepa2_ops
Details
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.
- Input / output
- Input: one RGB image. Output: dense patch features and a pooled image feature.
- Input size
- any H x W >= 1, resized or padded inside the model; tested up to 3000x4000 (2,557 MiB allocated)
- Outputs
last_hidden_state,pooler_output,hidden_states- Checkpoint
hidden=1024,depth=24,heads=16,mlp=4096- CUDA kernels
vjepa2_opsfastbbfast backbone kernels: flash attention, window attention, instance norm and rotary embeddings for ViT and similar backbonesdpt_fusedfused fp16 matrix multiplies and convolutions for DINOv2 backbones and DPT depth heads
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()`.
Full reference, generated from the repository
V-JEPA 2 (Meta, 2025): a self-supervised video encoder that turns a clip (or one photo) into patch features capturing motion and scene content. Encoder only, no classifier head. MIT code and weights (Apache-2.0 for the giant).
Commercial use: yes.
| variant | input | backend | time (ms) | peak memory (MiB, allocated / reserved) |
|---|---|---|---|---|
vjepa2-vitl-fpc64-256 | synthetic (224x224) | original (fp32) original portable kernels portable + torch.compile TensorRT fp16 | 64.6 82.1 9.63 5.13 4.83 2.98 | 1410 / 1428 1410 / 1428 717 / 746 617 / 626 656 / 666 1228 / 1238 |
vjepa2-vitg-fpc64-256 | synthetic (224x224) | original (fp32) original portable kernels portable + torch.compile TensorRT fp16 | 104 107 15.2 14.2 13.7 9.40 | 4196 / 4536 4196 / 4536 2081 / 2228 1969 / 1988 2017 / 2026 3931 / 3950 |
Details
- Original code: https://github.com/facebookresearch/vjepa2 at
204698b45b37 - Code licence: MIT (permissive); files:
LICENSE - Weights licence: MIT
vjepa2-vitg-fpc64-256: Apache-2.0
- Licence evidence: https://huggingface.co/facebook/vjepa2-vitl-fpc64-256/blob/b3c1679b7c34d3255ef3547f27c7b226aefab26f/README.md (metadata: license mit)
- Training data: VideoMix22M: Something-Something v2, Kinetics 400/600/700, HowTo100M, YT-Temporal-1B and ImageNet, self-supervised (no labels), per the paper
- Kernel libraries:
vjepa2_ops,fastbb,dpt_fused - Variants:
vjepa2-vitl-fpc64-256,vjepa2-vitg-fpc64-256 - Outputs: last_hidden_state, pooler_output, hidden_states
- Input size: any H x W >= 1, resized or padded inside the model
- Tested up to (portable, fp16, RTX 5060 Ti 16 GB):
vjepa2-vitl-fpc64-2563000x4000 (2.5 GiB peak allocated, 2.8 reserved);vjepa2-vitg-fpc64-2563000x4000 (4.4 GiB peak allocated, 4.9 reserved) vjepa2-vitl-fpc64-256224x224, first call: portable + torch.compile 12 s (cold Inductor cache), TensorRT fp16 37 s (ONNX + engine).vjepa2-vitg-fpc64-256224x224, first call: portable + torch.compile 19 s (cold Inductor cache), TensorRT fp16 74 s (ONNX + engine).vjepa2-vitl-fpc64-256original (fp32) 224x224: original default fp32 (HF transformers VJEPA2Model, sdpa)vjepa2-vitl-fpc64-256original 224x224: torch.autocast(float16) around the HF transformers VJEPA2Model forward (sdpa)vjepa2-vitg-fpc64-256original (fp32) 224x224: original default fp32 (HF transformers VJEPA2Model, sdpa)vjepa2-vitg-fpc64-256original 224x224: torch.autocast(float16) around the HF transformers VJEPA2Model forward (sdpa)vjepa2-vitl-fpc64-256load / first call: original 1.37 s / 0.295 s, portable 1.02 s / 0.085 s, kernels 1.5 s / 0.162 svjepa2-vitg-fpc64-256load / first call: original 1.25 s / 0.263 s, portable 2.2 s / 0.071 s, kernels 2.22 s / 0.158 s- Protocol, median of 5 after 3 warm-up, uint8 CUDA input, card defaults; peak = max over the first call and the timed calls
Measured
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
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).
| variant | kernels error vs original, mean / p99 | GPU, torch | kernels used |
|---|---|---|---|
vjepa2-vitl-fpc64-256 | 0.03809 / 0.31906 | RTX 5060 Ti, torch 2.14.1+cu130 | dpt_fused@48e0065bb7cf:sm_120, fastbb@7d058322634d:sm_120, vjepa2_ops@cd5139f56468:sm_120 |
vjepa2-vitg-fpc64-256 | 0.05547 / 0.5274 | RTX 5060 Ti, torch 2.14.1+cu130 | dpt_fused@48e0065bb7cf:sm_120, fastbb@7d058322634d:sm_120, vjepa2_ops@cd5139f56468:sm_120 |
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_outputis the mean of the final-LayerNorm tokens (this port's choice) andnum_prefix_tokensis 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 exportablemodule().
Example output
No example rendered for this checkpoint yet.