Lietorch

Teed 2021 · Paper

One-line summary — PyTorch library that implements 3D transformation groups (SO(3), RxSO3, SE(3), Sim(3)) as first-class differentiable tensor types, with backpropagation performed in the tangent space of each group element (paper: “Tangent Space Backpropagation for 3D Transformation Groups”, Teed & Deng, CVPR 2021, arXiv:2103.12032).

Problem

Deep networks that estimate or refine camera poses must differentiate through rotations and rigid-body transforms, but these live on curved manifolds, not in flat parameter space. Standard “embedding space” autodiff (differentiating matrix entries or quaternion components) has two failure modes the paper dissects: numerically unstable terms like ψ/sinψ\psi / \sin\psi whose Taylor-approximation gradients must be hand-tuned per operation, and outright singular gradients — e.g. cos1((tr(X)1)/2)\cos^{-1}\big((\mathrm{tr}(X)-1)/2\big) in the SO(3) logarithm has an undefined derivative at the identity, so PyTorch3D’s matrix logarithm returns NaN gradients there. Before Lietorch, every deep SLAM project re-implemented this manifold machinery by hand.

Method & architecture

Df(X)[v]=limt0f(tvX)f(X)t,Df(X)[\mathbf{v}] = \lim_{t\to 0} \frac{f(t\mathbf{v} \oplus X) \ominus f(X)}{t},

relating perturbations in the tangent space of XX to perturbations in the tangent space of f(X)f(X). Reverse-mode autodiff then propagates row-vector gradients by the chain rule LX=LYJ\frac{\partial\mathcal{L}}{\partial X} = \frac{\partial\mathcal{L}}{\partial Y} \mathbf{J}, where J\mathbf{J} is the tangent-space Jacobian — for SO(3) a 3-dimensional gradient instead of autograd’s 9-dimensional embedding gradient.

L(T1,,TK)=kLog(Tk1T),\mathcal{L}(\mathbf{T}_1,\ldots,\mathbf{T}_K) = \sum_k \|\operatorname{Log}(\mathbf{T}_k^{-1} \cdot \mathbf{T}^{*})\|,

where T\mathbf{T}^{*} is the ground-truth pose — a loss the authors note is hard to implement with standard backpropagation.

Results

Why it matters for SLAM

Every deep SLAM or deep VO system that learns through pose optimization needs derivatives with respect to elements of SE(3), and getting these right by hand is error-prone (NaNs at singularities, off-manifold drift). Lietorch made manifold-correct differentiation a reusable, tested library, and it supplies the pose layers of DROID-SLAM and DPVO among others. Together with Theseus (differentiable nonlinear least squares) it forms the standard toolbox for differentiable geometric optimization in PyTorch.