You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
where $$\operatorname{div}_g$$ is the Riemannian divergence operator and $$v_t \in T_x \mathcal{M}$$ is a time-dependent vector field. Riemannian Flow Matching aims to find a vector field $$v_\theta(x, t)$$ that generates a path $$p_t$$ such that $$p_0$$ is the data distribution and $$p_1$$ is an invariant noise distribution.
253
+
254
+
### Riemannian Concepts: Exp, Log, and Geodesics
255
+
256
+
The geometry of the manifold is abstracted through three key operations implemented in `lib/manifolds.py`:
257
+
258
+
#### 1. Exponential Mapping ($$\text{Exp}_x$$)
259
+
260
+
The exponential map $$\text{Exp}_x : T_x \mathcal{M} \to \mathcal{M}$$ provides a way to "map" a tangent vector $$v \in T_x \mathcal{M}$$ back onto the manifold. Intuitively, if you start at point $$x$$ and walk in the direction of $$v$$ for unit time along the unique "straightest" path (geodesic), you arrive at $$\text{Exp}_x(v)$$.
261
+
262
+
In the library, this is used during **sampling** (to move from $$x_t$$ to $$x_{t-dt}$$) and to construct geodesics.
263
+
264
+
#### 2. Logarithm Mapping ($$\text{Log}_x$$)
265
+
266
+
The logarithm map $$\text{Log}_x : \mathcal{M} \to T_x \mathcal{M}$$ is the inverse of the exponential map (where defined). Given two points $$x, y \in \mathcal{M}$$, $$\text{Log}_x(y)$$ returns the tangent vector at $$x$$ that points toward $$y$$ along the shortest geodesic. The length of this vector equals the Riemannian distance between the two points: $$\|\text{Log}_x(y)\|_g = d_g(x, y)$$.
267
+
268
+
In the library, this is used during **training** to find the direction of the conditional flow between noise and data.
269
+
270
+
#### 3. Geodesic Mapping ($$\gamma$$)
271
+
272
+
A geodesic is the generalization of a straight line to curved spaces. The unique geodesic path starting at $$x$$ and ending at $$y$$ can be parameterized by $$t \in [0, 1]$$ as:
This mapping ensures that the interpolation between distributions stays on the manifold and follows the shortest possible paths, which is the cornerstone of Riemannian Flow Matching.
The library uses a safe **cosc trick** ($$\text{cosc}(x) = \frac{1 - \cos x}{x^2} = \frac{1}{2} \text{sinc}(\frac{x}{2})^2$$) to ensure numerical stability in the Rodrigues formula.
325
+
326
+
#### 3. Flat Torus ($[0, 1]^d$)
327
+
328
+
The torus is a flat space with periodic boundary conditions.
where the norm is induced by the Riemannian metric $$g$$ at point $$x_t$$:
177
+
178
+
$$\| v \|_{g} = \sqrt{g_{x_t}(v, v)}$$
179
+
180
+
### Implementation for Embedded Manifolds
181
+
182
+
For many manifolds implemented in this library (like the Sphere $$S^d$$ or $$SO(3)$$), the Riemannian metric is induced by the standard Euclidean metric of the ambient space $$\mathbb{R}^n$$. In these cases, the loss simplifies to:
**Crucially**, this equivalence only holds if $$v_{\theta}$$ and $$u_t$$ are both valid **tangent vectors** (i.e., $$v, u \in T_{x_t} \mathcal{M}$$). The library ensures this via:
187
+
188
+
1.**True Target**: The `RiemannianProcess` returns a $$u_t$$ that is
189
+
mathematically guaranteed to be tangent to the manifold.
190
+
2.**Model Forecast**: The **`RiemannianConditionalBackbone`** (see
191
+
[Architecture docs](./architecture.md)) acts as a wrapper that projects the
192
+
raw model output onto the tangent space $$T_{x_t} \mathcal{M}$$ before
193
+
computing the loss.
194
+
195
+
By enforcing the tangent space constraint, the RFM objective can be optimized
196
+
using standard MSE loss while remaining geometrically rigorous.
0 commit comments