Riemannian geometry and Bayesian inference for diffusion model latent spaces
Project description
latent-riemannian-world
Riemannian geometry + Bayesian inference + world models for diffusion model latent spaces.
Why this library?
| latent-geometry | Diffusion-Pullback | lrw | |
|---|---|---|---|
| Pullback metric | ✓ | ✓ | ✓ |
| Fisher-Rao metric | ✗ | ✗ | ✓ |
| Bayesian metric | ✗ | ✗ | ✓ |
| Geodesic solver (IVP) | ✗ | ✗ | ✓ |
| Geodesic solver (BVP) | ✗ | ✗ | ✓ |
| Parallel transport | ✗ | ✗ | ✓ |
| SVGD / Riemannian SGLD | ✗ | ✗ | ✓ |
| World model / temporal | ✗ | ✗ | ✓ |
| Python 3.12+ / PyTorch 2.4+ | ✗ | ✗ | ✓ |
Installation
pip install latent-riemannian-world
Quick Start
import torch
from lrw.metric import PullbackMetric, BayesianMetric
from lrw.geodesic import GeodesicSolver, BVPSolver
from lrw.transport import SchildsLadder, PoleLadder
from lrw.bayes import SVGD, RiemannianSGLD
from lrw.world import LatentStateSpace, RiemannianRSSM
decoder = your_model.decode # (B, D) -> (B, C, H, W)
metric = PullbackMetric(decoder=decoder)
z = torch.randn(4, 16)
# IVP solver — fast, approximate
solver = GeodesicSolver(metric=metric)
path = solver.interpolate(z[0:1], z[1:2], n_points=10)
# BVP solver — true geodesic, guaranteed arrival at z1
bvp = BVPSolver(metric=metric, lr=0.1, max_iter=50)
true_path, info = bvp.geodesic_path(z[0:1], z[1:2], n_points=10)
print(f"Converged: {info['converged']}, error: {info['final_error']:.4f}")
IVP vs BVP
| GeodesicSolver (IVP) | BVPSolver | |
|---|---|---|
| Speed | Fast | Slower (iterative) |
| Arrival at z1 | Not guaranteed | Guaranteed |
| Use case | Prototyping | WAN keyframes, final quality |
Module Structure
lrw/
├── metric/ PullbackMetric, FisherMetric, BayesianMetric
├── geodesic/ GeodesicSolver (IVP), BVPSolver (true geodesic), slerp
├── transport/ SchildsLadder, PoleLadder
├── bayes/ SVGD, RiemannianSGLD
├── world/ LatentStateSpace, RiemannianRSSM
└── utils/ sym_inv, sym_sqrt, riemannian_norm, manifold_assert_*
References
- Shao et al. (2018) The Riemannian Geometry of Deep Generative Models. CVPR.
- Arvanitidis et al. (2018) Latent Space Oddity. ICLR.
- Park et al. (2023) Riemannian Geometry of Diffusion Models. NeurIPS.
- Liu et al. (2016) Stein Variational Gradient Descent. NeurIPS.
- Hafner et al. (2020) Dream to Control. ICLR.
License
BSL-1.1 — (c) 2025 lajjadred
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file latent_riemannian_world-0.3.0.tar.gz.
File metadata
- Download URL: latent_riemannian_world-0.3.0.tar.gz
- Upload date:
- Size: 19.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
51b2af41154357dcd0958f6084849d9170fdf8e8035fca650a4420fa145441e3
|
|
| MD5 |
d65640d2bf9faf94111b3797c0dad6c3
|
|
| BLAKE2b-256 |
22b11c6dea777207156929239dbc90ccadcc9ddcf6b5fb7f37893806bdc5eeec
|
File details
Details for the file latent_riemannian_world-0.3.0-py3-none-any.whl.
File metadata
- Download URL: latent_riemannian_world-0.3.0-py3-none-any.whl
- Upload date:
- Size: 27.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9ae044d4f68d766dd1c77daacacd7645f5d6a26389322eef7bc8a57c29a5eeee
|
|
| MD5 |
5e02825db5412bb9c9361912a6e9f1f5
|
|
| BLAKE2b-256 |
c56e8b9c62611872f299af7e7a366de32213886452a77292aae46d1ef84cd91e
|