You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bug in source/isaaclab/isaaclab/utils/warp/ops.py ray_distance.view(shape[0], shape[1]) causes shape mismatch #2416
ray_distance = ray_distance.to(device).view(shape[0], shape[1])
RuntimeError: shape '[4, 3]' is invalid for input of size 4
It seems ray_distance is initialized with shape (N,) where N = 4, but the code attempts to reshape it to (4, 3) which is incorrect for scalar distances.
On the "or the docs should say Shape (N, 1, 3)" alternative — I think the code is the thing to
fix rather than the docstring, because the reshape is not actually a 3-D design decision. It is
wrong for every rank except 3, and for some of them it fails silently:
ray_starts shape
ray_distance today
(N, 3)
RuntimeError (this issue)
(B, N, 3)
(B, N) — correct
(3, 1, 2, 3)
RuntimeError
(2, 3, 1, 3)
(2, 3) — no error, wrong shape
That last row is the part that worried me. When the leading dimensions happen to multiply out to shape[0] * shape[1], view(shape[0], shape[1]) succeeds and hands back a tensor whose shape does
not correspond to the rays that produced it.
The cause is that line 123 flattens any number of leading dimensions with .view(-1, 3), while
lines 178 and 182 assume exactly two of them. One line in between, ray_normal already uses the
generic .view(shape). Using .view(shape[:-1]) for the distance and face-id outputs matches it.
This is also why documenting 3-D would be awkward in practice: isaaclab/terrains/utils.py calls raycast_mesh(points.view(-1, 3), dirs.view(-1, 3), wp_mesh) with genuinely 2-D input and then
restores the shape itself. It only escapes the crash because it leaves return_distance at its
default.
Worth noting that shape[:-1] is not a behaviour change for anyone: for 3-D input it is the same
expression as (shape[0], shape[1]), so existing callers and the current test_ray_caster.py
assertions are unaffected. It only turns the error and the silent-wrong-shape cases into correct
output.
The PR adds a CPU regression test covering (2,), (1, 2), (3, 1, 2) and (2, 3, 1) ray
dimensions. It needs neither a GPU nor Isaac Sim, since utils/warp/ops.py imports only numpy,
torch and warp.
Activity
Finn-Sueberkrueb commentedon May 2, 2025
Or in the Docu it should say:
RandomOakForest commentedon May 5, 2025
Thanks for catching this. We will review.
samirbhattarai135 commentedon Aug 12, 2026
I looked into this and opened #7034.
On the "or the docs should say
Shape (N, 1, 3)" alternative — I think the code is the thing tofix rather than the docstring, because the reshape is not actually a 3-D design decision. It is
wrong for every rank except 3, and for some of them it fails silently:
ray_startsshaperay_distancetoday(N, 3)RuntimeError(this issue)(B, N, 3)(B, N)— correct(3, 1, 2, 3)RuntimeError(2, 3, 1, 3)(2, 3)— no error, wrong shapeThat last row is the part that worried me. When the leading dimensions happen to multiply out to
shape[0] * shape[1],view(shape[0], shape[1])succeeds and hands back a tensor whose shape doesnot correspond to the rays that produced it.
The cause is that line 123 flattens any number of leading dimensions with
.view(-1, 3), whilelines 178 and 182 assume exactly two of them. One line in between,
ray_normalalready uses thegeneric
.view(shape). Using.view(shape[:-1])for the distance and face-id outputs matches it.This is also why documenting 3-D would be awkward in practice:
isaaclab/terrains/utils.pycallsraycast_mesh(points.view(-1, 3), dirs.view(-1, 3), wp_mesh)with genuinely 2-D input and thenrestores the shape itself. It only escapes the crash because it leaves
return_distanceat itsdefault.
Worth noting that
shape[:-1]is not a behaviour change for anyone: for 3-D input it is the sameexpression as
(shape[0], shape[1]), so existing callers and the currenttest_ray_caster.pyassertions are unaffected. It only turns the error and the silent-wrong-shape cases into correct
output.
The PR adds a CPU regression test covering
(2,),(1, 2),(3, 1, 2)and(2, 3, 1)raydimensions. It needs neither a GPU nor Isaac Sim, since
utils/warp/ops.pyimports only numpy,torch and warp.
Fix raycast_mesh auxiliary output shapes (#7267)
Fix raycast_mesh auxiliary output shapes (isaac-sim#7267)
Fix ray mesh triangulation and query shape validation (#8781)