Skip to content

Fix SE3 translation and Log gradients in PyPose ambient mode - #49

Merged
zitongzhan merged 2 commits into
releasefrom
codex/fix-ambient-se3-translation
Oct 24, 2026
Merged

zitongzhan merged 2 commits into
releasefrom
codex/fix-ambient-se3-translation

Conversation

@zitongzhan

@zitongzhan zitongzhan commented Oct 19, 2026 •

Copy link
Copy Markdown
Collaborator

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:

  • Override SE3Type.translation with 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.
  • Protect the SO3 Log denominators before evaluating any branch, then select the existing regular, half-turn, or small-angle formula with torch.where. The previous masked nan_to_num expressions 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:

  • All four translation finite-difference cases failed before their fix and passed afterward. All five new Log regression cases likewise failed before the Log fix and passed afterward.
  • tests/autograd/test_pypose_ambient_grad.py: 14 passed on CUDA; 14 passed on CPU.
  • Together with tests/autograd/test_pgo_jacobian.py: 18 passed on CUDA, including sparse/dense comparisons.
  • All 8,647 initial SE3 Log Jacobians in sphere_bignoise_vertex3.g2o are finite; the previous ambient SO3 Log produced a NaN Jacobian for an identity-rotation residual.
  • Direct SO3/SE3 Log helpers pass torch.compile(backend="eager", fullgraph=True) forward/backward checks at identity and half turns.
  • Earlier full tests/autograd/test_pypose_compile.py run: 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.

@zitongzhan zitongzhan changed the title Fix SE3 translation gradients in PyPose ambient mode Fix SE3 translation and Log gradients in PyPose ambient mode Oct 19, 2026
@zitongzhan
zitongzhan merged commit afad40e into release Oct 24, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant