Add Jepa 2.1 contrib model#160
Open
dstair wants to merge 7 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
NxDI contrib implementation of V-JEPA 2.1, Meta's self-supervised video foundation model. V-JEPA 2.1 is a Vision Transformer encoder that learns visual representations by predicting masked video segments in representation space. This is a vision encoder — not a causal language model — compiled for inference on AWS Trainium via
torch_neuronx.trace().Key architecture features ported:
repeat_interleavelayoutvjepa2imports at runtimeModel Information
Model Name: V-JEPA 2.1 (vit_base, vit_large, vit_giant, vit_gigantic)
Model Architecture: Vision Transformer encoder with 3D RoPE (86M–1.8B params)
Purpose: Self-supervised video representation learning (feature extraction, not text generation)
Checklist
Required Components
Accuracy Test (
test/integration/test_model.py)neuron_allclose(rtol=0.01)test/integration/test_pretrained_smoke.py)README.md with the following sections:
dl.fbaipublicfiles.com/vjepa2/)Source Code (
src/)modeling_jepa21.py(~700 lines): Self-contained encoder implementation, no upstream importsOptional Components
test_encoder.py— Construction: 4/4 PASS (ViT-B/L/g construction, invalid arch)test_encoder.py— Forward: 6/6 PASS (video/image/batch shapes, hierarchical output, determinism, resolution)test_encoder.py— Components: 4/4 PASS (PatchEmbed3D, RoPEAttention, Block)Not Applicable (vision encoder, not causal LM)
Folder Structure
Testing
How did you test this change?
All tests run on a trn2.3xlarge instance (2 NeuronCores, sa-east-1) using the Neuron SDK 2.28 venv (
/opt/aws_neuronx_venv_pytorch_2_9_nxd_inference/). Unit tests run on CPU only. Integration tests compile and run the model on Neuron hardware. Pretrained smoke tests download official Meta weights and validate BF16 Neuron output against FP32 CPU reference.Test Results:
Compatibility
Tested with:
Additional Information
Key porting decisions:
F.scaled_dot_product_attentionis not supported bytorch_neuronx.trace()— replaced with manualQ @ K^T * scale → softmax → @ Vpath (use_sdpa=False).vjepa2repo replaced with inline implementations. No runtime dependency on the upstream repo.repeat_interleaveboth compile natively on Neuron — no workarounds needed.Known limitations:
parallel_model_traceto split across NeuronCoresPerformance (single NeuronCore, batch=1, BF16, 16 frames, 384×384):
Related Issues
N/A — initial contribution.
vLLM Integration
Not applicable. V-JEPA 2.1 is a vision encoder, not a text generation model. It does not use KV cache, token generation, or autoregressive decoding.
By submitting this PR, I confirm that: