KernelForge - Optimized Kernels for ML
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
Quick Start (Recommended)
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.10+
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.14 for CUDA):
uv pip install kernelforge # CPU (3.10–3.15)
uv pip install 'kernelforge[cuda]' # + torch + kernelforge-cuda
Or install the companion explicitly:
uv pip install kernelforge kernelforge-cuda
Notes:
- The
kernelforge-cudacompanion wheel is CPython 3.11–3.14 manylinux only. On 3.10/3.15,'kernelforge[cuda]'will not pull the companion (see thepython_versionmarker inpyproject.toml); use a local monorepo CUDA build instead. - Default-index
torchmay 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-cudawithmanylinux_cuda(no GPU needed to compile). - FCHL18 CUDA KRR supports
--dtype float32/float64viakernelcli(float32 uses GPUrfp_potrfend-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.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| kernelforge-1.1.0.tar.gz | 9.6 MB | With provenance | Details |
Built distributions (wheels)
Total release size: 97.9 MB
Release files / kernelforge-1.1.0.tar.gz
| Download URL | kernelforge-1.1.0.tar.gz |
|---|---|
| Size | 9.6 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
93e6c71b0209218a4205ed3c4a5a10011f9b0c029d303db12abf2cb9d0994eb4
|
|
BLAKE2b-256 checksum How to use checksums |
badc256ea232cda21dd41c54fcd7fb4334314991c9d37ce657862e49ef3f39ce
|
| 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 25, 2026.
Transparency logRelease files / kernelforge-1.1.0-cp315-cp315-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | kernelforge-1.1.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 |
18e145b13c283d8cb3a38398e37fb61cf1bf27bcc2efc1fb910fabf1acb3639a
|
|
BLAKE2b-256 checksum How to use checksums |
48a7ac7bea52ef79e9d2fe627716aee9aa49ee2dc13b6e49183af38d517bc952
|
| 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 25, 2026.
Transparency logRelease files / kernelforge-1.1.0-cp315-cp315-macosx_26_0_arm64.whl
| Download URL | kernelforge-1.1.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 |
b051917a4f4919d3bd232b85d9387ae7817f3ae2c1831195a8acf5a7d5abc7cb
|
|
BLAKE2b-256 checksum How to use checksums |
57c593529391d2bd01bfe5c96391cc3a8ae942d82e5ce0a09a5e8a43e4a8d50c
|
| 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 25, 2026.
Transparency logRelease files / kernelforge-1.1.0-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | kernelforge-1.1.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 |
f9baa85b081aef18038e92715391d19ced4c2fda075e2d383947ede32aeb5dc8
|
|
BLAKE2b-256 checksum How to use checksums |
e2dac9ef9c0f194026524c73162708dd63b763eb3eb5b6fec36977740efb3dc4
|
| 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 25, 2026.
Transparency logRelease files / kernelforge-1.1.0-cp314-cp314-macosx_26_0_arm64.whl
| Download URL | kernelforge-1.1.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 |
b71e4fa1a3ef993da6b0d2baf0de1dadbdb411e9641f333d2fb27b17d1cd29ee
|
|
BLAKE2b-256 checksum How to use checksums |
d7dd939d8d14a43da92857deaa55cf034bb8c28dbe4de061e694d99675bd834e
|
| 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 25, 2026.
Transparency logRelease files / kernelforge-1.1.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | kernelforge-1.1.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 |
33088c24f386bf097fdb972781245daab01b0164b6b7cb36a9f8477ec7c85873
|
|
BLAKE2b-256 checksum How to use checksums |
77a60c1ec41719065909950b5a522be2e269a496f6aa375889c1c61705d3d885
|
| 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 25, 2026.
Transparency logRelease files / kernelforge-1.1.0-cp313-cp313-macosx_26_0_arm64.whl
| Download URL | kernelforge-1.1.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 |
c97c84502a1e67d41356176604af007cbe785657d660402a535cbe9f2594257e
|
|
BLAKE2b-256 checksum How to use checksums |
62dec26eff7555790278229017537ce73c22c3b8e708216ca5a539d6ae6b80a4
|
| 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 25, 2026.
Transparency logRelease files / kernelforge-1.1.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | kernelforge-1.1.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 |
d430fe923c7dcdbbe9fc2f31fd42610bde34d4e3c6da374e3a5892a55080ddc4
|
|
BLAKE2b-256 checksum How to use checksums |
424cca9f1b6faa6b9b69d90fb815cf0b7eeff4f425f7962ea6a5d1bf48fb543b
|
| 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 25, 2026.
Transparency logRelease files / kernelforge-1.1.0-cp312-cp312-macosx_26_0_arm64.whl
| Download URL | kernelforge-1.1.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 |
b18c5d99d220f81b742a4018a75742d7cba73435c566a091cf596944df8dcd07
|
|
BLAKE2b-256 checksum How to use checksums |
8516c10cc9782d4fd6de3cbb0329acd1836b4bdc59982a3d745e8b153022240a
|
| 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 25, 2026.
Transparency logRelease files / kernelforge-1.1.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | kernelforge-1.1.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 |
20c2012b6a33f51fef071cc4c56f9f44b51721471d9c3d547c24930cd91c500d
|
|
BLAKE2b-256 checksum How to use checksums |
1471e68587ee45395d7c94cf03c1b039aec9215610c22ad141d5c68118f6d486
|
| 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 25, 2026.
Transparency logRelease files / kernelforge-1.1.0-cp311-cp311-macosx_26_0_arm64.whl
| Download URL | kernelforge-1.1.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 |
c97f9b515cf5687a66722c535eaba92e563112a52211cc3b653c7ad1206f1c7c
|
|
BLAKE2b-256 checksum How to use checksums |
07a46bea76ccb6c2ee6b5bd190f4d4b0976431c42cb669ff852c5c74bba30c81
|
| 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 25, 2026.
Transparency logRelease files / kernelforge-1.1.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | kernelforge-1.1.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 13.4 MB |
| Tags | CPython 3.10 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
86a47114eee78c7490d2001adc1075d900f1af1ed044b58f79da0369c6b5e696
|
|
BLAKE2b-256 checksum How to use checksums |
d1026395ee02f076137f35b52f26156836bda21194dc544eb8c942bffd665a7a
|
| 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 25, 2026.
Transparency logRelease files / kernelforge-1.1.0-cp310-cp310-macosx_26_0_arm64.whl
| Download URL | kernelforge-1.1.0-cp310-cp310-macosx_26_0_arm64.whl |
|---|---|
| Size | 1.3 MB |
| Tags | CPython 3.10 macOS 26.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
10ccf648493c79f1eedab85f287e61b6e3eace6bc6bec2a3440d787f7ef9ce06
|
|
BLAKE2b-256 checksum How to use checksums |
e83875d2e85ff8aba1cf818e758e3e6547db40be69d268a028ddcdbe66feb56f
|
| 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 25, 2026.
Transparency logSecurity for kernelforge 1.1.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 13 files in this release have been uploaded with provenance metadata.
Attestation for kernelforge-1.1.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 25, 2026.
Transparency logA 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.