From 8c0c9b5276c1ca21c0b49d1d4fb4ccacce259cca Mon Sep 17 00:00:00 2001 From: Mr-Neutr0n <64578610+Mr-Neutr0n@users.noreply.github.com> Date: Thu, 12 Feb 2026 00:04:03 +0530 Subject: [PATCH] Fix AttributeError in RayCollisionFunction.backward RayCollisionFunction.forward correctly saves tensors via ctx.save_for_backward(), but backward() retrieves them using the non-existent attribute ctx.input_tensors instead of the correct ctx.saved_tensors. This causes an AttributeError whenever gradients are backpropagated through checkpointed ray casting (i.e., when cast_rays is called with checkpoint=True). --- shap_e/rendering/raycast/cast.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shap_e/rendering/raycast/cast.py b/shap_e/rendering/raycast/cast.py index 7ef357128..5252ddf24 100644 --- a/shap_e/rendering/raycast/cast.py +++ b/shap_e/rendering/raycast/cast.py @@ -111,7 +111,7 @@ def forward( def backward( ctx, _collides_grad, ray_dists_grad, _tri_indices_grad, barycentric_grad, normals_grad ): - origins, directions, faces, vertices = ctx.input_tensors + origins, directions, faces, vertices = ctx.saved_tensors origins = origins.detach().requires_grad_(True) directions = directions.detach().requires_grad_(True)