Skip to content

[Newton] Report MJWarp capacity overflows in debug mode - #9164

Open
KuNaL8103 wants to merge 3 commits into
isaac-sim:mainfrom
KuNaL8103:fix/issue-8801-mjwarp-overflow-warning
Open

KuNaL8103 wants to merge 3 commits into
isaac-sim:mainfrom
KuNaL8103:fix/issue-8801-mjwarp-overflow-warning

Conversation

@KuNaL8103

@KuNaL8103 KuNaL8103 commented Nov 23, 2026 •

Copy link
Copy Markdown

Description

Fixes #8801.

MJWarp can silently drop contacts or constraints when a capacity buffer overflows (nconmax, njmax, the Newton collision pipeline contact buffer, or a MuJoCo Warp buffer). Newton prints an unstructured line that is easy to miss in training logs, after which the simulation can misbehave or produce NaNs.

This adds a debug-mode overflow diagnostic for MJWarp (use_mujoco_cpu=False):

  • When NewtonCfg.debug_mode=True, solver initialization allocates SolverMuJoCo.ObservableKind.OVERFLOW as an internal step-diagnostic output while keeping NewtonManager.get_solver_observables() restricted to caller-requested observables.
  • After eager or captured steps, MJWarpSolver.check_step() reduces the (world_count + 1,) int32 overflow mask, decodes newly observed Newton OverflowBits (nconmax, rigid_contact_max) and MuJoCo Warp OverflowType bits (njmax, njmax_nnz, broadphase, narrowphase, CCD, etc.), and emits one logger.warning per newly exhausted buffer per solver instance.
  • Affected environment counts include only environments matching the newly observed overflow bits, with the global slot reported separately.
  • Normal execution (debug_mode=False) does not allocate the overflow diagnostic observable or read the overflow buffer. Only the final solver substep is inspected by check_step().

Example warning:

MJWarp capacity overflow in the global world: solver contact buffer (nconmax).
Increase the named capacity; dropped contacts or constraints can invalidate the simulation.

Documentation was updated in docs/source/how-to/solver_tuning_mjwarp.rst, and a changelog fragment was added under source/isaaclab_newton/changelog.d/.

Type of change

  • New feature (non-breaking change which adds functionality)

Screenshots

Not applicable. This is a log-only diagnostic; no visual or rendered output changed.

Validation

Commands run from the repository root:

PYTHONPATH= uv run python -m pytest source/isaaclab_newton/test/physics/test_newton_solvers.py -q
# 42 passed

PYTHONPATH= uv run python -m pytest source/isaaclab_newton/test/physics/test_newton_manager.py -q -k "nconmax_overflow_in_debug or solver_observables"
# 5 passed

PYTHONPATH= uv run python -m pytest source/isaaclab_newton/test/physics/test_conveyor.py -q
# 3 passed

uv run python tools/changelog/cli.py check upstream/main --include-worktree
# exit 0

uv run isaaclab --format
# all pre-commit hooks passed

PYTHONPATH= uv run --extra dev --directory docs python -m sphinx -W --keep-going -j auto . _build/incremental
# build succeeded; HTML in docs/_build/incremental

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 validated the changed behavior with focused coverage and applied the test-audit criteria to any test changes
  • I have added a changelog fragment under source/<pkg>/changelog.d/ for every touched package
  • I have added my name to the CONTRIBUTORS.md

@KuNaL8103
KuNaL8103 requested a review from a team November 23, 2026 15:14
@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 Nov 23, 2026

@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: Scope and over-engineering (1), Compatibility and deprecation (1), Implementation (1), Style consistency (5), Test quality (3). Other reviewed categories look good.

  • PR description: The title matches the diff and validation is reported; shorten method and bit inventories, qualify allocation claims as overflow-specific, and remove the unsupported no-new-synchronization claim while preserving template sections.
  • Design and architecture: Architecture looks good.
  • Scope and over-engineering: Minimal implementation: Extend NewtonSolver, NewtonBackend, NewtonManager, and MJWarpSolver; no source modules were added, so none require merging or deletion. Keep allocation, output retention, decoding, and deduplication; collapse the index-and-gather reduction into a direct mask reduction, allocating world indices only for new warnings. Scope is cohesive; no split recommended.
  • API: API changes look good.
  • Compatibility and deprecation: Breaking changes: debug mode adds diagnostic kinds to get_solver_observables() and returns outputs without caller requests; no deprecation bridge exists, so preserve the getter’s requested-only result.
  • Implementation: Warning counts include the global slot and worlds containing only previously reported bits, misattributing newly named overflows; filter by new_bits and report the global slot separately.
  • Style consistency: Defaulted getattr hides a missing known overflow field; check container or kind absence explicitly, then use direct field access.
  • Test quality: The CPU capability test restates a private declaration and cannot detect incorrect initialization requests; replace it with an initialization-boundary assertion while retaining distinct physical-overflow and warning-decoding coverage.

Significant concerns. Posted 11 inline findings.

Automated review; human maintainers own approval decisions.

@greptile-apps

greptile-apps Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 4/5

[Low impact] The change reaches debug-mode MJWarp runs using the Warp backend.

The PR appears safe to merge, with a non-blocking gap in overflow warnings for coupled MJWarp entries.

Findings

  1. P2 Coupled runs miss overflow warnings ▶

Summary

Adds named MJWarp overflow warnings when NewtonCfg.debug_mode=True.

  • MJWarp debug runs name capacity buffers that overflow.
  • The contributor list now includes Kunal Dabbe.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Initialize solver] --> B{Debug mode?}
    B -->|Yes| C[Request driver diagnostic outputs]
    B -->|No| D[Keep caller-requested outputs only]
    C --> E[Allocate combined outputs]
    D --> E
    E --> F[Run solver substeps]
    F --> G[Check final outputs outside capture]
    G --> H[Warn once per new overflow bit]
Loading

Reviews (1) · Last reviewed commit: "Report MJWarp capacity overflows in debu..." · Reviewed by Greptile

Signed-off-by: KuNaL8103 <kunaldabbe2003@gmail.com>
@KuNaL8103
KuNaL8103 force-pushed the fix/issue-8801-mjwarp-overflow-warning branch from 7018ce9 to 2e9e2b3 Compare November 25, 2026 09:50
@KuNaL8103

Copy link
Copy Markdown
Author

Hello Reviewers, gentle ping on this PR whenever someone has a moment to review and approve the CI workflow run.

  • All 11 inline findings from isaaclab-review-bot have been addressed and resolved.
  • Rebased cleanly against main (Changes can be cleanly merged) with unit, CUDA integration, formatter, changelog, and Sphinx checks passing locally.

@kellyguo11 kellyguo11 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.

Thanks for the feature, this could be very useful for debugging! Do you think we can propose some of the generic features upstream to Newton? Maintaining the hardcoded list in Isaac Lab can be brittle against changes in Newton and other Newton users can also benefit from this.

Signed-off-by: KuNaL8103 <kunaldabbe2003@gmail.com>
@KuNaL8103

Copy link
Copy Markdown
Author

Thanks for the review @kellyguo11, that's a great point!

In this PR, I pushed d80d129 to remove the hardcoded 12-entry _MUJOCO_WARP_OVERFLOW_LABELS table from mjwarp_solver.py. It now iterates SolverMuJoCo.OverflowBits and mujoco_warp.OverflowType dynamically and keeps only the 3 overrides for the config-field names relevant to #8801 (nconmax, rigid_contact_max, and njmax). Any new canonical flags added to either enum will now be picked up automatically using the enum name as the fallback.

The only remaining coupling is calling SolverMuJoCo.import_mujoco() to inspect MuJoCo Warp's low-bit OverflowType. Since SolverMuJoCo in Newton already merges SolverMuJoCo.OverflowBits (bits 16-17) and mujoco_warp.OverflowType (bits 0-11) in collect_overflow_kernel, I'd be happy to open a PR upstream in newton-physics/newton adding a public SolverMuJoCo.decode_overflow(mask) helper (and unified flag descriptions) on SolverMuJoCo so all Newton users can use it directly, and then switch MJWarpSolver over to it once it lands in the pinned Newton version.

@kellyguo11

Copy link
Copy Markdown
Contributor

Thanks, that sounds like a great proposal. We can also work with the Newton team to get their feedback on the Newton side API.

@KuNaL8103

KuNaL8103 commented Nov 30, 2026 •

Copy link
Copy Markdown
Author

@kellyguo11 I just opened the upstream feature request in Newton here: newton-physics/newton#5708 and will prepare a PR on newton-physics/newton as well.

@tianyaohu

tianyaohu commented Dec 2, 2026 •

Copy link
Copy Markdown

Thanks for this, it's useful for us. One thing we noticed after d80d129: the pinned mujoco-warp also sets OverflowType.ITERATIONS and LS_ITERATIONS in the same mask when the solver hits iterations / ls_iterations. Since the labels now come from the enum, a step that only failed to converge is logged as

MJWarp capacity overflow in 1 environment(s) (0): iterations. Increase the named capacity; ...

Nothing was dropped there, so the advice points at the wrong setting. Masking those two bits out of the capacity report (or logging them separately as non-convergence) would fix it. Repro without a GPU: the existing solver_driver(MJWarpSolver, ...) test setup with an overflow observable of [OverflowType.ITERATIONS, 0].

Separately, we have a small opt-in follow-up (report or raise on overflow outside debug mode) proposed in #9345 so it doesn't widen this PR.

Signed-off-by: KuNaL8103 <kunaldabbe2003@gmail.com>
@KuNaL8103

Copy link
Copy Markdown
Author

Good catch @tianyaohu, thanks!

I pushed 340ca68 to mask OverflowType.ITERATIONS and OverflowType.LS_ITERATIONS out of the capacity-overflow check and label map (since check_step() already reports iteration stats separately), and added the unit test covering [ITERATIONS | LS_ITERATIONS] both alone and combined with SOLVER_NCONMAX.

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

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.

[Proposal] MJWarp manager: report contact/constraint buffer overflow via _check_solver_status

3 participants