Repository navigation
Fix SE3 translation and Log gradients in PyPose ambient mode - #49
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
BAE's ambient-gradient mode can produce incorrect translation derivatives with current PyPose and NaN Log derivatives at identity rotations. These failures affect chained pose residuals, including the initial Sphere big-noise Log residuals.
When
BAE_USE_PYPOSE_AMBIENT_GRAD=1:SE3Type.translationwith a differentiable tensor slice. PyPose's merged translation fix (Fix backward gradient calculation for SE3 and Sim3 translation pypose#422) returns a padded tangent gradient, while BAE needs ambient derivatives until the parameter-boundary retraction conversion.torch.where. The previous maskednan_to_numexpressions still differentiated divisions by zero in inactive branches. This also fixes SE3 Log, which calls SO3 Log. The principal-Log branch convention is preserved; the half-turn branch remains mathematically discontinuous.Regressions cover unbatched/batched translation, relative-pose translation followed by BAE's parameter-Jacobian conversion, SO3/SE3 Log at both identity quaternion signs and slightly non-unit identity, mixed batches, half-turn numerical finiteness, and a chained PGO Log residual at zero error. Translation is also included in the existing compiled SE3 pipeline test.
Validation against PyPose main
e37ed16688176596bfb60b1b9c525ba117e0688c, using PyTorch 2.7.1+cu126:tests/autograd/test_pypose_ambient_grad.py: 14 passed on CUDA; 14 passed on CPU.tests/autograd/test_pgo_jacobian.py: 18 passed on CUDA, including sparse/dense comparisons.sphere_bignoise_vertex3.g2oare finite; the previous ambient SO3 Log produced a NaN Jacobian for an identity-rotation residual.torch.compile(backend="eager", fullgraph=True)forward/backward checks at identity and half turns.tests/autograd/test_pypose_compile.pyrun: 4 passed, 6 failed in local TorchDynamo LieTensor tracing. The unmodified release compile tests produced the same six failures in this environment; full LieTensor graph validation remains limited locally. CI uses PyTorch 2.10.git diff --check: passed.