jepa-playground
This repo serves as a playground for me to explore and implement a variety of jepa variants in an attempt to understand.
All code handwritten by refering to the papers below and their associated code bases.
JEPA Variants
1. I-JEPA — Image JEPA
Paper: Self-Supervised Learning from Images with a Joint-Embedding Predictive Architecture (Assran et al., 2023)
2. V-JEPA — Video JEPA
Paper: V-JEPA: Latent Video Prediction for Visual Representation Learning (Bardes et al., 2024)
3. V-JEPA 2
Paper: V-JEPA 2: Self-Supervised Video Models Enable Understanding, Prediction and Planning (Meta, 2025)
Repo Layout
jepa-playground/
├── jepa_playground/
│ ├── encoder.py
│ ├── predictor.py
│ ├── ema.py
│ ├── masking/
│ │ ├── block.py
│ │ └── tube.py
│ └── variants/
│ ├── ijepa/
│ │ ├── model.py
│ │ └── train.py
│ ├── lejepa/
│ │ ├── model.py
│ │ └── train.py
│ ├── vjepa/
│ │ ├── model.py
│ │ └── train.py
│ └── vjepa2/
│ └── train.py
├── tests/
├── experiments/
├── reference/
└── pyproject.toml
Shared Architecture (jepa_playground/)
All variants share a common skeleton.
jepa_playground/
├── encoder.py
├── predictor.py
├── ema.py
└── masking/
├── block.py
└── tube.py
Setup
uv sync
uv run *
Overrides
Every train script and plan.py takes a YAML config followed by section.key=value overrides. A key
must already exist in the config and the value must keep its type, so a typo stops the run with an error.
uv run python -m jepa_playground.variants.ijepa.train jepa_playground/variants/ijepa/configs/cifar10_IJEPA.yaml optimization.lr=3e-4 data.fake_data=true
Runs
Each training run writes to runs/<name>/: config.yaml (the config as run), meta.json (git commit,
command line, versions, device), metrics.jsonl (one line per log step) and ckpt.pt. The name comes
from run.name and can be used once; pick another with run.name=.... run.seed seeds the run.
uv run python -m jepa_playground.variants.ijepa.train jepa_playground/variants/ijepa/configs/cifar10_IJEPA.yaml run.name=ijepa_lr3e-4 optimization.lr=3e-4
I-JEPA trains on CIFAR-10 by default; data.dataset=cifar100 trains it on CIFAR-100, downloaded to data/ on first use.
uv run python -m jepa_playground.variants.ijepa.train jepa_playground/variants/ijepa/configs/cifar10_IJEPA.yaml data.dataset=cifar100 run.name=ijepa_cifar100
Image data
I-JEPA and LeJEPA read data.dataset: cifar10, cifar100, imagenette (all downloaded to data.data_dir on first
use) or folder, your own images. A folder holds one sub-folder per class under train/ and under test/ or val/.
Images of any size are resized and centre-cropped to model.image_size.
uv run python -m jepa_playground.variants.lejepa.train jepa_playground/variants/lejepa/configs/imagenette_LeJEPA.yaml data.dataset=folder data.data_dir=path/to/images run.name=lejepa_mine
data.augmentations lists the random transforms of each training image, or for the video variants each clip, in
order, with their settings. Each name is a
key of AUGMENTATIONS in jepa_playground/data/images.py. An override changes one setting:
uv run python -m jepa_playground.variants.lejepa.train jepa_playground/variants/lejepa/configs/cifar10_LeJEPA.yaml data.augmentations.gaussian_blur.p=0
imagenette_LeJEPA.yaml is the setup of the LeJEPA authors' minimal example: a ViT-S/8 on 128-pixel Imagenette.
V-JEPA 2 also saves ckpt-pretrain.pt. To run only the cooldown, set pretrain_checkpoint=runs/<name>/ckpt-pretrain.pt.
V-JEPA and V-JEPA 2 hold data.test_fraction (10%) of each class's Kinetics videos out of training to test on, the
same videos in every run. data.test_fraction=0 trains on all of them and leaves the run nothing to evaluate on.
To continue an interrupted run from its last checkpoint, rerun the same command with run.resume=true. It ends with
the same weights and metrics as a run that was never interrupted. Only run.dir, data.data_dir and
logging.log_every may differ from the original command; any other change is refused.
Benchmark
jepa_playground.bench times a config's training step and its data pipeline separately.
It takes the same overrides; V-JEPA 2 configs also need --phase pretrain or --phase cooldown.
uv run python -m jepa_playground.bench jepa_playground/variants/ijepa/configs/cifar10_IJEPA.yaml --out result.json
Features
jepa_playground.eval.features runs a trained model's target encoder over its run's images or videos, without
augmentation and on the centre clip of each video, and caches the mean-pooled features and labels as
runs/<name>/features-<split>.pt. It prints their spread and effective rank. V-JEPA 2 is evaluated at the clip length
of its cooldown, the phase that saves ckpt.pt.
Training logs the same two signs of collapse at each log step as emb_std, emb_std_min and emb_rank.
uv run python -m jepa_playground.eval.features runs/ijepa_cifar10 --split test
A checkpoint outside a run directory works too, given the config it was trained with. Nothing is cached for it.
uv run python -m jepa_playground.eval.features --checkpoint old/ijepa.pt --config old/ijepa.yaml
Probes
jepa_playground.eval scores a run's cached train and test features with a kNN probe and
a linear probe.
It prints each test accuracy and writes runs/<name>/result-knn.json and result-linear.json.
probe=knn can be used to select only one.
uv run python -m jepa_playground.eval runs/ijepa_cifar10 probe=knn,linear
A video run works the same way. Its kNN and linear numbers come from mean-pooled features of one clip per video, so they are not the attentive-probe numbers the V-JEPA papers report.
uv run python -m jepa_playground.eval runs/vjepa_kinetics400
To watch the representation while I-JEPA, V-JEPA or V-JEPA 2 trains, eval.online_probe=true trains a linear head
on the target encoder's detached embeddings beside the main loss and logs probe_loss and probe_acc at each log
step. eval.knn_every=N logs the kNN test accuracy as knn_acc every N epochs (of each phase, for V-JEPA 2).
Neither changes the training: with the same seed, the weights and loss curve match a run without them.
uv run python -m jepa_playground.variants.ijepa.train jepa_playground/variants/ijepa/configs/cifar10_IJEPA.yaml eval.online_probe=true eval.knn_every=10
Results
jepa_playground.results prints a table of the result files in the run directories you give it. Runs that differ
only in their run section, such as the seed, become one row with the mean, standard deviation and 95% confidence
half-width of each metric.
uv run python -m jepa_playground.results runs/*
Add a method
A method is one folder with a train module and a config. tests/toy_method/ is a complete one in about 90 lines, and
tests/test_toy_method.py runs it through every tool below.
- Write a train module with three functions:
build(config, device, phase=None)returns the model, its optimiser and the training loader.training_step(model, batch, step)returns a dict of scalars."loss"is the one to backpropagate.load_split(config, split, phase=None)returns thetrainortestdata with labels and no augmentation. Leave it out if the data has no labels; the method then trains and benchmarks but cannot be probed.
- Give the model an
encode(inputs)method that returns tokens of shape[B, N, D]for unmasked inputs. - Write the training loop in the same module with the helpers in
jepa_playground/run.py:start_run,load_checkpoint,seed_epoch,logandsave_checkpoint. A checkpoint holdsmodel,epochandstep. - Write a config with a top-level
variantkey and theruntime,run,dataandoptimizationsections the toy config has. - Add one line to
VARIANTSinjepa_playground/variants/__init__.pythat maps the variant name to the train module.
The method then works with the shared tools, with no other file edited:
uv run python -m tests.toy_method.train tests/toy_method/config.yaml
uv run python -m jepa_playground.bench tests/toy_method/config.yaml
uv run python -m jepa_playground.eval runs/toy
uv run python -m jepa_playground.results runs/toy
These four commands need the VARIANTS line "toy": "tests.toy_method.train", which the test adds for itself.
Add a component
A component is a part a method picks by name in its config. The registries are in jepa_playground/components.py
and jepa_playground/targets.py.
| Config key | Registry | What to write |
|---|---|---|
model.encoder |
ENCODERS |
a module whose forward(x, keep_idx=None) returns tokens [B, N, D], with a grid_size |
model.predictor |
PREDICTORS |
a module whose forward(context, context_idx, target_idx) returns [B, M, D] |
loss.prediction |
PREDICTION_LOSSES |
a function of (prediction, target) that returns a scalar |
loss.target |
TARGETS |
a Target that says whether the target encoder is a copy and whether it gets a gradient |
loss.regularizer |
REGULARIZERS |
a function of (embeddings [N, D], step) that returns a scalar |
- Write the part beside the ones that exist, for example a new function in
jepa_playground/regularizers.py. - Add one line to its registry that maps a name to it.
- Pick it with an override:
uv run python -m jepa_playground.variants.ijepa.train jepa_playground/variants/ijepa/configs/cifar10_IJEPA.yaml loss.target=stopgrad loss.regularizer=sigreg
Other Resources
Metadata
Release files for jepa-playground 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| jepa_playground-0.0.1.tar.gz | 176.9 kB | Without provenance | Details for jepa_playground-0.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| jepa_playground-0.0.1-py3-none-any.whl | Python 3 | none | any | Details for jepa_playground-0.0.1-py3-none-any.whl |
Total release size: 269.2 kB
Release files / jepa_playground-0.0.1.tar.gz
| Download URL | jepa_playground-0.0.1.tar.gz |
|---|---|
| Size | 176.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
58ac6e4e15ca857567958d59f047a3bbc364b6826f2e55f37777e51df34debe4
|
|
BLAKE2b-256 checksum How to use checksums |
5bcfa9b0fdaa6d85b405686cff9890807debd8c93c53cd5c22392fdc0f2bb558
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.32 {"installer":{"name":"uv","version":"0.11.32","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / jepa_playground-0.0.1-py3-none-any.whl
| Download URL | jepa_playground-0.0.1-py3-none-any.whl |
|---|---|
| Size | 92.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d995cbb6debcceaf6bc06796304732e74f26ddf346b3bba75938747b41cdfbb6
|
|
BLAKE2b-256 checksum How to use checksums |
7f1ea537f3d7d5229880f3a672603d921fc4063b36ae9643fa900364d0d47e3e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.32 {"installer":{"name":"uv","version":"0.11.32","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for jepa-playground 0.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.