Skip to content

Resolve id and mask selections through shared helpers - #8821

Draft
hujc7 wants to merge 6 commits into
isaac-sim:mainfrom
hujc7:jichuanh/id-mask
Draft

hujc7 wants to merge 6 commits into
isaac-sim:mainfrom
hujc7:jichuanh/id-mask

Conversation

@hujc7

@hujc7 hujc7 commented Oct 26, 2026

Copy link
Copy Markdown
Collaborator

Summary

Id and mask selections now resolve through two shared helpers, resolve_ids and resolve_1d_mask, instead of
about 30 hand-written copies across the Newton, OVPhysX and PhysX assets, sensors and the wrench composer
(−1086 / +612 source lines). Newton mask writers that converted masks to ids now write through the mask: 4-11x faster.

Description

1. Changes

  1. Shared helpers (isaaclab/utils/warp/utils.py)
    • New resolve_ids: ids or a boolean mask → ids on a device.
    • resolve_1d_mask: scratch_mask is optional for callers that never pass ids; a Warp mask on another device is
      copied; a boolean torch mask already on the device is accepted inside a CUDA graph capture.
    • isaaclab_experimental.utils.warp.resolve_1d_mask is now this function instead of a copy.
  2. Callers routed through the helpers: the Newton, OVPhysX and PhysX assets, SensorBase, Camera and
    WrenchComposer. Every selection now accepts the same inputs: any integer sequence, slices with a negative step,
    ids on another device (moved to the owner's device). A ProxyArray raises TypeError.
  3. Faster Newton write paths (see 2)
    • The RigidObjectCollection mask writers and the fixed-tendon mask setters write through the masks instead of
      converting them to ids, which waited for the GPU on every call.
    • The joint-coordinate writes reuse a scratch mask instead of allocating one per call.
    • One generic masked 2-D write kernel, with a cached overload per dtype, replaces 2 copies.
  4. Fixes
    • The deformable write_nodal_*_to_sim_mask writers raised a RuntimeError whenever env_mask was given
      (BaseDeformableObject, so OVPhysX, and PhysX).
    • The Newton fixed-tendon mask setters accepted data whose shape does not match the articulation.

2. Performance

Desk RTX PRO 6000, Newton, main vs this PR. Micro: contract-test Newton assets, 4096 envs, host µs per call
including the GPU wait, median of 7x300 calls, 2 alternated runs per side.

Write path Selection main (µs) this PR (µs) Speed-up
Fixed-tendon stiffness mask setter half envs, 2 tendons 201-208 18.5-19.0 11x
Fixed-tendon position limit mask setter half envs, 2 tendons / all 185-194 / 80-86 18.3 / 17.5 10x / 4.7x
write_fixed_tendon_properties_to_sim_mask half envs, 2 tendons / all 263-272 / 147-154 26.0-26.8 / 25.2-25.8 10x / 5.9x
Collection link / com pose mask writers half envs, 2 bodies 165-175 32.6-38.9 4.5-5x
Collection link / com velocity mask writers half envs, 2 bodies 168-188 34.8-47.8 3.9-4.7x
write_joint_position_to_sim_index / write_joint_state_to_sim_index half envs 70-72 47.9-51.8 1.4-1.5x

End to end, isaaclab benchmark runtime ... presets=newton_mjwarp, 3 alternated runs per side, total FPS:

Task main this PR Change
Isaac-Cartpole-Direct (3000 steps) 2841-2851K 2985-3011K +5.4%
Isaac-Reorient-Cube-Shadow-Direct (1000 steps, 8192 envs) 495.7-495.8K 498.0-501.4K +0.9%
Isaac-Velocity-Flat-UnitreeGo2 (1000 steps) -0.6%, within noise

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist

Docker and GPU tests run on demand. Push the commits you want tested, then
comment run-ci on the pull request.

  • 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 (do not edit CHANGELOG.rst or bump package versions — CI handles that)
  • I have added my name to the CONTRIBUTORS.md or my name already exists there

@hujc7

hujc7 commented Oct 26, 2026

Copy link
Copy Markdown
Collaborator Author

run-ci

@github-actions github-actions Bot added the isaac-lab Related to Isaac Lab team label Oct 26, 2026
@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 Oct 26, 2026
@hujc7

hujc7 commented Oct 26, 2026

Copy link
Copy Markdown
Collaborator Author

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 Oct 26, 2026
hujc7 added 6 commits October 26, 2026 02:48
…pers

resolve_ids resolves ids or a boolean mask to ids on a device, as resolve_1d_mask does to a mask. resolve_1d_mask takes an optional scratch mask, copies a Warp mask on another device, and accepts a boolean torch mask on its device inside a graph capture. The experimental package now re-exports it instead of keeping a copy.
…red helpers

SensorBase, Camera and WrenchComposer resolve env_ids, env_mask and body_ids through resolve_ids and resolve_1d_mask instead of their own copies. The test doubles that build these objects without their initializer get the env masks a real sensor creates.
The nodal mask writers of BaseDeformableObject, which the OVPhysX deformable object inherits, and of the PhysX deformable object called wp.nonzero on a Warp array, which raised a RuntimeError. They now resolve the mask to ids with resolve_ids and call the index writers.
…sk writers through masks

The Newton assets resolve ids and masks through resolve_ids and resolve_1d_mask. The RigidObjectCollection mask writers and the fixed-tendon mask setters write through the masks instead of converting them to ids, which waited for the GPU on every call; the joint-coordinate writes reuse a scratch mask; one generic masked 2-D write kernel replaces two copies.
The OVPhysX assets resolve env, body, joint and tendon selections through resolve_ids and resolve_1d_mask instead of their own copies.
The PhysX assets resolve env, body, joint and tendon selections through resolve_ids and resolve_1d_mask instead of their own copies. The sensor test doubles get the env masks a real sensor creates.
@hujc7

hujc7 commented Oct 26, 2026

Copy link
Copy Markdown
Collaborator Author

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 Oct 26, 2026

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

isaac-lab Related to Isaac Lab team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant