Skip to main content

remblais

remblais logo

remblais computes geometric losses between measures on NVIDIA (CUDA), AMD (ROCm/HIP) and Intel (SYCL) GPUs, and on x86-64 CPUs: Sinkhorn divergences (entropic optimal transport), kernel norms (MMD) and Hausdorff divergences between point clouds, images and volumes. It is a drop-in replacement for GeomLoss 0.3.1, built on kernox instead of PyKeOps: write import remblais as geomloss and your code runs unchanged. A large loss can also be split across several GPUs or nodes. Support for other architectures and accelerators may be added later.

Why remblais

  • Same API as GeomLoss. SamplesLoss, sinkhorn_divergence, ImagesBarycenter and the ot module have the GeomLoss 0.3.1 signatures, calling conventions and output shapes. With backend="tensorized", values and gradients match GeomLoss bit for bit, apart from the documented fixes.
  • Faster. Every softmin is one fused kernox reduction, compiled once and reused for all values of ε; the debiased Sinkhorn loop fuses its four softmins into two reductions per iteration.
  • NVIDIA, AMD and Intel GPUs, and CPUs. The online and multiscale backends, which GeomLoss runs through PyKeOps on NVIDIA GPUs only, run here on CUDA, ROCm/HIP and SYCL through kernox, and on x86-64 Linux CPUs as multithreaded, vectorized C++. remblais's own test suite runs on the CPU, NVIDIA and Intel GPUs; on AMD GPUs it relies on kernox's tested HIP backend.
  • Several GPUs or nodes. SamplesLoss(..., distributed=True) splits the softmins of the online and multiscale backends across the processes of a torch.distributed group (NCCL between GPUs, Gloo between CPU nodes), with the same value and gradients on every process. The same training script runs alone or under torchrun, mpirun or srun: see Several GPUs or nodes.
  • Fixes, not surprises. A few GeomLoss bugs are fixed (the gradient of unbalanced transport, "hausdorff" without a kernel, ...). Every difference is listed in Coming from GeomLoss.

Installation

remblais needs Python 3.10 or later, PyTorch and kernox. Install PyTorch for your platform, then kernox with the extra that matches your GPU, then remblais, both from PyPI. For an NVIDIA GPU:

pip install torch --index-url https://download.pytorch.org/whl/cu126
pip install "kernox[cuda]"
pip install remblais

On the CPU only (x86-64 Linux, with g++ 12 or later for the fast path):

pip install torch --index-url https://download.pytorch.org/whl/cpu
pip install remblais

For AMD and Intel GPUs, install PyTorch from the rocm or xpu index and kernox with the rocm or xpu extra. Intel GPUs also need a SYCL runtime matching the host icpx compiler, see Intel GPUs. The details are in the kernox installation guide and in Getting started.

Performance

The goal of remblais is to be at least as fast as GeomLoss wherever GeomLoss runs. In every case measured so far, on an NVIDIA GPU and on the CPU, it is faster.

Sinkhorn divergence, p = 2, FP32, forward and backward passes, on an RTX 5090; remblais with its default settings, against GeomLoss 0.3.1 with PyKeOps 2.3 in its best configuration (each PyKeOps kernel compiled alone in a fresh process). Speed-up of remblais (GeomLoss time / remblais time):

Case N = 10³ N = 10⁴ N = 10⁵ N = 10⁶
multiscale, D = 2 × 2.0 × 1.9 × 1.8
multiscale, D = 3 × 2.4 × 1.3 × 1.15
online, D = 2 × 2.6 × 5.1 × 2.1 × 1.4
online, D = 3 × 2.6 × 5.6 × 1.7 × 1.2
online, D = 64 × 4.8 × 7.1 × 2.6 not measured

On the CPU (2 × AMD EPYC 9654, 192 threads), against GeomLoss on the CPU backend of PyKeOps:

Case N = 10³ N = 10⁴ N = 10⁵
multiscale, D = 2 × 1.3 × 1.6
multiscale, D = 3 × 22 × 13
online, D = 2 × 2.4 × 7.7 × 10
online, D = 3 × 2.4 × 8.2 × 11
online, D = 64 × 2.7 × 9.0 not measured

These figures cover only the cases listed; they are not a general claim of superiority over GeomLoss on every workload or machine. The full tables and the protocol are on the Performance page.

Several GPUs or nodes

A large loss can be split across several GPUs or CPU nodes. Every process runs the same script on the same clouds and gets the same value and the same gradients, so a plain optimizer keeps the parameters identical everywhere:

# fit.py
import torch
import kernox.distributed as kd
from remblais import SamplesLoss

info = kd.init_from_env()                 # first thing: joins the other processes
g = torch.Generator().manual_seed(0)      # the same clouds on every process
x = torch.rand(1_000_000, 3, generator=g).to(info.device).requires_grad_()
y = (torch.rand(1_000_000, 3, generator=g) + 0.5).to(info.device)

loss = SamplesLoss("sinkhorn", blur=0.05, backend="multiscale", distributed=True)
L = loss(x, y)
L.backward()                              # the full gradient, on every process
if info.rank == 0:                        # print and save on one process only
    print(L.item())

Test it on your machine, then launch it on the cluster with the tool you already use; init_from_env finds the rank, the GPU and the first node by itself, and no mpi4py is needed:

python fit.py                                                       # 1 process
torchrun --nproc-per-node 2 fit.py                                  # 2 processes, same result
torchrun --nproc-per-node 4 fit.py                                  # the 4 GPUs of a node
srun --nodes 2 --ntasks-per-node 4 --gpus-per-node 4 python fit.py  # SLURM, 2 nodes of 4 GPUs
mpirun -np 8 --map-by ppr:1:node --bind-to none python fit.py       # 8 CPU nodes, all their cores

Debiased Sinkhorn divergence, p = 2, blur = 0.05, D = 3, FP32, forward and backward passes, one process per GPU or per CPU node:

Case 1 device 8 devices Speed-up
online, N = 10⁶, AMD MI210 (2 nodes of 4) 176 s 21.3 s × 8.3
multiscale, N = 10⁷, AMD MI210 (2 nodes of 4) 1391 s 188 s × 7.4
online, N = 10⁶, CPU nodes (2 × EPYC 9654) 157 s 20.7 s × 7.6
multiscale, N = 10⁷, CPU nodes (2 × EPYC 9654) 1453 s 185 s × 7.9

The guide Several GPUs or nodes goes through it step by step, with all the measurements and when splitting pays. Batch scripts for SLURM and OAR, and troubleshooting: Running on a cluster.

In 1781, Gaspard Monge asked how to move a pile of earth, the déblais, into a hole of the same volume, the remblais, at the lowest cost: the founding problem of optimal transport. remblais is where the mass ends up. The logo shows the ox of symox and kernox, harnessed this time to a scraper, carrying the déblais to the remblais: Monge's optimal transport.

License

At your option, MIT or Apache-2.0. Code derived from GeomLoss stays under the MIT license of GeomLoss; its provenance and notice are in THIRD_PARTY.md.

Metadata

Release files for remblais 2.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for remblais 2.2.0
File Size Uploaded Provenance Actions
remblais-2.2.0.tar.gz 91.0 kB With provenance Details for remblais-2.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for remblais 2.2.0
File Interpreter ABI Platform Actions
remblais-2.2.0-py3-none-any.whl Python 3 none any Details for remblais-2.2.0-py3-none-any.whl

Total release size: 188.2 kB

Release files / remblais-2.2.0.tar.gz

Download URL remblais-2.2.0.tar.gz
Size 91.0 kB
Tags Source
SHA-256 checksum
How to use checksums
a201995c386c9c95107604b52aebea08dda14915b1a23ac967267816d4ae83bf
BLAKE2b-256 checksum
How to use checksums
08d09f394526a3fd6eaa770e7c052f7f783c740a7e60fc2bee8c89c90b93e763
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 21, 2026.

Transparency log

Release files / remblais-2.2.0-py3-none-any.whl

Download URL remblais-2.2.0-py3-none-any.whl
Size 97.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
19ff9f68b77502bc2d7d830c87c7723ca146f19d0ff8886e4d63601cd493e17e
BLAKE2b-256 checksum
How to use checksums
1d8be521128fddd035d1cdda1ec0b031028ed746effc8ef1b53258331afbad0e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 21, 2026.

Transparency log

Security for remblais 2.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for remblais-2.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 21, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page