Skip to content

Count solver iteration limits instead of aborting Newton runs - #1526

Open
daniel-debrun wants to merge 2 commits into
isaac-sim:mainfrom
daniel-debrun:daniel-debrun/fix/newton-iteration-limit-flags
Open

daniel-debrun wants to merge 2 commits into
isaac-sim:mainfrom
daniel-debrun:daniel-debrun/fix/newton-iteration-limit-flags

Conversation

@daniel-debrun

@daniel-debrun daniel-debrun commented Oct 26, 2026 •

Copy link
Copy Markdown

Count MuJoCo-Warp iteration-limit flags in NewtonBufferMonitor instead of aborting the run, and raise the Newton preset's ls_iterations from 30 to MuJoCo's default of 50. Fixes Issue #1525

Why this change?

NewtonBufferMonitor.check() aborts on every MuJoCo-Warp overflow flag. OverflowType.ITERATIONS and
OverflowType.LS_ITERATIONS only mean that a step's solver or line search reached its iteration limit; the step keeps its last iterate, as in MuJoCo, and no physics data is dropped. Aborting on them stops long runs: a 2048-environment PPO run aborted after a few minutes when one world reached 100 solver iterations.

The preset's ls_iterations=30 (since #1481) is below the 50 used by MuJoCo, Isaac Lab 3.0.0's MJWarpSolverCfg
default, and Arena's gear insertion environment. isaac-sim/IsaacLab#7942 raised its lift tasks to 50 for the same flag and notes that the line search exits when it converges, so easy scenes do not pay for the higher limit.

What changes?

  • check() separates ITERATION_LIMIT_FLAGS from the other flags. When they are set, it increments
    num_iteration_limit_checks, logs a warning the first time, and clears them so later checks start clean. Contact,
    constraint-row and all other flag checks still abort, with the same messages.
  • ArenaPhysicsCfg.newton sets ls_iterations=50.

The count covers all worlds together. Reporting it per world or per episode, for example as an evaluation metric, is
left for a follow-up.

Validation

  • pytest isaaclab_arena/tests/test_newton_buffer_monitor.py -k "not cuda_graph" on CPU (warp 1.17, mujoco-warp
    3.12): 11 passed, including new cases for both iteration flags alone and for an iteration flag together with a
    buffer-overflow flag (still aborts). Before the change, the three new iteration-limit cases fail and the rest pass.
    The CUDA graph test was not run (no GPU on the test machine).
  • The same logic in a downstream manager subclass (Isaac Lab 3.0.0, newton 1.6.1, L40S): two 2048-environment, 1000-iteration PPO runs that aborted before now complete.
  • With ls_iterations=50 instead of 30, a zero-action sweep of contact-rich manipulation scenes showed no measurable change in median step rate, and no run stopped on LS_ITERATIONS.

Signed-off-by: daniel-debrun <danieldebrun.brown@mail.utoronto.ca>
@greptile-apps

greptile-apps Bot commented Oct 26, 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 lets Newton runs continue when the solver reaches an iteration limit.

  • Newton runs count solver limits and allow 50 line-search iterations.

Reviews (1) · Last reviewed commit: "Count solver iteration limits instead of..." · Reviewed by Greptile

" Raise sim.physics.solver_cfg.iterations or ls_iterations if this repeats.",
iteration_flags,
)
wp.launch(_clear_flags, dim=1, inputs=[self._peaks, iteration_flags], device=self._peaks.device)

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.

🟡 Iteration bits come back on the next step

MuJoCo-Warp only ORs bits into data.overflow, and with the pinned newton 1.6.1 nothing clears that array between steps. newton-physics/newton#4086 adds a d.overflow.zero_() before each step, but it isn't in 1.6.1. So _clear_flags only clears _peaks, and the next record_solver_status ORs the same bit back in. After the first hit, num_iteration_limit_checks counts every later check, not the "checks in which some world reached the limit" its docstring describes.

Nothing reads the count yet. Could we drop num_iteration_limit_checks and _clear_flags, mask the bits, and warn once? That works whether or not Newton clears the flags, and the per-world or per-episode count can come with the follow-up that needs it:

num_contacts, num_constraints, flags = self._peaks.numpy().tolist()
iteration_flags = flags & ITERATION_LIMIT_FLAGS
if iteration_flags and not self._iteration_limit_logged:
    logger.warning(
        "MuJoCo-Warp reached a solver iteration limit (flags %#x). The step keeps its last iterate."
        " Raise sim.physics.solver_cfg.iterations or ls_iterations if this repeats.",
        iteration_flags,
    )
    self._iteration_limit_logged = True
flags &= ~ITERATION_LIMIT_FLAGS

This also needs self._iteration_limit_logged: bool = False in __init__. If you need the count now, clear the iteration bits in data.overflow itself after latching them in _record_solver_status. That's the same reset newton#4086 does.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done... I dropped the counter; mask and warn once

monitor.record_solver_status()
monitor.check()
assert monitor.num_iteration_limit_checks == 1
data.overflow.assign([0, 0])

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.

🔵 Test the flags the way production sets them

Production never resets data.overflow like this (see the comment on newton_buffer_monitor.py:106), so the test misses the case that actually happens. Could the second round leave the flags set and assert that check() still passes? Also, int(OverflowType.ITERATIONS) and int(OverflowType.LS_ITERATIONS) would read more clearly than 512 and 1024, here and in the 16 | 512 case above.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done... the test keeps the flags set across checks and uses OverflowType names

@arena-review-bot

Copy link
Copy Markdown
Contributor

🤖 Isaac Lab-Arena Review Bot

Summary

This PR stops NewtonBufferMonitor.check() from aborting when MuJoCo-Warp sets its ITERATIONS or LS_ITERATIONS flags. It also raises the Newton preset's ls_iterations from 30 to 50. Treating an iteration limit as non-fatal matches how MuJoCo handles it, and the PR description includes timing data for the ls_iterations change. The counting logic has a problem, though. It assumes the solver clears its overflow flags between steps, and the pinned versions (mujoco-warp 3.12.0, newton 1.6.1) don't.

Findings

🟡 Warning: isaaclab_arena/utils/newton_buffer_monitor.py:106: MuJoCo-Warp only ORs bits into data.overflow. In newton 1.6.1, nothing clears that array between steps (newton-physics/newton#4086 adds the zero_(), but it isn't in 1.6.1). After the first hit, record_solver_status latches the same bit again on every substep. As a result:

  • _clear_flags has no lasting effect.
  • num_iteration_limit_checks counts every later check, which doesn't match its docstring.

Nothing reads the counter yet. I'd suggest dropping it and _clear_flags, masking the bits, and warning once.

🔵 Improvement: isaaclab_arena/tests/test_newton_buffer_monitor.py:64: The new test resets data.overflow between checks, which production never does. That reset hides the issue above. Leaving the flags set would test the real case. Naming the flags with OverflowType would also read better than the raw values 512 and 1024.

🔵 Improvement: isaaclab_arena/environments/isaaclab_arena_manager_based_env_cfg.py:37 (unchanged line): The NewtonArenaMJWarpManager docstring still says the manager aborts on MuJoCo-Warp overflow flags. It could note that iteration-limit flags are now only logged.

Test Coverage and CI Cost

The new cases run on CPU in Phase 1 and are cheap. The only problem is the flag reset noted above. The only check run visible on the head commit is Greptile, so I couldn't confirm that the three pytest phases ran.

Verdict

Minor fixes needed

MuJoCo-Warp only ORs bits into data.overflow and newton 1.6.1 does not clear it between steps, so the iteration bits stay set after the first hit. Drop the counter and _clear_flags, mask the bits and warn once; test with the flags left set across checks.

Signed-off-by: daniel-debrun <danieldebrun.brown@mail.utoronto.ca>

This branch has not been deployed

No deployments
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.

1 participant