Skip to content

Fix raycast_mesh distance and face-id shapes for rays with any leading dimensions - #7034

Closed
samirbhattarai135 wants to merge 3 commits into
isaac-sim:mainfrom
samirbhattarai135:fix/raycast-mesh-ray-dimensions
Closed

samirbhattarai135 wants to merge 3 commits into
isaac-sim:mainfrom
samirbhattarai135:fix/raycast-mesh-ray-dimensions

Conversation

@samirbhattarai135

@samirbhattarai135 samirbhattarai135 commented Aug 12, 2026 •

Copy link
Copy Markdown

Description

raycast_mesh flattens the rays with .view(-1, 3), but reshaped the distance and face-id
outputs with .view(shape[0], shape[1]). That reshape is only correct when the rays have
exactly two leading dimensions, so every other input shape was mishandled — including the
(N, 3) shape the docstring advertises:

ray_starts shape ray_distance before after
(N, 3) (documented) RuntimeError (N,)
(B, N, 3) (B, N) (B, N) — unchanged
(3, 1, 2, 3) RuntimeError (3, 1, 2)
(2, 3, 1, 3) (2, 3) — silently wrong shape, no error (2, 3, 1)

The silent case is the one worth highlighting: when the leading dimensions happen to multiply
out to shape[0] * shape[1], the old reshape succeeded and returned a tensor whose shape did
not match the rays it came from.

Both reshapes now use .view(shape[:-1]), which is the same generic idiom the neighbouring
ray_normal line already used. For any 3-D input shape[:-1] is (shape[0], shape[1]), so the
reshape change alone is a strict superset of the current behaviour. The direction-shape guard in the
second commit is not — see below.

raycast_dynamic_meshes is deliberately untouched: it documents (B, N, 3) explicitly, so
view(shape[:2]) is correct for its contract.

Fixes #2416

On the second commit

fix(warp): require raycast_mesh directions to match ray starts is adjacent to the issue and can be
dropped if you would rather keep this PR to the reshape alone.

The kernel launches with dim=num_rays derived from ray_starts and indexes
ray_directions_wp[tid] unconditionally. Passing fewer directions than rays therefore reads past the
end of the direction array, and the values it reads are not stable between calls — four rays as
(1, 4, 3) with two directions, all starting at z = -1 above a plane at z = 0 so every distance
should be 1.0, returns [1.0, 1.0, 136.86, inf], then [1.0, 1.0, 136.59, inf], then
[1.0, 1.0, 137.91, inf] on successive calls. On CUDA an out-of-bounds read of a Warp array is an
illegal memory access.

The guard requires ray_directions to have the same shape as ray_starts, and runs before the
.view(-1, 3) flatten. Comparing counts after the flatten is not enough: the flatten reinterprets
whatever it is handed, so (4, 3) starts with (4, 2) or (2, 2, 3) directions both yield four
rows and pass a count check.

This is a behaviour change. Calls that passed surplus directions, or a direction tensor whose layout
differed from the ray starts, worked before and now raise. No in-tree caller is affected:
terrains/utils.py:245 is the only call site outside tests and passes points.view(-1, 3) and
dirs.view(-1, 3), which always have the same shape. The changelog fragment carries this as a
Changed entry with migration guidance; I left it at the patch tier on the reading that this closes
undefined behaviour rather than removing a feature, but that is a maintainer call and moving it to
.major.rst is a rename away.

Note

isaaclab/terrains/utils.py already works around this bug: it calls
raycast_mesh(points.view(-1, 3), dirs.view(-1, 3), wp_mesh) and then restores the shape itself
with ray_hits.view(points.shape). It avoids the crash only because it leaves return_distance
at its default. That workaround becomes unnecessary with this change, but I have left it alone to
keep the diff focused.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Breaking change (existing functionality will not work without user modification)

Testing

Added source/isaaclab/test/utils/warp/test_ops.py. It needs neither a GPU nor Isaac Sim — the
module under test imports only numpy, torch and warp — so it runs as a unit test alongside the
existing test/utils/warp/test_proxy_array.py.

The shape test is parametrized over (2,), (1, 2), (3, 1, 2) and (2, 3, 1) ray dimensions.
With the two reshapes reverted, three of the four fail; (1, 2) passes either way and is kept as
the control, since it is the only shape the existing suite covered. Ray depths are staggered so
the assertions also pin down the row-major ordering between the flatten and the unflatten, not
just the output shape.

The guard is covered by a second test parametrized over four mismatched direction shapes — too few,
too many, a wrong trailing dimension, and a different layout with a matching element count. Deleting
the guard fails all four; weakening it to a flattened-count comparison still fails the last.

I verified separately that for 3-D input the new reshape is byte-identical to the old one: 4344
output elements compared across batch shapes (1, 1), (1, 2), (4, 7) and (16, 32), 0
differences, 403 misses (inf distances, -1 face ids) included.

Please note what I could not run: I do not have an NVIDIA GPU, so I have not executed
test/sensors/test_ray_caster.py (it launches Kit) or anything on CUDA. The change is a pure
torch.Tensor.view on the host side plus a shape comparison, and is device-independent, but a GPU CI
run is worth having.

Checklist

  • 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

@greptile-apps

greptile-apps Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Fixes raycast_mesh so scalar outputs preserve all leading ray dimensions and validates that each ray has a corresponding direction.

  • Generalizes distance and face-ID reshaping from two fixed leading dimensions to shape[:-1].
  • Documents arbitrary leading ray dimensions.
  • Adds CPU unit coverage for output shape, ordering, and missing directions.
  • Adds the changelog fragment and contributor entry.

Confidence Score: 5/5

The PR appears safe to merge, with the shape correction, direction-count validation, and CPU regression tests aligned with the ray-casting implementation.

The scalar outputs are reshaped using the complete leading input dimensions, while existing three-dimensional inputs retain their previous shapes; the added validation prevents the kernel from indexing a direction array shorter than the launched ray count.

Important Files Changed

Filename Overview
source/isaaclab/isaaclab/utils/warp/ops.py Correctly preserves arbitrary leading dimensions for distance and face-ID outputs and prevents undersized direction arrays from reaching the Warp kernel.
source/isaaclab/test/utils/warp/test_ops.py Adds focused CPU tests covering one-, two-, and higher-dimensional ray layouts, flattened ordering, and mismatched direction counts.
source/isaaclab/changelog.d/raycast-mesh-ray-dimensions.rst Accurately documents the corrected output-shape behavior.
CONTRIBUTORS.md Adds the PR author to the contributor list in alphabetical order.

Reviews (1): Last reviewed commit: "docs: add Samir Bhattarai to contributor..." | Re-trigger Greptile

@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 generalized output reshaping is consistent with the widened arbitrary-leading-dimension contract, and the direction-count guard prevents out-of-bounds kernel indexing. One release-note update is needed for the newly enforced validation behavior.

  • Design and architecture: The reshape remains appropriately contained within the Warp wrapper and preserves existing behavior for (B, N, 3) inputs. The direction-count validation is placed before the kernel launch, where it can safely enforce the kernel’s one-direction-per-ray requirement.
  • API: The output-shape contract is widened compatibly, but the new equality check also rejects excess directions that were previously ignored. Because this is an observable contract tightening, the changelog must document it and provide appropriate migration guidance.
  • Implementation: Using view(shape[:-1]) correctly restores arbitrary leading dimensions for distance and face-ID outputs, and the tests cover the new shape behavior and missing-direction validation. The changelog currently describes only the reshape fix and omits the new validation error.

Minor fixes needed. Posted 1 actionable finding inline.

Automated review; human maintainers own approval decisions.

@@ -123,6 +125,12 @@ def raycast_mesh(
ray_starts = ray_starts.to(torch_device).view(-1, 3).contiguous()
ray_directions = ray_directions.to(torch_device).view(-1, 3).contiguous()
num_rays = ray_starts.shape[0]
# the kernel reads one direction per ray, so a shorter tensor would be indexed out of bounds
if ray_directions.shape[0] != num_rays:

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.

🔵 Suggestion · Implementation — New validation error absent from changelog fragment

This guard makes raycast_mesh raise ValueError whenever the flattened direction count differs from the ray count, including the previously tolerated case of passing more directions than rays (extras were silently ignored). The changelog fragment only documents the output-shape fix, so callers hitting the new exception get no release note or migration guidance, which the repository requires for changed behavior. Add a line to changelog.d/raycast-mesh-ray-dimensions.rst describing the validation.

@samirbhattarai135
samirbhattarai135 force-pushed the fix/raycast-mesh-ray-dimensions branch from d4680ae to 2b8005c Compare August 12, 2026 02:59
@AntoineRichard

Copy link
Copy Markdown
Collaborator

Thanks for contributing! @pascal-roth will take a look :).

Comment on lines +128 to +133
# the kernel reads one direction per ray, so a shorter tensor would be indexed out of bounds
if ray_directions.shape[0] < num_rays:
raise ValueError(
f"Expected at least one direction per ray. Received {num_rays} ray starts and"
f" {ray_directions.shape[0]} ray directions."
)

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.

I think we should raise an error when the number of directions is not equal to the number of ray starting positions, everything else is an undefined behavior

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Agreed. Switched to a shape check:

shape = ray_starts.shape
if ray_directions.shape != shape:
    raise ValueError(
        "Expected ray_directions to have the same shape as ray_starts. Received ray_starts"
        f" {tuple(shape)} and ray_directions {tuple(ray_directions.shape)}."
    )

I compared shapes rather than counts, and moved the check above the .view(-1, 3). A count check
placed after the flatten still lets undefined input through, because the flatten reinterprets whatever
it is handed: (4, 3) ray starts with (4, 2) directions, or with (2, 2, 3) directions, both come
out as four rows and pass a count comparison. Checking before the flatten also lets the message quote
the shapes the caller actually passed, and rejects the call before two host-to-device copies.

On the "undefined behavior" framing — it is worse than a wrong number, the values are not stable
between calls. Four rays as (1, 4, 3) with only two directions, every start at z = -1 above a
plane at z = 0, so every distance should be 1.0. Five consecutive calls in one process on
develop:

[1.0, 1.0, 136.86, inf]
[1.0, 1.0, 136.59, inf]
[1.0, 1.0, 137.91, inf]
[1.0, 1.0, 136.86, inf]
[1.0, 1.0, 136.59, inf]

Nothing in the tree relies on the old tolerance. terrains/utils.py:245 is the only non-test caller
and builds its directions with torch.zeros_like(points) a few lines above, so the shapes are equal
by construction; test/sensors/test_ray_caster.py passes matching (1, 2, 3) tensors. It also brings
this in line with raycast_dynamic_meshes, whose .view(n_envs, n_rays_per_env, 3) on the direction
tensor (ops.py:310) already rejects short, surplus and differently shaped input — the difference is
only that this is an explicit ValueError rather than a torch RuntimeError.

Calls that passed surplus directions did work before, so the changelog now carries this as a Changed
entry with migration guidance rather than a Fixed one, and I dropped the test that asserted the old
tolerance. I left the fragment at the patch tier on the reading that this closes undefined behaviour
rather than removes a feature — say the word and I will move it to .major.rst.

@@ -175,11 +183,11 @@ def raycast_mesh(
wp.synchronize()

if return_distance:
ray_distance = ray_distance.to(device).view(shape[0], shape[1])
ray_distance = ray_distance.to(device).view(shape[:-1])

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.

That change makes it more general, which is good. I think the prev. shape is the typical one in IsaacLabs parallel environment structure, which assumes (num_envs, num_rays_per_env, ...) and enforces a certain structure. Unsure whether that change will make it more general or more complex.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

This one is narrower than it looks. Before this PR the docstring already documented ray_starts as
Shape (N, 3) and the distance output as Shape (N,), but that exact call raised
RuntimeError: shape '[4, 3]' is invalid for input of size 4 as soon as return_distance was set,
because shape[1] there is the xyz axis rather than a ray count. The change makes the code match a
contract that was already published, rather than widening one.

For the (num_envs, num_rays_per_env, ...) layout you are protecting, the two expressions are the
same value — shape[:-1] is (shape[0], shape[1]) whenever shape has length three. I ran both
versions side by side on a bumpy 8×8 grid mesh over batch shapes (1, 1), (1, 2), (4, 7) and
(16, 32), with the ray origins spread wide enough to force misses: 4344 output elements compared,
0 differences, 403 misses (inf distances, -1 face ids) included. Nothing is traded away for that
layout.

The structure is still enforced where it is actually assumed. raycast_dynamic_meshes reshapes to
(n_envs, n_rays_per_env, 3) and launches dim=[n_meshes, n_envs, n_rays_per_env], and the ray-caster
sensors bypass both wrappers entirely — they allocate their own (num_envs, num_rays) buffers and
launch raycast_mesh_masked_kernel directly. raycast_mesh flattens to view(-1, 3) and launches
dim=num_rays, so it never reads a batch or a per-env count; the two-dimension assumption only ever
lived in those two reshape lines. ray_hits and ray_normal, on either side of them, already used
.view(shape) and already preserved arbitrary leading dimensions. So this is the two remaining outputs
agreeing with the other two, not a new rule — same one-liner, not a more complex one.

Its one non-test caller already works around the current behaviour: terrains/utils.py:245 passes a
flat (N, 3) and unflattens the hits itself, and escapes the crash only because it requests neither
distance nor face id.

If you would rather this layer required (num_envs, num_rays_per_env, 3), that is a defensible
position, but it is a separate and breaking change — it would reject terrains/utils.py:245 as
written. I would rather open it as its own issue than fold it into this fix.

@samirbhattarai135
samirbhattarai135 force-pushed the fix/raycast-mesh-ray-dimensions branch from 2b8005c to e2d9473 Compare August 13, 2026 01:45
@AntoineRichard

Copy link
Copy Markdown
Collaborator

@samirbhattarai135 could you kindly provide use-cases / justifications why this feature would be required? Is it just to solve #2416 ?

@samirbhattarai135

Copy link
Copy Markdown
Author

@AntoineRichard, the reshape commit is the fix for #2416 and changes nothing for existing callers. shape[:-1] is the same expression as (shape[0], shape[1]) for 3-D input, verified over 4344 output elements with 0 differences.
The second commit, the direction-shape guard, is not from #2416. I added it at @pascal-roth request in review, and it is the only reason the PR is marked as a breaking change. I'm happy to drop it if you'd prefer to keep this to the bug fix. The PR then has no behaviour change for any call that works today.
Could you also approve the workflow runs when you get a chance? All ten are still sitting at action_required behind the first-time-contributor gate.

ooctipus added a commit that referenced this pull request Oct 22, 2026
## Description

Specialized consumers rediscovered scene bodies or assumed every cloned
environment had USD geometry. Sensor reads could also retain
articulation poses from before a state write, or bind different sites
after a Newton hard reset. This change uses existing scene ownership and
repairs those lifecycle boundaries.

- **Ray casters:** bind tracked meshes and OVPhysX sensor frames to
exact native body paths. The shared ray-caster initializer resolves the
scene-data provider once; leaf consumers use that bound dependency.
Persistent `int32` index arrays use `-1` for static and padded slots,
with one per-slot check in Warp and a separate all-static fast path.
Missing native target bodies produce an error naming the target and
body.
- **Pose writes and environment coverage:** refresh pending articulation
kinematics before PhysX ray-caster frame reads and TacSL force-field
reads. Require one ray-caster mount per environment before allocating
ray output buffers; preserve heterogeneous target counts and padded
target slots.
- **Newton hard resets:** retain builder-owned sites, replace native
IMU/frame-transform sensor objects with the model, and expand frame
names from configuration on each initialization. Remove the duplicated
target-name field.
- **TacSL:** resolve the authored contact mesh and destination
expression from clone sources, including custom namespaces, and require
exactly one SDF mesh.
- **cuRobo:** import the selected world's source geometry when its
native copy has no USD prims. A temporary USD projection feeds the
existing importer and is discarded after initialization; asset data
supplies dynamic poses.

Remove six private wrappers and duplicate pose-buffer fields. Newton
keeps one sensor-site label, and PhysX allocates pose buffers directly
in Warp. No new public configuration fields, production modules, or
runtime resource owners.

**Size:** production **+244 / −737** (net **−493**); whole PR **+801 /
−910** (net **−109**), including regression coverage, documentation, and
changelogs. No new test files.

## Related fixes and scope

- Covers the exact body/environment mapping problems in #8678 and #8676
through the shared provider, with consolidated heterogeneous-link and
native-clone regression scenes.
- Incorporates the site/reset lifecycle fixes from #8674.
- Includes the ray-caster and TacSL read paths from #8663, and the
ray-caster mount validation from #8655. Their changes to other sensor
families remain separate. Missing target meshes remain supported by
padded slots.
- The output reshapes proposed by #7034 are already corrected in this
base. Its remaining stricter input-layout policy stays in that utility
PR.
- No unmerged PR dependency is required.

Fixes #8677.
Fixes #8675.
Fixes #8673.

## Validation at `9db57d446`

GPU0 / RTX 5090, **62 focused tests passed**:

- PhysX ray-caster integration: 9; standard ray-caster graph tests: 5.
- OVPhysX ray casters: 2, including 16 interleaved articulation
environments and rejection of partial native mounts.
- Newton ray casters: 8; site/index/lifecycle tests: 12, including three
hard resets at both one and two environments with ray caster, IMU, PVA
and frame transformer.
- TacSL: 10, including custom clone namespaces and tactile points
immediately after an articulation root write.
- Ray-caster kernel and ownership gates: 16.

The new pose-write, mount-count, tactile-write and hard-reset
regressions fail on the previous head `338d3161` and pass with this
change. The consolidated PhysX scene also rejects a deliberate mutation
that lets `-1` slots consume a body transform: its missing-target ray
incorrectly hits at 1 m instead of the static ground.

A central existence/ownership audit checked all 13 changed production
modules: the existing file tree is retained, old target-view hooks
remain absent, leaf consumers do not rediscover the provider, and Newton
STOP callbacks do not register sites again. `uv run isaaclab -f`, the
changelog gate against `73f275291`, and `git diff --check` passed.

Tests stay in the existing suites. Exact SDF-count assertions reject a
broken-discovery mutation that passed the former loose assertion. The
Newton reset and OV ray-caster cases honor the runtime GPU mask and
passed on `cuda:1`.

**Broader suite limitation from the expansion validation:** the broader
Newton frame-transformer file has 1 passing case and 2 failures
compiling MuJoCo Warp's tiled Cholesky kernel (`nvJitLink` error 6 /
NVVM container error). The same two cases fail on unchanged `338d3161`,
before this expansion; the focused hard-reset/name regression passes.
These compiler failures remain visible rather than being skipped.

The unchanged cuRobo implementation retains the previously recorded five
native-Newton obstacle-planning cases and PhysX pick-and-stack
validation.

## Simplification performance check

Compared `3808d2361` → `9db57d446` on GPU0 / RTX 5090 at 1,024
environments and 441 rays per environment, with the same workload and
sampling method recorded below. Three alternating fresh-process pairs
measured median paired refresh / full-step changes of **−7.3% / −3.0%
for PhysX** and **−3.2% / +0.2% for Newton**. PhysX varied between
processes: refresh changes ranged from −17.8% to +17.4%, and full-step
changes from −12.3% to +5.4%. One additional native-Newton control pair
measured +0.6% / +0.3%. **All seven paired hit buffers matched
bit-for-bit.** Training FPS was not measured.

<details>
<summary>Earlier performance measurements, startup costs, and pinned
methodology</summary>

## Expansion performance check

Compared `338d3161` → `3808d2361` on GPU0 / RTX 5090, using the same
four-cube, 441-ray workload as below at 1,024 environments. Three fresh
process pairs alternated revision order; each used 30 warm-up steps, 100
synchronized refresh samples, and five batches of 100 complete steps.
These are **median paired changes**:

- Newton, four targets: refresh **+0.6%**, full step **0.0%**.
- OVPhysX, four targets: refresh **−2.6%**, full step **−2.8%**.
- PhysX, four targets: refresh **−1.6%**, full step **+8.4%** in the
short runs.
- PhysX, one tracked target: refresh **−5.7%**, full step **+1.5%**.

The short PhysX full-step increase did not persist at that size in a
longer confirmation: three new alternating pairs, 200 warm-up steps, 500
refresh samples, and 20 batches of 500 complete steps measured median
paired changes of **+0.5% refresh and +1.6% full step**. Full-step
changes ranged from **−5.2% to +2.9%**. All 12 initial paired hit
buffers and all three confirmation pairs matched bit-for-bit. These
checks do not establish a new training/FPS claim.

## Original scene-binding performance

**Four-target sensor refresh took 18–52% less time.** The full
physics-and-sensor loop ranged from 16.5% less time to 0.7% more time.
Startup did not uniformly improve: Newton at 1,024 environments added
0.26 s, and OVPhysX added 0.10–0.45 s.

Before (`73f275291`) → PR (`c893dd599`), on GPU0 / RTX 5090. Lower is
better. This is a synthetic ray-caster workload with four rigid cubes
and one 441-ray grid per environment; task/training FPS was not
measured.

| Physics | Environments | Initialization (s) | Sensor refresh (ms) |
Physics + sensor step (ms) |
|---|---:|---:|---:|---:|
| Newton MJWarp | 1,024 | 3.31 → 3.57 | 0.359 → 0.172 | 0.356 → 0.320 |
| Newton MJWarp | 4,096 | 4.03 → 4.02 | 0.543 → 0.391 | 0.714 → 0.719 |
| OVPhysX | 1,024 | 2.48 → 2.58 | 0.372 → 0.284 | 1.392 → 1.394 |
| OVPhysX | 4,096 | 6.28 → 6.73 | 0.623 → 0.513 | 1.776 → 1.590 |
| PhysX (Kit) | 1,024 | 1.75 → 1.72 | 0.471 → 0.328 | 1.186 → 0.990 |
| PhysX (Kit) | 4,096 | 3.29 → 3.25 | 0.721 → 0.572 | 1.462 → 1.379 |

The multi-target gain comes from replacing separate target views/updates
with one gather. OVPhysX now initializes its shared body table when the
ray caster first requests it, which adds startup work when no earlier
consumer has created that table. The benefit depends on target count:
the longer one-target PhysX / 4,096 check measured median paired changes
of **+5.4% for refresh (about 0.020 ms) and +1.2% for the full loop**.

<details>
<summary>One-target and native ray-caster controls</summary>

The one-target cases retain all four bodies in the scene but track only
one. Native cases use Newton’s BVH ray caster, with and without its
query CUDA graph.

| Control | Environments | Sensor refresh (ms) | Physics + sensor step
(ms) |
|---|---:|---:|---:|
| Newton native / query graph | 1,024 | 0.082 → 0.082 | 0.282 → 0.280 |
| Newton native / query graph | 4,096 | 0.241 → 0.238 | 0.551 → 0.553 |
| Newton MJWarp / one target | 1,024 | 0.157 → 0.123 | 0.272 → 0.266 |
| Newton MJWarp / one target | 4,096 | 0.211 → 0.210 | 0.480 → 0.482 |
| OVPhysX / one target | 1,024 | 0.219 → 0.226 | 1.323 → 1.343 |
| OVPhysX / one target | 4,096 | 0.320 → 0.322 | 1.540 → 1.518 |
| PhysX (Kit) / one target | 1,024 | 0.266 → 0.275 | 1.024 → 1.009 |
| PhysX (Kit) / one target | 4,096 | 0.365 → 0.368 | 1.152 → 1.239 |
| Newton native / eager query | 1,024 | 2.884 → 2.874 | 3.008 → 3.065 |
| Newton native / eager query | 4,096 | 2.945 → 2.910 | 3.024 → 3.001 |

The initial one-target PhysX / 4,096 loop median was 1.152 → 1.239 ms
(+7.6%). A longer confirmation used three fresh pairs, 200 warm-up
steps, 500 refresh samples, and 20 batches of 500 steps. Paired refresh
changes ranged from −3.6% to +8.0% (median +5.4%); paired loop changes
ranged from −5.4% to +1.6% (median +1.2%). The initial 7.6% full-loop
slowdown did not persist.

</details>

**Method:** Median of three fresh processes per revision, alternating
base/head order, with the same locked dependencies and warm caches. Each
process used 30 warm-up steps, 100 GPU-synchronized sensor-refresh
samples, and five batches of 100 physics + scene-update + sensor-read
steps (dt=0.01 s, zero gravity, no rendering). Newton physics used CUDA
graphs; multi-mesh reads were eager. Initialization covers
simulation/scene construction, reset, and the first sensor read;
launcher startup and deferred first-physics-step graph capture are
excluded. All 48 measured before/after hit-buffer pairs, plus the three
longer confirmation pairs, matched bit-for-bit.

**Additional consumer initialization:** in the existing PhysX cube-stack
fixture, cuRobo collision-world import took **4.94 → 42.67 ms** (median
of five alternating warm samples, GPU-synchronized). All three obstacle
geometries and poses matched. The temporary source projection adds about
**38 ms once per planner**; it adds no per-step work. This is import
time, not full planner startup or training FPS. The original ray-caster
measurements above are pinned to `c893dd599`.

</details>

## Type of change

- Bug fixes and internal refactoring; existing supported configurations
retain their fields and construction API.

## Checklist

- [x] Read the contribution guidelines.
- [x] Ran formatting and changelog checks.
- [x] Extended or consolidated existing regressions using the test-audit
criteria.
- [x] Audited the production file tree and ownership boundaries.
- [x] Recorded numerical/performance evidence and the pre-existing
compiler limitation.
ooctipus added a commit that referenced this pull request Oct 22, 2026
# Description

USD polygon indices were passed directly to Warp as triangle indices,
creating artificial interior faces. Triangulate them with the existing
mesh utility before building the ray-caster mesh. A closed six-quad box
now reports its outer surface correctly.

Validate identical `(..., 3)` ray-start and direction shapes before
flattening so mismatched arrays cannot reach the native query. This
includes the remaining direction-shape validation from #7034; its
output-reshape fix and #2416 are already covered on main.

Fixes #3013

The shared distance-output proposal #2946 remains open. Existing
`raycast_mesh(..., return_distance=True)` and Newton's `ray_distances`
output remain available. This PR adds no sensor output or buffer and
makes no drift-semantics changes (#4333). It is independent of #8780.

## Type of change

- Bug fix

## Validation

- The existing ray integration fixture checks the six-quad box's
analytic outer-surface hits, misses, offsets, and maximum range.
Removing the triangulation makes it fail on interior intersections.
- Existing wrapper tests cover valid scalar/multidimensional ray layouts
and output ordering, plus mismatched direction shapes. Removing the
shape guard lets the surplus-direction case reach the native query and
fail to reject invalid input.
- 35 passed cases across the existing integration, wrapper, sensor, and
Newton test files, including camera projection paths and Newton
eager/captured distance queries.
- Passed formatting, changelog validation, and a file-by-file ownership
audit. Only the existing mesh loader and query wrapper change in
production; no new modules, helpers, API fields, or buffers.

## Checklist

- [x] I have read and understood the contribution guidelines.
- [x] I have run the pre-commit checks with `uv run isaaclab --format`.
- [x] I have updated the relevant changelog fragment.
- [x] My changes introduce no new production warnings.
- [x] I have validated the changed behavior and applied the test-audit
criteria.
- [x] I have added a changelog fragment for every touched package.
- [x] My name already exists in `CONTRIBUTORS.md`.
@ooctipus

Copy link
Copy Markdown
Collaborator

Closing as superseded: the generic distance/face-id output reshapes are already on main, and merged #8781 includes the remaining direction-shape validation before flattening, with coverage for multidimensional layouts, output ordering, and mismatched directions. #2416 is already closed as completed. No further implementation from this PR is needed for main.

@ooctipus ooctipus closed this Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working isaac-lab Related to Isaac Lab team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug in source/isaaclab/isaaclab/utils/warp/ops.py ray_distance.view(shape[0], shape[1]) causes shape mismatch

4 participants