Skip to content

[BUG] SolverMuJoCo.reset(flags=0) loses authored state with sparse or disabled imports #4949

Open

Description

@AntoineRichard

We hit a reset/state synchronization gap in Isaac Lab. After writing custom joint positions and velocities, we call:

solver.reset(state, world_mask=mask, flags=0)

This clears solver history while preserving our authored state. With sleeping disabled and update_data_interval=0 or 2, however, the next solver step can overwrite that state with stale MuJoCo coordinates.

With CUDA graph replay, a graph captured on a skipped-import step repeatedly loses the resets. In Isaac Lab, this surfaced as event/RSI resets being ignored and training collapsing to one-step episodes.

Cause

The sparse-import synchronization is nested inside if reset_q or reset_qd, so flags=0 skips it. The same gating remains in Newton main at a6a75619.

Reproduction Script

Save as repro_reset.py. Run python repro_reset.py cpu for eager stepping or python repro_reset.py cuda:0 for graph replay. The second argument selects the import interval and defaults to 2.

import sys

import newton
import numpy as np
import warp as wp
from newton.solvers import SolverMuJoCo

device = sys.argv[1] if len(sys.argv) > 1 else "cpu"
interval = int(sys.argv[2]) if len(sys.argv) > 2 else 2

builder = newton.ModelBuilder(gravity=(0.0, 0.0, 0.0))
body = builder.add_link(mass=1.0, inertia=wp.mat33(np.eye(3)))
joint = builder.add_joint_revolute(parent=-1, child=body, axis=(0, 0, 1))
builder.add_articulation([joint])
model = builder.finalize(device=device)
state, control = model.state(), model.control()
solver = SolverMuJoCo(
    model, update_data_interval=interval, njmax=5, nconmax=5
)
mask = wp.array([True, False], dtype=wp.bool, device=device)
dt = 1.0 / 120.0

# Put the next step / graph capture off cadence for interval=2.
solver.step(state, state, control, None, dt)
graph = None
if wp.get_device(device).is_cuda:
    with wp.ScopedCapture(device=device) as capture:
        solver.step(state, state, control, None, dt)
    graph = capture.graph

matches = []
for position, velocity in ((0.25, 0.5), (-0.25, -0.5)):
    state.joint_q.fill_(position)
    state.joint_qd.fill_(velocity)
    solver.reset(state, world_mask=mask, flags=0)

    if graph is None:
        solver.step(state, state, control, None, dt)
    else:
        wp.capture_launch(graph)

    actual_q = state.joint_q.numpy()
    actual_qd = state.joint_qd.numpy()
    expected_q = position + velocity * dt
    print("expected:", expected_q, velocity, "actual:", actual_q, actual_qd)
    matches.append(
        np.allclose(actual_q, expected_q, atol=1e-6)
        and np.allclose(actual_qd, velocity, atol=1e-6)
    )

assert all(matches), "Authored reset state was lost"

At interval 2, eager stepping loses the first reset; graph replay loses both. At interval 0, both are lost. Interval 1 preserves both.

System Information

Verified with:

  • Newton 1.6.1, MuJoCo/MuJoCo Warp 3.12.0.
  • Newton 42f7def118c2c4299ce493457bafd4e8a22a696e, MuJoCo/MuJoCo Warp 3.15.0.
  • Warp 1.17.0, CPU and RTX 5090 CUDA graph replay.

The latest-main reference above was inspected in source; runtime reproduction used the versions listed here.

Request

Could reset(..., flags=0) synchronize the selected authored joint state when periodic imports are sparse or disabled, independently of restoring model defaults?

If flags=0 should remain strictly buffer-only, could Newton expose a public masked state-sync operation instead? We need it to preserve unselected worlds, support mutable masks during CUDA graph replay, and synchronize without advancing physics.

Our temporary workaround calls _update_mjc_data directly. A supported entry point would let Newton own backend dispatch and cache handling. The workaround and regression coverage are in Isaac Lab #8852 and #8853.

Activity

  1. adenzler-nvidia commented on Oct 28, 2026

    @adenzler-nvidia
    Member

    Thanks for reporting, are you using update_data_interval != 1 in practice? I was just planning on getting rid of it.

  2. added theissue type on Nov 19, 2026
  3. added
    IsaacLab
    mujoco
    and removed on Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    IsaacLabmujoco

    Type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions