CleanJepa
Readable, hackable JEPAs and latent world models in plain PyTorch.
First exam · Quick start · Methods · Library · Roadmap · Contributing
A JEPA learns by predicting the representation of what it cannot see, instead of reconstructing pixels. JEPA world models go one step further: they predict the next latent state from an action, then plan by searching for actions whose predicted future matches a goal image. CleanJepa builds both:
- Plain PyTorch. Only
torch. No trainer classes, no config system, no custom runtime. - One file per recipe. The whole training loop in view, from data to
optimizer.step(). - Reusable blocks. Encoders, predictors, regularizers, planners, and evaluation, each usable on its own, with documented tensor shapes.
- Fast. SDPA flash attention,
torch.compile, mixed precision, fused AdamW, and multi-GPU withtorchrun.
World model's first exam
- Trains on an RTX 3060. One consumer GPU, minutes per level instead of days.
- Six levels, six problems. Movement, walls, distractors, contact, randomness, hidden state.
| Level | Dataset | World | What it tests |
|---|---|---|---|
| L0 | grid9-l0-empty | Empty board | Plain movement |
| L1 | grid9-l1-maze | S-maze | Walls that force detours |
| L2 | grid9-l2-distractor | Maze with flicker and a drifting square | Ignoring motion the actions do not cause |
| L3 | grid9-l3-push | One pushable block | Sparse contact, irreversible corners |
| L4 | grid9-l4-stochastic | Moves slip half the time | Two-outcome dynamics |
| L5 | grid9-l5-wind | Hidden per-episode wind | Partial observability |
Each model trains with train_wm.py --preset <method> --frameskip 1 (10 epochs) and plans with
eval_grid9.py (CEM MPC on 50 start/goal tasks per level). Raw results, training logs, and the
exact commands: CleanJepa/results.
Quick start
Train LeWM on Grid9 L1 (the maze), then plan with it:
git clone https://github.com/HappyFox001/CleanJepa.git && cd CleanJepa
pip install -e ".[wm]"
python recipes/train_wm.py --preset lewm --data CleanJepa/grid9-l1-maze/grid_l1.h5 --frameskip 1 \
--amp bf16 --save-dir runs/grid9_l1
python recipes/eval_grid9.py --ckpt runs/grid9_l1/epoch_10.pt --level l1
Methods
LeWMtrain_wm.py --preset lewmViTEncoder · ARPredictor · SIGReg (LeJEPA) |
LpWMtrain_wm.py --preset lpwmRDMReg (Rectified LpJEPA) |
VICReg world modeltrain_wm.py --preset vicregVICReg |
DINO-WMtrain_wm.py --preset dino-wmFrozenDINOv2Encoder |
Token world modeltrain_wm.py --rep patches --head residualTokenPredictor (joint or factorized) |
V-JEPA 2-ACtrain_vjepa2_ac.pyACPredictor · VJEPA2ACWorldModel |
I-JEPAtrain_ijepa.pyViTEncoder · EMAEncoder |
V-JEPAtrain_vjepa.pyVideoViTEncoder · EMAEncoder |
World models plan with CEMSolver, MPPISolver, or GradientPlanner. Each recipe lists its
differences from the official code in its docstring.
Use it as a library
The library is on PyPI and needs only PyTorch; the recipes stay in the repository.
pip install cleanjepa
import torch
from cleanjepa import CEMSolver, JEPAWorldModel, SIGReg, ViTEncoder
encoder = ViTEncoder(img_size=224, patch_size=14, embed_dim=192, depth=12, heads=3)
model = JEPAWorldModel(encoder, action_dim=10, embed_dim=192, history_size=3)
sigreg = SIGReg()
pixels = torch.randn(8, 4, 3, 224, 224) # (B, T, C, H, W)
actions = torch.randn(8, 4, 10) # (B, T, A)
emb = model.encode_pixels(pixels) # (B, T, D)
pred = model.predict(emb[:, :3], model.encode_actions(actions)[:, :3])
loss = (pred - emb[:, 1:]).pow(2).mean() + 0.09 * sigreg(emb)
loss.backward()
# Plan 5 action blocks that move the last frame towards a goal image.
planner = CEMSolver(model, horizon=5, num_samples=300, topk=30)
plan = planner.plan(pixels[:, :1], pixels[:, 3:], action_dim=10) # (B, 5, A)
Repository layout
cleanjepa/ The library: models, regularizers, planners, data, evaluation (torch only)
recipes/ One script per task: training, probing, planning evaluation, benchmarking
tests/ Fast CPU tests, one file per area
Learn more
- ROADMAP.md: goals and directions
- CONTRIBUTING.md: adding a method and reporting results
Citation
@software{cleanjepa,
title = {CleanJepa: Readable JEPAs and Latent World Models in PyTorch},
author = {{CleanJepa contributors}},
url = {https://github.com/HappyFox001/CleanJepa},
year = {2026}
}
Acknowledgements
CleanJepa builds on the papers and official code of LeWM, LeJEPA, DINO-WM, LpWM, Rectified LpJEPA, I-JEPA, V-JEPA, and VICReg, and on the design of nanoGPT and CleanRL.
License
Metadata
Release files for cleanjepa 0.2.0
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 |
|---|---|---|---|---|
| cleanjepa-0.2.0.tar.gz | 99.3 kB | With provenance | Details for cleanjepa-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cleanjepa-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for cleanjepa-0.2.0-py3-none-any.whl |
Total release size: 165.1 kB
Release files / cleanjepa-0.2.0.tar.gz
| Download URL | cleanjepa-0.2.0.tar.gz |
|---|---|
| Size | 99.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9eefac6d7579a6dd4a3c6429d6581f41d73b72e98d6212218221d84b89027c4b
|
|
BLAKE2b-256 checksum How to use checksums |
4e7da9c8ceebef1a9925c6ffc52d1e42c2e3352a6869c4b24670295489ac4d45
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 4, 2026.
Transparency logRelease files / cleanjepa-0.2.0-py3-none-any.whl
| Download URL | cleanjepa-0.2.0-py3-none-any.whl |
|---|---|
| Size | 65.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9a929d5182014b9344a98b3f8f5a72df0b08d88fd444212f918f8a2402f0ed90
|
|
BLAKE2b-256 checksum How to use checksums |
3179359febc36f2bea0ab45b7f12f4335b537afe0f15a83cfa526ec9ed25ea79
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 4, 2026.
Transparency logSecurity for cleanjepa 0.2.0
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for cleanjepa-0.2.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 4, 2026.
Transparency logA 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.