Skip to content

Encapsulate the articulation element kind into a type - #6507

Closed
AntoineRichard wants to merge 3 commits into
isaac-sim:developfrom
AntoineRichard:antoiner/ordering-element-kind
Closed

AntoineRichard wants to merge 3 commits into
isaac-sim:developfrom
AntoineRichard:antoiner/ordering-element-kind

Conversation

@AntoineRichard

Copy link
Copy Markdown
Collaborator

Description

Follow-up to #6335 addressing @hujc7's review note that the element kind in ordering_resolvers.py should be encapsulated rather than threaded as a Literal["joint", "body"] string with per-kind data scattered across inline ternaries and module dicts.

Introduces a module-private frozen _ArticulationElementKind carrying the per-kind data as fields:

  • backend_names_attr — backend_joint_names / backend_body_names
  • relationship_name — isaac:physics:robotJoints / isaac:physics:robotLinks
  • name_override_attrs — the schema name-override attributes (joint canonical isaac:NameOverride + lowercase fallback; body inverse)
  • config_field — joint_ordering / body_ordering
  • matches_backend_spelling — whether backend DoF-spelling matching applies (joints only)

Two interned singletons (_JOINT_KIND / _BODY_KIND) plus a label registry. _validate_ordering_kind is the single boundary conversion point; the public entry functions keep their Literal["joint", "body"] signatures, so callers and tests are unchanged. The two per-kind module dicts and the scattered kind == "joint" ternaries are gone.

Pure internal refactor, no behavior change and no public API change.

Type of change

  • Refactor (non-breaking, no functional change)

Checklist

  • Ran ./isaaclab.sh --format
  • Existing tests pass unchanged (test_articulation_ordering.py: 62 passed; test_articulation_ordering_kernels.py: 27 passed)
  • Added a .skip changelog fragment (internal refactor, no user-facing entry)

The articulation element kind was a stringly-typed
Literal["joint", "body"] threaded through the ordering resolvers, with
all kind-dependent data scattered as inline ternaries and per-kind
module dicts.

Introduce a module-private frozen _ArticulationElementKind dataclass
that carries the per-kind data as fields: the backend-names attribute,
the robot-schema relationship name and name-override attribute
spellings, the config-field label, and the spelling-match flag. Two
interned singletons (_JOINT_KIND, _BODY_KIND) and a label registry
replace the scattered ternaries and the _ROBOT_SCHEMA_RELATIONSHIP_NAMES
and _ROBOT_SCHEMA_NAME_OVERRIDE_ATTRS dicts.

_validate_ordering_kind becomes the single boundary conversion point,
accepting the public "joint"/"body" string (or an already-resolved
kind) and returning the singleton. The public entry points keep
accepting the string, so the external contract is unchanged. The
per-articulation convention cache stays keyed by the string label to
preserve the cache-key type.
@github-actions github-actions Bot added the isaac-lab Related to Isaac Lab team label Jul 14, 2026
@greptile-apps

greptile-apps Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR wraps articulation ordering kind data in a private type. The main changes are:

  • Added frozen joint and body kind singletons.
  • Moved per-kind relationship names, override attributes, config fields, and spelling policy onto the kind object.
  • Kept public entry points accepting "joint" and "body" strings.
  • Added a skip changelog fragment for the internal refactor.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.
  • The refactor keeps the same public inputs and preserves the previous joint/body metadata values.
  • Cache reads and writes still use plain "joint" and "body" labels.

Important Files Changed

Filename Overview
source/isaaclab/isaaclab/assets/articulation/ordering_resolvers.py Replaces string-threaded kind metadata with private frozen kind objects while preserving the same public labels and per-kind behavior.
source/isaaclab/changelog.d/ordering-element-kind.skip Adds an empty skip changelog fragment for the internal-only refactor.

Reviews (1): Last reviewed commit: "Encapsulate the articulation element kin..." | Re-trigger Greptile

@AntoineRichard
AntoineRichard requested a review from hujc7 July 14, 2026 07:56
Keep per-kind field usage encapsulated with the immutable kind metadata. This makes callers depend on behavior instead of knowing how backend names, robot-schema overrides, and spelling normalization consume each field.
@AntoineRichard
AntoineRichard requested a review from a team July 22, 2026 15:06
Make kind membership a consequence of construction so lookup and iteration cannot drift apart. Reject duplicate labels before equal instances can shadow the registered singleton in kind-keyed dictionaries.
@AntoineRichard

Copy link
Copy Markdown
Collaborator Author

Included with preserved ancestry in aggregate PR #6784. Please keep this source PR unchanged; after #6784 merges, this PR can be closed as superseded if it is still open.

@AntoineRichard

Copy link
Copy Markdown
Collaborator Author

Superseded by #6784, which preserves this PR's commits and ancestry in the aggregate integration branch.

kellyguo11 added a commit that referenced this pull request Aug 1, 2026
# Description

This aggregate PR preserves the ancestry of the articulation reordering
and selector stack so it can be reviewed and merged as one coherent
change.

Merge order preserved in this branch:

- #6507 — articulation ordering element-kind refactor
- #6479 — P9 cached articulation reads across Newton, PhysX, and
OVPhysX, including OVPhysX computed dynamics
- #6741 — rigid asset cache invalidation
- #6652 — P10 signed `int32`/`int64` selector support inside Warp work
kernels
- #6740 — P11 per-asset cached `ProxyArray` finder selectors and
explicit legacy return modes

The P10 commits remain ancestors of P11. The source PRs should stay open
and unchanged until this aggregate PR merges; they can then be closed as
superseded.

Related overlap: #6674. This branch includes the OVPhysX Jacobian,
mass-matrix, and gravity-compensation side folded into P9.

Key outcomes:

- Articulation work kernels accept signed 32-bit and signed 64-bit item
selectors without Torch conversion allocations.
- Raw kernel APIs use dtype-aware factories while retaining
compatibility aliases for deprecated kernels.
- Stable articulation reads are cached for Newton, PhysX, and OVPhysX.
- OVPhysX exposes computed dynamics through the backend-agnostic
articulation data API.
- Asset finders provide opt-in cached, immutable `ProxyArray` selectors
with zero-copy Torch and Warp views and per-asset LRU ownership.
- Implicit legacy finder returns are deprecated; `as_proxy=False`
retains them explicitly during migration.
- Rigid asset state/property writes invalidate same-timestamp derived
caches correctly.
- Changelog entries are consolidated to one fragment per touched
package.

## Asset performance before and after this PR

The table compares the PR merge-base (`a050ceade7`) with the pushed PR
head (`00c8c25cb1`) on an RTX 5090 using CUDA, 4,096 instances, 100
warmup calls, and 1,000 measured calls per operation. It contains only
timed asset method/property calls; application and benchmark startup are
excluded.

Values are the equal-weight mean of the per-operation mean latencies for
operations present on both revisions. The pre-PR `torch_tensor` mode and
post-PR `torch_tensor_int32` mode both generate CUDA `torch.int32`
selectors. Lower is better.

| Backend | Asset | Matched methods / data properties | API methods,
before → after | Data properties, before → after |
|---|---|---:|---:|---:|
| PhysX | Articulation | 24 / 65 | 129.12 → 90.82 µs (-29.7%) | 6.94 →
5.22 µs (-24.8%) |
| PhysX | Rigid object | 13 / 40 | 82.48 → 54.65 µs (-33.7%) | 16.36 →
7.86 µs (-51.9%) |
| PhysX | Rigid-object collection | 13 / 69 | 218.32 → 131.36 µs
(-39.8%) | 64.13 → 27.86 µs (-56.6%) |
| Newton | Articulation | 24 / 64 | 108.64 → 62.01 µs (-42.9%) | 6.48 →
4.70 µs (-27.4%) |
| Newton | Rigid object | 8 / 40 | 66.34 → 43.16 µs (-34.9%) | 15.21 →
10.28 µs (-32.5%) |
| Newton | Rigid-object collection | 8 / 78 | 83.08 → 50.47 µs (-39.3%)
| 37.99 → 12.12 µs (-68.1%) |
| OVPhysX | Articulation | 24 / — | 237.21 → 209.79 µs (-11.6%) |
Baseline failed preflight¹ |
| OVPhysX | Rigid object | 8 / 40 | 144.43 → 142.74 µs (-1.2%) | 18.57 →
15.36 µs (-17.3%) |
| OVPhysX | Rigid-object collection | 8 / 78 | 185.65 → 191.17 µs
(+3.0%) | 46.75 → 41.31 µs (-11.6%) |

API-method latency improved in 8 of 9 backend/asset pairs. Data-property
latency improved in every comparable pair.

¹ The merge-base OVPhysX articulation data benchmark fails during
`body_com_jacobian_w` preflight, while the post-PR suite passes. That
data row is excluded instead of mixing unmatched measurements. The new
`int64` and Warp selector modes are also excluded from this before/after
table because they have no pre-PR equivalent; the post-PR all-mode
matrix passes across all nine backend/asset pairs.

## Type of change

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

## Verification

- Aggregate ordering, dtype-kernel, proxy-cache, consumer,
documentation, and benchmark matrix: **868 passed**.
- Shared articulation, rigid-object, and rigid-object-collection
interface suites: **6,059 passed, 71 skipped, 68 expected failures**.
- OVPhysX computed dynamics: **4 CUDA tests passed** and **4 CPU tests
passed** in separate processes due the backend process-global device
lock.
- Changelog tooling: **90 passed**.
- `./isaaclab.sh -f`: all hooks passed at the pushed HEAD.
- Independent aggregate review: no remaining Critical, Important, or
Minor findings.

Full Kit-backed PhysX/Newton live asset suites were not completed
locally because the available Kit environment timed out during startup;
CI should provide that coverage.

## Screenshots

Not applicable.

## Checklist

- [x] I have read and understood the contribution guidelines
- [x] I have run the pre-commit checks with `./isaaclab.sh -f`
- [x] I have made corresponding changes to the documentation
- [x] My changes generate no unexpected new warnings
- [x] I have added tests that prove the fixes and features are effective
- [x] I have added one changelog fragment under
`source/<pkg>/changelog.d/` for every touched package
- [x] My name already exists in `CONTRIBUTORS.md`

---------

Co-authored-by: Kelly Guo <[email protected]>
matthewtrepte pushed a commit to matthewtrepte/IsaacLab that referenced this pull request Aug 4, 2026
# Description

This aggregate PR preserves the ancestry of the articulation reordering
and selector stack so it can be reviewed and merged as one coherent
change.

Merge order preserved in this branch:

- isaac-sim#6507 — articulation ordering element-kind refactor
- isaac-sim#6479 — P9 cached articulation reads across Newton, PhysX, and
OVPhysX, including OVPhysX computed dynamics
- isaac-sim#6741 — rigid asset cache invalidation
- isaac-sim#6652 — P10 signed `int32`/`int64` selector support inside Warp work
kernels
- isaac-sim#6740 — P11 per-asset cached `ProxyArray` finder selectors and
explicit legacy return modes

The P10 commits remain ancestors of P11. The source PRs should stay open
and unchanged until this aggregate PR merges; they can then be closed as
superseded.

Related overlap: isaac-sim#6674. This branch includes the OVPhysX Jacobian,
mass-matrix, and gravity-compensation side folded into P9.

Key outcomes:

- Articulation work kernels accept signed 32-bit and signed 64-bit item
selectors without Torch conversion allocations.
- Raw kernel APIs use dtype-aware factories while retaining
compatibility aliases for deprecated kernels.
- Stable articulation reads are cached for Newton, PhysX, and OVPhysX.
- OVPhysX exposes computed dynamics through the backend-agnostic
articulation data API.
- Asset finders provide opt-in cached, immutable `ProxyArray` selectors
with zero-copy Torch and Warp views and per-asset LRU ownership.
- Implicit legacy finder returns are deprecated; `as_proxy=False`
retains them explicitly during migration.
- Rigid asset state/property writes invalidate same-timestamp derived
caches correctly.
- Changelog entries are consolidated to one fragment per touched
package.

## Asset performance before and after this PR

The table compares the PR merge-base (`a050ceade7`) with the pushed PR
head (`00c8c25cb1`) on an RTX 5090 using CUDA, 4,096 instances, 100
warmup calls, and 1,000 measured calls per operation. It contains only
timed asset method/property calls; application and benchmark startup are
excluded.

Values are the equal-weight mean of the per-operation mean latencies for
operations present on both revisions. The pre-PR `torch_tensor` mode and
post-PR `torch_tensor_int32` mode both generate CUDA `torch.int32`
selectors. Lower is better.

| Backend | Asset | Matched methods / data properties | API methods,
before → after | Data properties, before → after |
|---|---|---:|---:|---:|
| PhysX | Articulation | 24 / 65 | 129.12 → 90.82 µs (-29.7%) | 6.94 →
5.22 µs (-24.8%) |
| PhysX | Rigid object | 13 / 40 | 82.48 → 54.65 µs (-33.7%) | 16.36 →
7.86 µs (-51.9%) |
| PhysX | Rigid-object collection | 13 / 69 | 218.32 → 131.36 µs
(-39.8%) | 64.13 → 27.86 µs (-56.6%) |
| Newton | Articulation | 24 / 64 | 108.64 → 62.01 µs (-42.9%) | 6.48 →
4.70 µs (-27.4%) |
| Newton | Rigid object | 8 / 40 | 66.34 → 43.16 µs (-34.9%) | 15.21 →
10.28 µs (-32.5%) |
| Newton | Rigid-object collection | 8 / 78 | 83.08 → 50.47 µs (-39.3%)
| 37.99 → 12.12 µs (-68.1%) |
| OVPhysX | Articulation | 24 / — | 237.21 → 209.79 µs (-11.6%) |
Baseline failed preflight¹ |
| OVPhysX | Rigid object | 8 / 40 | 144.43 → 142.74 µs (-1.2%) | 18.57 →
15.36 µs (-17.3%) |
| OVPhysX | Rigid-object collection | 8 / 78 | 185.65 → 191.17 µs
(+3.0%) | 46.75 → 41.31 µs (-11.6%) |

API-method latency improved in 8 of 9 backend/asset pairs. Data-property
latency improved in every comparable pair.

¹ The merge-base OVPhysX articulation data benchmark fails during
`body_com_jacobian_w` preflight, while the post-PR suite passes. That
data row is excluded instead of mixing unmatched measurements. The new
`int64` and Warp selector modes are also excluded from this before/after
table because they have no pre-PR equivalent; the post-PR all-mode
matrix passes across all nine backend/asset pairs.

## Type of change

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

## Verification

- Aggregate ordering, dtype-kernel, proxy-cache, consumer,
documentation, and benchmark matrix: **868 passed**.
- Shared articulation, rigid-object, and rigid-object-collection
interface suites: **6,059 passed, 71 skipped, 68 expected failures**.
- OVPhysX computed dynamics: **4 CUDA tests passed** and **4 CPU tests
passed** in separate processes due the backend process-global device
lock.
- Changelog tooling: **90 passed**.
- `./isaaclab.sh -f`: all hooks passed at the pushed HEAD.
- Independent aggregate review: no remaining Critical, Important, or
Minor findings.

Full Kit-backed PhysX/Newton live asset suites were not completed
locally because the available Kit environment timed out during startup;
CI should provide that coverage.

## Screenshots

Not applicable.

## Checklist

- [x] I have read and understood the contribution guidelines
- [x] I have run the pre-commit checks with `./isaaclab.sh -f`
- [x] I have made corresponding changes to the documentation
- [x] My changes generate no unexpected new warnings
- [x] I have added tests that prove the fixes and features are effective
- [x] I have added one changelog fragment under
`source/<pkg>/changelog.d/` for every touched package
- [x] My name already exists in `CONTRIBUTORS.md`

---------

Co-authored-by: Kelly Guo <[email protected]>
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.

2 participants