Repository navigation
Centralize statically specialized Warp wrench composition - #8844
Conversation
[Medium impact] The PR appears safe to merge; no actionable issues were found. SummaryMoves wrench kernels into
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[WrenchComposer call] --> B[Choose local or world buffers]
B --> C[Choose index or mask writer]
C --> D[Run specialized set or add kernel]
D --> E[Store force and torque contributions]
E --> F[Compose body-frame output when requested]
Reviews (1) · Last reviewed commit: "Centralize statically specialized Warp w..." · Reviewed by Greptile |
There was a problem hiding this comment.
Isaac Lab Review Bot
Needs attention: Design and architecture (1), Compatibility and deprecation (1), Style consistency (2), Test quality (1). Other reviewed categories look good.
- PR description: The body omits removed
warp.kernelssymbols and misstates existing static dispatch and explicit adds as new; document compatibility, correct claims, or supply baseline/candidate revisions, workload, hardware, backend, environments, warmup, and launch-time measurements. - Design and architecture: Destination-buffer selection is duplicated across four
WrenchComposerwriters, creating four policy owners; extract one private helper returning the selected force and torque buffers. - Scope and over-engineering: No over-engineering issues.
- API: API changes look good.
- Compatibility and deprecation: Breaking changes: non-private
warp.kernelswrench symbols were removed; add forwarding aliases with targeted warnings, migration and removal guidance, and transition tests. - Implementation: Implementation looks good.
- Style consistency: Keep module-specific policy and generated-writer contracts in
warp/wrench.py; the shared guide duplicates specialization rules while the writer omits launch, frame, null-array, and moment semantics. - Test quality: The CUDA capture test protects specialization replay, but the AST test only enforces file placement, syntax, names, and imports; delete the implementation-coupled test.
Significant concerns. Posted 5 inline findings.
Automated review; human maintainers own approval decisions.
| .. literalinclude:: snippets/code_skeleton.py | ||
| :language: python | ||
|
|
||
| Shared Warp wrench composition |
There was a problem hiding this comment.
🟡 Warning · Style Consistency — Module-specific section in style guide
This restates the static-specialization rule given above and encodes one module's ownership, naming, and test matrix as repository policy; the prescribed _kernel suffix matches no kernel added here. Move it to the module docstring.
| ## | ||
|
|
||
|
|
||
| @wp.kernel |
There was a problem hiding this comment.
🟡 Warning · Compatibility — Public wrench kernels removed without deprecation
compose_wrench_to_body_frame, add_raw_wrench_buffers, reset_wrench_composer_* and the *_to_dual_buffers_* writers are non-underscored symbols deleted from isaaclab.utils.warp.kernels; direct importers break. Re-export them with a DeprecationWarning for the prescribed cycle.
| selector_dtype = Any if indexed else wp.bool | ||
|
|
||
| @wp.kernel | ||
| def write_wrench( |
There was a problem hiding this comment.
🟡 Warning · Style Consistency — Generated writer lacks documented contract
The deleted kernels documented launch dims, frames, null-array handling, and the cross(positions, forces) moment convention; write_wrench and the four exported variants document none. Add a Google-style docstring covering those.
| else: | ||
| self._has_local_wrench = True | ||
|
|
||
| global_force = self._global_force_w if positions is not None else self._global_force_at_com_w |
There was a problem hiding this comment.
🟡 Warning · Design Architecture — Destination routing duplicated across four writers
The global_force selection and both is_global ternaries repeat verbatim in all four index/mask writers, giving buffer policy four owners. Extract one private _destination_buffers(is_global, positions) helper and reuse it.
| ) | ||
|
|
||
|
|
||
| def test_wrench_ownership_and_exclusive_writes(source_checkout_root): |
There was a problem hiding this comment.
🟡 Warning · Test Quality — AST source-structure test owns nothing
This greps file placement, augmented-assignment syntax, factory names, imports, and absent kernels.py symbols — no observable contract — and fails under behavior-preserving renames. Delete it; the CUDA replay test covers the writers.
## Description Quaternion/frame equations, heading, interval scaling, and Jacobian shifts were independently implemented in backend and task packages. Give shared mathematics one core owner, `isaaclab.utils.warp.math`, and migrate consumers to it. Device operations compose into fused caller kernels. Warp's `wp.map(..., return_kernel=True)` predeclares rank-1/rank-2 inverse rotation and heading, plus rank-2 interval scaling, using Warp's per-operation compilation modules. Zero-extent input and output descriptors avoid allocation and singleton-broadcast specialization; callers keep their existing launch cache. There is no project-specific elementwise mapping factory. Backends retain native solver access and policies. Quaternion `xyzw`, spatial `(linear, angular)`, frames, and existing non-unit-quaternion behavior are explicit contracts. The reorientation task also corrects its quaternion angular error to use `xyzw` components and shortest-rotation math. Deleted duplicate definitions and the Newton state-math module have no forwarding aliases. Shared math entry points use operation names: `quat_rotate_inv[rank]`, `heading[rank]`, `scale_intervals`, and `shift_jacobian_reference`. The device operation remains `scale_interval`; no `_kernel` compatibility aliases remain. This is an ownership refactor; no general environment-FPS improvement is claimed. ## Validation 62 tests passed across shared math (7), ray casting (16), and experimental observation/reward/termination parity (39). The shared math cases exercise both ranks with independently strided inputs and outputs, untouched padding, and CUDA graph replay after all inputs change. Interval scaling checks positive and negative runtime factors. All six native asset/articulation kernel modules compiled on CUDA. An import probe forbidding allocation, launch, and compilation passed. The architecture gate rejects restored custom-factory files, retired helper names, `_kernel` aliases, and forbidden backend dependencies; numerical tests separately protect the equations. Restoring the retired factory failed the intended gate. A centralized audit of all five review-change paths confirmed that the math equations are unchanged and the deleted factory has no callers. All GPU checks used `CUDA_VISIBLE_DEVICES=0`, Python 3.12, Warp 1.17, and the dependencies locked by main `fa569a550`. Each PR was tested in an isolated source checkout with verified import paths. Full `isaaclab --format`, changelog validation, `git diff --check`, and the combined clean Sphinx build passed. The integration branch also passed shared math, shared sensor contracts, and real Newton PVA tests (17 checks). Existing dependency deprecation warnings remain; complete OV/PhysX simulator tests require CI runtimes unavailable locally. ## Review and dependencies This is an independent PR against `main`, part 1/4 of the shared Warp refactor. It has no unmerged code dependency. The complete series is #8842 (math), #8843 (memory), #8844 (wrench), and #8820 (sensor integration), where the final end-to-end results are reported. Working branches are hosted only in `ooctipus/IsaacLab`. ## Checklist - [x] Contribution guidelines and test-audit criteria applied - [x] Full formatting and lint checks passed - [x] Documentation and per-package changelog fragments included - [x] Focused numerical/behavioral checks and structural regression gates passed - [ ] GitHub checks for the Warp map follow-up
AntoineRichard
left a comment
There was a problem hiding this comment.
My main concern is that we're pushing some if-else outside the kernel so potentially locking some switching logic out of the graph, and forcing CPU work before launching kernels, but this is likely neglectable.
| global_force if is_global else self._local_force_b, | ||
| self._global_torque_w if is_global else self._local_torque_b, |
There was a problem hiding this comment.
I think you're pushing a CPU sync here when it's not needed. When graphed it doesn't matter though.
| self._global_force_w, | ||
| self._global_torque_w, | ||
| self._global_force_at_com_w, | ||
| self._local_force_b, | ||
| self._local_torque_b, | ||
| is_global, | ||
| global_force if is_global else self._local_force_b, | ||
| self._global_torque_w if is_global else self._local_torque_b, |
There was a problem hiding this comment.
I think you're pushing a CPU sync here when it's not needed. When graphed it doesn't matter though.
| self._global_force_w, | ||
| self._global_torque_w, | ||
| self._global_force_at_com_w, | ||
| self._local_force_b, | ||
| self._local_torque_b, | ||
| is_global, | ||
| global_force if is_global else self._local_force_b, | ||
| self._global_torque_w if is_global else self._local_torque_b, |
There was a problem hiding this comment.
I think you're pushing a CPU sync here when it's not needed. When graphed it doesn't matter though.
| self._global_force_w, | ||
| self._global_torque_w, | ||
| self._global_force_at_com_w, | ||
| self._local_force_b, | ||
| self._local_torque_b, | ||
| is_global, | ||
| global_force if is_global else self._local_force_b, | ||
| self._global_torque_w if is_global else self._local_torque_b, |
There was a problem hiding this comment.
I think you're pushing a CPU sync here when it's not needed. When graphed it doesn't matter though.
| Dispatched with ``dim=(num_envs, num_bodies)``. Each ``src_*`` / ``dst_*`` pair corresponds | ||
| to one of the five input buffers (global_force_w, global_torque_w, global_force_at_com_w, | ||
| local_force_b, local_torque_b). | ||
| """ |
There was a problem hiding this comment.
Can we add the abreviations in the doc string?
gf = global force, gt = global torque, lf = local force, lt = local torque, gfc = global force at com?
ebae695 to
be26c2d
Compare
## Description Reuse Warp's native views, indexed arrays, copy and fill for ordinary memory movement. A single frequency-agnostic owner, `isaaclab.utils.warp.memory`, retains selection normalization, component views, boolean-masked updates, and measured fused operations. Physical equations, application frequencies, native gathering and simulator row-ID bookkeeping remain with their owners. `memory.concat(first, second, result)` now packs components through `tile_load`, `tile_empty`, `tile_assign` and `tile_store`. It owns validation, scalar views and the tiled grid. No array storage is allocated. Contiguous rank-1 and rank-2 arrays share the same cached specialization; strided arrays retain their layout. Specialization depends on scalar type and component widths, without body/joint/pose/velocity concepts. The cached kernel factory stays private to this operation. The existing launch cache records commands returned by a launch operation. Asset readers pass typed Warp arrays (`.warp` for public proxy properties) directly to `memory.concat`; other cached kernels pass `wp.launch`. This keeps layout preparation out of repeated eager reads and keeps operation-specific code out of the launch cache. CPU calls and CUDA graph capture invoke the operation directly. Callers must clear recorded commands when bound storage changes. Ordinary selected writes use `wp.indexedarray` with `wp.copy` or `.fill_()`. `resolve_1d_indices` returns contiguous int32 selectors: existing contiguous int32 storage is reused, while strided/int64 inputs require a copy/cast. Full-shaped sources select the same source and destination views. The general `make_copy`, `make_fill`, selector-width dispatch and `full_source` flags are removed. Small boolean-mask kernels retain dynamic device selection without compaction; custom factories construct only requested isolated kernels, without eager variant registries. **Migration:** import `resolve_1d_mask` from `isaaclab.utils.warp.memory`; the experimental re-export is removed. Warm execution paths before graph capture. Indexed conversion during capture requires Warp's memory pool. Concatenation inputs and output must not overlap; recorded commands require stable storage. Sensor callers and their buffer-lifetime handling are in #8820. ## Validation Regression validation on `366a86fdf`: **741 tests passed** — articulation contracts (487), rigid-object contracts (231), shared memory (13), mocked IMU/PVA recording (8), and mocked frame-transformer recording (2). The asset suites exercised PhysX, Newton, and OVPhysX with pinned optional OV dependencies; 16 unsupported cases skipped and 5 expected failures remain. The sensor unit cases ran with Kit bootstrap disabled, using their existing mocked views. Before the fix, the same suites reproduced all 37 failures covered by those local boundaries. Asset readers explicitly supply `.warp` views to the host concat operation. Tendon writers pass their already normalized int32 device selectors directly to the native binding, and sensor unit fixtures create the selector buffers normally owned by initialization. The contribution guide distinguishes host operations from `wp.launch` argument conversion. A file-by-file audit checked all 10 changed paths and all 36 concat calls in the six affected data classes. Full formatting, changelog validation and `git diff --check` passed. Earlier unchanged checks cover actuator collection (29), launch caching (1), and asset runtime boundaries (14), plus CPU/CUDA, float32/float64, gradients, tile tails, strides, and graph replay in the memory suite. The prior structural audit, negative controls and clean Sphinx build remain applicable. No kernel implementation changed in this correction. Checks used GPU 0 (RTX 5090), Python 3.12 and Warp 1.17 with verified checkout imports. All five previously failing jobs passed on this head in [Docker CI run 40635185447](https://github.com/isaac-sim/IsaacLab/actions/runs/40635185447): all three core shards, PhysX, and test-curobo. This verifies all 60 reported failures, including the 23 full-simulator concat cases unavailable locally. Other jobs in the wider CI matrix may still be running. Combined environment measurements are in #8820. ## Performance Measured on `3c98a7b08` against `ef3fbd818`, using three fresh processes. The subsequent caller/fixture correction leaves the measured kernels unchanged. CUDA-event measurements use eleven alternating trials of 200 captured operations; eager wall measurements use five alternating trials of 1,000 calls. Repeated operations reuse the same buffers, and all outputs are checked against NumPy. - 65,536 contiguous 7+6-component records: captured **7.76 → 3.02 µs** (2.57× faster); repeated recorded calls **8.40 → 4.03 µs**. - 4,099 contiguous records, including a partial tile: captured **3.01 → 1.50 µs**. - Strided 257×17 records: captured **3.41 → 1.67 µs**. - 65,536 3+4-component records: captured **2.71 → 2.23 µs**. Gains depend on the layout. - Initializing both rank-1 and rank-2 7+6 layouts: cold-cache median **429.66 → 362.93 ms**; warm-disk-cache median **4.67 → 2.78 ms**. These are first-operation setup/load/compile times, excluding process imports, context initialization and array allocation. One shared specialization avoids the second compilation; a single tiled specialization itself did not compile faster. **Tradeoff:** direct uncached eager calls rebuild views: **9.42 → 27.98 µs** for the large 7+6 case. Production asset readers reuse recorded commands; direct callers should do the same for stable hot-path buffers. These operation-level gains do not imply a corresponding environment FPS gain. The native-selector conversion tradeoff remains: per-call strided int64/int32 normalization measured 1.28 → 3.33 µs captured in the preceding follow-up. The tiled operation follows [Warp's concatenation example](https://nvidia.github.io/warp/stable/language_reference/_generated/warp.tile_empty.html), validated against the pinned Warp 1.17 runtime. ## Dependencies and review Part 2/4, independently based on `main`; #8842 is merged and this PR has no unmerged dependency. #8844 covers wrench composition. #8820 contains sensor integration and complete-series measurements. Working branches exist only in `ooctipus/IsaacLab`. ## Checklist - [x] Contribution and test-audit guidance applied - [x] Formatting, changelog, documentation and focused checks passed - [x] Structural gates and negative controls validated - [ ] GitHub checks for the updated head
be26c2d to
3c2b3c1
Compare
|
run-ci |
|
could we keep deprecated exports at the old wrench import paths for a release? for example, importing |
|
run-ci |
## What changed PVA's standard output arrays, cached Warp/Torch views, and reset defaults now have one owner in core. Each backend keeps its public `PvaData` class and inherits that storage. The core `PvaData` factory and `BasePvaData` interface remain available. Direct use of the backend classes and base interface is documented as deprecated; imports do not warn, and no removal release is scheduled. `PvaCfg.data_types` selects pose (required), velocity, acceleration, and projected gravity. Disabled groups allocate no output buffer and raise `NotImplementedError` when read. Each backend declares its supported groups. The shared `BasePva` owns validation, reset, and acceleration visualization; backends own native acquisition, solver mappings, and measurement conversion. Kernels take the optional output arrays separately, and the shared writer receives resolved Boolean options. Newton's native gather kernel remains in its backend. IMU, PVA, and frame-transformer equations have shared core kernel owners. Contact and frame-transformer packed reads use the existing `memory.concat` operation with buffer-lifetime-aware capture. Redundant PhysX/OV PVA, IMU, and joint-wrench kernel files and the PhysX frame kernel file are removed; OV's frame kernel keeps its native operation. The contribution guide now records the ownership and test criteria used here. The PR changes 59 files, with 1,081 additions and 1,693 deletions against its merge base. ## Review boundary and migration Antoine requested a consistent data-container direction. This PR retains the PVA public hierarchy and imports while sharing their storage implementation. IMU, joint wrench, frame transformer, and contact retain their existing public data hierarchies; a broader hierarchy removal can be reviewed separately. Ray-caster and camera data are untouched. See the PVA migration notes and per-package changelog fragments for direct-data users. This is part 4/4. #8842, #8843, and #8844 are merged; their implementation commits are absent from this branch. All working branches are in `ooctipus/IsaacLab`. No upstream mirror branch is used. ## Validation Head: `9d0a4cf37`, based on upstream `main` at `e125fd749`. On this head, 11 shared sensor tests and 4 real Newton PVA tests pass locally. Formatting, changelog checks, `git diff --check`, and a file-by-file owner/forbidden-path audit pass. The public PVA imports and inherited factory path are exercised without import warnings. The earlier 782-test local run and broader benchmark series belong to older revisions, so they are not claimed as current-head proof. Full PhysX/OV simulation coverage requires CI; Docker CI for this head is pending. On the prior head, its only failing job was performance smoke: Isaac Sim aborted while creating shared memory on the runner, so no performance conclusion was possible. Historical paired environment timings were noisy and do not establish a general FPS improvement. The operation-level concatenation timings and full reproduction method are in merged #8843.
Description
Wrench writes duplicated selector handling and global/local buffer routing across four set/add kernels.
isaaclab.utils.warp.wrenchnow owns force, torque and moment-arm algebra;WrenchComposerowns native buffers, destination selection and state bookkeeping in one shared preparation method.Cached factories define and return concrete kernels in isolated Warp modules. Writers specialize only the requested selector types and set/add operation. Index and mask resets share one factory and one seven-buffer reset body. Full resets still use native
zero_(). There are no eager variant tables or returned dispatchers.Frame and input-presence decisions use Python metadata without reading device values. They are fixed at graph capture; selector contents and force/torque values remain device inputs and can change during replay. Exclusive destinations retain ordinary read-add-write assignments. Kernel contracts document frames, launch shapes, null inputs and moment-arm semantics; buffer names spell out their meaning.
Deprecation until Isaac Lab 3.2: all 11 old wrench entry points in
isaaclab.utils.warp.kernelsremain importable and emitDeprecationWarningwith the removal release and migration path. Old kernel objects remain launchable with their original signatures, including generic index kernels, masks, Torch/Warp selector helpers and five-buffer frame routing. A lazily loaded compatibility module adapts those signatures to the shared wrench operations; the composer uses the new API directly. UseWrenchComposer, orisaaclab.utils.warp.wrenchfor direct launches. The new writer factory accepts the selected force/torque destinations rather than five buffers plusis_global. The release note records deprecation instead of an immediate breaking removal.Validation
Head
028b0fd80, based onmainat9860e2bd8after #8843 merged. 38 WrenchComposer tests passed, covering index/mask set/add, both selector widths, local/global frames, moment arms, partial/full reset, lazy composition and CUDA replay. Seven compatibility cases exercise all deprecated entry points and check warning text, original launch signatures, frame routing, null inputs and numerical results on CUDA. Those cases also passed on CPU during development and failed against the pre-fix imports for the intended missing-symbol errors.The structural audit verified file ownership, one-way compatibility dependencies, lazy loading and all 11 deprecated star imports. Full repository formatting, changelog validation and
git diff --checkpassed; the private compatibility module also passed explicit Ruff checks. A clean Sphinx HTML build (-E -a -W --keep-going) passed with zero warnings. Focused CUDA-event measurements of the six current mask/index set/add/reset variants found no material latency change after extracting the shared device functions.Full simulator CI previously passed on
ce4676b33in Docker run 40656490099. That result predates the deprecation change; Docker CI for the new head was triggered withrun-ciand is queued. Local validation used Python 3.12 and Warp 1.17 with verified checkout imports.Focused command:
CUDA_VISIBLE_DEVICES=0 uv run python -m pytest source/isaaclab/test/utils/test_wrench_composer.py -q.Why retain a fused partial reset?
On an RTX 5090 (driver 580.178.04), resetting seven
vec3fbuffers with shape 4,096×16 and half the environments selected took 2.98 µs with the fused indexed reset versus 20.42 µs for seven native indexed-view clears. The masked case took 2.00 µs versus 8.70 µs for seven shared masked fills. These are CUDA-event medians of nine alternating trials, each capturing 100 resets after warmup; indexed views were prebuilt. Shapes 4,096×1 and 65,536×16 were also checked for correctness and timing. This measures the value of retaining existing fusion, not a new throughput improvement.The previous fused implementation (
be26c2dcf, identical wrench source in64f723ba7) and the refactored3c2b3c107had comparable repeated latency. Three fresh-process trials of the first masked reset measured cold kernel initialization 279.36 → 262.86 ms, and warm disk-cache initialization 1.63 → 1.70 ms. These timings predate the deprecation adapters and include factory/compilation/launch and synchronization, excluding imports, CUDA context setup and allocation; they are not environment-startup measurements. No environment FPS gain is claimed.Review and dependencies
Independent PR against
main, part 3/4 of the shared Warp refactor. #8842 and #8843 are merged; #8820 contains sensor integration and complete-series measurements. All working branches are inooctipus/IsaacLab.Checklist