Skip to content

Fix stale same-step RTX captures with PhysX-owned pose writes - #7138

Open
StriverAlex wants to merge 1 commit into
isaac-sim:mainfrom
StriverAlex:striveralex/fix-physx-forward-sync
Open

StriverAlex wants to merge 1 commit into
isaac-sim:mainfrom
StriverAlex:striveralex/fix-physx-forward-sync

Conversation

@StriverAlex

@StriverAlex StriverAlex commented Aug 17, 2026 •

Copy link
Copy Markdown

Description

Reworks #7138 onto the pinned main snapshot 3e7e6137089d1db8823f3011941ab1ee73cc9954, addressing the PhysX ownership review. Follow-up to #6661; related to #6394.

Current main already publishes PhysX state through its scene-data backend. The remaining reproduced bug is frame reuse: a pose written after an RTX/Kit frame has been pumped can be hidden by same-step capture deduplication. This revision fixes that missing behavior without reinstating the old native synchronization barrier.

Ownership and implementation

  • PhysxManager now pairs successful native rigid-body, articulation-root and joint-position writes with publication invalidation. All six root/body pose implementations and both joint-position implementations delegate through these methods; indexed and mask APIs retain their existing delegation and selectors.
  • Native root_view objects retain their identity and type. No view proxy, conversion, immediate FK, or additional native barrier is introduced. Direct raw native view writes retain main's explicit invalidation/forward contract.
  • Failed native writes leave publication timestamps and pending FK unchanged. Combined joint-state writes still invalidate successful position writes before attempting velocity writes.
  • The quiet Cartpole action/physics hot path is unchanged. Encapsulation adds two Python helper calls per environment step that contains an automatic reset (one root pose and one joint-position write), not extra native synchronization; the measurements below include these reset costs.
  • PhysicsManager, PhysxManager.forward(), step(), pre_render(), and the generic RenderContext are unchanged from main. Existing PhysX publication owns deferred FK and native-to-Fabric synchronization.
  • A shared PhysX Fabric backend records the transform revision of a successfully rendered frame. RTX deduplication and Kit capture reuse are valid only for that revision. Writes during an app update remain due for the next frame.
  • Newly attached and headless-resumed RGB products retain their own first-frame obligation across failed app updates. Existing headless on-demand capture cadence is preserved.
  • Playback settings are restored with try/finally. No caller-managed pending -> before_kit_app_update -> forward -> Kit update sequence or generic Kit hooks remain.

Reviewer requirement mapping

For the ownership review and the follow-up:

  • One PhysX mutation operation owns both the native write and successful-write invalidation; asset callers no longer write and separately notify. Three manager methods preserve native view compatibility without introducing wrapper views.
  • Deferred FK and native publication stay behind main's existing PhysX forward() / pre_render() / scene-data backend paths. Reusing that implementation avoids another synchronization protocol or barrier.
  • Kit/RTX track only which published revision a frame contains, plus a product's first/resumed-frame obligation. They do not decide whether PhysX FK or native synchronization must run, and do not orchestrate PhysX-specific pending checks.

Regression validation

On the locked main stack: Python 3.12, Isaac Sim pip 6.2.0.0, Torch 2.11.0+cu130, Warp 1.17.0, and main's exact Newton revision 3f428bf1a7183d3d9a10cc17241e8a9eac3841eb.

  • 78 unit checks passed: RTX update/cache/retry/playback (17), Kit capture (6), RenderContext (27), scene-data transforms (14), viewport utilities (2), and Kit scene partitioning (12).
  • 20 checks passed under the actual native Kit/tensor/usdrt runtime: publication bookkeeping with native boundaries mocked (9), real rigid/collection writes (2), articulation writes (2), CPU/CUDA Fabric view contracts (4), lifecycle ownership (1), and real CUDA/RTX camera regressions (2). No failures, collection errors, or skips in these reports.
  • The existing camera reset regression is retained and extended with a same-step pose write and immediate depth capture, without advancing physics. Candidate passes all reset and same-step depth-silhouette assertions. The same test against explicitly verified main production imports fails specifically at the new same-step check: depth silhouette IoU 0.000, required >0.9. The textured-frame case passes on main.
  • Separately, the unmodified main camera test file passes both original cases on this same 6.2 stack. The original reset-publication scenario already passes; this PR's remaining regression is the zero-step same-step capture case above.
  • After fixing headless resumed products, first-product retry and joint-write ownership, final independent read-only standards/minimality and reviewer-spec reviews both reported zero findings. A fresh rerun of the 17 RTX and 6 Kit checks passed without changing the tested source tree.
  • Full-repository pre-commit passed, including Ruff, formatting, license, codespell, changelog, whitespace and LFS checks; git diff --check passed.
  • Full repository suite and multi-GPU matrix have not been run locally. Remote CI is a separate gate.

Performance: main / candidate / main

Used the unmodified upstream isaaclab benchmark runtime evaluator, Isaac-Cartpole-Direct, explicit physics=isaacsim_physx, 4096 environments, seed 42, --measure_sync_step, and schema output. All processes ran sequentially using the same interpreter/runtime/GPU. Production source paths and the candidate diff hash were checked for each run. Online extension resolution was disabled before sampling; no system governor or clock settings were changed.

Mean synchronized environment-step latency (lower is better):

Workload Main A1 Candidate B Main A2 B vs endpoint mean Baseline drift
Visible Kit, 200 warmup / 2000 measured 18.2324 ms 18.1952 ms 18.1823 ms -0.0669% -0.2746%
Quiet physics, 2000 warmup / 20000 measured 3.0227 ms 3.0531 ms 3.0244 ms +0.9779% +0.0590%
Quiet confirmation, 5000 warmup / 50000 measured 3.0343 ms 3.0137 ms 3.0478 ms -0.9004% +0.4465%

Kit B differs from the endpoints by -0.2041% / +0.0707%; the old +11% rendered-workload regression was not observed. The first quiet triplet was borderline: B was +1.0077% / +0.9481% versus its two stable baselines. This was not dismissed as noise or used alone to clear CI.

Before collecting confirmation data, all three quiet samples were extended identically to 5000 warmup / 50000 measured steps, retaining the first triplet. Confirmation B is -0.6792% / -1.1207% versus the two endpoints. Pooling both final-base quiet triplets by measured step count gives B -0.3660% versus the pooled endpoint mean (70,000 candidate measured steps, 140,000 baseline steps). These meet the predeclared confirmation gates: <=3% baseline drift, <=1% candidate slowdown versus both confirmation endpoints, and <=1% pooled slowdown. This is a bounded performance check, not a statistical proof of zero overhead.

Confirmation A2 was interrupted by SIGTERM before producing a report (cause unestablished). Its log is retained and excluded as incomplete; only A2 was rerun with identical parameters in a separate session. The completed A1/B samples were not reselected. No source or machine-setting changes were made during sampling. All completed final-base measurements, the interrupted log, JUnit, schema JSON and evaluator source-identity records are retained locally. Earlier pre-rebase measurements are archived separately and not used to clear this final snapshot.

Across the repeated samples, no reproducible slowdown exceeding the preselected 1% threshold was observed for the measured single-GPU Cartpole workloads. This is not a universal zero-cost guarantee or evidence of statistically significant speedup. CPU governor: powersave; GPU: RTX 4090 D, driver 580.178.04.

The benchmark commands use the official runtime entrypoint, for example:

HEADLESS=0 isaaclab benchmark runtime --task Isaac-Cartpole-Direct physics=isaacsim_physx --num_envs 4096 --seed 42 --visualizer kit --num_steps 2000 --warmup_steps 200 --measure_sync_step --kit_args=--/app/extensions/registryEnabled=false --benchmark_formatter schema --output_path /tmp/pr7138-kit
HEADLESS=1 isaaclab benchmark runtime --task Isaac-Cartpole-Direct physics=isaacsim_physx --num_envs 4096 --seed 42 --visualizer none --num_steps 50000 --warmup_steps 5000 --measure_sync_step --kit_args=--/app/extensions/registryEnabled=false --benchmark_formatter schema --output_path /tmp/pr7138-quiet

Run each command against main, candidate, then main sequentially in the same locked environment; visible Kit requires a working display. The local harness explicitly verifies the imported checkout rather than relying on editable-package defaults.

Remote CI and review status

Published head: 497a3d2dc7d72003f57c8661c2e978b5ff097b50. The CI request workflow succeeded, but Docker + Tests for that head reports action_required with zero jobs started. Remote tests have not passed or failed; maintainer action is required to allow CI to run. The existing CHANGES_REQUESTED review also still requires maintainer re-review. Local verification does not substitute for either gate.

Checklist

  • Rebased onto the current main snapshot and adapted to its instance-based managers and scene-data architecture.
  • Encapsulated mutation/invalidation and synchronization ownership in PhysX; removed obsolete generic Kit hooks and barriers.
  • Added observable regression tests and reproduced the missing behavior on main.
  • Ran targeted unit/native/RTX validation and bracketed rendered/quiet performance checks.
  • Updated changelog fragments and preserved the contributor entry.
  • Ran full repository formatting/static checks.
  • Full repository and multi-GPU suites.
  • Remote Docker/GPU CI result.

@StriverAlex
StriverAlex requested a review from a team August 17, 2026 10:42
@github-actions github-actions Bot added bug Something isn't working isaac-lab Related to Isaac Lab team labels Aug 17, 2026
@greptile-apps

greptile-apps Bot commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds a step-stamped PhysX tensor-pose synchronization barrier so same-step pose writes are propagated before the next Kit/RTX frame without adding work to normal physics or clean rendering paths.

  • Adds backend-neutral pending-work and frame-boundary hooks to PhysicsManager.
  • Tracks successful PhysX tensor pose writes across rigid objects, collections, and articulations.
  • Makes RTX renderer deduplication and Kit visualizer frame reuse conditional on the absence of pending synchronization.
  • Preserves and restores Kit playback state around frame updates.
  • Adds unit, integration, CUDA, and first-frame RTX regression coverage.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains; both previously reported stale-frame paths now check pending backend work and perform synchronization before producing or sampling the next Kit frame.

Important Files Changed

Filename Overview
source/isaaclab/isaaclab/physics/physics_manager.py Adds backend-neutral, no-op pending-work and pre-Kit-update hooks.
source/isaaclab_physx/isaaclab_physx/physics/physx_manager.py Implements the step-stamped tensor-pose write barrier, stale-token handling, retry preservation, and lifecycle cleanup.
source/isaaclab_physx/isaaclab_physx/renderers/isaac_rtx_renderer_utils.py Correctly bypasses same-frame deduplication and visualizer ownership skips when backend synchronization is pending.
source/isaaclab_visualizers/isaaclab_visualizers/kit/kit_visualizer.py Invalidates captured-frame reuse after a post-pump pose write and performs synchronization immediately before the Kit update.
source/isaaclab_physx/isaaclab_physx/assets/articulation/articulation.py Notifies the barrier after successful native root-link and center-of-mass pose writes.
source/isaaclab_physx/isaaclab_physx/assets/rigid_object/rigid_object.py Notifies the barrier after successful native rigid-object pose writes.
source/isaaclab_physx/isaaclab_physx/assets/rigid_object_collection/rigid_object_collection.py Notifies the barrier after successful native collection body-pose writes.
source/isaaclab_physx/test/renderers/test_isaac_rtx_renderer_utils.py Covers same-step pending-write dedup bypass and playback-state restoration.
source/isaaclab_visualizers/test/test_kit_visualizer.py Covers clean capture reuse, post-pump invalidation, synchronization ordering, and failure cleanup.

Sequence Diagram

sequenceDiagram
    participant Writer as Tensor pose writer
    participant PhysX as PhysxManager
    participant Owner as Renderer / KitVisualizer
    participant Fabric as Fabric
    participant Kit as Kit app
    Writer->>PhysX: notify_tensor_pose_write()
    PhysX->>PhysX: Record current public-step token
    Owner->>PhysX: has_pending_kit_app_update()
    PhysX-->>Owner: true
    Owner->>PhysX: before_kit_app_update()
    PhysX->>PhysX: update_simulation()
    PhysX-->>Owner: requires re-forward
    Owner->>Fabric: forward()
    Owner->>Kit: app.update()
    Kit-->>Owner: RTX frame with updated pose
Loading

Reviews (3): Last reviewed commit: "Keep post-pump pose writes visible to Ki..." | Re-trigger Greptile

@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

Reviewed the step-stamped PhysX tensor-pose write barrier, including all six writer notification paths, token coalescing and lifecycle, and consumption at Kit/RTX frame boundaries. The proposed concern that update_simulation(dt, 0.0) advances physics is not established by the patch: the public step count remains unchanged, and native callback emission alone does not demonstrate simulation advancement or rendered/headless divergence.

  • Design and architecture: The backend-specific synchronization obligation remains private to PhysxManager, while the additive backend-neutral hook lets frame owners request synchronization without burdening normal physics steps or clean rendering paths. The renderer utility and Kit visualizer both consume the hook at an actual app-update boundary.
  • API: PhysicsManager.before_kit_app_update() -> bool is an additive, documented default-no-op API. Both consumers honor its boolean re-forward contract, existing tensor writer signatures remain unchanged, and package changelog coverage is present.
  • Implementation: The six PhysX tensor pose implementations notify only after their native transform write, writes coalesce by public physics-step epoch, stale tokens are dropped after a real step, failed synchronization is requeued, and lifecycle resets clear pending state. Kit playback state is restored with try/finally. Native pre/post callback emission during the synchronization is an observable tradeoff covered by tests, but the supplied finding does not establish that it advances simulation state or identify a broken callback consumer; using zero elapsed time is likewise not shown to preserve the required propagation.

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.

@StriverAlex

Copy link
Copy Markdown
Author

@greptileai

@StriverAlex

Copy link
Copy Markdown
Author

@greptileai

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

There are a few things I don’t like about this PR:

  1. Kit-specific concepts have leaked into the backend-neutral PhysicsManager interface. Methods such as before_kit_app_update() and has_pending_kit_app_update() belong to the concrete PhysX/Kit integration, not the common physics contract. I think PhysxManager.forward() should conditionally perform the required synchronization and hide this complexity from its callers.

  2. The current API requires callers to understand the synchronization sequence: check for pending work, call before_kit_app_update(), conditionally call forward(), and finally update Kit. This leaks implementation details and is fragile because every frame-producing caller must reproduce the sequence correctly.

  3. The pairing of self.root_view.set_transforms(...) with a separate notify_tensor_pose_write() call suggests a missing abstraction. Correctness currently depends on every existing and future writer remembering to issue the notification after a successful mutation. These operations should be coupled by construction, for example:

class PhysxArticulationView:
    def set_root_transforms(self, transforms, indices):
        self._native_view.set_root_transforms(transforms, indices)
        self._manager.mark_render_state_dirty()

Ideally, callers should perform a single mutation through the PhysX abstraction. The abstraction should automatically track whether synchronization is required, and PhysxManager.forward() should consume that state. Neither asset writers nor Kit frame owners should need to understand or maintain this synchronization protocol.

@pbarejko pbarejko mentioned this pull request Sep 14, 2026
8 tasks
@maxkra15 maxkra15 self-assigned this Oct 28, 2026
@maxkra15
maxkra15 self-requested a review October 28, 2026 12:44
@maxkra15

Copy link
Copy Markdown
Contributor

@StriverAlex please respond to the PhysX ownership review and update the design. Dirty tracking and synchronization should live behind the PhysX view/manager, without caller-managed Kit sequencing. Rebase and restore CI so we can finish this PR.

Pair successful pose and joint-position mutations with invalidation inside
PhysxManager, preserving native views and main's deferred publication path.
Reuse a successfully rendered Fabric revision only while it is current.

Constraint: Keep PhysicsManager and PhysxManager forward/step/pre_render unchanged.
Rejected: Caller-managed Kit hooks and update_simulation barriers | Leak ownership and add steady-state synchronization cost.
Scope-risk: moderate
Confidence: high
Directive: Invalidate only after successful native writes; do not wrap or replace native tensor views.
Tested: 78 unit checks; 20 native-runtime checks; CUDA/RTX negative control; Kit and quiet main/candidate/main synchronized benchmarks; full pre-commit.
Not-tested: Full repository suite and multi-GPU matrix; remote Docker CI follows local performance gates.
@StriverAlex
StriverAlex force-pushed the striveralex/fix-physx-forward-sync branch from 79be514 to 497a3d2 Compare November 17, 2026 08:45
@StriverAlex StriverAlex changed the title Fix first-frame RTX synchronization after tensor pose writes Fix stale same-step RTX captures with PhysX-owned pose writes Nov 17, 2026
@StriverAlex

Copy link
Copy Markdown
Author

Addressed the PhysX ownership review in 497a3d2, rebased onto main at 3e7e613.

Successful pose/joint-position writes and invalidation are now paired inside PhysxManager. Native view identity and main's deferred publication are preserved; PhysicsManager and PhysxManager.forward/step/pre_render are unchanged. The old caller-managed Kit hooks and native synchronization barrier are gone. The remaining reproduced bug on main is same-step frame reuse, rather than its already-supported reset publication.

Local gates passed before requesting CI: 78 unit checks plus 20 native-runtime checks, a real CUDA/RTX negative control (main fails the same-step silhouette check at IoU=0.000; candidate passes), and full pre-commit. The 20 native-runtime checks include 9 bookkeeping checks with native boundaries mocked, as detailed in the PR description.

For synchronized 4096-environment Cartpole A/B/A, Kit is -0.0669% versus the endpoint mean. Quiet's first 20k triplet was borderline at +0.9779%, so it was retained and followed by a predeclared 50k confirmation (-0.9004%); pooling both quiet triplets gives -0.3660%. The description includes all measurements, the interrupted baseline/retry, commands, thresholds, and verification limits. No reproducible slowdown above the preselected 1% gate was observed in these workloads; this is not an all-task or multi-GPU guarantee.

Ready for re-review. Requesting remote CI only after these local functional, performance, and independent evidence gates passed.

@StriverAlex

Copy link
Copy Markdown
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 Nov 17, 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

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