From 40ad0923d0f78bbda7718e2254f336fb7885cc3d Mon Sep 17 00:00:00 2001 From: Soumya Snigdha Kundu Date: Fri, 31 Oct 2025 15:28:37 +0000 Subject: [PATCH] fix(scene): clone configured_vertices to prevent gradient flow aliasing When observe_from() is called multiple times during optimization loops with gradient computation, the tensor aliasing between the robot's configured_vertices and intermediate tensors in the matmul chain causes incorrect gradient flow. Adding .clone() breaks the aliasing, ensuring independent tensor graphs for each iteration. Fixes #81 --- roboreg/differentiable/scene.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roboreg/differentiable/scene.py b/roboreg/differentiable/scene.py index 20afe21..fc107cb 100644 --- a/roboreg/differentiable/scene.py +++ b/roboreg/differentiable/scene.py @@ -50,7 +50,7 @@ def observe_from( device=self._cameras[camera_name].extrinsics.device, ) observed_vertices = torch.matmul( - self._robot.configured_vertices, + self._robot.configured_vertices.clone(), torch.matmul( torch.linalg.inv( torch.matmul(