Skip to content

kernox

kernox logo

kernox computes pairwise reductions on GPUs (Gaussian kernel sums, nearest neighbours, log-sum-exp, softmax-weighted sums, ...) without ever building the M×N matrix. You write the formula with symbolic variables indexed by i and j, and kernox turns it into a single fused GPU kernel for NVIDIA (CUDA), AMD (ROCm/HIP) or Intel (SYCL) cards. Support for other accelerators may be added later.

kernox is a successor to PyKeOps, built on the symox symbolic engine. It works with PyTorch tensors.

Why kernox

  • No M×N matrix. Memory stays linear in the number of points, so each row can be reduced over millions of points.
  • Three GPU vendors. One formula runs on NVIDIA, AMD and Intel GPUs.
  • Formulas, not strings. Formulas are Python expressions. Derivatives are computed symbolically and run as fused reductions too.
  • Predictable numerics. IEEE arithmetic by default, an explicit opt-in for approximate exp and log, and an explicit error instead of a silent fallback when something is not supported.
  • Familiar to PyKeOps users. The PyKeOps reductions and formula operations are available for PyTorch on GPUs. kernox has no NumPy interface and no CPU backend; the other differences are listed in Coming from PyKeOps.

Installation

kernox needs Python 3.10 or later, PyTorch and a supported GPU. Install PyTorch for your platform first, then kernox from PyPI (symox, its symbolic engine, comes with it as a dependency):

pip install torch --index-url https://download.pytorch.org/whl/cu126   # NVIDIA
pip install "kernox[cuda]"
python -m kernox.diagnostics --check

AMD and Intel instructions, and the details, are in Getting started.

Performance

The goal of kernox is to be at least as fast as PyKeOps wherever PyKeOps runs, and to bring the same performance to AMD and Intel GPUs, which PyKeOps does not support. On NVIDIA GPUs, kernox is already faster than PyKeOps in several cases.

LogSumExp reduction, M = N = 10⁵, FP32, on an RTX 2080 Ti; kernox with fast_math=True, PyKeOps 2.4b in its best configuration (each kernel compiled alone in a fresh process); median of two runs:

Case kernox PyKeOps kernox / PyKeOps
D = 2, dense 20.1 ms 21.9 ms ×0.92
D = 3, dense 24.6 ms 25.8 ms ×0.95
D = 2, block-sparse ranges 8.4 ms 8.9 ms ×0.95
D = 3, block-sparse ranges 4.2 ms 4.2 ms ×1.01 (same within noise)

These figures cover only the cases listed; they are not a general claim of superiority over PyKeOps on every workload or card. A case where kernox is slower than PyKeOps is treated as a bug.

Learn more

symox is symbolic plus ox: a rusty ox, since symox is written in Rust. kernox is kernels plus the ox of symox, and also a nod to the redox chemistry of copper. The logo goes from orange copper (the ox) to turquoise verdigris (the trails and the compute grid), that is, from copper to its oxidation patina. And redox contains reduction, which is what kernox does: sum, min and max, as drawn in the logo.

License

At your option, MIT or Apache-2.0. Provenance of third-party code and algorithms (KeOps, symox): THIRD_PARTY.md.

Projects using kernox