Add JEPA / V-JEPA 2 / LeWorldModel HF adapter#1
Merged
Conversation
Adds full support for joint-embedding predictive world models so users can download and convert them like any other HF family. New `JepaAdapter` (n_orca/hf/adapters/jepa.py) normalizes two unrelated config schemas into one encoder -> predictor DAG: - Flat HF transformers configs: V-JEPA 2 (vjepa2 / VJEPA2Model) and I-JEPA (ijepa / IJepaModel), with pred_* predictor fields. - Nested Hydra configs: LeWorldModel (quentinll/lewm-*), which ship no model_type and are matched structurally. The graph parses the ViT encoder and the joint-embedding predictor (distinct widths/depths), a latent bridge between them, optional additive action conditioning, and an optional projector head. It emits two latent outputs (encoder_latents, predicted_latents) that share the encoder's embedding space, so a single output_shape invariant enforces latent-dim consistency. Mask tokens, the EMA stop-gradient target, SIGReg, and rotary/sincos positions are captured as verification rules + hyperparameters (mirroring how the LLaMA adapter treats RoPE/RMSNorm), keeping the output round-trippable and compilable. Op library: add TubeletEmbed (Conv3d, video) and PatchEmbed (Conv2d, image) patch embedders with shape inference + param counting; the verifier's param count matches PyTorch exactly. Add a `prefix=` arg to pre_norm_decoder_block so encoder and predictor stacks don't collide (default reproduces prior names byte-for-byte). CLI: `n-orca hf download --include-processor` also fetches preprocessor / video_preprocessor configs (V-JEPA ships the latter). Examples: vjepa2.n.orca.md (V-JEPA 2 ViT-L, 326M params) and lewm-pusht .n.orca.md (action-conditioned LeWorldModel), each with a matching .mmd — verified byte-identical to live-Hub `hf convert` output. Tests: +22 covering the new ops, dispatch (incl. structural LeWM detection), clean verify, parser round-trip, Mermaid, and torch forward passes for video V-JEPA 2, encoder-only I-JEPA, and action-conditioned LeWM. Full suite: 140 passing (was 118). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- Expand the LeWM Hydra-detection docstring/comments so the structural fallback path (encoder+predictor dict pair, no model_type) is obvious to future maintainers. - README: "SIGReg (latent regularizer)" for clarity in the family table. No behavior change; 140 tests still pass and example files are byte-stable. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
New backward-compatible feature: JepaAdapter + TubeletEmbed/PatchEmbed ops + `hf download --include-processor`. Minor version bump under semver. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
What
Adds full support for JEPA-family joint-embedding world models so users can
hf download/hf convertthem like any other family. Primary focus: V-JEPA 2 (facebook/vjepa2-*) and LeWorldModel (quentinll/lewm-*); also covers I-JEPA (facebook/ijepa_*).n-orca hf convert facebook/vjepa2-vitl-fpc64-256 --out vjepa2.n.orca.md --mermaid vjepa2.mmd n-orca verify vjepa2.n.orca.md # VALID params=325,967,488 depth=222 n-orca hf convert quentinll/lewm-pusht --out lewm-pusht.n.orca.mdNew
JepaAdapter(n_orca/hf/adapters/jepa.py)Normalizes two unrelated config schemas into one encoder → predictor DAG:
transformersconfigs — V-JEPA 2 (vjepa2/VJEPA2Model) and I-JEPA (ijepa/IJepaModel), withpred_*predictor fields.quentinll/lewm-*), which ship nomodel_typeand are matched structurally (_target_+ nestedencoder/predictordicts).The graph parses the ViT encoder, the joint-embedding predictor (distinct width/depth), a latent bridge between them, optional additive action conditioning, and an optional projector head. It emits two outputs —
encoder_latents(the representation) andpredicted_latents(the forecast) — that share the encoder's embedding space, so a singleoutput_shapeinvariant enforces latent-dim consistency.Mask tokens, the EMA stop-gradient target, SIGReg, and rotary/sincos positions are captured as
verification rules+ hyperparameters (mirroring how the LLaMA adapter treats RoPE/RMSNorm), keeping output round-trippable and compilable.Supporting changes
TubeletEmbed(Conv3d, video) andPatchEmbed(Conv2d, image) patch embedders with shape inference + param counting. Verifier param count matches PyTorch exactly (11,943,104 for LeWM).pre_norm_decoder_blockgains aprefix=arg so encoder/predictor stacks don't collide (default reproduces prior names byte-for-byte).n-orca hf download --include-processoralso fetchespreprocessor_config.json/video_preprocessor_config.json(V-JEPA ships the latter).examples/hf-generated/vjepa2.{n.orca.md,mmd}(V-JEPA 2 ViT-L, 326M params) andlewm-pusht.{n.orca.md,mmd}(action-conditioned). Verified byte-identical to live-Hubhf convertoutput.TubeletEmbed/PatchEmbedin the op table; download/convert examples.Testing
140 passing(was 118). +22 tests: new ops, dispatch (incl. structural LeWM detection with nomodel_type), clean verify, parser round-trip, Mermaid branch rendering, and torch forward passes for video V-JEPA 2 (5D(B,C,T,H,W)clip), encoder-only I-JEPA, and action-conditioned LeWM. The exact target commands were run against the live Hub.🤖 Generated with Claude Code