Skip to content

Cache marker scene-partition tokens instead of rebuilding them each f… - #7647

Merged
kellyguo11 merged 2 commits into
isaac-sim:developfrom
mataylor-nvidia:mataylor/cache-marker-scene-partition
Sep 9, 2026
Merged

kellyguo11 merged 2 commits into
isaac-sim:developfrom
mataylor-nvidia:mataylor/cache-marker-scene-partition

Conversation

@mataylor-nvidia

@mataylor-nvidia mataylor-nvidia commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

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

  • 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

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.

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
  • 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

…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.
@greptile-apps

greptile-apps Bot commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge; no new actionable defects remain, and the sole previous thread was manually resolved.

Summary

  • Caches the source environment-ID tensor, resolved environment-ID tuple, and currently authored tuple.
  • Rebuilds and re-authors primvars:omni:scenePartition only when marker ownership changes.
  • Caches successful detection of renderer scene partitioning while continuing to retry negative detection.
  • Adds regression coverage for unchanged and changed environment IDs.
  • Fixes the per-frame device-to-host copy, token-string allocation, and redundant USD write described in the PR; the remaining tensor comparison can still synchronize CUDA and is now accurately documented.
  • Adds changelog fragments for the affected packages.
  • Requires no new dependencies.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[visualize called] --> B{Environment IDs supplied?}
    B -->|Yes| C{Match cached IDs?}
    C -->|No| D[Clone IDs and rebuild tuple]
    C -->|Yes| E[Reuse cached tuple]
    B -->|No and marker count changed| F[Clear cached ownership]
    D --> G{Scene partitioning active?}
    E --> G
    F --> G
    G -->|No| H[Clear authored primvar if needed]
    G -->|Yes| I{Target tuple already authored?}
    I -->|Yes| J[Skip USD write]
    I -->|No| K[Build token array and author primvar]
Loading

@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 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() converts torch.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.
@mataylor-nvidia

Copy link
Copy Markdown
Contributor 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 Sep 8, 2026
assert list(primvar.Get()) == ["env_1", "env_0"]


def test_unchanged_environment_ids_do_not_rebuild_scene_partitions(sim, monkeypatch):

@mataylor-nvidia mataylor-nvidia Sep 8, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

maybe some of these tests can be removed, they were added to test cache-hit vs. cache-miss paths

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

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.

@kellyguo11
kellyguo11 merged commit 1326e94 into isaac-sim:develop Sep 9, 2026
54 checks passed
@isaaclab-bot

isaaclab-bot Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Backported to release/3.0.0 as 5050618.

isaaclab-bot Bot pushed a commit that referenced this pull request Sep 9, 2026
#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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

isaac-lab Related to Isaac Lab team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants