Skip to content

Fix touch sensors under nested vmap - #3574

Open
sylvesterkaczmarek wants to merge 1 commit into
google-deepmind:mainfrom
sylvesterkaczmarek:fix/mjx-nested-vmap-touch
Open

sylvesterkaczmarek wants to merge 1 commit into
google-deepmind:mainfrom
sylvesterkaczmarek:fix/mjx-nested-vmap-touch

Conversation

@sylvesterkaczmarek

Copy link
Copy Markdown
Contributor

Fixes #3209.

Summary

Fix touch-sensor evaluation under nested jax.vmap by avoiding matrix multiplication in the contact-to-site coordinate transform. JAX's matmul batching rule can reorder nested batch dimensions in this path, producing an invalid dot_general shape.

The replacement uses equivalent elementwise products followed by a reduction over the vector dimension, preserving arbitrary leading batch axes.

A regression test uses the existing touch-sensor fixture under a 2 × 4 nested vmap and checks that the batched sensor output matches repeated unbatched evaluation.

Testing

  • pytest mjx/mujoco/mjx/_src/sensor_test.py -q → 11 passed
  • focused nested-vmap regression after minimizing the diff → 1 passed, 10 deselected
  • pyink --check --fast mjx/mujoco/mjx/_src/sensor_test.py
  • git diff --check

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MJX JAX backend: dot_general batch dimension transposition under nested vmap

1 participant