Skip to main content

kernox

kernox logo

kernox computes pairwise reductions on GPUs and CPUs (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, or into vectorized multithreaded C++ on x86-64 CPUs. One reduction can also be split across several GPUs or nodes, from a laptop script to a cluster job. Support for other architectures and 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 and the CPU. One formula runs on NVIDIA, AMD and Intel GPUs, and on x86-64 CPUs (OpenMP, SIMD).
  • Several GPUs or nodes. kernox.distributed splits a reduction across the processes of a torch.distributed group (NCCL between GPUs, Gloo between CPU nodes), with gradients. The same script runs alone or under torchrun, mpirun or srun, without mpi4py.
  • 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 and CPUs. kernox has no NumPy interface; the other differences are listed in Coming from PyKeOps.

Installation

kernox needs Python 3.10 or later, PyTorch, and a supported GPU or an x86-64 Linux CPU with g++ 12 or later. 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

On the CPU only:

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

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. In every case measured so far, kernox is faster.

M = N = 10⁵, FP32, on an RTX 5090; kernox with fast_math=True, PyKeOps 2.3 through Genred in its best configuration (each kernel compiled alone in a fresh process); median of three runs. The last column is the speed-up of kernox (PyKeOps time / kernox time):

Case kernox PyKeOps Speed-up
Log-sum-exp, D = 2 3.60 ms 7.02 ms × 1.95
Log-sum-exp, D = 3 4.36 ms 8.03 ms × 1.84
Log-sum-exp, D = 2, block-sparse ranges 0.249 ms 0.552 ms × 2.22
Log-sum-exp, D = 3, block-sparse ranges 0.359 ms 0.739 ms × 2.06
Gaussian kernel sum, D = 3 3.49 ms 5.24 ms × 1.50
Gaussian kernel sum, D = 3, block-sparse ranges 0.321 ms 0.563 ms × 1.76
10 nearest neighbours, D = 3 5.29 ms 8.70 ms × 1.64

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. To reproduce: python tools/bench_pykeops.py --device cuda --repeat 3.

On the CPU, kernox uses every core and SIMD instructions (AVX2, AVX-512) with glibc's vectorized math functions. Against the CPU backend of PyKeOps 2.3, M = N = 10⁵, FP32, IEEE arithmetic on both sides, on a node with 2 × AMD EPYC 9654 (192 cores, 192 threads), same protocol as above:

Case kernox PyKeOps Speed-up
Log-sum-exp, D = 2 35.2 ms 344 ms × 9.8
Log-sum-exp, D = 3 37.4 ms 374 ms × 10.0
Log-sum-exp, D = 2, block-sparse ranges 1.35 ms 21.6 ms × 16.0
Log-sum-exp, D = 3, block-sparse ranges 1.72 ms 33.7 ms × 19.6
Gaussian kernel sum, D = 3 47.2 ms 343 ms × 7.3
Gaussian kernel sum, D = 3, block-sparse ranges 1.94 ms 36.1 ms × 18.6
10 nearest neighbours, D = 3 13.8 ms 110 ms × 7.9

Against PyTorch computing the distance matrix by blocks (same node, 192 threads, FP32, M = N = 20,000):

Case kernox PyTorch Speed-up
Gaussian kernel sum, D = 3 2.1 ms 242 ms × 113
Log-sum-exp, D = 3 1.7 ms 157 ms × 91
10 nearest neighbours, D = 3 1.4 ms 113 ms × 79
Gaussian kernel sum, D = 16 3.4 ms 170 ms × 50

Details, thread scaling and larger sizes: CPU backend.

Several GPUs or nodes

Strong scaling of a Gaussian kernel product in D = 3, FP32, forward and backward, split with kernox.distributed. The block-sparse case keeps, for each point, the 27 neighbouring cells of a grid (2.7 × 10¹² pairs for 10⁸ points):

Case 1 device 8 devices Speed-up
Dense, N = 10⁷, AMD MI210 (2 nodes of 4) 756 s 94.6 s × 8.0
Block-sparse, N = 10⁸, AMD MI210 (2 nodes of 4) 21.4 s 2.79 s × 7.7
Dense, N = 3 × 10⁶, CPU nodes (2 × EPYC 9654) 94.9 s 13.2 s × 7.2
Block-sparse, N = 10⁸, CPU nodes (2 × EPYC 9654) 28.0 s 5.40 s × 5.2

All the measurements, and when splitting pays: Several GPUs or nodes.

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

Metadata

Release files for kernox 1.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 kernox 1.2.0
File Size Uploaded Provenance Actions
kernox-1.2.0.tar.gz 253.4 kB With provenance Details for kernox-1.2.0.tar.gz

Built distribution (wheel)

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

Total release size: 471.4 kB

Release files / kernox-1.2.0.tar.gz

Download URL kernox-1.2.0.tar.gz
Size 253.4 kB
Tags Source
SHA-256 checksum
How to use checksums
ddaf1344cf46dc5fbd7cbaf98b215f54c95f93b10816ee70c0700acc7c89d17f
BLAKE2b-256 checksum
How to use checksums
be325ca37870ec94ae1786b87ecaa6d6ff95253fe44d758bfe2efbf3d29d1f22
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 / kernox-1.2.0-py3-none-any.whl

Download URL kernox-1.2.0-py3-none-any.whl
Size 218.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
abc070a4b03dd8e231f5ae784b33d9600aba803649fdeadde9d9965060bb5ecd
BLAKE2b-256 checksum
How to use checksums
c0d5dd22c232e63d956560f6c23080dbf0ad161b59d1531922948578a26c44e3
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 kernox 1.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 kernox-1.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