[Feature] MuJoCo custom envs with selectable physics backend#3700
Merged
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/rl/3700
Note: Links to docs will display an error until the docs builds have been completed. This comment was automatically generated by Dr. CI and updates every 15 minutes. |
4 tasks
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.
Summary
torchrl/envs/custom/mujoco/-- a baseMujocoEnv(EnvBase, abc.ABC)plus 5 task subclasses (HumanoidEnv,AntEnv,Walker2dEnv,HopperEnv,SatelliteEnv).mujoco-torch(default; native torch + vmap,torch.compile-friendly),mjx(JAX-vmap+jit, DLPack-bridged),mujoco(C-bindings, single-env, composed viaParallelEnv/SerialEnvthrough a metaclass).from_pixels=True/pixel_only/render_width/render_height/camera_id. Torch backend uses mujoco-torch's pure-torch ray-cast renderer; mjx/mujoco usemujoco.Renderer.Design
The satellite task uses a manipulability-based singularity penalty (
r = -|q_err| - lambda_s/sqrt(det(J J^T) + eps) - lambda_u * |a|^2) over a 4-CMG pyramid (skew = arctan(sqrt(2))) or a 6-CMG orthogonal cluster -- both hardcoded in_math.py. Target attitude is sampled uniformly onSO(3)at reset via Marsaglia's method.XML assets
Bundled under
torchrl/envs/custom/mujoco/assets/with a NOTICE preserving the upstream Apache-2.0 attribution (DeepMind / mujoco-torch). Subclasses can also point at remote URLs to avoid re-vendoring.Tests
test/libs/test_mujoco.py-- parametrized tests covering specs, rollouts, dispatch validation, satellite finite-reward over 50 steps, custom XML loading, andfrom_pixels/pixel_only/render()across all available backends. Skipped cleanly when a backend isn't installed.CI
Dedicated path-triggered workflow
.github/workflows/test-linux-mujoco.yml(mirrorstest-linux-libs.yml's brax pattern) with scripts under.github/unittest/linux_libs/scripts_mujoco/. Pinned versions:mujoco==3.7.0,mujoco-mjx==3.7.0(3.8.0 removedmjENBL_MULTICCDreferenced by mujoco-torch 0.2.0)mujoco-torch==0.2.0jax[cuda12]>=0.7.0,<0.11Test plan
pytest test/libs/test_mujoco.py -v-- pending rerun after splitting the satellite examples into [Feature] Add satellite MuJoCo SAC examples #3802 (previous local run: 58 passed on macOS before the split)pytest test/test_custom_envs.py -v-- 8 passed (no regression on pre-existing custom envs)check_env_specspasses for every (env class, backend) paircompile_step=Truesmoke runs onmujoco-torchbackendfrom_pixels=Trueproducesuint8(B, H, W, 3)tensors with non-trivial RGB content on all three backends