Skip to content

perf(mjwarp): skip the backend's blocking finite check under deferred… - #2598

Merged
TATP-233 merged 2 commits into
Motphys:mainfrom
Cudrix-dev:perf/mjwarp-skip-backend-finite-check
Nov 7, 2026
Merged

TATP-233 merged 2 commits into
Motphys:mainfrom
Cudrix-dev:perf/mjwarp-skip-backend-finite-check

Conversation

@Cudrix-dev

Copy link
Copy Markdown
Contributor

Summary

  • What changed
    • Pin unisim-core==2.7.1 in the default and ROCm profiles (pyproject.toml, pyproject.rocm.toml). In both uv.lock and uv.rocm.lock, only unisim-core changes.
    • Add EnvCfg.mjwarp_validate_tensor_finite (bool or None, default None). env_backend_kwargs passes it to UniSim as mjwarp_validate_tensor_finite, and other backends ignore it.
    • Add tests/base/backend/test_mjwarp_backend_options.py (13 tests).
  • Why it changed
  • User-facing / training-impact behavior
    • With mjwarp_validate_tensor_finite=None (the default), the MJWarp check is off when defer_finite_validation=True, which is the default for training configs. It stays on when defer_finite_validation=False. An explicit true/false overrides this.
    • Under deferred validation, NaN/Inf in device push, wrench, or root-velocity payloads is no longer rejected at the call. It shows up as NaN state at the next finite-validation poll.
    • Physics results are unchanged.

Linked Work

Validation

Profiling: torch.profiler over 50 MJWarp step_tensor calls (1024 envs, cartpole):

Mode Stream/device syncs DtoH copies
defer_finite_validation=False (check on) 50 50
defer_finite_validation=True (default, check off) 0 0

These counts exclude the profiler's own end-of-trace cudaDeviceSynchronize.

Impact

  • Backend impact: none for mujoco / motrix. Only mjwarp behavior changes.
  • Platform impact: Linux (MJWarp needs CUDA)
  • Training effect expected: no change to physics or results. Faster MJWarp stepping, since each step no longer waits on the host.

Artifacts

  • W&B: n/a
  • benchmark result: profiler counts above
  • video / screenshot: n/a
  • ONNX / checkpoint: n/a

Checklist

  • Added or updated tests where needed
  • Updated docs if behavior or workflow changed
  • Linked the driving issue
  • Noted any follow-up work explicitly

… validation

MJWarp's step_tensor checked ctrl for NaN/Inf with a blocking device-to-host
read on every call, duplicating TorchEnv's own control validation and making
the host wait for the policy forward before it could submit physics.
unisim-core 2.7.1 lets the caller own that check.

- Pin unisim-core==2.7.1 in the default and ROCm profiles (both locks change
  only unisim-core).
- Add EnvCfg.mjwarp_validate_tensor_finite (bool or None). None turns the
  backend check off when defer_finite_validation already validates on the
  device and keeps it otherwise; an explicit bool wins. env_backend_kwargs
  forwards it as mjwarp_validate_tensor_finite; other backends ignore it.

On an RTX 5090, 50 step_tensor calls drop from 50 stream syncs and 50 DtoH
copies to none under the default deferred validation.

Refs Motphys#2587

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Cudrix-dev
Cudrix-dev requested a review from TATP-233 as a code owner November 6, 2026 16:57
Make EnvCfg.mjwarp_validate_tensor_finite a bool defaulting to False and
forward it unconditionally, so UniLab never inherits UniSim's blocking MJWarp
default. TorchEnv validates the final control on every step (eagerly or
through deferred finite validation), so the backend check is a duplicate in
both modes; set the option to True only to debug a non-finite operand at the
backend call.

Refs Motphys#2587

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@TATP-233
TATP-233 merged commit 5dd8d86 into Motphys:main Nov 7, 2026
12 checks passed
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.

2 participants