gpflash 0.2.0__tar.gz → 0.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {gpflash-0.2.0 → gpflash-0.3.0}/.github/workflows/ci.yml +11 -2
- gpflash-0.3.0/.github/workflows/weekly.yml +25 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/.github/workflows/wheels.yml +2 -1
- {gpflash-0.2.0 → gpflash-0.3.0}/.gitignore +1 -0
- gpflash-0.3.0/CHANGELOG.md +61 -0
- gpflash-0.3.0/PKG-INFO +208 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/README.md +46 -20
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/Version.hpp +1 -1
- {gpflash-0.2.0 → gpflash-0.3.0}/pyproject.toml +14 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/python/CMakeLists.txt +1 -1
- gpflash-0.3.0/python/README.md +174 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/python/gpflash/__init__.py +2 -1
- {gpflash-0.2.0 → gpflash-0.3.0}/python/gpflash/_core.pyi +24 -221
- gpflash-0.3.0/python/gpflash/_gp.py +298 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/python/src/bindings.cpp +38 -10
- {gpflash-0.2.0 → gpflash-0.3.0}/python/tests/test_core.py +37 -11
- gpflash-0.3.0/python/tests/test_diagnostics.py +123 -0
- gpflash-0.3.0/python/tests/test_gaussian_process.py +317 -0
- gpflash-0.3.0/python/tests/test_numerics.py +159 -0
- gpflash-0.2.0/CHANGELOG.md +0 -35
- gpflash-0.2.0/PKG-INFO +0 -179
- gpflash-0.2.0/python/README.md +0 -145
- gpflash-0.2.0/python/gpflash/_gp.py +0 -218
- gpflash-0.2.0/python/tests/test_diagnostics.py +0 -118
- gpflash-0.2.0/python/tests/test_gaussian_process.py +0 -181
- gpflash-0.2.0/python/tests/test_numerics.py +0 -154
- {gpflash-0.2.0 → gpflash-0.3.0}/.clang-format +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/CITATION.cff +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/CMakeLists.txt +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/LICENSE +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/NOTICE +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/THIRD-PARTY-NOTICES +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/cmake/GpFlashConfig.cmake.in +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/cmake/GpFlashDependencies.cmake +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/assembly/CholTerms.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/assembly/EtaTermHpGrad.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/assembly/KernTermHpGrad.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/assembly/KernelAssembly.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/assembly/KernelMatrix.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/assembly/KernelMatrixGrad.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/assembly/KmatNuggetGrad.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/assembly/PosteriorCovariance.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/assembly/SigmaGrad.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/assembly/SigmaMatrix.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/assembly/SymmetryMatrix.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/core/Errors.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/core/NoiseModel.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/core/ParallelContext.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/core/Platform.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/core/StringFormat.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/inputs/EigMaxUbMethod.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/inputs/HpVal.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/inputs/KernelId.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/inputs/ModelOptions.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/inputs/SymmetrySpec.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/inputs/TrainingData.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/kernels/HpGradInputs.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/kernels/KernelBase.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/kernels/KernelDispatch.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/kernels/KernelStationary.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/kernels/OptzSeeding.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/kernels/inner_product/KernelInnerProduct.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/kernels/inner_product/Linear.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/kernels/inner_product/Quadratic.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/kernels/radial/KernelRadial.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/kernels/radial/Matern32.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/kernels/radial/Matern52.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/kernels/radial/RatQuad.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/kernels/radial/SqExp.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/kernels/stationary/Periodic.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/linear_algebra/BlasLapack.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/linear_algebra/Cholesky.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/linear_algebra/InnerProducts.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/linear_algebra/RecursiveInv.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/mean/MeanModel.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/mean/MeanModelWeights.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/optimization/HpOptimizer.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/optimization/MllOptzObjective.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/optimization/MllOptzResult.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/optimization/MultistartReport.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/optimization/README.md +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/optimization/local_optz/LocalOptzResult.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/optimization/local_optz/OptimizerNlopt.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/optimization/multistart/LatinHypercube.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/optimization/multistart/MultistartResult.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/optimization/multistart/OptimumClusters.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/optimization/multistart/RunMultistart.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/optimization/search_space/ActiveBounds.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/optimization/search_space/HpAtBound.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/optimization/search_space/HpOptzLayout.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/optimization/search_space/OptzOptions.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/optimization/search_space/OptzRegion.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/posterior_build/PosteriorBuild.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/posterior_cache/CacheInfo.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/posterior_cache/CacheInputHash.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/posterior_cache/CacheLayout.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/posterior_cache/Hdf5Store.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/posterior_cache/PosteriorCache.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/posterior_cache/PosteriorContents.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/posterior_cache/PosteriorModelInfo.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/posterior_cache/PosteriorPrecompute.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/posterior_cache/README.md +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/posterior_eval/GpPosterior.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/posterior_eval/PosteriorEval.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/posterior_eval/PosteriorGrad.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/posterior_eval/PosteriorOptions.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/posterior_eval/PosteriorQuery.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/posterior_eval/PosteriorResult.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/preconditioning/ConditionedCholesky.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/preconditioning/EtaTerms.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/preconditioning/PreconScales.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/training/EvalMll.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/training/EvalMllDispatch.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/training/EvalMllGrad.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/training/EvalVariances.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/training/MllHpGrad.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/training/MllResult.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/include/gpflash/training/StageTiming.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/python/LICENSES_bundled.txt +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/python/ci/install_deps_unix.sh +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/python/ci/install_deps_windows.ps1 +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/python/gpflash/py.typed +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/tst/CMakeLists.txt +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/tst/GpFlashTestSupport.hpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/tst/check_formatting.cmake +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/tst/check_prediction_only_includes.cmake +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/tst/test_gpflash_cache.cpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/tst/test_gpflash_chol_solves.cpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/tst/test_gpflash_inner_product_gradient.cpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/tst/test_gpflash_input_validation.cpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/tst/test_gpflash_kernel_assembly.cpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/tst/test_gpflash_kernel_center.cpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/tst/test_gpflash_kernel_contract.cpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/tst/test_gpflash_kernel_finite_difference.cpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/tst/test_gpflash_kernel_matrix_grad.cpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/tst/test_gpflash_kernel_posterior_assembly.cpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/tst/test_gpflash_kmat_nugget.cpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/tst/test_gpflash_kmat_nugget_grad.cpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/tst/test_gpflash_linear.cpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/tst/test_gpflash_local_optz.cpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/tst/test_gpflash_multistart.cpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/tst/test_gpflash_multistart_report.cpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/tst/test_gpflash_optimizer.cpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/tst/test_gpflash_optimizer_mpi.cpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/tst/test_gpflash_optimizer_periodic.cpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/tst/test_gpflash_periodic.cpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/tst/test_gpflash_posterior.cpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/tst/test_gpflash_posterior_nonradial.cpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/tst/test_gpflash_recursive_inv.cpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/tst/test_gpflash_search_space.cpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/tst/test_gpflash_sigma_matrix.cpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/tst/test_gpflash_stage_timing.cpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/tst/test_gpflash_string_format.cpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/tst/test_gpflash_struct_checks.cpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/tst/test_gpflash_symmetry.cpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/tst/test_gpflash_training.cpp +0 -0
- {gpflash-0.2.0 → gpflash-0.3.0}/tst/test_gpflash_version.cpp +0 -0
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
# Builds the C++ library and runs its tests (ctest) on Linux and macOS, after every push to main.
|
|
2
2
|
#
|
|
3
|
-
# Linux installs everything the tests can use, so it runs the full suite: the formatting check with clang-format 15
|
|
4
|
-
# and the MPI optimizer test with MPICH. macOS runs the rest, with Apple clang and Homebrew's libraries, as the README's
|
|
3
|
+
# Linux installs everything the tests can use, so it runs the full suite: the formatting check with clang-format 15,
|
|
4
|
+
# ruff's check of the Python files, and the MPI optimizer test with MPICH. macOS runs the rest, with Apple clang and Homebrew's libraries, as the README's
|
|
5
5
|
# macOS build does. A manual run (workflow_dispatch) tests any branch on request.
|
|
6
6
|
name: CI
|
|
7
7
|
|
|
8
8
|
on:
|
|
9
9
|
push:
|
|
10
10
|
branches: [main]
|
|
11
|
+
workflow_call: # from weekly.yml
|
|
11
12
|
workflow_dispatch:
|
|
12
13
|
|
|
13
14
|
permissions:
|
|
@@ -39,6 +40,14 @@ jobs:
|
|
|
39
40
|
if: runner.os == 'macOS'
|
|
40
41
|
run: brew install armadillo libomp hdf5 nlopt
|
|
41
42
|
|
|
43
|
+
# Pinned, as clang-format is, so a ruff release cannot change what passes.
|
|
44
|
+
- name: Check the Python files (Linux)
|
|
45
|
+
if: runner.os == 'Linux'
|
|
46
|
+
run: |
|
|
47
|
+
pip install ruff==0.17.1
|
|
48
|
+
ruff check .
|
|
49
|
+
ruff format --check .
|
|
50
|
+
|
|
42
51
|
- name: Configure (Linux)
|
|
43
52
|
if: runner.os == 'Linux'
|
|
44
53
|
run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Runs the C++ CI and the wheel builds every Saturday at 15:00 UTC (8:00 Pacific daylight time), in marchildon/gpflash
|
|
2
|
+
# only, not in forks or copies. It catches changes to GitHub's runners and to Homebrew before a release does, and keeps
|
|
3
|
+
# the Windows dependency cache from expiring. A failure emails whoever last changed the schedule below.
|
|
4
|
+
name: Weekly
|
|
5
|
+
|
|
6
|
+
on:
|
|
7
|
+
schedule:
|
|
8
|
+
- cron: "0 15 * * 6"
|
|
9
|
+
|
|
10
|
+
permissions:
|
|
11
|
+
contents: read
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
ci:
|
|
15
|
+
if: github.repository == 'marchildon/gpflash'
|
|
16
|
+
uses: ./.github/workflows/ci.yml
|
|
17
|
+
|
|
18
|
+
wheels:
|
|
19
|
+
if: github.repository == 'marchildon/gpflash'
|
|
20
|
+
uses: ./.github/workflows/wheels.yml
|
|
21
|
+
# wheels.yml's PyPI job declares id-token: write, and a called workflow may not ask for more than its caller
|
|
22
|
+
# grants. That job runs only on a published release, so a weekly run never publishes.
|
|
23
|
+
permissions:
|
|
24
|
+
contents: read
|
|
25
|
+
id-token: write
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Builds the Python wheels and sdist and tests each wheel, after every push to main, and publishes to PyPI when a
|
|
2
2
|
# GitHub release is published. A manual run (workflow_dispatch) tests any branch, and can publish to TestPyPI to try a
|
|
3
|
-
# release first. Pull requests do not run it
|
|
3
|
+
# release first. Pull requests do not run it, since a full run takes over an hour of runner time.
|
|
4
4
|
#
|
|
5
5
|
# Publishing uses PyPI trusted publishing: no token is stored. Before the first release, add this repository and
|
|
6
6
|
# workflow (wheels.yml, environment "pypi") as a trusted publisher on the PyPI project, and likewise on TestPyPI with
|
|
@@ -12,6 +12,7 @@ on:
|
|
|
12
12
|
branches: [main]
|
|
13
13
|
release:
|
|
14
14
|
types: [published]
|
|
15
|
+
workflow_call: # from weekly.yml; builds every platform and never publishes
|
|
15
16
|
workflow_dispatch:
|
|
16
17
|
inputs:
|
|
17
18
|
platforms:
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
Every release of GpFlash and what it changed. Version numbers follow
|
|
4
|
+
[semantic versioning](https://semver.org); before 1.0, a minor release may change the interface.
|
|
5
|
+
|
|
6
|
+
## 0.3.0 (2026-10-18)
|
|
7
|
+
|
|
8
|
+
### Changed
|
|
9
|
+
|
|
10
|
+
- **Python:** `GaussianProcess` now uses the C++ library's names, which breaks code written for 0.2.0:
|
|
11
|
+
|
|
12
|
+
| 0.2.0 | Now |
|
|
13
|
+
|---|---|
|
|
14
|
+
| `GaussianProcess(kernel=..., mean=..., n_starts=..., seed=...)`, `from_options` | `GaussianProcess(optz_opts)`, an `OptzOptions` whose fields carry the C++ names |
|
|
15
|
+
| `noise=...` in the constructor; `"estimate"` | `fit(..., sig2_f_val=...)`; a negative value estimates it |
|
|
16
|
+
| `predict(X)` returns arrays; `predict_gradient(X)` | `predict(X)` returns a `PosteriorPrediction`; flags select the mean, variance and gradients, and unrequested fields are `None` |
|
|
17
|
+
| `save` / `load`, `include_variance` | `save_precompute` / `load_posterior`, `include_variance_data` |
|
|
18
|
+
| `summary()`, `fit_result_`, `posterior_` | `to_summary_string()`, `mll_optz_result()`, `posterior()` |
|
|
19
|
+
| `hyperparameters_` (a dict), `log_marginal_likelihood_`, `kernel` | `hp_val_struct()` (an `HpVal`), `hp_beta_vec()`, `mll()`, `kernel_id()` |
|
|
20
|
+
|
|
21
|
+
- **Python:** `predict` returns the variance by default, as C++'s `PosteriorOptions` does.
|
|
22
|
+
- **Python:** points must be 2-D, `(n_points, n_dim)`; a 1-D array is no longer read as one point.
|
|
23
|
+
- **Python:** the wrapper's input checks raise `InvalidInputError`, as the C++ layer does.
|
|
24
|
+
- **Python:** the enums (`KernelId`, `OptzStopReason`, ...) are `enum.Enum` subclasses.
|
|
25
|
+
|
|
26
|
+
### Added
|
|
27
|
+
|
|
28
|
+
- **Python:** `GaussianProcess.eval_mll`, `make_posterior`, `load_posterior_verified` and
|
|
29
|
+
`optz_opts()`. `HpVal`, `TrainingData`, `MllResult` and `PosteriorModelInfo` print their fields.
|
|
30
|
+
- Continuous integration: a weekly run of both workflows, and a ruff check of the Python files.
|
|
31
|
+
|
|
32
|
+
## 0.2.0 (2026-10-17)
|
|
33
|
+
|
|
34
|
+
### Added
|
|
35
|
+
|
|
36
|
+
- **Python package**, `pip install gpflash`, with wheels for Linux (x86_64, aarch64), macOS
|
|
37
|
+
(arm64, x86_64) and Windows (x64) on Python 3.11 to 3.14, every dependency included. It offers
|
|
38
|
+
a NumPy-style `GaussianProcess` (`fit`, `predict`, `predict_gradient`, `save`, `load`) and the
|
|
39
|
+
C++ interface under its C++ names. See [`python/README.md`](python/README.md).
|
|
40
|
+
- CMake option `GPFLASH_BUILD_PYTHON`, off by default, to build the Python module.
|
|
41
|
+
- Citation information for the GpFlash paper, [arXiv:2610.16861](https://arxiv.org/abs/2610.16861):
|
|
42
|
+
`CITATION.cff`, which gives the repository a "Cite this repository" button, and a BibTeX
|
|
43
|
+
entry in [`python/README.md`](python/README.md).
|
|
44
|
+
- Continuous integration: the C++ tests on Linux and macOS, and the Python wheels on every
|
|
45
|
+
platform, after each push to `main`.
|
|
46
|
+
|
|
47
|
+
### Fixed
|
|
48
|
+
|
|
49
|
+
- A cache save that fails part way, as on a full disk, no longer leaves its file open in HDF5. HDF5 1.10
|
|
50
|
+
cannot close it, and the process may crash as it exits.
|
|
51
|
+
|
|
52
|
+
### Changed
|
|
53
|
+
|
|
54
|
+
- The version is set in one place, `include/gpflash/Version.hpp`; CMake and the Python package
|
|
55
|
+
read it from there.
|
|
56
|
+
|
|
57
|
+
## 0.1.0 (2026-10-12)
|
|
58
|
+
|
|
59
|
+
First release: a header-only C++14 library for exact Gaussian process regression, with the
|
|
60
|
+
marginal log likelihood and its analytic hyperparameter gradients, hyperparameter fitting
|
|
61
|
+
through NLopt, posterior mean and variance with their gradients, and an HDF5 posterior cache.
|
gpflash-0.3.0/PKG-INFO
ADDED
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: gpflash
|
|
3
|
+
Version: 0.3.0
|
|
4
|
+
Summary: Fast, exact Gaussian process regression: marginal log-likelihood with analytic gradients, hyperparameter fitting and posterior evaluation.
|
|
5
|
+
Keywords: gaussian-process,kriging,surrogate-model,bayesian-optimization,machine-learning
|
|
6
|
+
Author: André Marchildon
|
|
7
|
+
License-Expression: Apache-2.0
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
License-File: NOTICE
|
|
10
|
+
License-File: THIRD-PARTY-NOTICES
|
|
11
|
+
License-File: python/LICENSES_bundled.txt
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
|
14
|
+
Classifier: Operating System :: MacOS
|
|
15
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
16
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
17
|
+
Classifier: Programming Language :: C++
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
24
|
+
Classifier: Topic :: Scientific/Engineering :: Mathematics
|
|
25
|
+
Project-URL: Homepage, https://github.com/marchildon/gpflash
|
|
26
|
+
Project-URL: Source, https://github.com/marchildon/gpflash
|
|
27
|
+
Project-URL: Issues, https://github.com/marchildon/gpflash/issues
|
|
28
|
+
Project-URL: Paper, https://arxiv.org/abs/2610.16861
|
|
29
|
+
Requires-Python: >=3.11
|
|
30
|
+
Requires-Dist: numpy>=1.23
|
|
31
|
+
Provides-Extra: test
|
|
32
|
+
Requires-Dist: pytest>=7; extra == "test"
|
|
33
|
+
Description-Content-Type: text/markdown
|
|
34
|
+
|
|
35
|
+
# GpFlash for Python
|
|
36
|
+
|
|
37
|
+
Fast, exact Gaussian process regression: the marginal log likelihood (MLL) with analytic
|
|
38
|
+
hyperparameter gradients, hyperparameter fitting, and posterior mean and variance. Python bindings
|
|
39
|
+
to the header-only C++ library [GpFlash](https://github.com/marchildon/gpflash).
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
pip install gpflash
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Wheels for Linux, macOS and Windows need nothing else installed: BLAS/LAPACK, HDF5, NLopt and the
|
|
46
|
+
OpenMP runtime are included.
|
|
47
|
+
|
|
48
|
+
## Quick start
|
|
49
|
+
|
|
50
|
+
```python
|
|
51
|
+
import numpy as np
|
|
52
|
+
import gpflash
|
|
53
|
+
|
|
54
|
+
n_dim = 2
|
|
55
|
+
n_train = 50
|
|
56
|
+
n_post = 100
|
|
57
|
+
|
|
58
|
+
# Training data: n_train points, one per row, and the function's values there.
|
|
59
|
+
rng = np.random.default_rng(0)
|
|
60
|
+
X_train_mat = rng.random((n_train, n_dim))
|
|
61
|
+
f_train_vec = np.sin(3 * X_train_mat[:, 0]) + X_train_mat[:, 1] ** 2
|
|
62
|
+
|
|
63
|
+
gp = gpflash.GaussianProcess().fit(X_train_mat, f_train_vec) # the Matern 5/2 kernel and a constant mean
|
|
64
|
+
|
|
65
|
+
# The posterior mean and variance at n_post new points.
|
|
66
|
+
X_post_mat = rng.random((n_post, n_dim))
|
|
67
|
+
posterior_prediction = gp.predict(X_post_mat)
|
|
68
|
+
mean_post_vec = posterior_prediction.mean_post_vec # (n_post)
|
|
69
|
+
var_post_vec = posterior_prediction.var_post_vec # (n_post)
|
|
70
|
+
|
|
71
|
+
print(gp.to_summary_string()) # MLL, optimality, evaluations, bounds hit
|
|
72
|
+
print(gp.hp_val_struct()) # hp_sig2_k, hp_sig2_f_val, hp_gamma_vec, hp_kern_extra_vec
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## `GaussianProcess`
|
|
76
|
+
|
|
77
|
+
The options are C++'s `OptzOptions`, passed to the constructor; the data, with its noise
|
|
78
|
+
variance, go to `fit`. `GaussianProcess()` uses the defaults: the Matern 5/2 kernel, a constant
|
|
79
|
+
mean and one optimization. Any other choice is a field of `OptzOptions`, under its C++ name:
|
|
80
|
+
|
|
81
|
+
```python
|
|
82
|
+
optz_opts = gpflash.OptzOptions()
|
|
83
|
+
optz_opts.model_options.kernel_id = gpflash.KernelId.RatQuad # or gpflash.parse_kernel_id("rat_quad")
|
|
84
|
+
optz_opts.model_options.mean_model_degree_vec = [1] # a linear mean model
|
|
85
|
+
optz_opts.use_multistart = True # 5 optimizations, the best kept
|
|
86
|
+
optz_opts.n_ind_optz = 5
|
|
87
|
+
|
|
88
|
+
gp = gpflash.GaussianProcess(optz_opts).fit(X_train_mat, f_train_vec, sig2_f_val=-1.0) # estimate the noise
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
The [kernel table](https://github.com/marchildon/gpflash#kernels) lists the kernels.
|
|
92
|
+
[`OptzOptions.hpp`](https://github.com/marchildon/gpflash/blob/main/include/gpflash/optimization/search_space/OptzOptions.hpp)
|
|
93
|
+
and [`ModelOptions.hpp`](https://github.com/marchildon/gpflash/blob/main/include/gpflash/inputs/ModelOptions.hpp)
|
|
94
|
+
list every other option with its default: bounds, tolerances, the algorithm, the conditioning
|
|
95
|
+
limit, symmetry. The constructor copies the options, so they are set once;
|
|
96
|
+
`gp.optz_opts()` returns a copy. Array fields are copied in and out too, so assign a whole array:
|
|
97
|
+
`optz_opts.hp_gamma_ub_vec = [100.0]` works; `optz_opts.hp_gamma_ub_vec[0] = 100.0` changes only
|
|
98
|
+
a copy. Every points argument is `(n_points, n_dim)`, one point per row,
|
|
99
|
+
and must be 2-D: a 1-D problem's points are `(n_points, 1)`, a single point is `(1, n_dim)`.
|
|
100
|
+
|
|
101
|
+
| Method | Returns |
|
|
102
|
+
|---|---|
|
|
103
|
+
| `fit(X_train_mat, f_train_vec, sig2_f_val=0.0)` | `self`. `sig2_f_val` is the noise variance on the values: `0.0` for noise-free data, a known variance > 0, or a negative value to estimate it |
|
|
104
|
+
| `predict(X_post_mat, return_mean=True, return_var=True, return_mean_gradient=False, return_var_gradient=False)` | A `PosteriorPrediction` with `mean_post_vec`, `var_post_vec`, `d_mean_post_d_x_post_mat` and `d_var_post_d_x_post_mat`; the gradients are `(n_post, n_dim)`, and a field not asked for is `None`. The variance costs `O(n_train^2)` per point against `O(n_train)` for the mean |
|
|
105
|
+
| `eval_mll(X_train_mat, f_train_vec, hp_val_struct, return_mll_gradient=False, sig2_f_val=0.0)` | The MLL at given hyperparameters, an `MllResult` |
|
|
106
|
+
| `make_posterior(X_train_mat, f_train_vec, hp_val_struct, sig2_f_val=0.0)` | `self`, with a posterior at given hyperparameters, without fitting |
|
|
107
|
+
| `hp_val_struct()`, `hp_beta_vec()`, `mll()`, `kernel_id()`, `optz_opts()` | The hyperparameters, the mean model weights, the MLL, the kernel and the options |
|
|
108
|
+
| `posterior()`, `mll_optz_result()` | The `GpPosterior` that `predict` evaluates, and the fit's `MllOptzResult`, for the C++ interface below |
|
|
109
|
+
| `to_summary_string()` | A short report of the fit |
|
|
110
|
+
| `save_precompute(path)` / `GaussianProcess.load_posterior(path)` | An HDF5 file the C++ library also reads; a loaded model predicts but holds no fit |
|
|
111
|
+
| `load_posterior_verified(path, X_train_mat, f_train_vec, hp_val_struct, sig2_f_val=0.0)` | `self`, loaded from a file only if these data and hyperparameters produced it |
|
|
112
|
+
|
|
113
|
+
Invalid inputs raise `gpflash.InvalidInputError`, a
|
|
114
|
+
`ValueError`, from either layer.
|
|
115
|
+
|
|
116
|
+
A noise-free fit adds a small nugget, sized from `ModelOptions.cond_max`, so the factorization is
|
|
117
|
+
always well conditioned; predictions at the training points then match the data closely rather
|
|
118
|
+
than exactly.
|
|
119
|
+
|
|
120
|
+
## The C++ interface
|
|
121
|
+
|
|
122
|
+
Everything in the C++ library is also available under its C++ names: `TrainingData`, `HpVal`,
|
|
123
|
+
`ModelOptions`, `OptzOptions`, `eval_mll`, `select_hp_with_max_mll`, `make_posterior`,
|
|
124
|
+
`GpPosterior`, `load_posterior` and the rest, so the
|
|
125
|
+
[C++ README](https://github.com/marchildon/gpflash#readme) documents this layer too. It keeps the
|
|
126
|
+
C++ shapes: points are columns, so `TrainingData.X_ndim_ntrain_mat` is `(n_dim, n_train)`.
|
|
127
|
+
|
|
128
|
+
```python
|
|
129
|
+
# The quick start's training data, transposed to the C++ layout.
|
|
130
|
+
train_data = gpflash.TrainingData()
|
|
131
|
+
train_data.X_ndim_ntrain_mat = X_train_mat.T # (n_dim, n_train)
|
|
132
|
+
train_data.f_train_vec = f_train_vec
|
|
133
|
+
|
|
134
|
+
hp_val_struct = gpflash.HpVal()
|
|
135
|
+
hp_val_struct.hp_gamma_vec = [1.0, 1.0] # inverse length scales
|
|
136
|
+
mll_result = gpflash.eval_mll(train_data, hp_val_struct, gpflash.ModelOptions(), return_mll_gradient=True)
|
|
137
|
+
print(mll_result.mll, mll_result.mll_hp_grad_struct.d_mll_d_hp_gamma_vec)
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
Numerical failures raise `gpflash.NumericalFailureError`, an `ArithmeticError`. The enums
|
|
141
|
+
(`KernelId`, `OptzStopReason`, ...) are Python `enum.Enum` subclasses.
|
|
142
|
+
|
|
143
|
+
### Inspecting a fit and a saved file
|
|
144
|
+
|
|
145
|
+
```python
|
|
146
|
+
mll_optz_result = gp.mll_optz_result()
|
|
147
|
+
mll_optz_result.build_best_local_optz_result().stop_reason # why the winning solve stopped
|
|
148
|
+
mll_optz_result.calc_hp_at_bound_struct().to_summary_string() # which hyperparameters a bound holds
|
|
149
|
+
gpflash.print_multistart_report(mll_optz_result) # every optimization, where each started and landed
|
|
150
|
+
|
|
151
|
+
gp.save_precompute("model.h5") # the posterior, as an HDF5 file
|
|
152
|
+
cache_info = gpflash.peek_info("model.h5") # the file's header, without loading it
|
|
153
|
+
gpflash.print_cache_info(cache_info) # kernel, MLL, size, note, writing version
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
`save_multistart_report` writes the report to a file. `GpPosterior.post_model_info()` is the
|
|
157
|
+
record of the fit a posterior came from, and `calc_default_cache_path` names a file after the
|
|
158
|
+
kernel and the training set's shape. Because `None` is a Python keyword, `SymmetryKind`'s
|
|
159
|
+
no-symmetry value is `SymmetryKind.None_`.
|
|
160
|
+
|
|
161
|
+
The one C++ feature the Python package leaves out is MPI: a fit runs in one process, using its
|
|
162
|
+
cores through OpenMP.
|
|
163
|
+
|
|
164
|
+
## Threads
|
|
165
|
+
|
|
166
|
+
Fits and queries run in parallel with OpenMP and release the GIL, so other Python threads run
|
|
167
|
+
meanwhile. `OMP_NUM_THREADS` sets the thread count. Loading two different OpenMP runtimes into
|
|
168
|
+
one process, for example GpFlash's alongside another library's, can slow both down; if that
|
|
169
|
+
happens, set `OMP_NUM_THREADS` or import one library at a time.
|
|
170
|
+
|
|
171
|
+
## Building from source
|
|
172
|
+
|
|
173
|
+
`pip install .` from a clone of the repository builds the module with CMake. It needs a C++14
|
|
174
|
+
compiler and the C++ library's dependencies; the
|
|
175
|
+
[C++ README](https://github.com/marchildon/gpflash#building) lists them per platform. On macOS,
|
|
176
|
+
point CMake at Homebrew's OpenMP:
|
|
177
|
+
|
|
178
|
+
```
|
|
179
|
+
CMAKE_ARGS="-DOpenMP_ROOT=$(brew --prefix libomp)" pip install ".[test]"
|
|
180
|
+
pytest python/tests
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
`ruff check .` and `ruff format .`, with the version `.github/workflows/ci.yml` pins, keep the Python
|
|
184
|
+
files and the READMEs' Python blocks in the style CI checks. After changing `python/src/bindings.cpp`, regenerate the type stubs with
|
|
185
|
+
`pybind11-stubgen gpflash._core -o python` (it writes `python/gpflash/_core.pyi`), then change the
|
|
186
|
+
`__version__` line it writes to `__version__: str`, so the stub carries no copy of the version.
|
|
187
|
+
|
|
188
|
+
## Citing
|
|
189
|
+
|
|
190
|
+
If you use GpFlash, please cite the paper,
|
|
191
|
+
[arXiv:2610.16861](https://arxiv.org/abs/2610.16861):
|
|
192
|
+
|
|
193
|
+
```bibtex
|
|
194
|
+
@misc{marchildon2026gpflash,
|
|
195
|
+
title = {GpFlash: Maximizing Speed and Minimizing Memory for Gaussian Process Training and Prediction},
|
|
196
|
+
author = {Marchildon, Andr{\'e}},
|
|
197
|
+
year = {2026},
|
|
198
|
+
eprint = {2610.16861},
|
|
199
|
+
archivePrefix = {arXiv},
|
|
200
|
+
primaryClass = {cs.LG},
|
|
201
|
+
doi = {10.48550/arXiv.2610.16861}
|
|
202
|
+
}
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
## License
|
|
206
|
+
|
|
207
|
+
Apache License 2.0. The wheels also contain compiled third-party libraries under their own
|
|
208
|
+
licenses; `LICENSES_bundled.txt`, installed with the package metadata, reproduces them.
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# GpFlash
|
|
2
2
|
|
|
3
|
+
[](https://pypi.org/project/gpflash/)
|
|
4
|
+
[](https://github.com/marchildon/gpflash/actions/workflows/ci.yml)
|
|
5
|
+
[](https://github.com/marchildon/gpflash/actions/workflows/wheels.yml)
|
|
6
|
+
[](https://arxiv.org/abs/2610.16861)
|
|
7
|
+
|
|
3
8
|
Header-only C++ Gaussian process library: marginal log-likelihood (MLL) with analytic
|
|
4
9
|
hyperparameter gradients, posterior mean and variance, and hyperparameter fitting. Dense and
|
|
5
10
|
exact — see [Assumptions and limitations](#assumptions-and-limitations).
|
|
@@ -11,6 +16,32 @@ Gaussian Process Training and Prediction"**, A. Marchildon
|
|
|
11
16
|
gradient expression, which this README does not restate. If you use GpFlash, please cite
|
|
12
17
|
it; GitHub's "Cite this repository" button, from `CITATION.cff`, gives the reference.
|
|
13
18
|
|
|
19
|
+
From Python, `pip install gpflash` installs it with every dependency included:
|
|
20
|
+
|
|
21
|
+
```python
|
|
22
|
+
import numpy as np
|
|
23
|
+
import gpflash
|
|
24
|
+
|
|
25
|
+
n_dim = 2
|
|
26
|
+
n_train = 50
|
|
27
|
+
n_post = 100
|
|
28
|
+
|
|
29
|
+
# Training data: n_train points, one per row, and the function's values there.
|
|
30
|
+
rng = np.random.default_rng(0)
|
|
31
|
+
X_train_mat = rng.random((n_train, n_dim))
|
|
32
|
+
f_train_vec = np.sin(3 * X_train_mat[:, 0]) + X_train_mat[:, 1] ** 2
|
|
33
|
+
|
|
34
|
+
gp = gpflash.GaussianProcess().fit(X_train_mat, f_train_vec) # the Matern 5/2 kernel and a constant mean
|
|
35
|
+
|
|
36
|
+
# The posterior mean and variance at n_post new points.
|
|
37
|
+
X_post_mat = rng.random((n_post, n_dim))
|
|
38
|
+
posterior_prediction = gp.predict(X_post_mat)
|
|
39
|
+
mean_post_vec = posterior_prediction.mean_post_vec # (n_post)
|
|
40
|
+
var_post_vec = posterior_prediction.var_post_vec # (n_post)
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
[`python/README.md`](python/README.md) covers the Python package; the rest of this README covers the C++ library.
|
|
44
|
+
|
|
14
45
|
## Requirements
|
|
15
46
|
|
|
16
47
|
C++14, Armadillo 9.870 or later, a BLAS/LAPACK with the standard 32-bit integer interface (Accelerate on macOS and
|
|
@@ -21,20 +52,21 @@ OpenBLAS elsewhere by default; not an ILP64 build such as openblas64), OpenMP, H
|
|
|
21
52
|
|
|
22
53
|
## Kernels
|
|
23
54
|
|
|
24
|
-
`ModelOptions::kernel_id` selects one
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
| `
|
|
33
|
-
| `
|
|
34
|
-
| `
|
|
35
|
-
| `
|
|
36
|
-
| `
|
|
37
|
-
| `
|
|
55
|
+
`ModelOptions::kernel_id` selects one; `parse_kernel_id` turns a name into a `KernelId`, in C++ and
|
|
56
|
+
Python. Every kernel fits `hp_gamma`, one per dimension: an inverse length scale, or
|
|
57
|
+
for `Periodic` an inverse period. `hp_kern_extra` holds whatever else it declares.
|
|
58
|
+
`ModelOptions::symmetry_spec` gives a kernel that supports it an even or odd mirror symmetry about
|
|
59
|
+
an axis-aligned plane.
|
|
60
|
+
|
|
61
|
+
| `KernelId` | name | kernel | type | `hp_kern_extra` | symmetry |
|
|
62
|
+
|---|---|---|---|---|---|
|
|
63
|
+
| `SqExp` | `sq_exp` | squared exponential | radial | none | yes |
|
|
64
|
+
| `Matern52` | `matern_5_2` | Matérn 5/2, the default | radial | none | yes |
|
|
65
|
+
| `Matern32` | `matern_3_2` | Matérn 3/2 | radial | none | yes |
|
|
66
|
+
| `RatQuad` | `rat_quad` | rational quadratic | radial | the shape `hp_rho` | yes |
|
|
67
|
+
| `Periodic` | `periodic` | periodic | stationary | one amplitude per dimension | yes |
|
|
68
|
+
| `Linear` | `linear` | inhomogeneous linear | inner product | none | no |
|
|
69
|
+
| `Quadratic` | `quadratic` | inhomogeneous quadratic | inner product | none | no |
|
|
38
70
|
|
|
39
71
|
Radial kernels are functions of the scaled distance alone. An inner-product kernel's diagonal
|
|
40
72
|
varies with the point. Adding a kernel means one header under `kernels/`, one entry in
|
|
@@ -317,12 +349,6 @@ Do not use `-ffast-math` or `-Ofast`: they fold `std::isfinite` to true, which d
|
|
|
317
349
|
|
|
318
350
|
Link BLAS, LAPACK and HDF5's C library, and NLopt when `optimization/` is included.
|
|
319
351
|
|
|
320
|
-
## Python
|
|
321
|
-
|
|
322
|
-
`pip install gpflash` installs Python bindings with every dependency included. They offer a NumPy-style
|
|
323
|
-
`GaussianProcess` (`fit`, `predict`, `save`, `load`) and the C++ interface above under its C++ names and shapes.
|
|
324
|
-
[`python/README.md`](python/README.md) covers both, and building them from source.
|
|
325
|
-
|
|
326
352
|
## License
|
|
327
353
|
|
|
328
354
|
Copyright 2026 André Marchildon, under the Apache License 2.0; see `LICENSE` and `NOTICE`. `THIRD-PARTY-NOTICES`
|
|
@@ -63,6 +63,20 @@ result = "{major}.{minor}.{patch}"
|
|
|
63
63
|
[tool.pytest.ini_options]
|
|
64
64
|
testpaths = ["python/tests"]
|
|
65
65
|
|
|
66
|
+
# ── Formatting and linting (ruff, pinned in .github/workflows/ci.yml) ────────
|
|
67
|
+
# The same 120-column limit as .clang-format. Python code blocks in the READMEs are formatted too, which keeps the quick
|
|
68
|
+
# start identical in README.md and python/README.md. _core.pyi is generated by pybind11-stubgen, so it is left as written.
|
|
69
|
+
[tool.ruff]
|
|
70
|
+
line-length = 120
|
|
71
|
+
target-version = "py311"
|
|
72
|
+
extend-exclude = ["python/gpflash/_core.pyi"]
|
|
73
|
+
|
|
74
|
+
[tool.ruff.lint]
|
|
75
|
+
select = ["E", "F", "W", "I", "B", "UP", "RUF"]
|
|
76
|
+
|
|
77
|
+
[tool.ruff.lint.isort]
|
|
78
|
+
known-first-party = ["gpflash"]
|
|
79
|
+
|
|
66
80
|
# ── Wheels (cibuildwheel, run by .github/workflows/wheels.yml) ───────────────
|
|
67
81
|
[tool.cibuildwheel]
|
|
68
82
|
# CPython 3.11 to 3.14, each runner's own 64-bit architecture, glibc Linux only.
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
# the wheel, so the headers and CMake package files the root installs stay out of it.
|
|
4
4
|
|
|
5
5
|
find_package(Python 3.11 REQUIRED COMPONENTS Interpreter Development.Module)
|
|
6
|
-
find_package(pybind11 CONFIG REQUIRED)
|
|
6
|
+
find_package(pybind11 3.0 CONFIG REQUIRED) # 3.0 for py::native_enum; pyproject.toml requires the same
|
|
7
7
|
|
|
8
8
|
pybind11_add_module(gpflash_python MODULE src/bindings.cpp)
|
|
9
9
|
set_target_properties(gpflash_python PROPERTIES OUTPUT_NAME _core)
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
# GpFlash for Python
|
|
2
|
+
|
|
3
|
+
Fast, exact Gaussian process regression: the marginal log likelihood (MLL) with analytic
|
|
4
|
+
hyperparameter gradients, hyperparameter fitting, and posterior mean and variance. Python bindings
|
|
5
|
+
to the header-only C++ library [GpFlash](https://github.com/marchildon/gpflash).
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
pip install gpflash
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Wheels for Linux, macOS and Windows need nothing else installed: BLAS/LAPACK, HDF5, NLopt and the
|
|
12
|
+
OpenMP runtime are included.
|
|
13
|
+
|
|
14
|
+
## Quick start
|
|
15
|
+
|
|
16
|
+
```python
|
|
17
|
+
import numpy as np
|
|
18
|
+
import gpflash
|
|
19
|
+
|
|
20
|
+
n_dim = 2
|
|
21
|
+
n_train = 50
|
|
22
|
+
n_post = 100
|
|
23
|
+
|
|
24
|
+
# Training data: n_train points, one per row, and the function's values there.
|
|
25
|
+
rng = np.random.default_rng(0)
|
|
26
|
+
X_train_mat = rng.random((n_train, n_dim))
|
|
27
|
+
f_train_vec = np.sin(3 * X_train_mat[:, 0]) + X_train_mat[:, 1] ** 2
|
|
28
|
+
|
|
29
|
+
gp = gpflash.GaussianProcess().fit(X_train_mat, f_train_vec) # the Matern 5/2 kernel and a constant mean
|
|
30
|
+
|
|
31
|
+
# The posterior mean and variance at n_post new points.
|
|
32
|
+
X_post_mat = rng.random((n_post, n_dim))
|
|
33
|
+
posterior_prediction = gp.predict(X_post_mat)
|
|
34
|
+
mean_post_vec = posterior_prediction.mean_post_vec # (n_post)
|
|
35
|
+
var_post_vec = posterior_prediction.var_post_vec # (n_post)
|
|
36
|
+
|
|
37
|
+
print(gp.to_summary_string()) # MLL, optimality, evaluations, bounds hit
|
|
38
|
+
print(gp.hp_val_struct()) # hp_sig2_k, hp_sig2_f_val, hp_gamma_vec, hp_kern_extra_vec
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## `GaussianProcess`
|
|
42
|
+
|
|
43
|
+
The options are C++'s `OptzOptions`, passed to the constructor; the data, with its noise
|
|
44
|
+
variance, go to `fit`. `GaussianProcess()` uses the defaults: the Matern 5/2 kernel, a constant
|
|
45
|
+
mean and one optimization. Any other choice is a field of `OptzOptions`, under its C++ name:
|
|
46
|
+
|
|
47
|
+
```python
|
|
48
|
+
optz_opts = gpflash.OptzOptions()
|
|
49
|
+
optz_opts.model_options.kernel_id = gpflash.KernelId.RatQuad # or gpflash.parse_kernel_id("rat_quad")
|
|
50
|
+
optz_opts.model_options.mean_model_degree_vec = [1] # a linear mean model
|
|
51
|
+
optz_opts.use_multistart = True # 5 optimizations, the best kept
|
|
52
|
+
optz_opts.n_ind_optz = 5
|
|
53
|
+
|
|
54
|
+
gp = gpflash.GaussianProcess(optz_opts).fit(X_train_mat, f_train_vec, sig2_f_val=-1.0) # estimate the noise
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
The [kernel table](https://github.com/marchildon/gpflash#kernels) lists the kernels.
|
|
58
|
+
[`OptzOptions.hpp`](https://github.com/marchildon/gpflash/blob/main/include/gpflash/optimization/search_space/OptzOptions.hpp)
|
|
59
|
+
and [`ModelOptions.hpp`](https://github.com/marchildon/gpflash/blob/main/include/gpflash/inputs/ModelOptions.hpp)
|
|
60
|
+
list every other option with its default: bounds, tolerances, the algorithm, the conditioning
|
|
61
|
+
limit, symmetry. The constructor copies the options, so they are set once;
|
|
62
|
+
`gp.optz_opts()` returns a copy. Array fields are copied in and out too, so assign a whole array:
|
|
63
|
+
`optz_opts.hp_gamma_ub_vec = [100.0]` works; `optz_opts.hp_gamma_ub_vec[0] = 100.0` changes only
|
|
64
|
+
a copy. Every points argument is `(n_points, n_dim)`, one point per row,
|
|
65
|
+
and must be 2-D: a 1-D problem's points are `(n_points, 1)`, a single point is `(1, n_dim)`.
|
|
66
|
+
|
|
67
|
+
| Method | Returns |
|
|
68
|
+
|---|---|
|
|
69
|
+
| `fit(X_train_mat, f_train_vec, sig2_f_val=0.0)` | `self`. `sig2_f_val` is the noise variance on the values: `0.0` for noise-free data, a known variance > 0, or a negative value to estimate it |
|
|
70
|
+
| `predict(X_post_mat, return_mean=True, return_var=True, return_mean_gradient=False, return_var_gradient=False)` | A `PosteriorPrediction` with `mean_post_vec`, `var_post_vec`, `d_mean_post_d_x_post_mat` and `d_var_post_d_x_post_mat`; the gradients are `(n_post, n_dim)`, and a field not asked for is `None`. The variance costs `O(n_train^2)` per point against `O(n_train)` for the mean |
|
|
71
|
+
| `eval_mll(X_train_mat, f_train_vec, hp_val_struct, return_mll_gradient=False, sig2_f_val=0.0)` | The MLL at given hyperparameters, an `MllResult` |
|
|
72
|
+
| `make_posterior(X_train_mat, f_train_vec, hp_val_struct, sig2_f_val=0.0)` | `self`, with a posterior at given hyperparameters, without fitting |
|
|
73
|
+
| `hp_val_struct()`, `hp_beta_vec()`, `mll()`, `kernel_id()`, `optz_opts()` | The hyperparameters, the mean model weights, the MLL, the kernel and the options |
|
|
74
|
+
| `posterior()`, `mll_optz_result()` | The `GpPosterior` that `predict` evaluates, and the fit's `MllOptzResult`, for the C++ interface below |
|
|
75
|
+
| `to_summary_string()` | A short report of the fit |
|
|
76
|
+
| `save_precompute(path)` / `GaussianProcess.load_posterior(path)` | An HDF5 file the C++ library also reads; a loaded model predicts but holds no fit |
|
|
77
|
+
| `load_posterior_verified(path, X_train_mat, f_train_vec, hp_val_struct, sig2_f_val=0.0)` | `self`, loaded from a file only if these data and hyperparameters produced it |
|
|
78
|
+
|
|
79
|
+
Invalid inputs raise `gpflash.InvalidInputError`, a
|
|
80
|
+
`ValueError`, from either layer.
|
|
81
|
+
|
|
82
|
+
A noise-free fit adds a small nugget, sized from `ModelOptions.cond_max`, so the factorization is
|
|
83
|
+
always well conditioned; predictions at the training points then match the data closely rather
|
|
84
|
+
than exactly.
|
|
85
|
+
|
|
86
|
+
## The C++ interface
|
|
87
|
+
|
|
88
|
+
Everything in the C++ library is also available under its C++ names: `TrainingData`, `HpVal`,
|
|
89
|
+
`ModelOptions`, `OptzOptions`, `eval_mll`, `select_hp_with_max_mll`, `make_posterior`,
|
|
90
|
+
`GpPosterior`, `load_posterior` and the rest, so the
|
|
91
|
+
[C++ README](https://github.com/marchildon/gpflash#readme) documents this layer too. It keeps the
|
|
92
|
+
C++ shapes: points are columns, so `TrainingData.X_ndim_ntrain_mat` is `(n_dim, n_train)`.
|
|
93
|
+
|
|
94
|
+
```python
|
|
95
|
+
# The quick start's training data, transposed to the C++ layout.
|
|
96
|
+
train_data = gpflash.TrainingData()
|
|
97
|
+
train_data.X_ndim_ntrain_mat = X_train_mat.T # (n_dim, n_train)
|
|
98
|
+
train_data.f_train_vec = f_train_vec
|
|
99
|
+
|
|
100
|
+
hp_val_struct = gpflash.HpVal()
|
|
101
|
+
hp_val_struct.hp_gamma_vec = [1.0, 1.0] # inverse length scales
|
|
102
|
+
mll_result = gpflash.eval_mll(train_data, hp_val_struct, gpflash.ModelOptions(), return_mll_gradient=True)
|
|
103
|
+
print(mll_result.mll, mll_result.mll_hp_grad_struct.d_mll_d_hp_gamma_vec)
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Numerical failures raise `gpflash.NumericalFailureError`, an `ArithmeticError`. The enums
|
|
107
|
+
(`KernelId`, `OptzStopReason`, ...) are Python `enum.Enum` subclasses.
|
|
108
|
+
|
|
109
|
+
### Inspecting a fit and a saved file
|
|
110
|
+
|
|
111
|
+
```python
|
|
112
|
+
mll_optz_result = gp.mll_optz_result()
|
|
113
|
+
mll_optz_result.build_best_local_optz_result().stop_reason # why the winning solve stopped
|
|
114
|
+
mll_optz_result.calc_hp_at_bound_struct().to_summary_string() # which hyperparameters a bound holds
|
|
115
|
+
gpflash.print_multistart_report(mll_optz_result) # every optimization, where each started and landed
|
|
116
|
+
|
|
117
|
+
gp.save_precompute("model.h5") # the posterior, as an HDF5 file
|
|
118
|
+
cache_info = gpflash.peek_info("model.h5") # the file's header, without loading it
|
|
119
|
+
gpflash.print_cache_info(cache_info) # kernel, MLL, size, note, writing version
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
`save_multistart_report` writes the report to a file. `GpPosterior.post_model_info()` is the
|
|
123
|
+
record of the fit a posterior came from, and `calc_default_cache_path` names a file after the
|
|
124
|
+
kernel and the training set's shape. Because `None` is a Python keyword, `SymmetryKind`'s
|
|
125
|
+
no-symmetry value is `SymmetryKind.None_`.
|
|
126
|
+
|
|
127
|
+
The one C++ feature the Python package leaves out is MPI: a fit runs in one process, using its
|
|
128
|
+
cores through OpenMP.
|
|
129
|
+
|
|
130
|
+
## Threads
|
|
131
|
+
|
|
132
|
+
Fits and queries run in parallel with OpenMP and release the GIL, so other Python threads run
|
|
133
|
+
meanwhile. `OMP_NUM_THREADS` sets the thread count. Loading two different OpenMP runtimes into
|
|
134
|
+
one process, for example GpFlash's alongside another library's, can slow both down; if that
|
|
135
|
+
happens, set `OMP_NUM_THREADS` or import one library at a time.
|
|
136
|
+
|
|
137
|
+
## Building from source
|
|
138
|
+
|
|
139
|
+
`pip install .` from a clone of the repository builds the module with CMake. It needs a C++14
|
|
140
|
+
compiler and the C++ library's dependencies; the
|
|
141
|
+
[C++ README](https://github.com/marchildon/gpflash#building) lists them per platform. On macOS,
|
|
142
|
+
point CMake at Homebrew's OpenMP:
|
|
143
|
+
|
|
144
|
+
```
|
|
145
|
+
CMAKE_ARGS="-DOpenMP_ROOT=$(brew --prefix libomp)" pip install ".[test]"
|
|
146
|
+
pytest python/tests
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
`ruff check .` and `ruff format .`, with the version `.github/workflows/ci.yml` pins, keep the Python
|
|
150
|
+
files and the READMEs' Python blocks in the style CI checks. After changing `python/src/bindings.cpp`, regenerate the type stubs with
|
|
151
|
+
`pybind11-stubgen gpflash._core -o python` (it writes `python/gpflash/_core.pyi`), then change the
|
|
152
|
+
`__version__` line it writes to `__version__: str`, so the stub carries no copy of the version.
|
|
153
|
+
|
|
154
|
+
## Citing
|
|
155
|
+
|
|
156
|
+
If you use GpFlash, please cite the paper,
|
|
157
|
+
[arXiv:2610.16861](https://arxiv.org/abs/2610.16861):
|
|
158
|
+
|
|
159
|
+
```bibtex
|
|
160
|
+
@misc{marchildon2026gpflash,
|
|
161
|
+
title = {GpFlash: Maximizing Speed and Minimizing Memory for Gaussian Process Training and Prediction},
|
|
162
|
+
author = {Marchildon, Andr{\'e}},
|
|
163
|
+
year = {2026},
|
|
164
|
+
eprint = {2610.16861},
|
|
165
|
+
archivePrefix = {arXiv},
|
|
166
|
+
primaryClass = {cs.LG},
|
|
167
|
+
doi = {10.48550/arXiv.2610.16861}
|
|
168
|
+
}
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
## License
|
|
172
|
+
|
|
173
|
+
Apache License 2.0. The wheels also contain compiled third-party libraries under their own
|
|
174
|
+
licenses; `LICENSES_bundled.txt`, installed with the package metadata, reproduces them.
|