Registry / ai-ml / pykeops

pykeops

JSON →
library2.3pypypiunverified

PyKeOps is a Python package providing bindings to the KeOps library, which enables efficient computation of kernel operations on CPUs and GPUs with automatic differentiation and without memory overflows. It is widely used in geometry processing, shape analysis, and machine learning for large-scale distance and kernel computations. Current version is 2.3, with active development on GitHub.

pip install pykeops
INSTALL
IMPORT
SIG · PYKEOPS
P
pykeops
ai-mlpythonv2.3
Install
6.1s avg
Import
Disk
94MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.3 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 95.2MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 6.1s · import 0.000s · 91MB
94MB installed
● package 94MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

LazyTensor
from pykeops import LazyTensor
from pykeops.torch import LazyTensor

Compute pairwise Gaussian kernel sum using LazyTensors for memory-efficient reduction.

import torch from pykeops.torch import LazyTensor # Create sample data x = torch.randn(1000, 3).cuda() y = torch.randn(2000, 3).cuda() # Define LazyTensors X = LazyTensor(x[:, None, :]) # (1000, 1, 3) Y = LazyTensor(y[None, :, :]) # (1, 2000, 3) # Compute pairwise distances squared D = ((X - Y) ** 2).sum(2) # Symbolic reduction # Compute softmin (log-sum-exp) with Gaussian kernel K = (-D).exp() result = K.sum(1) # (1000,) actually returns a LazyTensor, evaluate with .detach() print(result.detach())
Debug
Known issues
breakingPyKeOps 2.0 introduced a completely reworked compilation engine. Old code using from pykeops.torch import generic_logsumexp or similar may not work. Update to LazyTensor API.
fix
Migrate to LazyTensor-based API: replace generic reductions with symbolic expressions.
affects: <2.0
gotchaLazyTensor operations must be explicitly evaluated (e.g., .eval(), .detach(), or .sum() returns a LazyTensor, not a torch.Tensor). Forgetting evaluation leads to symbolic objects in the result.
fix
Call .eval() on the final LazyTensor or use reduction operations that return tensors (some like .sum() still return LazyTensor).
affects: all
deprecatedThe old API using pykeops.torch.generic_sum, generic_logsumexp, etc. is deprecated in 2.x and may be removed. Use LazyTensor or Genred instead.
fix
Use LazyTensor or Genred for custom formulas.
affects: >=2.0
Upgrade
Version history
2.3latest on PyPI · released Apr 17, 2025
Audit
Dependencies
torchrequiredPyKeOps integrates with PyTorch for tensor operations and autograd.
Agent activity
12 hits · last 30 days
node
10
OpenAI (training)
1
Resources
pykeops — pip install pykeops · libregistry