-
Notifications
You must be signed in to change notification settings - Fork 341
[Bug]: SelfCollisionDistance's backward arise a broadcast error #707
Open
Description
Prerequisites
- I have searched existing issues and discussions and could not find a duplicate.
- I have read the relevant section of the documentation.
- I can reproduce this on the latest
main(or the most recent release).
Bug summary
When joint_positions' horizon >1, using RobotCollisionChecker.get_scene_self_collision_distance_from_joints() to get self_dist, the backward() will arise a broadcast error at curobo/_src/curobolib/cuda_ops/geometry.py, line 101.
The grad_out_distance missing final dimension leads to the error.
g_vec = g_vec * grad_out_distance.unsqueeze(-1) will fix this error.
test_collision.py
Steps to reproduce
from curobo.collision_checking import RobotCollisionChecker, RobotCollisionCheckerCfg from curobo.scene import Scene import torch # Create collision checker for custom pipeline config = RobotCollisionCheckerCfg.load_from_config( robot_config="franka.yml", scene_model="collision_test.yml", collision_activation_distance=0.01, ) checker = RobotCollisionChecker(config) # Query collision at joint configurations joint_positions = torch.rand((10, 50, 7)).to('cuda:0') # 10 configurations, horizon 1 scene_distance, self_distance = checker.get_scene_self_collision_distance_from_joints( joint_positions ) # Validate configurations is_valid = checker.validate(joint_positions) # Use in custom optimization (differentiable) joint_positions.requires_grad = True scene_dist, self_dist = checker.get_scene_self_collision_distance_from_joints( joint_positions ) cost = scene_dist.sum() + self_dist.sum() print(scene_dist.shape,self_dist.shape) cost.backward() # Gradients flow through
Expected behavior
No error happen.
Actual behavior / error output
.venv/lib/python3.11/site-packages/curobo/_src/curobolib/cuda_ops/geometry.py", line 101, in backward g_vec = g_vec * grad_out_distance ~~~~~~^~~~~~~~~~~~~~~~~~~ RuntimeError: The size of tensor a (65) must match the size of tensor b (50) at non-singleton dimension 2
cuRobo version + commit SHA
0.8.0.post1.dev42+dirty 8e734f3
Installation method
Source — CUDA 13 + PyTorch (uv pip install .[cu13-torch])
Kernel backend
cuda_core (default, runtime compilation)
Python version
3.11.15
PyTorch version (if installed)
2.11.0+cu130 13.0
GPU / driver / CUDA toolkit
RTX 2080 Ti
Operating system
Ubuntu 20.04
Isaac Sim version (if applicable)
No response
Additional context
No response