Repository navigation
Count solver iteration limits instead of aborting Newton runs - #1526
daniel-debrun wants to merge 2 commits into
Conversation
Signed-off-by: daniel-debrun <danieldebrun.brown@mail.utoronto.ca>
[Medium impact] The PR appears safe to merge; no actionable issues were found. SummaryThe PR lets Newton runs continue when the solver reaches an iteration limit.
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) |
There was a problem hiding this comment.
🟡 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_FLAGSThis 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.
There was a problem hiding this comment.
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]) |
There was a problem hiding this comment.
🔵 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.
There was a problem hiding this comment.
Done... the test keeps the flags set across checks and uses OverflowType names
🤖 Isaac Lab-Arena Review BotSummaryThis PR stops Findings🟡 Warning: isaaclab_arena/utils/newton_buffer_monitor.py:106: MuJoCo-Warp only ORs bits into
Nothing reads the counter yet. I'd suggest dropping it and 🔵 Improvement: isaaclab_arena/tests/test_newton_buffer_monitor.py:64: The new test resets 🔵 Improvement: isaaclab_arena/environments/isaaclab_arena_manager_based_env_cfg.py:37 (unchanged line): The Test Coverage and CI CostThe 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. VerdictMinor 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>
Count MuJoCo-Warp iteration-limit flags in
NewtonBufferMonitorinstead of aborting the run, and raise the Newton preset'sls_iterationsfrom 30 to MuJoCo's default of 50. Fixes Issue #1525Why this change?
NewtonBufferMonitor.check()aborts on every MuJoCo-Warp overflow flag.OverflowType.ITERATIONSandOverflowType.LS_ITERATIONSonly 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'sMJWarpSolverCfgdefault, 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()separatesITERATION_LIMIT_FLAGSfrom the other flags. When they are set, it incrementsnum_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.newtonsetsls_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-warp3.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).