`import mujoco.mjx` fails with TypeError when warp-lang is too old
I maintainer di solito rispondono entro 6 giorni
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 78/100
Direzione di ricerca
Inizia leggendo mjx/warp/__init__.py intorno alle righe 36–42 e l’errore di importazione descritto per mujoco.mjx.third_party.mujoco_warp. Riproducilo con mujoco-mjx 3.17.0 e warp-lang 1.12.1, poi verifica che l’importazione riesca e che MJX possa usare il backend JAX quando l’importazione del Warp incluso non riesce. L’issue suggerisce di ampliare le eccezioni intercettate e menziona il miglioramento del messaggio sulla versione.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Intro
Hi!
I just finished my PhD at Inria Scool (France), I use MuJoCo for my research on Reinforcement Learning.
My setup
mujoco 3.17.0, mujoco-mjx 3.17.0 (Python API), warp-lang 1.12.1, jax 0.11.2, Python 3.12.8, macOS 15.7.4 on Apple M4 Pro (arm64), CPU only.
What's happening? What did you expect?
import mujoco.mjx raises a TypeError, instead of falling back to the JAX backend, when the installed warp-lang is older than the bundled mujoco_warp needs. I expected the import to succeed and MJX to use the JAX backend, as it does when warp-lang is not installed.
Where (main):
- mjx/warp/init.py#L36-L42 always tries to import the bundled mujoco_warp, and catches only
ImportErrorandRuntimeError:
try:
from mujoco.mjx.third_party import mujoco_warp
from mujoco.mjx.third_party.mujoco_warp._src import types as mjwp_types
from mujoco.mjx.third_party.mujoco_warp._src import io as mjwp_io
except (ImportError, RuntimeError) as e:
print('Failed to import mujoco_warp:', e)
pass
- mujoco_warp/_src/solver.py#L1700 uses
@wp.kernel(grid_stride=True), which warp-lang 1.12.1 rejects with aTypeErrorat import time.
The warp extra pins warp-lang==1.18.0 (mjx/pyproject.toml#L38-L41), but nothing stops another package from bringing an older one. For example, MuJoCo Playground 0.2.0 declares mujoco-mjx>=3.6.0 and warp-lang>=1.11, so a resolver can pick exactly this pair. Then import mujoco.mjx fails, even for users who only need the JAX backend. The docs' pip install mujoco-mjx[warp] avoids this; here the older warp-lang comes from another package. Related, but the other way round: #2894 (a warp-lang too new for impl='warp').
A possible fix is to catch any exception from the bundled import:
from mujoco.mjx.third_party.mujoco_warp._src import io as mjwp_io
- except (ImportError, RuntimeError) as e:
+ except Exception as e: # pylint: disable=broad-exception-caught
+ # e.g. TypeError when warp-lang is older than the bundled mujoco_warp needs.
print('Failed to import mujoco_warp:', e)
With this change applied to a local copy of 3.17.0, the import succeeds with warp-lang 1.12.1, prints the message, and mjx.step runs on the JAX backend. Naming the required warp-lang version in the message could also help. I'm happy to send a PR.
Steps for reproduction
- Install mujoco-mjx 3.17.0 together with warp-lang 1.12.1 (and jax).
- Run the code below.
- The import fails:
File ".../mujoco/mjx/warp/__init__.py", line 37, in <module>
from mujoco.mjx.third_party import mujoco_warp
...
File ".../mujoco/mjx/third_party/mujoco_warp/_src/solver.py", line 1677, in <module>
@wp.kernel(grid_stride=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: kernel() got an unexpected keyword argument 'grid_stride'
Without warp-lang installed, the same import prints the two "Failed to import" messages and succeeds.
Minimal model for reproduction
Not needed: the error happens at import mujoco.mjx, before any model is loaded.
Code required for reproduction
import importlib.metadata as md
for dist in ("mujoco", "mujoco-mjx", "warp-lang", "jax"):
try:
print(dist, md.version(dist))
except md.PackageNotFoundError:
print(dist, "not installed")
import mujoco.mjx # noqa: E402,F401
print("import mujoco.mjx: ok")
Confirmations
- I searched the latest documentation thoroughly before posting.
- I searched previous Issues and Discussions, I am certain this has not been raised before.
- Lingua principale
- C++
- Stelle
- 18.3k
- Fork
- 2.2k
- Merge medio
- 9g 11h
- PR unite (30g)
- 5
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di google-deepmind/mujoco
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
google-deepmind/mujoco#3932 ·
I maintainer di solito rispondono entro 6 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
google-deepmind/mujoco#3929 ·
I maintainer di solito rispondono entro 6 giorni
-
Unity 6.6 supportForse di nuovo libera @Balint-H l’ha presa 53 giorni fa e non c’è nessuna pull request aperta. Apertaenhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
google-deepmind/mujoco#3615 · 1 commento · 1 assegnatario ·
I maintainer di solito rispondono entro 6 giorni
-
Filament: `filament.ao.bilateral_threshold` and six other model options are ignored since 4.0.1, which changed the default ambient occlusionForse già presa @jeongseok-meta l’ha presa oggi. Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 56/100
google-deepmind/mujoco#3933 ·
I maintainer di solito rispondono entro 6 giorni
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 56/100
google-deepmind/mujoco#3931 ·
I maintainer di solito rispondono entro 6 giorni
Tutte le issue di google-deepmind/mujoco
Issue simili
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 91/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 69/100
maplibre/maplibre-native#5072 ·
I maintainer di solito rispondono entro 1 giorno
-
[UBSan] spawn_simulator passes null child_options.args to uv_spawn (execvp nonnull violation)Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 79/100
tenstorrent/tt-umd#4017 ·
I maintainer di solito rispondono entro 3 giorni
-
difficulty:easy func:gui prio:low type:bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
NatronGitHub/Natron#1538 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
hyprwm/hyprsunset#103 · 1 commento ·