Repository navigation
Unify frequency-agnostic Warp memory operations - #8843
Conversation
[High impact] The PR appears safe to merge; no actionable regression was found. SummaryMoves value-preserving Warp memory operations into
No actionable issues were found. This review inspected code and tests; it did not run them. Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["Callers choose types, shapes, and selectors"] --> B["isaaclab.utils.warp.memory"]
B --> C["Cached Warp kernels"]
C --> D["Caller-owned arrays"]
E["Backend mappings and derived quantities"] --> A
Reviews (1) · Last reviewed commit: "Unify frequency-agnostic Warp memory ope..." · Reviewed by Greptile |
There was a problem hiding this comment.
Isaac Lab Review Bot
Needs attention: Scope and over-engineering (1), API (1), Compatibility and deprecation (2), Style consistency (2), Test quality (1). Other reviewed categories look good.
- PR description: The body describes migration and validation but omits removed public symbols; document deprecation paths and provide selected-write timing with revisions, command, hardware, backend, environment count, warmup, and latency.
- Design and architecture: Architecture looks good.
- Scope and over-engineering: Minimal implementation: keep
utils.warp.memoryas the sole added source module; extend existing asset/backend owners only for bindings and mappings, and deletemake_clear_pairplus the unusedmake_splitmask path. Remaining flow is factory binding, caller migration, and helper deletion. Scope is cohesive; no split recommended. - API: The eager 2-D indexed writer registry omits
wp.transformfdespite the wrapper’s documented generic dtype contract, causingKeyError; bindtransformfor restore on-demand specialization. - Compatibility and deprecation: Breaking changes:
resolve_1d_mask,warp.math_ops, and backend kernel symbols lose old imports or signatures without functional warning bridges; retain deprecated aliases and document migration and removal. - Implementation: Implementation looks good.
- Style consistency: Section banners now misclassify active Jacobian, gravity, and heading kernels as deprecated or writes; move each banner back to the section it actually describes.
- Test quality: Behavioral tests cover distinct layout, stride, aliasing, selector-width, and capture contracts, but the ownership test greps source structure; remove those assertions and retain caching and module-isolation checks.
Significant concerns. Posted 7 inline findings.
Automated review; human maintainers own approval decisions.
| @cache | ||
| def _write_2d_user_to_backend_with_indices_dispatcher(dtype: type) -> IndexKernelDispatcher: | ||
| return IndexKernelDispatcher( | ||
| _WRITE_2D_USER_TO_BACKEND_WITH_INDICES_DISPATCHERS = { |
There was a problem hiding this comment.
🟡 Warning · Api — Dtype registry drops documented transformf
The eager dict replaces the on-demand cache but binds only float32 and vec3f, so write_2d_user_to_backend_with_indices(dtype=wp.transformf) — named in its own docstring and supported by the mask variant — now raises KeyError.
|
|
||
|
|
||
| @cache | ||
| def make_clear_pair(dtype, ndim: int) -> wp.Kernel: |
There was a problem hiding this comment.
🟡 Warning · Scope Complexity — Unused clear factory and split mask
make_clear_pair has no production caller in this PR, and make_split's row-mask argument is only ever None outside tests. Delete both and their coverage until a caller exists.
| import torch | ||
| import warp as wp | ||
|
|
||
| ## |
There was a problem hiding this comment.
🟡 Warning · Compatibility — Public mask helper removed without deprecation
resolve_1d_mask is deleted here and its device keyword dropped; warp/math_ops.py goes too. The isaaclab changelog records only an addition. Add forwarding wrappers and a breaking note.
| source = source_checkout_root / "source" | ||
| core = source / "isaaclab/isaaclab" | ||
| owner = core / "utils/warp/memory.py" | ||
| for node in ast.walk(ast.parse(owner.read_text())): |
There was a problem hiding this comment.
🟡 Warning · Test Quality — Drop source-grep ownership assertions
The identifier blacklist, deleted-file checks, and retired-symbol inventory restate this refactor's steps and fail on benign renames rather than on a broken contract. Keep only the caching and module-isolation assertions.
| dst[i, user_dof] = src[dof_start + backend_dof] | ||
|
|
||
|
|
||
| """ |
There was a problem hiding this comment.
🟡 Warning · Style Consistency — Deprecated banner now precedes active kernel
Moving this block above shift_jacobian_com_to_origin marks a live Jacobian kernel as deprecated, and the banner's text describes joint write APIs. Restore it immediately before write_joint_vel_data_index.
| """ | ||
| Generic buffer-writing kernels (used by Articulation + RigidObject + RigidObjectCollection). | ||
| """ | ||
|
|
There was a problem hiding this comment.
🟡 Warning · Compatibility — Backend kernel exports deleted without aliases
vec13f, state packing/splitting, and the write_*_to_buffer* helpers disappear here and in the Newton/OV equivalents; this PR's own multirotor imported one cross-package. Keep deprecated aliases for the removal window.
| """ | ||
| i, j = wp.tid() | ||
| state[i, j] = concat_pose_and_vel_to_state_func(pose[i, j], vel[i, j]) | ||
| """ |
There was a problem hiding this comment.
🟡 Warning · Style Consistency — Section banners mislabel remaining kernels
"Derived property kernels" now heads nothing while the gravity and heading kernels sit under "Root-level write kernels (1D)", which the real write kernels lost. Same shuffle in the Newton and OV modules.
## 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
b7c0b27 to
46941e3
Compare
| shape = (env_ids.shape[0], joint_ids.shape[0]) | ||
| stiffness = self._broadcast_scalar_to_2d(stiffness, shape) | ||
| self.assert_shape_and_dtype(stiffness, shape, wp.float32, "stiffness") | ||
| if not isinstance(stiffness, float): |
There was a problem hiding this comment.
Minor validation issue: please keep assert_shape_and_dtype(...) unconditional here and in the analogous scalar setters. The helper already accepts floats while still checking selector counts. With two instances, stiffness=10.0, env_ids=[1, 0, 1], and joint_ids=[0] previously raised an assertion; this branch bypasses that check and can create a three-entry _sim_env_ids view over a two-entry buffer. That input is invalid, so this does not affect supported calls, but retaining the check helps users catch oversized selectors before an out-of-bounds scratch-buffer write.
AntoineRichard
left a comment
There was a problem hiding this comment.
Nice changes overall! I did some benchmarking on it, it looks good. Thanks a lot for going through this unification.
|
|
||
| def write_joint_state_user_to_backend_with_indices_kernel( | ||
| env_ids: wp.array | torch.Tensor, user_ids: wp.array | torch.Tensor | ||
| env_ids: "wp.array | torch.Tensor", user_ids: "wp.array | torch.Tensor" |
|
run-ci |
Main moved resolve_1d_mask into isaaclab.utils.warp.memory (isaac-sim#8843). resolve_ids and write_2d_with_mask move next to it, and write_2d_with_mask launches the memory module's masked copy and fill kernels instead of its own. resolve_1d_mask keeps the optional scratch mask; masks given without one are returned as given. The SensorBase, sensor test stub and experimental re-export changes are now main's.
## Description Wrench writes duplicated selector handling and global/local buffer routing across four set/add kernels. `isaaclab.utils.warp.wrench` now owns force, torque and moment-arm algebra; `WrenchComposer` owns 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.kernels` remain importable and emit `DeprecationWarning` with 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. Use `WrenchComposer`, or `isaaclab.utils.warp.wrench` for direct launches. The new writer factory accepts the selected force/torque destinations rather than five buffers plus `is_global`. The release note records deprecation instead of an immediate breaking removal. ## Validation Head `028b0fd80`, based on `main` at `9860e2bd8` after #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 --check` passed; 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 `ce4676b33` in [Docker run 40656490099](https://github.com/isaac-sim/IsaacLab/actions/runs/40656490099). That result predates the deprecation change; [Docker CI for the new head](https://github.com/isaac-sim/IsaacLab/actions/runs/40860136394) was triggered with `run-ci` and 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 `vec3f` buffers 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 in `64f723ba7`) and the refactored `3c2b3c107` had 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 in `ooctipus/IsaacLab`. ## Checklist - [x] Contribution and test-audit guidance applied - [x] Formatting, changelog and focused tests passed - [x] Structural audit and regression gates passed - [ ] GitHub checks for the updated head
## 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 Asset micro-benchmarks could abort on missing mock initialization or CPU gravity buffers during CUDA reads. Newton's timed mock callbacks recorded call histories and retained array arguments, while automatic cyclic garbage collection remained enabled during sampling. These issues were found while benchmarking #8843. This fixes the PhysX, Newton, and OVPhysX mock setup, uses non-recording Newton callbacks during benchmarking, and suspends automatic cyclic GC only while collecting samples, restoring the caller's state on failure too. It also includes the seven missing packed root/body state readers, prepares their dependencies outside timing, and keeps Newton rigid-object root/body sources consistent. This PR is based on `main` and does not depend on #8843. ## Type of change - Bug fix - Documentation update ## Validation - 82 existing/focused benchmark tests passed, with each file run separately. Added one small GC lifecycle regression and extended the existing Newton refresh test; confirmed both detect the original failures before applying the fixes. - All nine GPU reader/writer CLI combinations passed: PhysX, Newton MJWarp, and OVPhysX × articulation, rigid object, and collection. Used 32 instances, all input modes, one warmup and two timed calls; checked all 2,003 emitted statistical measurements were finite with `n=2`. These are correctness smoke runs, not performance reference numbers. - All 42 added packed-reader cases matched an independent pose/velocity concatenation exactly on CUDA. - Full `uv run isaaclab -f`, changelog validation, `git diff --check`, and clean `uv run --extra dev isaaclab --docs` passed. Existing dependency/task deprecation notices remain. - GPU validation used an RTX 5090, Python 3.12, Torch 2.11.0+cu128, Warp 1.17.0, Newton 1.8.0.dev0, and OVPhysX 0.6.4.72118723, with imports verified against this worktree. ## Checklist - [x] I have read and understood the contribution guidelines - [x] I have run the pre-commit checks with `uv run isaaclab --format` - [x] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have validated the changed behavior with focused coverage and applied the test-audit criteria to test changes - [x] I have added a changelog fragment for every touched source package - [x] My name already exists in `CONTRIBUTORS.md`
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 throughtile_load,tile_empty,tile_assignandtile_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 (
.warpfor public proxy properties) directly tomemory.concat; other cached kernels passwp.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.indexedarraywithwp.copyor.fill_().resolve_1d_indicesreturns 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 generalmake_copy,make_fill, selector-width dispatch andfull_sourceflags 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_maskfromisaaclab.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
.warpviews 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 fromwp.launchargument 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 andgit diff --checkpassed.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: 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
3c98a7b08againstef3fbd818, 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.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, 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 inooctipus/IsaacLab.Checklist