OneVision-Encoder: spend video tokens only on surprise
A video codec already marks the patches that the previous frame cannot predict. OneVision-Encoder keeps only those patches, from 64 frames, and gives them to a plain ViT at the token cost of 8 frames.
Eight frames miss the fast part
A typical video encoder (CLIP, SigLIP2, DINOv3 used frame by frame) samples 8 or 16 frames and encodes every patch of each. Most of those tokens show a wall, a sky or a floor that did not change. An event that falls between two sampled frames is lost.
Take a 15-second dive at 30 fps: 450 frames. Eight evenly spaced frames are 2.1 s apart. A full twist lasts well under a second, so the encoder sees at most one pose per phase of the dive. Sixty-four frames are 0.23 s apart, but 64 dense frames at 224 px are 16,384 patches, and the attention cost grows with the square of that.
OV-Encoder (arXiv 2602.08683) keeps the 64-frame time axis and drops most of the patches. It does not learn which patches to drop. It reads the choice from the compressed video file, where the codec has already measured, for every block of every frame, how much of the block the past cannot predict. The paper calls this the “surprise”.
The pipeline has five steps, one section each below: read the codec signals, score and select patches, pack them with their positions, run a ViT with 3D RoPE, and train it with a cluster-classification loss. This note follows the paper and the released code. Where the two disagree, the note says so.
What the codec already knows
A codec stores a few frames in full and the rest as differences:
- An I-frame (key frame) is a full picture. It does not depend on other frames.
- A P-frame (predicted frame) is stored as notes against the previous frame. For each block of pixels, the encoder searches the previous frame for the best copy source. The shift is the motion vector (MV). What is still wrong after the copy is the residual.
- A GOP (group of pictures) is one I-frame plus the P-frames that follow it.
In formula form, a P-frame is a copy with the motion vectors , plus the residual :
The block search picks the shift with the smallest sum of absolute differences:
A block of static background costs nothing. A block that moved costs a motion vector. A block with new content costs a residual.
playground
A codec writes notes only where the row changes
Click any pixel to change its value (20 → 90 → 200). Press Copy previous to make the frames equal.
The two kinds of note detect different things. Motion vectors find movement: a hand, a ball, a camera pan. The residual finds new appearance: a light that switches on, an object that enters. Together they are a change map that the decoder computes anyway.
The map has limits. The codec chooses notes to save bits, not to describe the world, so a flat wall can get random small motion vectors. A camera pan gives every block a motion vector. A still scene gives no signal at all.
For training, the authors re-encode every clip with libx265: no B-frames, one reference frame, CRF 23, and a fixed GOP. The paper says GOP 32. The released script defaults to GOP 16. Benchmark videos keep their original bitstream, so motion statistics at test time can differ from those in training.
Score every patch, keep the global top K
The paper describes the score only in words. The released code (the step3 preprocessing script) gives the exact rule. For each frame with motion field in quarter-pixel units and luma residual (zero stored as 128):
is the 95th percentile over the pixels of that frame. The patch score is the sum of over the pixels of the patch. The selection is the top of all patch scores, over the whole clip at once. Frame 0 is treated as the I-frame and gets score 0.
The per-frame division by does two jobs. It puts pixels of motion and grey levels of residual on one scale, so the two cues can be averaged. It also stretches every frame to the same range. The authors explain (GitHub issue #116) that this stops one dramatic frame from taking the whole budget. The walkthrough points out the cost: a frame with almost no change also gets a full range, so its codec noise competes equally with real motion in other frames.
playground
Codec saliency on a 16-frame toy clip
Press Play or drag across the bar chart to scrub time. Switch Normalise to Fixed, then try Pan and Pan−med.
The budget sets the sparsity. With patches per clip:
| kept | reduction | frame equivalents | used for | |
|---|---|---|---|---|
| 512 | 3.1% | 96.9% | 2 | smallest budget (Table 5) |
| 1024 | 6.25% | 93.75% | 4 | Table 5 |
| 2048 | 12.5% | 87.5% | 8 | training default; 8-frame probe |
| 4096 | 25% | 75% | 16 | 16-frame probe |
Two more facts about selection. Over 200,000 training clips, central patches are chosen about 1.5× as often as corners (0.62% vs 0.42%, against a uniform 0.39%). The authors attribute this to camera framing and balance it with full-frame training inputs. The LMM version of the selector also subtracts the median motion vector of each frame, so a pure pan gives almost no motion score. The training tool does not.
Pack the survivors into eight fake frames
Every patch of the clip has one flat index on a fixed “virtual” grid of 64 frames:
For example, index 5000 is frame 19, row 8, column 8. The selected patches are gathered in index order and written into the slots of a tensor of shape : a fake 8-frame video. A patch lands in slot , next to random other patches.
This is exact, not an approximation, for two reasons. The patch embedding is a Conv2d with kernel = stride = 14, so each token depends only on its own pixels. And the model has no absolute position embedding: the only position signal is the RoPE angle, computed from the true of each slot (visible_indices). The canvas layout carries no information. The token list is a set of (embedding, true position) pairs, and bidirectional attention does not care about their order.
animation
Kept patches move to the canvas with their labels
Press Play. Then switch the mode to Frames or Tiling and play it again.
One set of weights is trained on several input layouts. Batch shares are from paper Table 9, and the 128-GPU training script reproduces them (8 : 6 : 2 clips per GPU):
| Mode | Tensor | Tokens | Position of a token | Share |
|---|---|---|---|---|
| Codec | 2048 | true and | 50% | |
| Frame sampling | 2048 | one frame per bin of 8; all 256 | 37.5% | |
| Tiling | 2048 | , | 12.5% | |
| Single image | 1024 | , | image heads |
Frame sampling covers the frame border, which the codec mode under-samples, and it is the fallback when no codec data exist. Tiling teaches the “storyboard” images that are common in LMM data. The paper defines the chunk-wise time offset by chunk number. The code uses the frame number on the 64-frame grid, so frames 3 and 60 are 57 steps apart, not 7.
3D RoPE gives each token its true place
RoPE splits a head vector of channels into 32 pairs and rotates pair by the angle , where is the position. Because , the query–key score depends only on the offset . A token does not need its neighbours to be present. This is the property that sparse input needs.
OV-Encoder gives each pair one axis: 8 pairs for time, 12 for rows, 12 for columns (the 4:6:6 split). Each axis gets its own geometric list of frequencies, from 1 down to almost (base ): for time and for rows and columns. Positions in training are short (64 frames, 16 patches), so the slow pairs hardly turn. Over the whole clip, the last 3 time pairs turn by at most 0.2 rad, and the last 6 row pairs and 6 column pairs by at most 0.15 rad. Thus 15 of the 32 pairs act almost like content channels with no position. The paper does not ablate the base or the split.
playground
One offset, many absolute positions
Change the offset. Watch the dials (one per pair) and the two score curves. Press New q, k for other random vectors.
The shuffle control in the results (below) relies on positions. Because the released RoPE mixes relative and absolute signals, a shuffle disturbs both.
A plain ViT at the price of eight frames
The network is a standard pre-norm ViT-L/14: 24 layers, width 1024, 16 heads of 64 channels, MLP 1024 → 4096 → 1024. It has no [CLS] token, no register tokens and no absolute position embedding. A pooling head (one learned query with 16-head attention, then an MLP) gives a 1024-d embedding. The walkthrough counts about 315M parameters, pooling head included. Every sample has exactly tokens, so attention needs no padding mask. There are no temporal tubelets: a tubelet would need the same patch in two frames, and selection keeps patches per frame.
The walkthrough estimates the FLOPs of one forward pass as for the linear layers and for attention. At the total is 1.65 TFLOP; all 64 frames dense () cost 36.3 TFLOP, 22× more. The linear part grows 8×, the attention part 64×.
calculator
Tokens and compute for one clip
Switch between the probe setting (224 px) and the LMM setting (504 px). Change the number of frames and the budget.
In the LMM setting, frames are , so each has patches. Dense 64 frames are 82,944 patches. The codec budget of 8 frame equivalents is 10,368 patches. The projector has no merge step, so each patch becomes one LLM token: exactly the count of 8 dense frames. The LLM gets the same number of tokens. Only their spread over time differs.
Training without captions: cluster discrimination
The encoder never sees captions in pre-training. Its labels come from one offline -means run on features of a frozen teacher, MetaCLIP-H/14:
- Image head: 2,000,000 clusters of LAION and COYO image features. Each image gets its 10 nearest centres as labels.
- Video head: 400,000 clusters. The clip feature is “L2-normalise each frame → concatenate → L2-normalise”, so frame order is part of the vector. Each clip gets 10 labels.
- OCR head: each word of a 365,187-word vocabulary (count from the code) is a class; a document image gets 100 tags.
The encoder must classify each sample into its clusters. The paper writes the objective as a logistic loss per (sample, centre) pair (Eq. 9). The released code does something else: Partial FC with a CosFace margin. Each step keeps 8 of a sample’s labels. For each kept label there is one softmax over a candidate set of sampled negative centres:
with scale and margin . The margin forces the target to beat every negative by a cosine gap of 0.3. The filter sets very close “negatives” to 0. Such negatives are often another true label of the same sample, or a near-duplicate cluster, and pushing the embedding away from them would hurt.
playground
Margin and filter on one label slot
Drag the dots along their lanes. Turn the filter off. Set the margin to 0.
A full classifier over 2M classes in 1024-d is 8.19 GB of fp32 weights. Partial FC splits the centres over the 128 GPUs (15,625 each) and samples 10% of them per step, so one softmax sees about 200,000 centres. The normaliser is computed with two all-reduces (max, then sum), without gathering logits.
Training has two stages. Stage 1 uses only images at 224 px, 13B samples, AdamW at lr . Stage 2 adds OCR and video (64 frames at 224 px, with the 50 / 37.5 / 12.5 mode mix) and 448 px images, for 4B samples at lr . The released Stage-2 shell uses lr and samples; it may be one of several runs.
What the results show
The cleanest test is the attentive probe: the backbone is frozen, and a new pooling head plus a linear classifier are trained on top. The same OV-Encoder weights can be fed codec-selected patches or dense frames at the same budget, so the gap between the two rows isolates the input layout.
playground
Attentive-probe results
Switch tables. In Probe, pick Diving48 and then CharadesEgo. In Controls, pick SSV2 and then Diving48.
What the tables support:
- Average. OV-Encoder (Codec) has the best average in both blocks: 60.2 (8 frames, 2048 patches) and 61.5 (16 frames, 4096 patches), against DINOv3 at 58.0 and 59.1.
- Diving48. Codec 67.2 vs Frame 57.6 with the same weights: +9.6 points from the layout alone (+6.2 at 16 frames). The abstract’s “+17.1 over SigLIP2 and +8.1 over DINOv3” mixes the two blocks (67.2 − 50.1 at 8 frames, 69.4 − 61.3 at 16 frames).
- Budget. Codec at 1024 patches (average 56.2) beats SigLIP2 at 4096 patches (55.7).
- Controls. Shuffling patch positions costs 13.4 average points, the largest drop in every column. Replacing 50% of the selected patches with non-motion patches costs 6.1; with motion patches from another video, 6.6. The paper says the second drop is “even larger” on fine-grained benchmarks, but on Diving48 it is smaller (12.2 vs 14.0), and the 0.5-point average gap has no error bars.
- Not best everywhere. DINOv3 leads on CharadesEgo in both blocks and on Epic-Verb at 8 frames.
In the LMM probe (Qwen3-4B, about 1.5M SFT samples), the language-aligned OV-Encoder-Lang averages 52.1 on 7 video benchmarks against 48.0 for Qwen3-ViT, the abstract’s +4.1. The paper also claims wins “on all 16 benchmarks”. Table 2 does not support this:
| Comparison (paper Table 2) | Rows where OV-Encoder is not ahead |
|---|---|
| OV-Encoder (Codec) vs SigLIP2 | 7 of 16: MLVU, TOMATO, AI2D, MMBench, OCRBench, MMStar, RealWorldQA |
| OV-Encoder-Lang vs Qwen3-ViT | 4 of 16: TOMATO, DocVQA, OCRBench, MMStar (tie) |