Skip to content

[Release 3.0] Fix MJWarp resets with sparse state imports - #8852

Merged
kellyguo11 merged 3 commits into
isaac-sim:release/3.0.0from
AntoineRichard:codex/fix-mjwarp-authored-state-sync
Nov 10, 2026
Merged

kellyguo11 merged 3 commits into
isaac-sim:release/3.0.0from
AntoineRichard:codex/fix-mjwarp-authored-state-sync

Conversation

@AntoineRichard

@AntoineRichard AntoineRichard commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

Description

MJWarp could discard an environment reset when the next solver substep skipped its periodic Newton-state import. With update_data_interval=2 and an odd number of solver steps per control step, CUDA graph replay could repeatedly restore the old MuJoCo state, leaving terminated robots in place.

Synchronize authored joint state for flagged worlds at forward and physics-step boundaries when periodic imports are sparse or disabled. Preserve native MuJoCo's single template-world state when another world is reset. Updated the configuration docs and added a changelog fragment.

This PR targets release/3.0.0, matching the affected checkout, and adds no dependencies.

Newton currently exposes no public masked state import. With sleeping disabled, reset(state, world_mask, flags=0) preserves authored coordinates but skips importing them. The manager therefore reuses Newton's coordinate conversion through one private call until the solver's public reset contract supports this case; this constraint is documented beside the call.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Documentation update

Validation

  • Six focused cases: disabled/sparse imports on CPU eager stepping and GPU CUDA graph replay, plus two native MuJoCo template-world selection cases. Each MJWarp case covers direct-step and forward-then-step resets with two independent, unactuated worlds.
  • Expected motion uses a constant-velocity calculation. Distinct uncommitted inputs in the unselected world verify that forward() respects the import mask; normal periodic imports remain allowed during stepping.
  • With Newton 1.6.1 and Warp 1.17.0: all 6 focused cases passed, including CUDA graph replay on an NVIDIA GeForce RTX 5090.
  • Mutation checks: removing authored-state synchronization caused 5 failures; removing the import mask caused all 4 MJWarp cases to fail; accepting any native-world mask caused the remaining non-template case to fail. Each mutation was reverted.
  • Full test_newton_manager_abstraction.py: 119 passed, with existing model-fixture warnings.
  • uv run isaaclab --format and the changelog gate passed.
  • Clean Sphinx HTML build passed with warnings treated as errors; all tracked documentation was included.

Solver-boundary microbenchmark: baseline 1117519054 versus candidate 935641f42d, pinned Newton 1.6.1 / Warp 1.17.0, MJWarp CUDA graph on RTX 5090, 4096 unactuated revolute worlds without contacts, empty reset masks, update_data_interval=2, decimation=1, num_substeps=1. Median throughput was 6,389 versus 6,404 control steps/s over five alternating 1000-step samples after 200 warmup replays per graph. Each replay runs the reset hook and one off-cadence solver step. Command: UV_PROJECT_ENVIRONMENT=/tmp/mjwarp-pr-venv WARP_CACHE_PATH=/tmp/codex-warp-cache uv run --no-sync python /tmp/bench_mjwarp_reset_sync.py.

Checklist

  • I have read and understood the contribution guidelines.
  • I have run the pre-commit checks with uv run isaaclab --format.
  • I have made corresponding changes to the documentation.
  • My changes generate no new warnings.
  • I have added tests that prove the fix is effective.
  • I have added a changelog fragment for the touched source package.
  • My name already exists in CONTRIBUTORS.md.

@AntoineRichard
AntoineRichard requested a review from a team October 27, 2026 10:43
@github-actions github-actions Bot added bug Something isn't working documentation Improvements or additions to documentation isaac-lab Related to Isaac Lab team labels Oct 27, 2026
@greptile-apps

greptile-apps Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable issues were found.

Summary

The PR keeps authored joint state from being lost when MJWarp skips periodic imports.

  • MJWarp applies reset joint states before sparse imports can skip them.
  • Native MuJoCo resets affect the template world only when it is selected.

No actionable issues were found. Tests were not run during this review.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Asset writes joint state] --> B[Flag affected worlds]
  B --> C[Forward or physics-step boundary]
  C --> D[Clear flagged solver history]
  D --> E{Sparse or disabled imports?}
  E -->|Yes| F[Import authored joint state]
  E -->|No| G[Use normal per-substep import]
  F --> H[Refresh body poses and clear masks]
  G --> H
  H --> I[Next solver step or graph replay]
Loading

Reviews (1) · Last reviewed commit: "Fix MJWarp resets with sparse state impo..." · Reviewed by Greptile

@isaaclab-review-bot isaaclab-review-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isaac Lab Review Bot

Needs attention: Design and architecture (1). Other reviewed categories look good.

  • PR description: Title and body match the five-file diff; remove the scratch-document note and report sparse-import baseline/candidate steps/s with revisions, command, GPU, backend, environment count, and warmup.
  • Design and architecture: The reset hook calls Newton-private _update_mjc_data and duplicates backend dispatch; expose a public masked import on the solver and call that instead.
  • Scope and over-engineering: No over-engineering issues.
  • API: API changes look good.
  • Compatibility and deprecation: No breaking changes identified.
  • Implementation: Implementation looks good.
  • Style consistency: Style consistency looks good.
  • Test quality: Test quality looks good.

Minor fixes needed. Posted 1 inline finding.

Automated review; human maintainers own approval decisions.

@AntoineRichard AntoineRichard changed the title Fix MJWarp resets with sparse state imports [Release 3.0] Fix MJWarp resets with sparse state imports Oct 27, 2026
@AntoineRichard

Copy link
Copy Markdown
Collaborator Author

Addressed the PR-description requests from the review summary: removed the local scratch-document note and recorded the sparse-import baseline/candidate measurement, revisions, command, GPU/backend, world count, and warmup in the description.

The solver-boundary microbenchmark measured median throughput of 6,389 versus 6,404 control steps/s on an RTX 5090 with 4096 unactuated worlds, MJWarp CUDA graph replay, empty reset masks, update_data_interval=2, and one solver step per control step. It uses pinned Newton 1.6.1 / Warp 1.17.0, 200 warmup replays per graph, and five alternating 1000-step samples. This measurement covers the reset hook plus one off-cadence solver step.

The private-API finding is answered in its inline thread. Current local validation is six focused cases and 119 tests in the full manager file, plus formatting, changelog checks, and a clean documentation build; all passed.

AntoineRichard added a commit that referenced this pull request Nov 3, 2026
# Description

MJWarp could discard authored reset state when the next solver substep
skipped its periodic Newton-state import. With `update_data_interval=2`
and an odd number of solver steps per control step, CUDA graph replay
could repeatedly restore the old MuJoCo state and leave terminated
robots in place.

Synchronize authored joint state in `MJWarpSolver.reset` for flagged
worlds at forward and physics-step boundaries when periodic imports are
sparse or disabled. Preserve native MuJoCo's template-world state when
another world is reset. Updated the configuration docs and added a
changelog fragment.

This is the `main` counterpart of release PR #8852, implemented in the
Newton solver adapter selected by `MJWarpSolverCfg`. It adds no
dependencies.

The pinned Newton version exposes no public masked state import. With
sleeping disabled, `reset(state, world_mask, flags=0)` preserves
authored coordinates but skips importing them. The adapter therefore
reuses Newton's coordinate conversion through one private call until the
solver's public reset contract supports this case; this constraint is
documented beside the call and tracked in [Newton
#4949](newton-physics/newton#4949).

## Type of change

- Bug fix (non-breaking change which fixes an issue)
- Documentation update

## Validation

- One 39-line parameterized reset-contract test in
`test_newton_solvers.py` covers native MuJoCo on CPU and MuJoCo-Warp
under CUDA graph replay. It changes authored joint state and the
selected world, then checks actual MuJoCo qpos/qvel buffers for selected
imports and unselected-state preservation.
- Against main `86a648ed05`, the complete `test_newton_solvers.py` file
passed on the CPU device mask: 34 passed, 1 skipped. The retired
`test_newton_manager_abstraction.py` file is removed as intended by
main's test reorganization.
- The unchanged CUDA variant previously passed before the workstation's
CUDA driver became unavailable; GPU checks could not be rerun after
moving the test file.
- Negative checks previously caught missing synchronization and the
incorrect native-world guard on CPU. A real CPU-backed MuJoCo-Warp probe
also caught an import that ignored the world mask.
- `uv run isaaclab --format` and the changelog gate passed.
- Clean Sphinx HTML build passed with base `bfcf3ca2e5`; the PR
documentation changes are unchanged.

## Checklist

- [x] I have read and understood the contribution guidelines.
- [x] I have run the pre-commit checks with `uv run isaaclab --format`.
- [x] I have made corresponding changes to the documentation.
- [x] My changes generate no new warnings.
- [x] I have validated the changed behavior with focused coverage and
applied the test-audit criteria.
- [x] I have added a changelog fragment for the touched source package.
- [x] My name already exists in `CONTRIBUTORS.md`.
@kellyguo11

Copy link
Copy Markdown
Contributor

run-ci

@isaaclab-bot isaaclab-bot Bot added ci:run-docker Trigger the on-demand Docker and GPU CI workflow and removed ci:run-docker Trigger the on-demand Docker and GPU CI workflow labels Nov 7, 2026
@kellyguo11
kellyguo11 merged commit fe9e112 into isaac-sim:release/3.0.0 Nov 10, 2026
58 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working documentation Improvements or additions to documentation isaac-lab Related to Isaac Lab team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants