Skip to content

Roll the Newton contact sensor's force-matrix history one thread per filter object - #9297

Merged
AntoineRichard merged 1 commit into
isaac-sim:mainfrom
StafaH:fix/newton-contact-sensor-history-threads
Nov 30, 2026
Merged

AntoineRichard merged 1 commit into
isaac-sim:mainfrom
StafaH:fix/newton-contact-sensor-history-threads

Conversation

@StafaH

@StafaH StafaH commented Nov 29, 2026 •

Copy link
Copy Markdown
Collaborator

Description

update_contact_sensor_kernel ran one thread per (env, sensor) and looped over the filter objects, so the force-matrix history copies strided through memory. It now launches one thread per (env, sensor, filter object); the f == 0 thread of each sensor rolls the per-sensor buffers and air/contact times as before.

# before
wp.launch(update_contact_sensor_kernel, dim=(num_envs, num_sensors), ...)
# after
wp.launch(update_contact_sensor_kernel, dim=(num_envs, num_sensors, max(num_filter_objects, 1)), ...)

Sensors without filter objects launch one thread per sensor, as before.

Performance

G1 self-contact sensor (30 bodies × 30 filter bodies, history_length=4), 4096 envs, RTX PRO 6000:

Before After
Kernel alone (all envs updated) 3.28 ms 0.51 ms (6.4×)
In the G1 motion-tracking task, per physics substep 2.2 ms 0.5 ms

The sensor updates every substep (4 per env step), so the task's env step drops by about 7 ms.

Tests

  • test_contact_sensor_history.py: launch dim updated to (2, 1, 1); newest-first ordering and env mask still checked.
  • test_contact_sensor.py: 28 passed, 3 skipped. test_resting_object_contact_force[kamino*] fails locally on main without this change too.

Type of change

  • Performance improvement (non-breaking)

Checklist

  • I have run the pre-commit checks on the changed files
  • I have added a changelog fragment
  • I have updated the tests

…filter object

The update kernel ran one thread per sensor looping over the filter objects, so its history copies strided through memory. For the G1's self-contact sensor (30 x 30 bodies, history 4) at 4096 envs it took 2.2 ms per physics substep; with a thread per filter object it takes 0.5 ms.
@StafaH
StafaH requested a review from a team November 29, 2026 13:19
@github-actions github-actions Bot added bug Something isn't working isaac-lab Related to Isaac Lab team labels Nov 29, 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: Compatibility and deprecation (1). Other reviewed categories look good.

  • PR description: Title and scope match; supplied G1/RTX timings need reproducible baseline/candidate revisions, commands, backend/environment versions, warmup, timing methods, and kernel/substep/step metrics; retain supplied hardware/environment counts and template sections, and remove the repeated launch snippet.
  • Design and architecture: Architecture looks good.
  • Scope and over-engineering: No over-engineering issues.
  • API: API changes look good.
  • Compatibility and deprecation: Breaking changes: update_contact_sensor_kernel now requires three-dimensional launches, breaking its documented two-dimensional contract without a functional bridge, targeted warning, migration and removal guidance, or transition coverage.
  • 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.

force-matrix histories of its filter object, and the first one of each sensor rolls the rest.
"""
env, sensor = wp.tid()
env, sensor, f = wp.tid()

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.

🟡 Warning · Compatibility — Preserve documented two-dimensional launches

Unpacking three thread indices breaks callers using the kernel's previously documented two-dimensional launch. Keep that launch functional through deprecation and use a separate three-dimensional kernel, with migration guidance and transition coverage.

@greptile-apps

greptile-apps Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 4/5 · The PR appears safe to merge, with a non-blocking request to test history rolling and timers with multiple filters.RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] The change affects Newton contact-sensor updates whenever those sensors run.

The PR appears safe to merge, with a non-blocking request to test history rolling and timers with multiple filters.

Findings

  1. P2 Multiple filters remain untested ▶

Summary

Moves contact-history updates to one thread per sensor and filter object.

  • Contact sensor history updates spread across filter-object threads.

Reviews (1) · Last reviewed commit: "Roll the Newton contact sensor's force-m..." · Reviewed by Greptile

wp.launch(
update_contact_sensor_kernel,
dim=(2, 1),
dim=(2, 1, 1),

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.

P2 Multiple filters remain untested

The updated history test still launches only f == 0, so it never checks history rolling across filter objects—the behavior this PR changes. The other two-filter test uses history_length=0, so it cannot check older samples. A regression that leaves later filters' histories stale or advances timers once per filter could pass.

Extend this test to use at least two filters with different values and enable air-time tracking. Check that each filter keeps its own history, masked environments stay unchanged, and timers advance once per update.

@ooctipus

Copy link
Copy Markdown
Collaborator

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 29, 2026
@AntoineRichard
AntoineRichard merged commit 121fc81 into isaac-sim:main Nov 30, 2026
63 checks passed
StafaH added a commit that referenced this pull request Dec 3, 2026
…ct history fix (#9362)

## Description

Backport #9297, #9112, and #9323 to `release/3.1.0`. These merged to
`main` after the release branch was cut. The first MDP2 parts (#9016,
#9120) are already on the release branch.

- #9297: Newton contact sensor rolls its force-matrix history with one
thread per filter object.
- #9112: MDP2 resets: reset MDP2 episodes to stored reset states, which
can be generated, recorded during training, pinned, and saved, all
inside the captured step. Its prerequisite, the reset-state API from
#8872, is already on the release branch.
- #9323: MDP2 tracked tasks (`TaskCfg.tracked`) and per-occurrence
events (`MDP2RLEnv.episode_events()`, opt-in with
`record_episode_events`), for Arena's tracked events.

Cherry-picked with `-x`, in merge order, from `121fc8113`, `880939cae`,
and `5fa33d124`. All three applied without conflicts or manual edits,
and their stable patch IDs match the original commits. The original
changelog fragments are included.

## Type of change

- Release backport: features, a bug fix, tests, and documentation

## Validation

- Pre-commit hooks pass on all changed files, with
`ISAACLAB_CHANGELOG_BASE_REF=upstream/release/3.1.0`.
- The changelog check against `upstream/release/3.1.0` passes, and so
does `git diff --check`.
- Every touched test file passes locally on this branch:

- `isaaclab_experimental`: `test_mdp2.py` 63 passed, `test_mdp2_env.py`
31 passed, `test_mdp2_reset_states.py` 19 passed
  - `isaaclab_tasks_experimental`: `test_lift_kuka_allegro.py` 6 passed
- `isaaclab`: `test_reset_state_sampler.py` 11, `test_reset_states.py`
8, `test_dict.py` 12, `test_yaml_io.py` 5 passed
  - `isaaclab_newton`: `test_contact_sensor_history.py` 2 passed
- Hardware: RTX PRO 6000 Blackwell, Linux. Full CI has not run yet.

## Checklist

- [x] Read the contribution guidelines
- [x] Run formatting and lint checks
- [x] Keep the original documentation, tests, and changelog fragments
- [x] Verify the cherry-picks match the original patches

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
AntoineRichard added a commit to AntoineRichard/IsaacLab that referenced this pull request Dec 3, 2026
…ates

Move the PR description evidence rules into the contribution guide and route
the PR workflow skill to them. The SPRI skill now scales with the change,
keeps the number or name that is the point, keeps per-section openings for
long documents only, treats inferences as invented facts, and uses merged PR
descriptions (isaac-sim#9283, isaac-sim#9297, isaac-sim#9167) as examples. The issue skill stops when
issues are disabled or a duplicate exists, and checks permalinks instead of
every link.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working isaac-lab Related to Isaac Lab team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants