-
Notifications
You must be signed in to change notification settings - Fork 3.8k
fix: Order OVRTX mapped-attribute commits after the producing Warp stream #7166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
kellyguo11
merged 4 commits into
isaac-sim:develop
from
pv-nvidia:pv/ovrtx-mapping-stream-sync
Aug 20, 2026
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
f3dcbe2
Order OVRTX mapped-attribute commits after the producing Warp stream
pv-nvidia 7e85e0b
Resolve the mapping device through Warp and defer the ovrtx import
pv-nvidia 72ff1d2
Extract get_warp_device_id and give it its own unit test
pv-nvidia 309c345
Keep the pre-existing bare-cuda parse; defer device resolution to a f…
pv-nvidia File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
source/isaaclab_ov/changelog.d/pv-ovrtx-mapping-stream-sync.minor.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| Added | ||
| ^^^^^ | ||
|
|
||
| * Added :func:`~isaaclab_ov.renderers.map_attribute_for_warp_writes`, a context manager that maps | ||
| an OVRTX attribute binding for CUDA writes and unmaps it with the producing Warp stream as the | ||
| CUDA sync. Use it instead of ``with binding.map(...)`` for GPU writes: the binding's own context | ||
| manager unmaps without a CUDA sync, so OVRTX's commit is not ordered against the fill. | ||
|
|
||
| Fixed | ||
| ^^^^^ | ||
|
|
||
| * Fixed the OVRTX renderer's GPU transform writes (object and camera ``omni:xform`` mappings) | ||
| committing without CUDA synchronization against the Warp kernels that fill the mapped buffers. | ||
| The commit is now ordered on the producing Warp stream, as the OVRTX API contract requires; | ||
| previously the ordering held only through CUDA legacy default-stream serialization, an | ||
| implementation detail the contract does not promise. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| # Copyright (c) 2022-2026, The Isaac Lab Project Developers (https://github.com/isaac-sim/IsaacLab/blob/main/CONTRIBUTORS.md). | ||
| # All rights reserved. | ||
| # | ||
| # SPDX-License-Identifier: BSD-3-Clause | ||
|
|
||
| """Stream-safe helpers for OVRTX attribute-binding mappings. | ||
|
|
||
| Filling a CUDA-mapped OVRTX attribute buffer from Warp is only correct when the commit at unmap | ||
| time is ordered against the Warp stream that produced the data: OVRTX's API contract requires the | ||
| mapped data to be ready when the unmap's CUDA sync signals, and an unmap without a sync performs | ||
| no synchronization at all. The ``with binding.map(...)`` form cannot carry that sync -- its | ||
| ``__exit__`` takes no arguments -- so GPU writes through a mapping should use | ||
| :func:`map_attribute_for_warp_writes` instead of the binding's own context manager. | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from collections.abc import Iterator | ||
| from contextlib import contextmanager | ||
| from typing import Any | ||
|
|
||
| import warp as wp | ||
|
|
||
|
|
||
| def _cuda_device_id(device: str) -> int: | ||
| """CUDA device index parsed from a Warp device string, e.g. ``"cuda:1"`` -> ``1``. | ||
|
|
||
| TODO: A bare ``"cuda"`` parses to ``0`` while Warp enqueues fill work on its *current* CUDA | ||
| device, so the mapping and the fill can target different GPUs on multi-GPU processes. The | ||
| split predates this helper and is kept here to avoid a behavior change; a follow-up caches | ||
| the resolved Warp device on the renderer instead of re-deriving it from strings. | ||
|
|
||
| Args: | ||
| device: Warp CUDA device string (``"cuda"`` or ``"cuda:<index>"``). | ||
|
|
||
| Returns: | ||
| The parsed CUDA device index, ``0`` when the string carries none. | ||
| """ | ||
| parts = device.split(":") | ||
| return int(parts[1]) if len(parts) > 1 else 0 | ||
|
|
||
|
|
||
| @contextmanager | ||
| def map_attribute_for_warp_writes(binding: Any, device: str, dtype: Any) -> Iterator[wp.array]: | ||
| """Map ``binding`` for CUDA writes and yield its buffer as a Warp array; commit after the fill. | ||
|
|
||
| The caller fills the yielded array with Warp work enqueued on ``device``'s current stream (the | ||
| default for ``wp.launch``/``wp.copy``). On exit -- error or not -- the mapping is unmapped with | ||
| that stream as the CUDA sync, so OVRTX's commit of the mapped data waits for the fill on the | ||
| GPU instead of racing it. OVRTX has no discard path (unmap always commits), so a failed fill | ||
| still publishes whatever landed in the buffer. | ||
|
|
||
| Args: | ||
| binding: OVRTX attribute binding (from ``bind_attribute``) whose buffer is written. | ||
| device: Warp CUDA device the fill work runs on (e.g. ``"cuda:0"``). | ||
| dtype: Warp dtype the mapped tensor is viewed as (e.g. ``wp.mat44d``). | ||
|
|
||
| Yields: | ||
| The mapped buffer as a zero-copy Warp array, valid only inside the ``with`` block. | ||
| """ | ||
| # Deferred so importing this module (e.g. through the package's lazy exports) cannot initialize | ||
| # ovrtx without the guarded environment ``ovrtx_renderer`` establishes (OVRTX_SKIP_USD_CHECK, | ||
| # actionable install error). Any real ``binding`` was created through that path, so ovrtx is | ||
| # already imported by the time this runs. | ||
| from ovrtx import Device # noqa: PLC0415 | ||
|
|
||
| attr_mapping = binding.map(device=Device.CUDA, device_id=_cuda_device_id(device)) | ||
| try: | ||
| yield wp.from_dlpack(attr_mapping.tensor, dtype=dtype) | ||
| finally: | ||
| attr_mapping.unmap(stream=wp.get_stream(device).cuda_stream) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we have the stream defined once and reused for all writes?
_write_particle_q_slicesuses it too!Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could do that, but my upcoming PR #7169 goes a bit further and caches the warp device itself to work around a bug where passing device id
"cuda"would pick up whatever the current device is instead of using the device at the time the ovrtx renderer was created; a potential bug in mgpu scenarioAnd then we can just do
self._warp_device.stream.cuda_streamWhatever you prefer, I could also do it in this PR but it felt a different task