cpp_jepa
Python bindings for jepa.cpp — CPU (and optional CUDA) inference for the JEPA family: I-JEPA, V-JEPA 2, V-JEPA 2.1, LeJEPA, LeVJEPA, LeWorldModel and H-JEPA. One GGUF file in, numpy arrays out.
The package is a thin wrapper over the C API in include/jepa.h. The engine, the preprocessing —
the bit-exact torchvision-style resize the golden fixtures were generated against — and every
floating-point operation are on the C side; Python only marshals arguments and copies results into
numpy. python/tests/test_parity.py gates that: on a CPU the bindings reproduce
build/jepa-embed's output bit for bit.
Install
From a recursive clone, with a compiler and CMake on the machine:
git clone --recursive https://github.com/aselimc/jepa.cpp && cd jepa.cpp
pip install ./python # -march=native, matching the repository's own build/
The package bundles one self-contained shared library (libjepa plus ggml, linked whole), so there is no ggml to install.
These bindings are not on PyPI yet; they will be published as cpp_jepa, imported as jepa_cpp.
jepa-cpp on PyPI is an unrelated project, so pip install jepa-cpp does not install this package.
An installed package can also be pointed at a library you built yourself, which is how the parity
tests make the bindings and build/jepa-embed the very same code:
export JEPA_CPP_LIB=/path/to/libjepa.so
A few lines
import jepa_cpp, numpy as np
with jepa_cpp.Model("models/gguf/lejepa-vits16-pretrain-in1k-f16.gguf", threads=8) as m:
print(m.family, m.embed_dim, m.file_type_name) # hfvit 384 f16
tokens = m.encode("cat.jpg") # [197, 384] float32, every token
feature = m.encode("cat.jpg", pool="cls") # [384]
batch = m.encode(["cat.jpg", "dog.jpg"], pool="cls") # [2, 384], one encoder graph
with jepa_cpp.Model("models/gguf/vjepa2-vitl-fpc16-256-ssv2-f16.gguf", threads=32) as m:
clip = np.load("clip.npy") # uint8 [T, H, W, 3]
print(m.classify(clip).top(5)) # [(index, label, probability), ...]
with jepa_cpp.Model("models/gguf/ant_hjepa_l3-seed42-f16.gguf", threads=32) as m:
plan = m.hjepa_plan(m.hjepa_states("now.png"), m.hjepa_states("goal.png"))
print(plan.actions.shape) # level-1 actions, z-scored
What is on Model
Model(path, device=…, threads=…, flash_attn=…, flash_kv=…, max_batch=…, verbose=…) |
load and build a context; device is "cpu", "cuda:0", an index, or None to follow $JEPA_DEVICE |
encode(x, pool=None, as_video=None) |
one item → [n_tokens, dim], a list → [batch, n_tokens, dim]; pool="mean" / "cls" / "lewm" collapses each to [dim] |
pool(tokens, mode), preprocess(x), load_image(path), token_grid(t, h, w) |
the pieces encode is made of |
classify(x) |
attentive-pool head → Classification(logits, probs, pooled, labels) with .top(k) |
predict(tokens, target, context, mask_index=1, modality="video") |
the masked predictor → [n_target, out_dim] |
lewm_project(tokens), lewm_project_rows(rows), lewm_predict(embs, actions), lewm_rollout(embs, actions, n_steps) |
the LeWorldModel path |
hjepa_states(image, proprio=None), hjepa_embed, hjepa_lift, hjepa_action_embed, hjepa_action_encode, hjepa_predict, hjepa_rollout |
the H-JEPA world models; levels are 1-based |
hjepa_plan(states, goals, levels=None, randn=None), hjepa_solve, hjepa_plan_cost, hjepa_horizons, hjepa_default_levels() |
the H-JEPA planner; jepa_cpp.hjepa_level_plan(**fields) makes one level's settings |
hjepa_n_levels, hjepa_embed_dim(level), hjepa_action_dim(level), hjepa_action_embed_dim(level), hjepa_stride(level), hjepa_n_frames(level), hjepa_proprio_dim, hjepa_raw_action_dim, hjepa_frameskip, hjepa_norm_stats(column), hjepa_action_prior(level) |
a hierarchy's shape and training statistics |
family, name, embed_dim, patch_size, tubelet_size, img_size, n_frames, n_layer, n_head, has_cls, n_registers, n_prefix_tokens, has_predictor, has_head, has_projector, n_classes, labels, file_type, file_type_name, n_bytes, device, device_name, is_gpu, is_video |
the model |
threads, max_batch, last_batch, last_compute_ms, mul_mat_prec_f32 |
the context |
Module level: jepa_cpp.version(), jepa_cpp.devices(), jepa_cpp.system_info(),
jepa_cpp.library_path(), and jepa_cpp.JepaError, which carries the text the C library logged
for the failure.
Every C entry point is also reachable unwrapped as jepa_cpp._api.jepa_*, with the header's own
signatures and its own conventions (0 / -1 return codes, jepa_free on returned buffers).
tests/test_api_coverage.py parses include/jepa.h and fails if any of them is missing.
Images, clips and batches
encode follows jepa-embed's rules so that the two agree:
- a path, a
uint8 [H, W, 3]array, or a preprocessedfloat32 [3, T, H, W]array is one item; - a
uint8 [T, H, W, 3]array is one clip; - a list is a batch of independent items — unless the model is a video family and the list is
longer than one, or
as_video=True, in which case the entries are the frames of a single clip and may have different sizes; - a still image through LeVJEPA is repeated to the trained clip length, because that is how its
model card feeds one.
jepa_encodeitself never repeats: a one-frame clip stays a one-frame clip.
Image families fold up to max_batch items (default 32) into one encoder graph, which is
bit-identical to encoding them one at a time and considerably faster. Video families run one clip
per graph.
Threads and lifetime
A Model owns one jepa_context, which is per-thread compute state in C, so calls on it are
serialised on a lock: sharing a Model between Python threads is safe but not concurrent. Give
each thread its own Model, or raise threads to parallelise inside one graph. Model is a
context manager; close() frees the weights and is idempotent.
Tests
pip install -e ".[test]" && pytest tests
tests/test_parity.py is the one that matters: it runs build/jepa-embed and
build/jepa-worldmodel as subprocesses and requires the bindings' arrays to match theirs bit for
bit on a CPU, then compares both to the PyTorch golden dumps in tests/fixtures/ref/ with the same
per-family, per-dtype bars tests/test-parity.cpp uses. tests/test_hjepa.py holds H-JEPA, planner included, to the authors' reference dumps and to
build/jepa-plan; tests/test_api_coverage.py parses include/jepa.h and fails when an entry point
is unbound, and CI runs it on every push; tests/test_model_api.py covers lifetime, argument
checking and error text. GGUF files and golden dumps are not in the repository,
so a test whose assets are missing skips.
Licence
MIT, the same as jepa.cpp.
Metadata
Release files for cpp-jepa 0.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cpp_jepa-0.5.0-py3-none-manylinux_2_28_x86_64.whl | Python 3 | none | Linux glibc 2.28+ x86-64 | Details for cpp_jepa-0.5.0-py3-none-manylinux_2_28_x86_64.whl |
| cpp_jepa-0.5.0-py3-none-macosx_11_0_arm64.whl | Python 3 | none | macOS 11.0+ ARM64 | Details for cpp_jepa-0.5.0-py3-none-macosx_11_0_arm64.whl |
Total release size: 2.5 MB
Release files / cpp_jepa-0.5.0-py3-none-manylinux_2_28_x86_64.whl
| Download URL | cpp_jepa-0.5.0-py3-none-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 1.2 MB |
| Tags | Linux glibc 2.28+ x86-64 Python 3 |
|
SHA-256 checksum How to use checksums |
c36ec18cdac7fd25708fe8a6b8980ccc85c06ffdb0d2618ae10ad3d4418816ec
|
|
BLAKE2b-256 checksum How to use checksums |
531a21b25f3253fc06f454a97fb5d8b84bb3d8031d342986e97ca26005b5061d
|
| 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 Nov 1, 2026.
Transparency logRelease files / cpp_jepa-0.5.0-py3-none-macosx_11_0_arm64.whl
| Download URL | cpp_jepa-0.5.0-py3-none-macosx_11_0_arm64.whl |
|---|---|
| Size | 1.2 MB |
| Tags | Python 3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
50e8223da738110b11b7b875d2cbb10818b3bdf21da521e6dee3d92430782e9a
|
|
BLAKE2b-256 checksum How to use checksums |
6ab34f42756240087da077714463c0f08fcbed5857a4713004a9b999d591b1fa
|
| 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 Nov 1, 2026.
Transparency logSecurity for cpp-jepa 0.5.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 cpp_jepa-0.5.0-py3-none-manylinux_2_28_x86_64.whl
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 Nov 1, 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.