Remove _full_compat from MJX io.

PiperOrigin-RevId: 817337868
Change-Id: Ic61b8d57937452371b85416c624ff2672c908aac
This commit is contained in:
Baruch Tabanpour
2025-10-09 14:25:31 -07:00
committed by Copybara-Service
parent 50e163748d
commit 192da87475
3 changed files with 1 additions and 67 deletions
+1
View File
@@ -18,6 +18,7 @@ General
in a future release.
**Migration:** Replace ``meshdir`` and ``texturedir`` with ``compiler.meshdir`` and ``compiler.texturedir``.
- Remove ``_full_compat`` from ``mjx.put_data`` and ``mjx.put_model``.
- Joint decorators and spatial tendons which have limits defined and whose current value (angle or length) exceeds the
limit, are recolored by using the :ref:`constraint impedance<soParameters>` :math:`d` to mix the existing color with
-40
View File
@@ -493,7 +493,6 @@ def put_model(
m: mujoco.MjModel,
device: Optional[jax.Device] = None,
impl: Optional[Union[str, types.Impl]] = None,
_full_compat: bool = False, # pylint: disable=invalid-name
) -> types.Model:
"""Puts mujoco.MjModel onto a device, resulting in mjx.Model.
@@ -501,27 +500,14 @@ def put_model(
m: the model to put onto device
device: which device to use - if unspecified picks the default device
impl: implementation to use
_full_compat: put all MjModel fields onto device irrespective of MJX support
This is an experimental feature. Avoid using it for now.
Returns:
an mjx.Model placed on device
Raises:
ValueError: if impl is not supported
DeprecationWarning: if _full_compat is True
"""
if _full_compat:
warnings.warn(
'mjx.put_model(..., _full_compat=True) is deprecated and will be'
' removed in MuJoCo >=3.4. Use mjx.put_model(..., impl=types.Impl.C)'
' instead.',
DeprecationWarning,
stacklevel=2,
)
impl = types.Impl.C
impl, device = _resolve_impl_and_device(impl, device)
if impl == types.Impl.JAX:
return _put_model_jax(m, device)
@@ -899,9 +885,6 @@ def make_data(
m: the model to use
device: which device to use - if unspecified picks the default device
impl: implementation to use ('jax', 'warp')
_full_compat: put all fields onto device irrespective of MJX support This is
an experimental feature. Avoid using it for now. If using this flag, also
use _full_compat for put_model.
nconmax: maximum number of contacts to allocate for warp across all worlds
Since the number of worlds is **not** pre-defined in JAX, we use the
`nconmax` argument to set the upper bound for the number of contacts
@@ -915,17 +898,7 @@ def make_data(
Raises:
ValueError: if the model's impl does not match the make_data impl
NotImplementedError: if the impl is not implemented yet
DeprecationWarning: if _full_compat is used
"""
if _full_compat:
warnings.warn(
'mjx.make_data(..., _full_compat=True) is deprecated. Use'
' mjx.make_data(..., impl=types.Impl.C) instead.',
DeprecationWarning,
stacklevel=2,
)
impl = types.Impl.C
impl, device = _resolve_impl_and_device(impl, device)
if isinstance(m, types.Model) and m.impl != impl:
@@ -1231,7 +1204,6 @@ def put_data(
impl: Optional[Union[str, types.Impl]] = None,
nconmax: int = -1,
njmax: int = -1,
_full_compat: bool = False, # pylint: disable=invalid-name
) -> types.Data:
"""Puts mujoco.MjData onto a device, resulting in mjx.Data.
@@ -1242,23 +1214,11 @@ def put_data(
impl: implementation to use ('jax', 'warp')
nconmax: maximum number of contacts to allocate for warp
njmax: maximum number of constraints to allocate for warp
_full_compat: put all MjModel fields onto device irrespective of MJX support
This is an experimental feature. Avoid using it for now. If using this
flag, also use _full_compat for put_model.
Returns:
an mjx.Data placed on device
"""
del nconmax, njmax
if _full_compat:
warnings.warn(
'mjx.put_data(..., _full_compat=True) is deprecated. Use'
' mjx.put_data(..., impl=types.Impl.C) instead.',
DeprecationWarning,
stacklevel=2,
)
impl = types.Impl.C
impl, device = _resolve_impl_and_device(impl, device)
if impl == types.Impl.JAX:
return _put_data_jax(m, d, device)
-27
View File
@@ -790,33 +790,6 @@ class DataIOTest(parameterized.TestCase):
self.assertEqual(dx[0]._impl.contact__dist.shape, (dx._impl.naconmax,))
class FullCompatTest(parameterized.TestCase):
"""Tests for the _full_compat flag."""
def test_full_compat_deprecated(self):
"""Tests that _full_compat is deprecated."""
xml = """
<mujoco>
<worldbody>
<body name="box">
<joint name="slide1" type="slide" axis="1 0 0" />
<geom type="box" size=".05 .05 .05" mass="1"/>
</body>
</worldbody>
<actuator>
<motor joint="slide1"/>
</actuator>
</mujoco>
"""
m = mujoco.MjModel.from_xml_string(xml)
with self.assertWarns(DeprecationWarning):
out = mjx_io.put_model(m, _full_compat=True)
self.assertEqual(out.impl, Impl.C)
with self.assertWarns(DeprecationWarning):
out = mjx_io.make_data(m, _full_compat=True)
self.assertEqual(out.impl, Impl.C)
# Test cases for `_resolve_impl_and_device` where the device is
# specified by the user and the device is available.
_DEVICE_TEST_CASES = [