Skip to content
Draft
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
ff3ebd9
Add the recording utilities and keep lazy data correct under recording
hujc7 Nov 14, 2026
d495a1e
Register model changes again on each replay of a GraphedCallable reco…
hujc7 Nov 14, 2026
5a65f94
Reset the delayed PD actuators and torch-driven Newton actuator state…
hujc7 Nov 14, 2026
275e7c2
Count Warp's CPU capture as a capture in capturing()
hujc7 Nov 14, 2026
19df241
Read the finite-difference accelerations as they are in a recording
hujc7 Nov 15, 2026
64f42d4
Refresh cameras eagerly on each replay of a recording
hujc7 Nov 15, 2026
65c28a6
Key recordings by argument position and scalar type
hujc7 Nov 15, 2026
86e7a63
Refresh host-bound sensors eagerly and read CPU-view body properties …
hujc7 Nov 15, 2026
883dc25
Repeat forward kinematics before an eager call that consumed them whi…
hujc7 Nov 16, 2026
bcf4edf
Read lazy data as stale inside any graph capture
hujc7 Nov 16, 2026
c88845c
Resolve flagged state writes at the start of the Newton step graph
hujc7 Nov 16, 2026
5f6671c
Run a recorded call that makes an eager call without a graph
hujc7 Nov 16, 2026
cf463a5
Raise on torch work and host synchronizations while a graph records
hujc7 Nov 16, 2026
8e44a49
Keep one recorded Warp launch per call site outside the graphs
hujc7 Nov 16, 2026
08b7b71
Document the host work an abandoned recording repeats
hujc7 Nov 16, 2026
133c350
Test that repeated sensor reads in a capture refresh the data once pe…
hujc7 Nov 16, 2026
03d29aa
Mark work that cannot be recorded only with eager_method
hujc7 Nov 16, 2026
3d4a2b7
Record without pausing the garbage collector
hujc7 Nov 16, 2026
fd1e9f9
Remove the process-wide switch that turned recording off
hujc7 Nov 16, 2026
84565e7
Read the PhysX joint state as it is inside a graph capture
hujc7 Nov 17, 2026
0e71e2c
Skip the in-place root pose test for OVPhysX, whose reads copy the bi…
hujc7 Nov 17, 2026
1dd3e6a
Stop labelling the other backends' sensors as unrecordable
hujc7 Nov 17, 2026
638e595
Prune recording tests that stronger tests already cover
hujc7 Nov 17, 2026
7c0784c
Leave resetting recordings to their owners
hujc7 Nov 17, 2026
908ff15
Resolve flagged writes in the step graph only after writes were recor…
hujc7 Nov 17, 2026
90bbae9
Set the recorded-write flag in the captured-step reset test
hujc7 Nov 17, 2026
02fb34c
Merge the plain-call cases of GraphedCallable and comment its recordi…
hujc7 Nov 17, 2026
c0c292a
Say "cached launch" for the launch cache, keeping "record" for Graphe…
hujc7 Nov 17, 2026
3c65f77
Restore the lazy finite differences of the Newton asset data, keeping…
hujc7 Nov 17, 2026
741e29d
Keep a solver reset that reads the host before the step graph, also a…
hujc7 Nov 17, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs/source/api/lab/isaaclab.utils.rst
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,13 @@ so callers must not retain a scratch result across another resolution using the
.. automodule:: isaaclab.utils.warp.memory
:members:

Warp CUDA graph capture
^^^^^^^^^^^^^^^^^^^^^^^

.. automodule:: isaaclab.utils.warp.capture
:members:
:show-inheritance:

Warp Fabric kernels
^^^^^^^^^^^^^^^^^^^

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
* Added :mod:`isaaclab.utils.warp.capture`. :class:`~isaaclab.utils.warp.capture.GraphedCallable` records a call as
a CUDA graph on its first run with a given argument layout and replays it after; it records again for another
layout, or after its owner calls :meth:`~isaaclab.utils.warp.capture.GraphedCallable.reset`.
* Added :func:`~isaaclab.utils.warp.capture.eager_method` to mark methods that cannot be recorded. A
:class:`~isaaclab.utils.warp.capture.GraphedCallable` that calls one while it records abandons the recording
without launching it and runs without a CUDA graph from then on, logging a warning that names both calls.
* Added the ``update_in_graph`` argument to :class:`~isaaclab.utils.buffers.TimestampedBuffer`. Inside any CUDA
graph capture a buffer's :attr:`~isaaclab.utils.buffers.TimestampedBuffer.timestamp` now reads as stale and an
update does not mark it fresh, so a lazily cached value read in a capture is recomputed on every replay, and the
first read after an abandoned capture recomputes it; ``update_in_graph=False`` keeps the plain timestamp rule.
* Added checks to :class:`~isaaclab.utils.warp.capture.GraphedCallable` recordings, with and without Kit: a torch
operation on the recording's device that is not a view, or a host synchronization, while the graph records raises a
:class:`RuntimeError` naming the recorded call and the operation, since a replay would skip it or keep the value it
read. The checks end with the graph, also when the recording raises or is abandoned.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* Changed the cached Warp launches of asset data, sensors and managers to keep one cached launch per call site: an
argument or launch dimension that changes is set on that launch in place instead of building a new one. The
sensor clock update of each physics step reuses a cached launch.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
* Fixed sensors read inside a recorded CUDA graph after a reset keeping their data from before the recording:
:class:`~isaaclab.sensors.SensorBase` now records the buffer refresh in every CUDA graph capture that reads the
data, so each replay refreshes the environments whose data is outdated. :class:`~isaaclab.sensors.Camera` renders
on the host, so a recorded call that reads it runs without a CUDA graph.
Empty file.
2 changes: 2 additions & 0 deletions source/isaaclab/isaaclab/actuators/actuator_pd.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

from ..utils import DelayBuffer, LinearInterpolation
from ..utils.types import ArticulationActions
from ..utils.warp.capture import eager_method
from .actuator_base import ActuatorBase, resolve_joint_parameter

if TYPE_CHECKING:
Expand Down Expand Up @@ -436,6 +437,7 @@ def __init__(self, cfg: DelayedPDActuatorCfg, *args, **kwargs):
self.efforts_delay_buffer = DelayBuffer(cfg.max_delay, self._num_envs, device=self._device)
self._delay_buffers = (self.positions_delay_buffer, self.velocities_delay_buffer, self.efforts_delay_buffer)

@eager_method # samples new delays and resets the delay buffers with torch
def reset(self, env_ids: Sequence[int] | slice | None = None, env_mask: wp.array | None = None) -> None:
super().reset(env_ids, env_mask)
if env_mask is not None:
Expand Down
26 changes: 20 additions & 6 deletions source/isaaclab/isaaclab/actuators/newton/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
from newton.selection import ArticulationView

from ...utils import index_fill_
from ...utils.warp.capture import eager_method
from .kernels import (
build_implicit_dof_mask,
build_per_dof_env_mask_kernel,
Expand Down Expand Up @@ -201,11 +202,9 @@ def reset(
self._reset_states(env_mask)
return
if env_ids is None or env_ids == slice(None):
for sa, sb in zip(self._states_a, self._states_b):
for act, sa, sb in zip(self.actuators, self._states_a, self._states_b):
if sa is not None:
sa.reset(None)
if sb is not None:
sb.reset(None)
self._reset_state_pair(act, sa, sb, None)
return

num_envs = len(range(self._num_envs)[env_ids]) if isinstance(env_ids, slice) else len(env_ids)
Expand Down Expand Up @@ -329,8 +328,23 @@ def _reset_states(self, env_mask: wp.array) -> None:
inputs=[act.indices, env_mask, self._dof_offset, self.num_joints, per_dof_mask],
device=self._device,
)
sa.reset(per_dof_mask)
sb.reset(per_dof_mask)
self._reset_state_pair(act, sa, sb, per_dof_mask)

@staticmethod
def _reset_state_pair(act: Actuator, sa: Any, sb: Any, per_dof_mask: wp.array | None) -> None:
"""Reset both state buffers of an actuator; a torch state, such as a neural network drive's, cannot be
recorded, so its reset goes through :meth:`_reset_unrecordable_state`."""
for state in (sa, sb):
if act.is_graphable():
state.reset(per_dof_mask)
else:
NewtonActuatorAdapter._reset_unrecordable_state(state, per_dof_mask)

@staticmethod
@eager_method
def _reset_unrecordable_state(state: Any, per_dof_mask: wp.array | None) -> None:
"""Reset an actuator state that cannot be recorded, so a recorded call that resets it runs without a graph."""
state.reset(per_dof_mask)


# ---------------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions source/isaaclab/isaaclab/scene_data/scene_data_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def get_transforms(
)
if allow_passthrough:
if cached is None:
cached = self._cache[key] = TimestampedBuffer()
cached = self._cache[key] = TimestampedBuffer(update_in_graph=False)
# Shared requests own the result; Fabric owns its destination, not SDP.
cached.data, cached.timestamp = (layout if fabric else result), timestamp
for name in output_format.vars:
Expand Down Expand Up @@ -382,7 +382,7 @@ def get_geometry_points(
jobs.append((source_indices, destination_indices, buffer, transfer))
if offsets is not None and bound != offsets.keys():
raise KeyError(f"Geometry destinations have no native publication: {offsets.keys() - bound}")
cached = self._cache[key] = TimestampedBuffer((views, jobs, offsets))
cached = self._cache[key] = TimestampedBuffer((views, jobs, offsets), update_in_graph=False)

views, jobs, _ = cached.data
timestamp = self.backend.geometry_timestamp
Expand Down
2 changes: 2 additions & 0 deletions source/isaaclab/isaaclab/sensors/camera/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
quat_from_matrix,
)
from ...utils.warp import ProxyArray
from ...utils.warp.capture import eager_method
from ...utils.warp.memory import resolve_1d_indices, resolve_ids
from ..sensor_base import SensorBase
from .camera_data import CameraData, RenderBufferKind
Expand Down Expand Up @@ -728,6 +729,7 @@ def _prepare_camera(self, env_mask: wp.array) -> None:
self._update_camera_state(env_mask=env_mask, frame_op=1)
self._renderer.prepare_capture(self._render_data, self._data, self._frame)

@eager_method # reads the outdated mask on the host and renders
def _update_buffers_impl(self, env_mask: wp.array):
if not self._env_mask_has_any(env_mask):
return
Expand Down
21 changes: 15 additions & 6 deletions source/isaaclab/isaaclab/sensors/sensor_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
from ..physics import PhysicsEvent, PhysicsManager
from ..sim.utils.queries import get_first_matching_ancestor_prim
from ..sim.utils.transforms import resolve_prim_pose
from ..utils.warp.capture import capturing
from ..utils.warp.launch_cache import _WarpLaunchCache
from ..utils.warp.memory import resolve_1d_mask
from .kernels import invalidate_buffers_kernel, reset_envs_kernel, update_outdated_envs_kernel, update_timestamp_kernel

Expand Down Expand Up @@ -217,7 +219,7 @@ def reset(self, env_ids: Sequence[int] | None = None, env_mask: wp.array | None
],
device=self._device,
)
if env_mask is self._ALL_ENV_MASK:
if env_mask is self._ALL_ENV_MASK and not capturing(self._device):
self._data_dirty = False

def update(self, dt: float, force_recompute: bool = False):
Expand All @@ -226,8 +228,11 @@ def update(self, dt: float, force_recompute: bool = False):
if not self._is_initialized:
return
self._data_dirty |= dt > 0.0
# Update the timestamp for the sensors
wp.launch(
# Update the timestamp for the sensors, through a cached launch: the update runs once per physics step
# outside the recorded parts of the step
self._launch_cache.launch(
"update_timestamp",
wp.launch,
update_timestamp_kernel,
dim=self._num_envs,
inputs=[
Expand All @@ -238,7 +243,6 @@ def update(self, dt: float, force_recompute: bool = False):
dt,
self.cfg.update_period - 1e-6,
],
device=self._device,
)
# Update the buffers; debug visualization refreshes lazily from its callback.
if force_recompute:
Expand Down Expand Up @@ -465,6 +469,7 @@ def _create_timing_buffers(self) -> None:
# A negative timestamp means no backend sample has been read since initialization/reset.
self._timestamp_last_update = wp.full(self._num_envs, -1.0, dtype=wp.float32, device=self._device)
self._elapsed_since_update = wp.zeros(self._num_envs, dtype=wp.float64, device=self._device)
self._launch_cache = _WarpLaunchCache(self._device)

def _invalidate_buffers(self, env_mask: wp.array | None = None) -> None:
"""Invalidate selected results without advancing sampling clocks; None selects all environments."""
Expand All @@ -478,7 +483,9 @@ def _invalidate_buffers(self, env_mask: wp.array | None = None) -> None:

def _update_outdated_buffers(self) -> None:
"""Fills the sensor data for the outdated sensors."""
if not self._data_dirty:
# a graph replays without this check, so every capture that reads the data holds the refresh; the outdated
# mask selects the environments each replay updates
if not self._data_dirty and not capturing(self._device):
return
self._update_buffers_impl(self._is_outdated)
self._mark_buffers_updated()
Expand All @@ -492,7 +499,9 @@ def _mark_buffers_updated(self) -> None:
inputs=[self._is_outdated, self._timestamp, self._timestamp_last_update, self._elapsed_since_update],
device=self._device,
)
self._data_dirty = False
if not capturing(self._device):
# the refresh is recorded, not run: only the replays fill the buffers
self._data_dirty = False

@staticmethod
def _process_batch(sensors: Sequence[SensorBase]) -> None:
Expand Down
42 changes: 35 additions & 7 deletions source/isaaclab/isaaclab/utils/buffers/timestamped_buffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
# SPDX-License-Identifier: BSD-3-Clause

from collections.abc import Iterable
from dataclasses import dataclass
from typing import Any

from ..warp.capture import capture_in_progress


def reset_timestamps(buffers: Iterable["TimestampedBuffer | None"]) -> None:
"""Invalidate cached values, skipping unallocated or unaffected buffers.
Expand All @@ -19,16 +20,43 @@ def reset_timestamps(buffers: Iterable["TimestampedBuffer | None"]) -> None:
buffer.timestamp = -1.0


@dataclass
class TimestampedBuffer:
"""Cached data and its last successful update timestamp.

The owner supplies storage and updates the timestamp after computing the value.
Array caches accept Torch or Warp arrays directly; no conversion is performed.
"""

data: Any = None
"""Cached array, native-format struct, or grouped data; None before allocation."""
Inside any graph capture, on any device, :attr:`timestamp` reads -1 (stale) and a fresh timestamp is not
committed: a graph replays without the owner's timestamp check, so a capture that reads the data must hold its
update for every replay to recompute it, and the update of a capture that is abandoned never runs. Data whose
update a capture must not hold, such as a value its owner fetches through a host call or a cache that records its
own graph, opts out with ``update_in_graph=False``.
"""

timestamp: float = -1.0
"""Source timestamp represented by the data; -1 marks it stale."""
__slots__ = ("data", "update_in_graph", "_timestamp")

def __init__(self, data: Any = None, timestamp: float = -1.0, *, update_in_graph: bool = True):
"""Initialize the buffer.

Args:
data: Cached array, native-format struct, or grouped data. Defaults to None, before allocation.
timestamp: Source timestamp represented by the data. Defaults to -1, which marks it stale.
update_in_graph: Whether a graph capture that reads the data updates it. Defaults to True.
"""
self.data = data
self.update_in_graph = update_in_graph
self._timestamp = timestamp

@property
def timestamp(self) -> float:
"""Source timestamp represented by the data; -1 marks it stale."""
if self.update_in_graph and capture_in_progress():
return -1.0
return self._timestamp

@timestamp.setter
def timestamp(self, value: float) -> None:
if value >= 0.0 and self.update_in_graph and capture_in_progress():
# the update is recorded, not run: only the replays make the data fresh
return
self._timestamp = value
Loading
Loading