Repository navigation
Conversation
…a joint When a trajectory's joints don't exactly match the model's, for example after adding a joint to a model or with motions prepared for a slightly different skeleton, `TrajectoryHandler.filter_and_extend` adds or removes joints with `add_joint()` and `remove_joints()`, which default to `jnp`. For a numpy trajectory, `qpos` then comes back JAX while every other field, `split_points` included, stays numpy. `is_numpy` is judged on `qpos` alone, so the environment skips `to_jax()`, and the first jitted call that indexes `split_points` fails with a `TracerArrayConversionError`, which is hard to trace back to the joint mismatch.
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.
When a trajectory's joints don't exactly match the model's, for example after adding a joint to a model or with motions prepared for a slightly different skeleton,
TrajectoryHandler.filter_and_extendadds or removes joints withadd_joint()andremove_joints(), which default tojnp. For a numpy trajectory,qposthen comes back JAX while every other field,split_pointsincluded, stays numpy.is_numpyis judged onqposalone, so the environment skipsto_jax(), and the first jitted call that indexessplit_pointsfails with aTracerArrayConversionError, which is hard to trace back to the joint mismatch.This PR passes the data's own backend to those calls (four lines in
loco_mujoco/trajectory/handler.py); the default staysjnpfor every other caller.tests/unit/test_trajectory_handler_backend.pycovers a missing and an extra joint, with the full and the sparse cache: on main (47b653d) all four fail, and with the change all four pass.add_bodyandadd_sitehave the same default, butmaterialize_trajectoryrebuilds those fields right after, so I left them alone.Let me know what you think,
Flavio