Skip to main content

KernelForge - Optimized Kernels for ML

CI PyPI version Python Versions Platform License: MIT

I really only care about writing optimized kernel code, so this project will be completed as I find additional time... XD

I'm reviving this project to finish an old project using random Fourier features for kernel ML.

Installation

For most users, install from PyPI:

pip install kernelforge

This installs pre-compiled wheels with optimized BLAS libraries:

  • Linux: OpenBLAS
  • macOS: Apple Accelerate framework

Requirements: Python 3.11+

Development Installation

Linux

# Create virtual environment with uv
uv venv
source .venv/bin/activate

# Install in editable mode with test dependencies
make install-linux

# Or manually:
CMAKE_ARGS="-DKF_USE_NATIVE=ON" uv pip install -e .[test] --verbose

macOS

macOS requires Homebrew LLVM for OpenMP support:

# Install dependencies
brew install llvm libomp

# Create virtual environment
uv venv
source .venv/bin/activate

# Install in editable mode
make install-macos

# Or manually:
CMAKE_ARGS="-DCMAKE_C_COMPILER=/opt/homebrew/opt/llvm/bin/clang -DCMAKE_CXX_COMPILER=/opt/homebrew/opt/llvm/bin/clang++ -DKF_USE_NATIVE=ON" uv pip install -e .[test] --verbose

Note: The -DKF_USE_NATIVE=ON flag enables -march=native/-mcpu=native optimizations for maximum performance on your specific CPU.

Linux with CUDA

PyPI ships a CPU kernelforge wheel plus a Linux companion kernelforge-cuda that drops cuda_*.so into site-packages/kernelforge/.

From PyPI (Linux, CPython 3.11–3.15 for CUDA):

uv pip install kernelforge                 # CPU (3.11–3.15)
uv pip install 'kernelforge[cuda]'         # + torch + kernelforge-cuda

Or install the companion explicitly:

uv pip install kernelforge kernelforge-cuda

Notes:

  • The kernelforge-cuda companion wheel is Linux manylinux only (CPython 3.11–3.15, same as CPU).
  • Default-index torch may be CPU-only. For GPU runs, install a CUDA build of PyTorch (e.g. from the PyTorch CUDA wheel index) and an NVIDIA driver compatible with that build.
  • Release CUDA wheels are built on GHA build-wheels-cuda with manylinux_cuda (no GPU needed to compile).
  • FCHL18 CUDA KRR supports --dtype float32 / float64 via kernelcli (float32 uses GPU rfp_potrf end-to-end).

Local monorepo / wheel smoke (developers):

# One editable tree with CPU+CUDA (needs CUDA toolkit + torch):
source /opt/intel/oneapi/setvars.sh
make install-linux-mkl-ilp64-cuda   # passes -DKF_WITH_CUDA=ON

# Or build the split wheels and smoke-test imports in a fresh venv:
make demo-cuda-wheels

Requires a CUDA toolkit + PyTorch for local CUDA builds.

Advanced: Custom BLAS/LAPACK Libraries

Intel MKL (Linux)

# Install Intel oneAPI Base Toolkit
sudo apt install intel-oneapi-base-toolkit

# Set up environment
source /opt/intel/oneapi/setvars.sh

# Install (MKL will be auto-detected by CMake)
uv pip install -e .[test] --verbose

# Optional: Use Intel compilers
CC=icx CXX=icpx uv pip install -e .[test] --verbose

Note: In practice, GCC/G++ with OpenBLAS performs similarly to (or better than) Intel compilers with MKL. On macOS, LLVM with Accelerate framework is highly optimized for Apple Silicon.

ASE molecular dynamics

Install the optional ASE extra:

pip install 'kernelforge[ase]'

Wrap a fitted force-capable model (for example CudaLocalKRRModel) with KernelForgeCalculator, or use run_md() / the kernelmd CLI:

kernelmd --model model.npz --structure start.xyz --steps 5000 --dt 0.5 \
         --temperature 300 --output traj.extxyz

See examples/run_md_rmd17_*.py and examples/run_opt_rmd17_*.py.

Timings

I've rewritten a few of the kernels from the original QML code completely in C++. There are performance gains in most cases. These are primarily due to better use of BLAS routines for calculating, for example, Gramian sub-matrices with chunked DGEMM/DSYRK calls, etc. In the gradient and Hessian matrices there are also some algorithmic improvements and pre-computed terms. Memory usage might be a bit higher, but this could be optimized with more fine-grained chunking if needed. More is coming as I find the time ...

Some speedups vs the original QML code are shown below:

Benchmark QML [s] Kernelforge [s]
Upper triangle Gaussian kernel (16K x 16K) 1.82 0.64
1K FCHL19 descriptors (1K) N/A 0.43
1K FCHL19 descriptors+jacobian (1K) N/A 0.62
FCHL19 Local Gaussian scalar kernel (10K x 10K) 76.81 18.15
FCHL19 Local Gaussian gradient kernel (1K x 2700K) 32.54 1.52
FCHL19 Local Gaussian Hessian kernel (5400K x 5400K) 29.68 2.05

TODO list

Tracked in GitHub issue #45 (roadmap, open items, and stretch goals).

Metadata

Release files for kernelforge 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 kernelforge 1.2.0
File Size Uploaded Provenance Actions
kernelforge-1.2.0.tar.gz 8.4 MB With provenance Details for kernelforge-1.2.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for kernelforge 1.2.0
File Actions
kernelforge-1.2.0-cp315-cp315-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.15 CPython 3.15 Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details for kernelforge-1.2.0-cp315-cp315-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
kernelforge-1.2.0-cp315-cp315-macosx_26_0_arm64.whl CPython 3.15 CPython 3.15 macOS 26.0+ ARM64 Details for kernelforge-1.2.0-cp315-cp315-macosx_26_0_arm64.whl
kernelforge-1.2.0-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.14 CPython 3.14 Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details for kernelforge-1.2.0-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
kernelforge-1.2.0-cp314-cp314-macosx_26_0_arm64.whl CPython 3.14 CPython 3.14 macOS 26.0+ ARM64 Details for kernelforge-1.2.0-cp314-cp314-macosx_26_0_arm64.whl
kernelforge-1.2.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details for kernelforge-1.2.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
kernelforge-1.2.0-cp313-cp313-macosx_26_0_arm64.whl CPython 3.13 CPython 3.13 macOS 26.0+ ARM64 Details for kernelforge-1.2.0-cp313-cp313-macosx_26_0_arm64.whl
kernelforge-1.2.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details for kernelforge-1.2.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
kernelforge-1.2.0-cp312-cp312-macosx_26_0_arm64.whl CPython 3.12 CPython 3.12 macOS 26.0+ ARM64 Details for kernelforge-1.2.0-cp312-cp312-macosx_26_0_arm64.whl
kernelforge-1.2.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details for kernelforge-1.2.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
kernelforge-1.2.0-cp311-cp311-macosx_26_0_arm64.whl CPython 3.11 CPython 3.11 macOS 26.0+ ARM64 Details for kernelforge-1.2.0-cp311-cp311-macosx_26_0_arm64.whl

Total release size: 82.0 MB

Release files / kernelforge-1.2.0.tar.gz

Download URL kernelforge-1.2.0.tar.gz
Size 8.4 MB
Tags Source
SHA-256 checksum
How to use checksums
aaebff0bbb1f0317d3d5e47c9b1963286aadd4711ecb1f4e03c57b7673c6ae0b
BLAKE2b-256 checksum
How to use checksums
1061d82833936accc025eeda86e0fa50578c4c2c250b176f6efbfe30d5da8914
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 Oct 29, 2026.

Transparency log

Release files / kernelforge-1.2.0-cp315-cp315-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL kernelforge-1.2.0-cp315-cp315-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 13.4 MB
Tags CPython 3.15 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
0033d286edc8fbc3bd78c853d7710ccef28afcb278f79efd5633324cf8a5c6ab
BLAKE2b-256 checksum
How to use checksums
78d8d333ffcbde86bf77e272c0d3c6b9d470283825225a8536e3cd96c85c09b8
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 Oct 29, 2026.

Transparency log

Release files / kernelforge-1.2.0-cp315-cp315-macosx_26_0_arm64.whl

Download URL kernelforge-1.2.0-cp315-cp315-macosx_26_0_arm64.whl
Size 1.3 MB
Tags CPython 3.15 macOS 26.0+ ARM64
SHA-256 checksum
How to use checksums
0262eefbd931b2cc9bd66cfee72e64c54e7daef3e9f47f0da24f763f743d76f0
BLAKE2b-256 checksum
How to use checksums
9da6f416083d49f16c51f216b12e7728810b903570becac594b3bb736b8b7836
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 Oct 29, 2026.

Transparency log

Release files / kernelforge-1.2.0-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL kernelforge-1.2.0-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 13.4 MB
Tags CPython 3.14 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
338891af54162966ec8616d68415251e958386b079782be048b91b69a5373d52
BLAKE2b-256 checksum
How to use checksums
46c1e1180bb76ebf0bb4b9356368b2c85dac3aed44df3fe157dfd0b6469c0ba0
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 Oct 29, 2026.

Transparency log

Release files / kernelforge-1.2.0-cp314-cp314-macosx_26_0_arm64.whl

Download URL kernelforge-1.2.0-cp314-cp314-macosx_26_0_arm64.whl
Size 1.3 MB
Tags CPython 3.14 macOS 26.0+ ARM64
SHA-256 checksum
How to use checksums
1d70e498c38f3ea5f0ad87eb40f342112becf65e449ac58feba2631dad6aa1ee
BLAKE2b-256 checksum
How to use checksums
dbe1539427d28e3995fcec0e7b859da9961292379b402e8dc17c10bac634f89b
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 Oct 29, 2026.

Transparency log

Release files / kernelforge-1.2.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL kernelforge-1.2.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 13.4 MB
Tags CPython 3.13 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
77cc7a7f388b54758eee009e4640fc17b7266756d0eb384d9f9812e58472cdef
BLAKE2b-256 checksum
How to use checksums
39c4985981d6229aa43310631c560930d71df2ca228801d09a6ea8612336288c
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 Oct 29, 2026.

Transparency log

Release files / kernelforge-1.2.0-cp313-cp313-macosx_26_0_arm64.whl

Download URL kernelforge-1.2.0-cp313-cp313-macosx_26_0_arm64.whl
Size 1.3 MB
Tags CPython 3.13 macOS 26.0+ ARM64
SHA-256 checksum
How to use checksums
67ad60a2510282bef5811c7e9b20d260db4b779b51c9a0c0b5d67a3c7b31c489
BLAKE2b-256 checksum
How to use checksums
77ecdefd85ef84bcb4ef8d3bc04a38eea6871b129b4691df59985519b2b582a6
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 Oct 29, 2026.

Transparency log

Release files / kernelforge-1.2.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL kernelforge-1.2.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 13.4 MB
Tags CPython 3.12 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
a92dd7e2ca30947a0de9fc6de7c4c4314ee24654fc6ac10d7785595589947a79
BLAKE2b-256 checksum
How to use checksums
eec6d43cec0fc9dca7acc9131c8bb7be1805614d2176fc23cab9daa5acd0e0f7
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 Oct 29, 2026.

Transparency log

Release files / kernelforge-1.2.0-cp312-cp312-macosx_26_0_arm64.whl

Download URL kernelforge-1.2.0-cp312-cp312-macosx_26_0_arm64.whl
Size 1.3 MB
Tags CPython 3.12 macOS 26.0+ ARM64
SHA-256 checksum
How to use checksums
ef96e246879ac81a916017307dd402c591eb22b613afbcb6ad0f07a5dd8078fd
BLAKE2b-256 checksum
How to use checksums
edc575f2ed9523f4ca4eb06760e8535f1eb671f00e6204986687c6599c595cd3
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 Oct 29, 2026.

Transparency log

Release files / kernelforge-1.2.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL kernelforge-1.2.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 13.4 MB
Tags CPython 3.11 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
43f5f6f609c2e7144b6a81121bd4ec88b5c305367b6f7fbc8c21f44b74512a64
BLAKE2b-256 checksum
How to use checksums
f84af2dc08ae6ca932678de38a8d20c1063597733718ae6a61abe85dadfc4675
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 Oct 29, 2026.

Transparency log

Release files / kernelforge-1.2.0-cp311-cp311-macosx_26_0_arm64.whl

Download URL kernelforge-1.2.0-cp311-cp311-macosx_26_0_arm64.whl
Size 1.3 MB
Tags CPython 3.11 macOS 26.0+ ARM64
SHA-256 checksum
How to use checksums
e85a1bc33d9d9e75cbd8612b042921eadd2894decf5781b9ab7a7657809965cf
BLAKE2b-256 checksum
How to use checksums
3969c7f04da73825d60dc0a63e7b62480fb79c746d122e22bc6246bb6ddae48f
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 Oct 29, 2026.

Transparency log

Security for kernelforge 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

All 11 files in this release have been uploaded with provenance metadata.

Select from 11 files

Attestation for kernelforge-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 Oct 29, 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