Repository navigation
Cache marker scene-partition tokens instead of rebuilding them each f… - #7647
kellyguo11 merged 2 commits into
Conversation
…rame KitVisualizationMarkers.visualize() resolved and re-authored the primvars:omni:scenePartition token array on every call. Marker ownership is static in most tasks, but visualize() runs every frame, and command terms such as ObjectUniformPoseCommand call it independently of debug_vis. At high environment counts each frame paid a device synchronization, a tuple rebuild, and one token string per marker for a value that never changed. Cache the resolved tokens, the tensor they came from, and the tokens currently authored, so the primvar is only rebuilt and rewritten when the environment IDs actually change. Cache the positive result of the partition-active probe as well; markers can be created before the renderer prepares the stage, so a negative result is still re-checked, but partitions are never withdrawn.
There was a problem hiding this comment.
Isaac Lab Review Bot
The PR caches marker scene-partition ownership and skips token reconstruction and USD re-authoring when environment IDs are unchanged. One performance claim needs correction: the fast path still performs a CUDA-to-host synchronization through bool(torch.equal(...)).
- Design and architecture: The cache remains internal to the Kit visualization backend and preserves ownership updates, clearing, and delayed scene-partition activation. The identity check for the authored tuple is sound because ownership changes create a new tuple.
- API: No public symbols or signatures change. The visualizer changelog is present, but its claim that the change removes the per-frame device synchronization is inaccurate and should instead describe the avoided device-to-host copy, token construction, and USD write.
- Implementation: The unchanged-ID path avoids rebuilding and re-authoring partition tokens, while changed IDs still update them. However,
_matches_cached_environment_ids()convertstorch.equal()to a Python boolean, which synchronizes CUDA execution each frame; the changelog and matching class comment must not claim that synchronization was eliminated.
Minor fixes needed. Posted 1 actionable finding inline.
Automated review; human maintainers own approval decisions.
Fix per Greptile/isaaclab-review-bot review: torch.equal against the cached environment IDs still synchronizes the device every call; only the device-to-host copy, token rebuild, and USD write are actually skipped.
|
run-ci |
| assert list(primvar.Get()) == ["env_1", "env_0"] | ||
|
|
||
|
|
||
| def test_unchanged_environment_ids_do_not_rebuild_scene_partitions(sim, monkeypatch): |
There was a problem hiding this comment.
maybe some of these tests can be removed, they were added to test cache-hit vs. cache-miss paths
matthewtrepte
left a comment
There was a problem hiding this comment.
nice find, looks good. it'd be good to also test, if you haven't yet, if markers which spawn in after scene initialization are updated & cached correctly.
|
Backported to |
#7647) # Description KitVisualizationMarkers.visualize() re-resolved and re-authored the primvars:omni:scenePartition token array on every call. Marker ownership is static in most tasks, but visualize() runs every frame — and ObjectUniformPoseCommand._update_metrics() calls it independently of debug_vis. At 4096 envs, every frame paid a device synchronization, a 4096-entry tuple rebuild, and 4096 token strings for a value that never changed. Isaac-Lift-KukaAllegro-Camera has two such instancers (SuccessMarkers, ObservationPointCloud). This caches the resolved tokens, the tensor they came from, and the tokens currently authored, so the primvar is rebuilt only when the environment IDs change. The partition-active probe caches its positive result; a negative one is still re-checked, since markers can be created before the renderer prepares the stage. Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change. Fixes # (issue) <!-- As a practice, it is recommended to open an issue to have discussions on the proposed pull request. This makes it easier for the community to keep track of what is being developed or added, and if a given feature is demanded by more than one party. --> ## Type of change <!-- As you go through the list, delete the ones that are not applicable. --> - Bug fix (non-breaking change which fixes an issue) ## Release backport - [x] <!-- backport-active-release --> Backport this pull request to the active release branch after it merges into `develop` ## Benchmark Results Measured on `Isaac-Lift-KukaAllegro-Camera` (4096 envs, `duo_camera` preset, single L40 GPU), 200-step `isaaclab benchmark runtime` run before vs. after this commit on top of `develop` (25fad3e): | Metric | Before | After | Change | | --- | --- | --- | --- | | Mean Total FPS | 3773.4 | 4270.6 | **+13.2%** | | Mean Iteration Time | 1085.5 ms | 959.1 ms | -11.6% | | Max Total FPS | 4284.9 | 4703.1 | +9.8% | | GPU Utilization | 28.6% | 37.3% | +8.7 pts | | Scene Creation Time | 295.9 s | 282.0 s | -4.7% | Single run per side, but well outside the ~150-180 FPS std-dev band reported within each run. Confirms the throughput improvement claimed above for this task's SuccessMarkers/ObservationPointCloud instancers. ## Screenshots Please attach before and after screenshots of the change if applicable. <!-- Example: | Before | After | | ------ | ----- | | _gif/png before_ | _gif/png after_ | To upload images to a PR -- simply drag and drop an image while in edit mode and it should upload the image directly. You can then paste that source into the above before/after sections. --> ## Checklist Docker and GPU tests run on demand. Push the commits you want tested, then comment `run-ci` on the pull request. - [ ] I have read and understood the [contribution guidelines](https://isaac-sim.github.io/IsaacLab/main/source/refs/contributing.html) - [ ] I have run the [`pre-commit` checks](https://pre-commit.com/) 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 <!-- As you go through the checklist above, you can mark something as done by putting an x character in it For example, - [x] I have done this task - [ ] I have not done this task --> (cherry picked from commit 1326e94)
Description
KitVisualizationMarkers.visualize() re-resolved and re-authored the primvars:omni:scenePartition token array on every call. Marker ownership is static in most tasks, but visualize() runs every frame — and ObjectUniformPoseCommand._update_metrics() calls it independently of debug_vis. At 4096 envs, every frame paid a device synchronization, a 4096-entry tuple rebuild, and 4096 token strings for a value that never changed. Isaac-Lift-KukaAllegro-Camera has two such instancers (SuccessMarkers, ObservationPointCloud).
This caches the resolved tokens, the tensor they came from, and the tokens currently authored, so the primvar is rebuilt only when the environment IDs change. The partition-active probe caches its positive result; a negative one is still re-checked, since markers can be created before the renderer prepares the stage.
Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context.
List any dependencies that are required for this change.
Fixes # (issue)
Type of change
Release backport
developBenchmark Results
Measured on
Isaac-Lift-KukaAllegro-Camera(4096 envs,duo_camerapreset, single L40 GPU), 200-stepisaaclab benchmark runtimerun before vs. after this commit on top ofdevelop(25fad3e):Single run per side, but well outside the ~150-180 FPS std-dev band reported within each run. Confirms the throughput improvement claimed above for this task's SuccessMarkers/ObservationPointCloud instancers.
Screenshots
Please attach before and after screenshots of the change if applicable.
Checklist
Docker and GPU tests run on demand. Push the commits you want tested, then
comment
run-cion the pull request.pre-commitchecks with./isaaclab.sh --formatsource/<pkg>/changelog.d/for every touched package (do not editCHANGELOG.rstor bumpextension.toml— CI handles that)CONTRIBUTORS.mdor my name already exists there