Repository navigation
Reserve CUDA graph memory when the simulation context is created - #8539
kellyguo11 merged 3 commits into
Conversation
On Windows, the first allocation recorded in a CUDA graph after the renderer's first frame can stall the CUDA driver for minutes while it places the graph-memory address range. Record one tiny allocation in a graph right after selecting the device, before physics backends and renderers are created, so later captures reuse the early reservation. Fixes isaac-sim#8342.
|
run-ci |
|
| or warp_device.alias in _GRAPH_MEMORY_RESERVED_DEVICES | ||
| ): | ||
| return | ||
| _GRAPH_MEMORY_RESERVED_DEVICES.add(warp_device.alias) |
There was a problem hiding this comment.
Failed attempts block later retries
reserve_cuda_graph_memory marks the device as reserved before the capture succeeds. If capture fails, every later call for that device returns without trying again, including after a new SimulationContext is created. Add the alias only after a successful capture, or remove it on failure, and test that a failed attempt can be retried.
There was a problem hiding this comment.
Fixed in 71079fc: the device is marked as reserved only after the capture succeeds, so a failed attempt is retried by the next call. The device test now covers a failure followed by a successful retry.
StafaH
left a comment
There was a problem hiding this comment.
Let's minimize the additional test coverage, and also leave a #TODO to remove this after the bug is fixed
Mark a device as reserved only after the capture succeeds, so a failed attempt is retried by the next simulation context. Reduce the new device tests to one, and add a TODO to remove the workaround once the CUDA driver bug is fixed.
|
@StafaH Thanks. Done in 71079fc: added a TODO at the call site to remove the workaround once the CUDA driver bug is fixed, and reduced the new tests to one device test plus the ordering test (the earlier skip-case and real-CUDA tests are removed). The commit also marks a device as reserved only after a successful capture, per the Greptile comment. |
There was a problem hiding this comment.
Isaac Lab Review Bot
Needs attention: Style consistency (1), Test quality (2). Other reviewed categories look good.
- PR description: The stall-rate evidence covers hardware, backend, workload, environment count, samples, and results; add exact baseline and candidate revisions, the reproduction command, and warmup procedure.
- Design and architecture: Architecture looks good.
- Scope and over-engineering: No over-engineering issues.
- API: API changes look good.
- Compatibility and deprecation: No breaking changes identified.
- Implementation: Implementation looks good.
- Style consistency: The
utils.devicemodule docstring excludes graph-memory reservation, leaving its documented scope stale; broaden it to cover both device selection and CUDA graph reservation. - Test quality: The added tests duplicate SimulationContext construction setup and never assert
wp.empty; share the harness and verify the allocation call.
Minor fixes needed. Posted 3 inline findings.
Automated review; human maintainers own approval decisions.
| wp.set_device(warp_device) | ||
|
|
||
|
|
||
| def reserve_cuda_graph_memory(device: str) -> None: |
There was a problem hiding this comment.
🟡 Warning · Style Consistency — Module docstring excludes graph reservation
The module documents itself as "Internal utilities for selecting compute devices", which no longer covers this graph-memory reservation. Update the module docstring to cover both responsibilities.
| physics_manager.initialize.side_effect = lambda sim: order.append("physics_initialize") | ||
| physics_cfg = SimpleNamespace(class_type=physics_manager, dt=0.01) | ||
| settings = {} | ||
| monkeypatch.setattr(context_module, "_resolve_physics_cfg", lambda cfg, use_isaac_sim: physics_cfg) |
There was a problem hiding this comment.
🟡 Warning · Test Quality — Duplicated SimulationContext construction setup
These monkeypatch lines repeat verbatim the harness in test_visualizer_construction_precedes_initialization_and_happens_once, so future __init__ changes must be mirrored twice. Extract the shared construction setup into one fixture or helper.
|
|
||
|
|
||
| def test_reserve_cuda_graph_memory_captures_once_and_retries_after_failure(monkeypatch): | ||
| """One allocation is recorded per device; a failed attempt is retried by the next call.""" |
There was a problem hiding this comment.
🟡 Warning · Test Quality — Test docstring claims unverified allocation
The mocked wp.empty is never recorded or asserted, so deleting the production allocation leaves this test green despite the "one allocation is recorded" claim. Assert the allocation or narrow the docstring to capture count and…
|
run-ci |
|
@egolubev-nvda to @StafaH's point - the new tests only are for a temporary workaround. Could you drop the tests in the PR. I can re-trigger the pipeline after |
|
run-ci |
Backports #8539 to `release/3.0.0`. The original cherry-pick conflicted. An NVIDIA inference model proposed this resolution, and deterministic validation confirmed that it changes no paths outside the original PR. Because conflict resolution cannot be certified as an exact patch replay, this PR is intentionally a draft and requires release-maintainer review. | Field | Commit | |---|---| | Original merged change | `c647410de088139054199f41bb71b451602a5fe7` | | Release base used | `34ba08a104f370fa22d6136bb4e64a1190096c5a` | | Proposed backport | `ae4599d5cd4d2ce592459ffe3cf5b978af18ec1d` | Co-authored-by: Evgenii Golubev <[email protected]>

Description
On Windows, the first CUDA graph capture after the renderer's first frame can stall for many minutes. This PR applies the workaround from @shi-eric's analysis in #8342: record one tiny allocation in a CUDA graph when
SimulationContextis created, so the CUDA driver reserves graph memory before anything can block its placement.Fixes #8342. Supersedes #8528.
Root cause (summary of #8342)
Change
isaaclab.utils.device.reserve_cuda_graph_memory(device): records onewp.empty(1)insidewp.ScopedCapture, once per CUDA device. It skips non-CUDA devices, devices with the Warp memory pool disabled, and devices that are already capturing. A failure is logged as a warning and never blocks startup.SimulationContext.__init__calls it right after selecting the device, before physics backends and renderers are created. Every entry point (environments, benchmarks, tests) goes through this path.Measurements
Windows 11, RTX 6000 Ada, driver 596.72,
Isaac-Lift-KukaAllegro-Camera, 1024 envs,newton_mjwarp, capture watchdog 8–15 s:developpresets=newton_mjwarp,ovrtx,single_camera,simple_shading_full_mdl64presets=newton_mjwarp,isaacsim_rtx,single_cameraThe Kit result means this stall is not limited to OVRTX: Kit with Newton physics hits it too.
Other checks with the same workaround (applied at
gym.make, physics-only task, 8192 envs):develop.Limits
SimulationContext, so the reservation cannot precede it. It still precedes Cubric's managed memory and the next rendered frame, which was enough in the measurements above.ovstagein_prepare_stage_creation, before this call. OvPhysX with OVRTX was not measured.Type of change
Release backport
developChecklist
pre-commitchecks withuv run isaaclab --format(ruff check and format on the changed files)source/<pkg>/changelog.d/for every touched packageCONTRIBUTORS.mdor my name already exists there