Skip to content

fix(vla_jepa): pair rotary frequencies with adjacent coordinates - #4835

Merged
Maximellerbach merged 2 commits into
huggingface:mainfrom
Afloat16:fix/vla-jepa-paired-rotary-frequencies
Oct 22, 2026
Merged

Maximellerbach merged 2 commits into
huggingface:mainfrom
Afloat16:fix/vla-jepa-paired-rotary-frequencies

Conversation

@Afloat16

@Afloat16 Afloat16 commented Oct 2, 2026 •

Copy link
Copy Markdown

Summary / Motivation

VLA-JEPA rotates adjacent query/key coordinate pairs, but repeats the frequency vector as two complete blocks. The two coordinates of a pair therefore use different angles, breaking RoPE's norm and relative-position inner-product invariants. For example, rotating [1, 2, 3, 4] at position 1 changes its norm from 5.4772 to 4.9628.

Repeat each frequency twice and retain the position axis. This also fixes broadcasting for a single frequency. The change is confined to the training-only world predictor.

Related issues and source

This applies the known pairwise correction proposed by echosprint in V-JEPA 2 #15. V-JEPA 2 #75 documented the issue while retaining the original expansion for released-checkpoint compatibility. The source and compatibility rationale are linked in the production helper and documentation.

This is separate from #4116 (multi-horizon world-model training) and #4814 (action-noise handling).

What changed

  • Match the sine/cosine layout to the existing adjacent-pair rotation.
  • Document the source of the correction and training compatibility. Parameter names and shapes are unchanged, but existing world-model checkpoints produce different predictor outputs and training losses with corrected positions. Pretrained quality has not been evaluated.
  • Keep the four existing world-model tests unchanged. The earlier additional 107-line test block was removed from the PR; the current diff contains only the production helper and documentation.

How was this tested

During preparation of 7f9f6d1 on Linux CPU/Python 3.12.14/PyTorch 2.9.1+cpu:

  • The four existing tests/policies/vla_jepa/test_world_model.py tests passed with native imports.
  • A separate isolated CPU regression harness passed 25 cases against the corrected helper; the original helper failed 21 and passed 4. It checks complex-pair values, norms, inner products, relative positions, gradients, attention and predictor backward behavior. This harness is not an added repository test file.

GPU execution, the complete repository test suite, full pretrained-checkpoint evaluation and closed-loop robot benchmarks were not run. The earlier broad local runs described in the initial body do not establish a full-suite pass for this final revision. The four upstream test/documentation/quality/security workflows require maintainer approval; hosted CI has not passed.

Checklist

Reviewer notes

Significant AI assistance was used for source analysis, implementation, testing and this description. Independent human review is not claimed. Ready for maintainer review of this scoped correction; pretrained model-quality and robot-performance improvements are unverified.

@Maximellerbach
Maximellerbach self-requested a review October 7, 2026 09:23

@Maximellerbach Maximellerbach left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Afloat16 Hey! what's the status on this PR? I still see it as a draft but it seems ready to review already.
You forgot to mention in the PR that the error orriginates from VJEPA2 and is already known.
I'm not against fixing it for this policy, but there should be a good traceability

Comment thread docs/source/policy_vla_jepa_README.md Resolved
Han-Shen-math added a commit to Han-Shen-math/lerobot that referenced this pull request Oct 10, 2026
Publish 18 original paired CUDA runs, unchanged raw archives and checkpoints, and frozen-checkpoint CPU diagnostics with exact feedback and dynamics-defect error decompositions. Preserve mixed outcomes and negative intervention findings. Component evidence accompanying huggingface#4835; production model code is unchanged. AI assistance was used for implementation, analysis and separate automated review.

Signed-off-by: ShenHan <132526278+Han-Shen-math@users.noreply.github.com>
@Han-Shen-math

Copy link
Copy Markdown

AI-assisted component validation and a mathematical diagnosis of mixed rollout results for this correction.

Reproducible scripts, complete logs, frozen checkpoints, checksums and the derivation are published here: study package, report.

I used the actual ActionConditionedVideoPredictor at pinned source commit b9cb121cb7d4e3e26ec5c906d08dda68d151ba52, reduced to 153,808 parameters. Only the two sin/cos expansion lines differ. Eighteen formal CUDA runs on an RTX 3070 Laptop / PyTorch 2.11.0+cu128 completed 1,000 steps each: three trajectory folds × three initialization seeds × two variants. Each pair shares initial weights, batches and episode splits; validation selects checkpoints. All selected checkpoints are at step 1,000, so convergence is not established. Data are synthetic, fixed position/action features with hidden velocity, not video-encoder latents or a full VLA.

Selected CUDA mathematical checks passed 8/8 for corrected and 2/8 for old (rotation, norm, same-position inner product, joint position shift, dim=2, reference input gradients, finite attention forward/backward and causal prefix). These are selected reference checks, not exhaustive backend or finite-difference gradcheck coverage.

Original CUDA feature MSE, lower is better Old Corrected Change
8-frame teacher-forced one-step 0.00439821 0.00413298 -6.03%
First 7 recursive predictions 0.04554162 0.04486660 -1.48%
All 15 recursive predictions 0.19014696 0.20038236 +5.38%

All nine pairs improve the primary one-step metric. All three cross-fold seed means worsen the 15-step recursive feature metric. The corrected horizon mean already becomes worse at prediction 7, still within the trained eight-frame input length.

Post-hoc CPU diagnosis uses all 18 frozen checkpoints, with no retraining. The exact decomposition recursive error = true-history residual + feedback-induced shift explains the feature-MSE difference: corrected minus old is -0.00018606 + 0.00978016 + 0.00064128 = +0.01023538, including the signed residual/shift cross term. Better true-history fit is outweighed by a larger feedback-shift term.

For decoded position, the generator has the exact recurrence p_next = 1.85*p_current - 0.85*p_previous + 0.15*action, with characteristic roots 1 and 0.85. Its impulse kernel permits an exact quadratic error decomposition. The corrected weighted individual-defect energy decreases by 0.00674760, but its cross-time defect term increases by 0.01309242, giving a net position-MSE increase of 0.00634482. Smaller individual errors can reinforce across time rather than cancel. This accounts for measured accumulation; it does not identify a unique neural cause or prove universal instability.

Eight-frame clipping retains relative degradation (+3.00%). Two-frame clipping and known-feature re-encoding flip the relative ranking, but are not established fixes: re-encoding worsens absolute position accuracy for both variants. All mixed/negative findings are retained.

Mac regeneration has a different data hash from Windows. Original CUDA recursive horizons reproduce numerically to maximum absolute MSE difference 2.37e-7; bit-identical data are not claimed. Separate automated replay and Gram-matrix audits checked all 2,430 horizon records and the error identities. These results do not establish statistical significance, pretrained-checkpoint compatibility, full-PR acceptance or robot-performance improvement. AI assistance was used for implementation, analysis and automated review; independent human review is not claimed. The original correction remains credited to this PR's author.

@github-actions github-actions Bot added documentation Improvements or fixes to the project’s docs policies Items related to robot policies labels Oct 14, 2026
@Afloat16

Copy link
Copy Markdown
Author

Thanks for the review. The current revision links V-JEPA 2 #15 and #75 in both the helper and the training-compatibility notes, credits the original correction, and removes the added test block as requested. The diff is now limited to the helper and documentation. Existing CPU world-model checks and focused mathematical regressions passed during preparation; the final files also pass pinned Ruff and Prettier. Checkpoint-quality and robot-performance improvements remain unverified.

The PR is now ready for review.

@HuggingFaceDocBuilderDev

Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@Maximellerbach
Maximellerbach merged commit f9e9d73 into huggingface:main Oct 22, 2026
13 checks passed
@ravediamond

Copy link
Copy Markdown
Collaborator

Follow-up on #4835 (pairwise rotary frequencies in the VLA-JEPA world predictor), on the docs line saying pretrained
world-model quality "needs separate evaluation when continuing training". I measured it on one checkpoint.

Setup:

  • Checkpoint: ravediamond/vla_jepa_so101_bowls_trimmed, a VLA-JEPA fine-tune trained with the world model on, before
    fix(vla_jepa): pair rotary frequencies with adjacent coordinates #4835 (legacy rotary).
  • Data: 200 windows (8 per episode) from 25 held-out episodes of its own dataset, ravediamond/so101_bowls_all_trimmed.
  • For each window the encoders and Qwen run once. Then only the predictor runs twice on the same tensors: with the old
    expansion patched back in (bit-identical to 2e88044) and with main (d3793b7). Baseline: predict each next
    position with the current one.
  • The loss is _world_model_loss's L1. Paired bootstrap over episodes, 2000 resamples.
world-model L1
old rotary 1.175
new rotary (main) 1.731
copy last position 2.235

new / old = 1.47 (95 % CI 1.46 to 1.48), new − old = +0.556 (0.547 to 0.564). The new rotary is worse on 25 of 25
episodes and at every predicted position. It still beats copy-last (−0.505, CI −0.508 to −0.501).

So continuing training from an existing checkpoint (the documented --policy.path=lerobot/VLA-JEPA-Pretrain recipe)
starts the world-model loss about half way back to the copy-last baseline. Upstream V-JEPA 2 kept the old expansion
for its released checkpoints (facebookresearch/vjepa2#75).

Suggestion: an opt-in config flag, for example world_model_rope_legacy: bool = False, that selects the old
expansion in rotate_queries_or_keys. Checkpoints trained before #4835 can then set it in their config, new training
keeps the fixed version, and nothing changes by default. I can open a PR with the flag and a parity test against
2e88044 if that sounds useful.

Caveat: one checkpoint (a small SO-101 fine-tune), evaluated on its own training distribution. I could not run
lerobot/VLA-JEPA-LIBERO on the Jetson I used (disk), so the LIBERO numbers are still missing.

Reproduce (Jetson Orin NX, lerobot d3793b7 and 2e88044 checked out side by side):

PYTHONPATH=<d3793b7>/src python eval_rope_compat.py checks  --ckpt <snapshot> --root <so101_bowls_all_trimmed> --split split.json --prefix-tree <2e88044> --out checks.json
PYTHONPATH=<d3793b7>/src python eval_rope_compat.py compare --ckpt <snapshot> --root <so101_bowls_all_trimmed> --split split.json --windows-per-episode 8 --out results.json

Script: https://github.com/ravediamond/paper-vs-hardware/blob/main/posts/2026-10-26-vla-jepa-rope-compat/scripts/eval_rope_compat.py

Maximellerbach pushed a commit that referenced this pull request Nov 2, 2026
…d before #4835 (#5098)

* feat(vla_jepa): opt-in world_model_rope_legacy for checkpoints trained before #4835

* test(vla_jepa): drop the rope-legacy tests, as asked in review
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or fixes to the project’s docs policies Items related to robot policies

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants