Skip to content

Fix OVPhysX re-reading static joint and body properties every step - #7800

Merged
kellyguo11 merged 2 commits into
developfrom
antoiner/fix-ovphysx-property-reads
Sep 16, 2026
Merged

kellyguo11 merged 2 commits into
developfrom
antoiner/fix-ovphysx-property-reads

Conversation

@AntoineRichard

Copy link
Copy Markdown
Collaborator

Description

Fixes the AnymalD / OVPhysX env-step regression introduced when #7713 made the native Newton actuator path the default (perf team repro: 16384 envs, 47 → 256 ms per env step, GPU utilization 65% → 12%; bisected to cdb244d1).

Root cause. PhysxActuatorRuntime._run_native_actuator_kernels launches sync_torque_telemetry with data.joint_stiffness, data.joint_damping and data.joint_effort_limits every physics step. On OVPhysX those are CPU-only bindings whose getters were gated on the simulation timestamp, so each access was a blocking TensorBinding.read into pinned host staging plus an H2D copy — three host round-trips per physics step, re-fired every step because update() bumps the timestamp, with cost linear in the environment count (measured 0.35 ms at 256 envs, 1.07 ms at 1024; extrapolates to ~15 ms per physics step at 16384). PhysX returns cached views and the Isaac Lab actuator path only reads gains for implicit actuators, which is why only OVPhysX × native regressed.

The LSTM itself is on the GPU throughout (DriveNeuralLSTM reports warp_device=cuda:0 torch_device=cuda:0); the regression is host-side.

Fix. Joint properties (gains, limits, armature, friction) and body mass/inertia are static under stepping, and their write_* / set_* setters already update the data buffers in place before pushing to the wheel. They are now read through the existing _read_static_binding_into_buf gate — once after explicit invalidation — instead of once per step. Body state buffers (poses, velocities, accelerations) keep the per-step refresh. Tendon properties are left unchanged (GPU-resident; separate writers) and can follow in a later PR.

Measured (laptop RTX 5000 Ada, isaaclab benchmark runtime, Isaac-Velocity-Flat-AnymalD, physics=ovphysx, 1024 envs, 100 steps):

native actuators, before native actuators, after Isaac Lab actuators
env step 22–30 ms (unstable) 14 ms, std 0 14–15 ms
actuator step / physics step (median) 2.0–2.4 ms 0.94 ms 0.75 ms
gain/limit getters / physics step 1.07 ms (3 blocking reads) 0.01 ms n/a

Regression test test_static_property_reads_are_not_invalidated_by_simulation_steps asserts one binding read across several steps for joint and body properties, one more after explicit invalidation, per-step refresh for state buffers, and the joint-ordering gather path. It fails on develop (assert 3 == 1) and passes with this change.

Fixes # (perf team regression report; no issue filed yet)

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Release backport

  • Backport this pull request to the active release branch after it merges into develop

Checklist

  • I have read and understood the contribution guidelines
  • I have run the pre-commit checks with ./isaaclab.sh --format
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • I have added a changelog fragment under source/<pkg>/changelog.d/ for every touched package (do not edit CHANGELOG.rst or bump extension.toml — CI handles that)
  • I have added my name to the CONTRIBUTORS.md or my name already exists there

OVPhysX joint gains, limits, armature, friction and body mass/inertia are
CPU-only bindings, and their public getters were gated on the simulation
timestamp, so every physics step that touched them paid a blocking host
round-trip whose cost scales linearly with the environment count. The
native Newton actuator path reads stiffness, damping and effort limits on
every physics step for its telemetry sync, which made AnymalD on OVPhysX
several times slower than the Isaac Lab actuator path once #7713 enabled
that path by default (5.4x at 16384 envs on an L40; 1.6x at 1024 envs on a
laptop, with the three reads accounting for the whole gap).

Read these static properties once after explicit invalidation instead. The
write_*/set_* setters already update the buffers in place before pushing to
the wheel, so no per-step refresh is needed; body state buffers keep the
per-step refresh. With the change the native actuator path on OVPhysX
matches the Isaac Lab path at 1024 envs (14 ms vs 14 ms per env step).
@AntoineRichard
AntoineRichard requested a review from a team September 14, 2026 20:48
@github-actions github-actions Bot added bug Something isn't working isaac-lab Related to Isaac Lab team labels Sep 14, 2026
@greptile-apps

greptile-apps Bot commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

The PR appears safe to merge; no actionable correctness, security, or repository-rule issues were identified.

Summary

This PR prevents OVPhysX from repeatedly reading static articulation properties through CPU-only bindings during simulation stepping.

  • Routes joint gains, limits, armature, friction, body mass, and body inertia through explicit-invalidation-based caching.
  • Preserves per-step refresh behavior for dynamic body-state buffers.
  • Adds regression coverage for repeated steps, explicit invalidation, state refreshes, and non-identity joint ordering.
  • Adds the required changelog fragment.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Property getter] --> B{Static property?}
    B -- No: body state --> C{Buffer current for simulation timestamp?}
    C -- No --> D[Read binding and refresh buffer]
    C -- Yes --> E[Return cached buffer]
    B -- Yes: joint/body property --> F{Explicitly invalidated?}
    F -- Yes --> G[Read CPU-only binding once]
    G --> H[Gather into public order if needed]
    H --> E
    F -- No --> E
    I[Property setter] --> J[Update owned cache in place]
    J --> K[Push value to OVPhysX]
    K --> E
Loading

Reviews (1) · Last reviewed commit: "Fix OVPhysX re-reading static joint and ..."

@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

The change consistently applies the existing static-binding cache policy to OVPhysX joint properties and body mass/inertia, avoiding simulation-step-triggered rereads while preserving per-step refreshes for dynamic body state. The focused regression test covers identity ordering, reordered joints, explicit invalidation, and dynamic-state refresh behavior.

  • Design and architecture: The static-versus-dynamic distinction remains contained within the OVPhysX articulation data layer through the existing _read_static_binding_into_buf abstraction and a keyword-only flag on a private body-buffer helper. Limiting this change to CPU-backed joint and body properties while leaving tendon properties unchanged is a proportionate scope choice.
  • API: Public property signatures, return types, shapes, and units are unchanged. The helper parameter is private, and the package includes an appropriately scoped changelog fragment describing the user-visible performance fix.
  • Implementation: The identity-order and reordered-buffer paths both use the static read gate where intended, while reordered paths continue to gather from backend order and propagate timestamps to public buffers. Dynamic pose and velocity paths retain simulation-timestamp refreshes. The principal maintenance dependency is that explicit invalidation and setters continue to keep public and backend staging buffers coherent, matching the caching contract already used elsewhere in this class.

No blocking issues. No inline issue met the actionable-evidence threshold; the assessment above records the review feedback.

Automated review; human maintainers own approval decisions.

@marcodiiga

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 Sep 15, 2026

@marcodiiga marcodiiga left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The static-property read optimization passes the three focused cache/ordering tests, and the new regression test fails against the parent implementation as expected. I found one additional cache-invalidation regression in a runtime readback check: COM orientation writes leave the newly static inertia cache stale. Details inline.

"""
self._refresh_reordered_body_buffer(
self._body_inertia, self._body_inertia_backend, TT.BODY_INERTIA, component_count=9
self._body_inertia, self._body_inertia_backend, TT.BODY_INERTIA, component_count=9, static=True

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Invalidate inertia caches after COM orientation writes

body_inertia can change through set_coms_index() / set_coms_mask(), not only through set_inertias_*(): rotating the COM frame changes the inertia tensor returned by BODY_INERTIA for a body with unequal principal moments. _set_coms() calls _reset_body_com_pose_b_dependents(), but that invalidates neither _body_inertia nor _body_inertia_backend. With static=True, subsequent simulation steps no longer recover the correct value.

Reproduced with ovphysx 0.5.11 on CPU: set inertia to diag(1, 2, 3), prime data.body_inertia, rotate the COM 90 degrees about Z through set_coms_index(), then step and update. The direct BODY_INERTIA read returns approximately diag(2, 1, 3), while data.body_inertia still returns diag(1, 2, 3). The parent getter returns the correct value after the same step; explicitly invalidating the inertia cache also restores the correct readback.

Please include both inertia buffers in the COM-write invalidation path and extend the COM-cache regression test to cover a rotated COM with unequal principal moments, including non-identity body ordering.

@kellyguo11

Copy link
Copy Markdown
Contributor

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 Sep 15, 2026
@kellyguo11
kellyguo11 merged commit 416a1d1 into develop Sep 16, 2026
83 of 84 checks passed
@kellyguo11
kellyguo11 deleted the antoiner/fix-ovphysx-property-reads branch September 16, 2026 11:19
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