gpflash 0.2.0__tar.gz → 0.3.1__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.
Files changed (159) hide show
  1. {gpflash-0.2.0 → gpflash-0.3.1}/.github/workflows/ci.yml +11 -2
  2. gpflash-0.3.1/.github/workflows/weekly.yml +25 -0
  3. {gpflash-0.2.0 → gpflash-0.3.1}/.github/workflows/wheels.yml +4 -3
  4. {gpflash-0.2.0 → gpflash-0.3.1}/.gitignore +1 -0
  5. gpflash-0.3.1/CHANGELOG.md +80 -0
  6. gpflash-0.3.1/PKG-INFO +212 -0
  7. {gpflash-0.2.0 → gpflash-0.3.1}/README.md +50 -23
  8. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/Version.hpp +2 -2
  9. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/core/Platform.hpp +2 -1
  10. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/posterior_cache/Hdf5Store.hpp +12 -2
  11. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/posterior_cache/PosteriorCache.hpp +12 -2
  12. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/posterior_cache/README.md +3 -1
  13. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/posterior_eval/PosteriorOptions.hpp +4 -4
  14. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/posterior_eval/PosteriorQuery.hpp +9 -6
  15. {gpflash-0.2.0 → gpflash-0.3.1}/pyproject.toml +15 -1
  16. gpflash-0.3.1/python/CMakeLists.txt +44 -0
  17. gpflash-0.3.1/python/README.md +178 -0
  18. {gpflash-0.2.0 → gpflash-0.3.1}/python/ci/install_deps_unix.sh +2 -1
  19. {gpflash-0.2.0 → gpflash-0.3.1}/python/gpflash/__init__.py +7 -1
  20. {gpflash-0.2.0 → gpflash-0.3.1}/python/gpflash/_core.pyi +24 -221
  21. gpflash-0.3.1/python/gpflash/_gp.py +300 -0
  22. {gpflash-0.2.0 → gpflash-0.3.1}/python/src/bindings.cpp +40 -11
  23. {gpflash-0.2.0 → gpflash-0.3.1}/python/tests/test_core.py +37 -11
  24. gpflash-0.3.1/python/tests/test_diagnostics.py +123 -0
  25. gpflash-0.3.1/python/tests/test_gaussian_process.py +377 -0
  26. gpflash-0.3.1/python/tests/test_numerics.py +159 -0
  27. gpflash-0.3.1/python/tests/test_openmp_isolation.py +66 -0
  28. {gpflash-0.2.0 → gpflash-0.3.1}/tst/test_gpflash_cache.cpp +99 -8
  29. {gpflash-0.2.0 → gpflash-0.3.1}/tst/test_gpflash_input_validation.cpp +20 -5
  30. gpflash-0.2.0/CHANGELOG.md +0 -35
  31. gpflash-0.2.0/PKG-INFO +0 -179
  32. gpflash-0.2.0/python/CMakeLists.txt +0 -19
  33. gpflash-0.2.0/python/README.md +0 -145
  34. gpflash-0.2.0/python/gpflash/_gp.py +0 -218
  35. gpflash-0.2.0/python/tests/test_diagnostics.py +0 -118
  36. gpflash-0.2.0/python/tests/test_gaussian_process.py +0 -181
  37. gpflash-0.2.0/python/tests/test_numerics.py +0 -154
  38. {gpflash-0.2.0 → gpflash-0.3.1}/.clang-format +0 -0
  39. {gpflash-0.2.0 → gpflash-0.3.1}/CITATION.cff +0 -0
  40. {gpflash-0.2.0 → gpflash-0.3.1}/CMakeLists.txt +0 -0
  41. {gpflash-0.2.0 → gpflash-0.3.1}/LICENSE +0 -0
  42. {gpflash-0.2.0 → gpflash-0.3.1}/NOTICE +0 -0
  43. {gpflash-0.2.0 → gpflash-0.3.1}/THIRD-PARTY-NOTICES +0 -0
  44. {gpflash-0.2.0 → gpflash-0.3.1}/cmake/GpFlashConfig.cmake.in +0 -0
  45. {gpflash-0.2.0 → gpflash-0.3.1}/cmake/GpFlashDependencies.cmake +0 -0
  46. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/assembly/CholTerms.hpp +0 -0
  47. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/assembly/EtaTermHpGrad.hpp +0 -0
  48. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/assembly/KernTermHpGrad.hpp +0 -0
  49. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/assembly/KernelAssembly.hpp +0 -0
  50. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/assembly/KernelMatrix.hpp +0 -0
  51. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/assembly/KernelMatrixGrad.hpp +0 -0
  52. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/assembly/KmatNuggetGrad.hpp +0 -0
  53. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/assembly/PosteriorCovariance.hpp +0 -0
  54. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/assembly/SigmaGrad.hpp +0 -0
  55. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/assembly/SigmaMatrix.hpp +0 -0
  56. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/assembly/SymmetryMatrix.hpp +0 -0
  57. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/core/Errors.hpp +0 -0
  58. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/core/NoiseModel.hpp +0 -0
  59. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/core/ParallelContext.hpp +0 -0
  60. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/core/StringFormat.hpp +0 -0
  61. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/inputs/EigMaxUbMethod.hpp +0 -0
  62. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/inputs/HpVal.hpp +0 -0
  63. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/inputs/KernelId.hpp +0 -0
  64. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/inputs/ModelOptions.hpp +0 -0
  65. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/inputs/SymmetrySpec.hpp +0 -0
  66. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/inputs/TrainingData.hpp +0 -0
  67. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/kernels/HpGradInputs.hpp +0 -0
  68. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/kernels/KernelBase.hpp +0 -0
  69. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/kernels/KernelDispatch.hpp +0 -0
  70. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/kernels/KernelStationary.hpp +0 -0
  71. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/kernels/OptzSeeding.hpp +0 -0
  72. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/kernels/inner_product/KernelInnerProduct.hpp +0 -0
  73. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/kernels/inner_product/Linear.hpp +0 -0
  74. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/kernels/inner_product/Quadratic.hpp +0 -0
  75. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/kernels/radial/KernelRadial.hpp +0 -0
  76. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/kernels/radial/Matern32.hpp +0 -0
  77. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/kernels/radial/Matern52.hpp +0 -0
  78. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/kernels/radial/RatQuad.hpp +0 -0
  79. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/kernels/radial/SqExp.hpp +0 -0
  80. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/kernels/stationary/Periodic.hpp +0 -0
  81. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/linear_algebra/BlasLapack.hpp +0 -0
  82. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/linear_algebra/Cholesky.hpp +0 -0
  83. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/linear_algebra/InnerProducts.hpp +0 -0
  84. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/linear_algebra/RecursiveInv.hpp +0 -0
  85. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/mean/MeanModel.hpp +0 -0
  86. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/mean/MeanModelWeights.hpp +0 -0
  87. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/optimization/HpOptimizer.hpp +0 -0
  88. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/optimization/MllOptzObjective.hpp +0 -0
  89. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/optimization/MllOptzResult.hpp +0 -0
  90. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/optimization/MultistartReport.hpp +0 -0
  91. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/optimization/README.md +0 -0
  92. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/optimization/local_optz/LocalOptzResult.hpp +0 -0
  93. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/optimization/local_optz/OptimizerNlopt.hpp +0 -0
  94. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/optimization/multistart/LatinHypercube.hpp +0 -0
  95. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/optimization/multistart/MultistartResult.hpp +0 -0
  96. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/optimization/multistart/OptimumClusters.hpp +0 -0
  97. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/optimization/multistart/RunMultistart.hpp +0 -0
  98. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/optimization/search_space/ActiveBounds.hpp +0 -0
  99. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/optimization/search_space/HpAtBound.hpp +0 -0
  100. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/optimization/search_space/HpOptzLayout.hpp +0 -0
  101. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/optimization/search_space/OptzOptions.hpp +0 -0
  102. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/optimization/search_space/OptzRegion.hpp +0 -0
  103. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/posterior_build/PosteriorBuild.hpp +0 -0
  104. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/posterior_cache/CacheInfo.hpp +0 -0
  105. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/posterior_cache/CacheInputHash.hpp +0 -0
  106. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/posterior_cache/CacheLayout.hpp +0 -0
  107. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/posterior_cache/PosteriorContents.hpp +0 -0
  108. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/posterior_cache/PosteriorModelInfo.hpp +0 -0
  109. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/posterior_cache/PosteriorPrecompute.hpp +0 -0
  110. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/posterior_eval/GpPosterior.hpp +0 -0
  111. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/posterior_eval/PosteriorEval.hpp +0 -0
  112. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/posterior_eval/PosteriorGrad.hpp +0 -0
  113. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/posterior_eval/PosteriorResult.hpp +0 -0
  114. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/preconditioning/ConditionedCholesky.hpp +0 -0
  115. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/preconditioning/EtaTerms.hpp +0 -0
  116. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/preconditioning/PreconScales.hpp +0 -0
  117. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/training/EvalMll.hpp +0 -0
  118. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/training/EvalMllDispatch.hpp +0 -0
  119. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/training/EvalMllGrad.hpp +0 -0
  120. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/training/EvalVariances.hpp +0 -0
  121. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/training/MllHpGrad.hpp +0 -0
  122. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/training/MllResult.hpp +0 -0
  123. {gpflash-0.2.0 → gpflash-0.3.1}/include/gpflash/training/StageTiming.hpp +0 -0
  124. {gpflash-0.2.0 → gpflash-0.3.1}/python/LICENSES_bundled.txt +0 -0
  125. {gpflash-0.2.0 → gpflash-0.3.1}/python/ci/install_deps_windows.ps1 +0 -0
  126. {gpflash-0.2.0 → gpflash-0.3.1}/python/gpflash/py.typed +0 -0
  127. {gpflash-0.2.0 → gpflash-0.3.1}/tst/CMakeLists.txt +0 -0
  128. {gpflash-0.2.0 → gpflash-0.3.1}/tst/GpFlashTestSupport.hpp +0 -0
  129. {gpflash-0.2.0 → gpflash-0.3.1}/tst/check_formatting.cmake +0 -0
  130. {gpflash-0.2.0 → gpflash-0.3.1}/tst/check_prediction_only_includes.cmake +0 -0
  131. {gpflash-0.2.0 → gpflash-0.3.1}/tst/test_gpflash_chol_solves.cpp +0 -0
  132. {gpflash-0.2.0 → gpflash-0.3.1}/tst/test_gpflash_inner_product_gradient.cpp +0 -0
  133. {gpflash-0.2.0 → gpflash-0.3.1}/tst/test_gpflash_kernel_assembly.cpp +0 -0
  134. {gpflash-0.2.0 → gpflash-0.3.1}/tst/test_gpflash_kernel_center.cpp +0 -0
  135. {gpflash-0.2.0 → gpflash-0.3.1}/tst/test_gpflash_kernel_contract.cpp +0 -0
  136. {gpflash-0.2.0 → gpflash-0.3.1}/tst/test_gpflash_kernel_finite_difference.cpp +0 -0
  137. {gpflash-0.2.0 → gpflash-0.3.1}/tst/test_gpflash_kernel_matrix_grad.cpp +0 -0
  138. {gpflash-0.2.0 → gpflash-0.3.1}/tst/test_gpflash_kernel_posterior_assembly.cpp +0 -0
  139. {gpflash-0.2.0 → gpflash-0.3.1}/tst/test_gpflash_kmat_nugget.cpp +0 -0
  140. {gpflash-0.2.0 → gpflash-0.3.1}/tst/test_gpflash_kmat_nugget_grad.cpp +0 -0
  141. {gpflash-0.2.0 → gpflash-0.3.1}/tst/test_gpflash_linear.cpp +0 -0
  142. {gpflash-0.2.0 → gpflash-0.3.1}/tst/test_gpflash_local_optz.cpp +0 -0
  143. {gpflash-0.2.0 → gpflash-0.3.1}/tst/test_gpflash_multistart.cpp +0 -0
  144. {gpflash-0.2.0 → gpflash-0.3.1}/tst/test_gpflash_multistart_report.cpp +0 -0
  145. {gpflash-0.2.0 → gpflash-0.3.1}/tst/test_gpflash_optimizer.cpp +0 -0
  146. {gpflash-0.2.0 → gpflash-0.3.1}/tst/test_gpflash_optimizer_mpi.cpp +0 -0
  147. {gpflash-0.2.0 → gpflash-0.3.1}/tst/test_gpflash_optimizer_periodic.cpp +0 -0
  148. {gpflash-0.2.0 → gpflash-0.3.1}/tst/test_gpflash_periodic.cpp +0 -0
  149. {gpflash-0.2.0 → gpflash-0.3.1}/tst/test_gpflash_posterior.cpp +0 -0
  150. {gpflash-0.2.0 → gpflash-0.3.1}/tst/test_gpflash_posterior_nonradial.cpp +0 -0
  151. {gpflash-0.2.0 → gpflash-0.3.1}/tst/test_gpflash_recursive_inv.cpp +0 -0
  152. {gpflash-0.2.0 → gpflash-0.3.1}/tst/test_gpflash_search_space.cpp +0 -0
  153. {gpflash-0.2.0 → gpflash-0.3.1}/tst/test_gpflash_sigma_matrix.cpp +0 -0
  154. {gpflash-0.2.0 → gpflash-0.3.1}/tst/test_gpflash_stage_timing.cpp +0 -0
  155. {gpflash-0.2.0 → gpflash-0.3.1}/tst/test_gpflash_string_format.cpp +0 -0
  156. {gpflash-0.2.0 → gpflash-0.3.1}/tst/test_gpflash_struct_checks.cpp +0 -0
  157. {gpflash-0.2.0 → gpflash-0.3.1}/tst/test_gpflash_symmetry.cpp +0 -0
  158. {gpflash-0.2.0 → gpflash-0.3.1}/tst/test_gpflash_training.cpp +0 -0
  159. {gpflash-0.2.0 → gpflash-0.3.1}/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: a run takes several hundred billed minutes on a private repository.
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:
@@ -71,8 +72,8 @@ jobs:
71
72
  key: windows-deps-${{ hashFiles('python/ci/install_deps_windows.ps1') }}
72
73
  - uses: pypa/cibuildwheel@v4.2.1
73
74
  env:
74
- # The oldest macOS the wheel runs on. It must not be older than the Homebrew libraries delocate bundles,
75
- # which are built for the runner's own macOS.
75
+ # The oldest macOS the wheel runs on. It must not be older than Homebrew's libomp, which the module links
76
+ # statically and which is built for the runner's own macOS.
76
77
  MACOSX_DEPLOYMENT_TARGET: ${{ matrix.macos_deployment_target }}
77
78
  - name: Check Windows libraries
78
79
  id: windows_deps_check
@@ -11,5 +11,6 @@
11
11
  # the module, matches the build-directory rule above.
12
12
  __pycache__/
13
13
  .pytest_cache/
14
+ .ruff_cache/
14
15
  /dist/
15
16
  *.egg-info/
@@ -0,0 +1,80 @@
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.1 (2026-11-05)
7
+
8
+ ### Fixed
9
+
10
+ - The cache calls (`peek_info`, `peek_kernel_id`, `save_precompute`, `load_posterior`, `load_posterior_verified` and
11
+ the `load_precompute` functions) may run on several threads at once: they hold one process-wide lock, so a second
12
+ call waits for the first, even on another file. HDF5 is not built thread-safe, and two calls that overlapped,
13
+ as Python threads could since the bindings release the GIL, could crash or corrupt its state.
14
+ - A query checks its points' row count even with `PosteriorOptions::check_query_points` cleared, which now skips only
15
+ the finiteness check. Before, clearing it let a point of the wrong dimension read out of bounds. A query that asks
16
+ for nothing now raises on a wrong row count too, rather than returning an empty result.
17
+ - **Python:** the macOS wheel links the OpenMP runtime statically and exports only the module's entry point, so it
18
+ runs in a process that has imported PyTorch, which loads its own copy of the runtime.
19
+
20
+ ### Changed
21
+
22
+ - The README and `core/Platform.hpp` say that GpFlash's declarations of glibc's vector `exp`, `log`, `pow`, `sin` and
23
+ `cos` apply to every call to them in a file that includes a GpFlash header, the caller's own included.
24
+
25
+ ## 0.3.0 (2026-10-18)
26
+
27
+ ### Changed
28
+
29
+ - **Python:** `GaussianProcess` now uses the C++ library's names, which breaks code written for 0.2.0:
30
+
31
+ | 0.2.0 | Now |
32
+ |---|---|
33
+ | `GaussianProcess(kernel=..., mean=..., n_starts=..., seed=...)`, `from_options` | `GaussianProcess(optz_opts)`, an `OptzOptions` whose fields carry the C++ names |
34
+ | `noise=...` in the constructor; `"estimate"` | `fit(..., sig2_f_val=...)`; a negative value estimates it |
35
+ | `predict(X)` returns arrays; `predict_gradient(X)` | `predict(X)` returns a `PosteriorPrediction`; flags select the mean, variance and gradients, and unrequested fields are `None` |
36
+ | `save` / `load`, `include_variance` | `save_precompute` / `load_posterior`, `include_variance_data` |
37
+ | `summary()`, `fit_result_`, `posterior_` | `to_summary_string()`, `mll_optz_result()`, `posterior()` |
38
+ | `hyperparameters_` (a dict), `log_marginal_likelihood_`, `kernel` | `hp_val_struct()` (an `HpVal`), `hp_beta_vec()`, `mll()`, `kernel_id()` |
39
+
40
+ - **Python:** `predict` returns the variance by default, as C++'s `PosteriorOptions` does.
41
+ - **Python:** points must be 2-D, `(n_points, n_dim)`; a 1-D array is no longer read as one point.
42
+ - **Python:** the wrapper's input checks raise `InvalidInputError`, as the C++ layer does.
43
+ - **Python:** the enums (`KernelId`, `OptzStopReason`, ...) are `enum.Enum` subclasses.
44
+
45
+ ### Added
46
+
47
+ - **Python:** `GaussianProcess.eval_mll`, `make_posterior`, `load_posterior_verified` and
48
+ `optz_opts()`. `HpVal`, `TrainingData`, `MllResult` and `PosteriorModelInfo` print their fields.
49
+ - Continuous integration: a weekly run of both workflows, and a ruff check of the Python files.
50
+
51
+ ## 0.2.0 (2026-10-17)
52
+
53
+ ### Added
54
+
55
+ - **Python package**, `pip install gpflash`, with wheels for Linux (x86_64, aarch64), macOS
56
+ (arm64, x86_64) and Windows (x64) on Python 3.11 to 3.14, every dependency included. It offers
57
+ a NumPy-style `GaussianProcess` (`fit`, `predict`, `predict_gradient`, `save`, `load`) and the
58
+ C++ interface under its C++ names. See [`python/README.md`](python/README.md).
59
+ - CMake option `GPFLASH_BUILD_PYTHON`, off by default, to build the Python module.
60
+ - Citation information for the GpFlash paper, [arXiv:2610.16861](https://arxiv.org/abs/2610.16861):
61
+ `CITATION.cff`, which gives the repository a "Cite this repository" button, and a BibTeX
62
+ entry in [`python/README.md`](python/README.md).
63
+ - Continuous integration: the C++ tests on Linux and macOS, and the Python wheels on every
64
+ platform, after each push to `main`.
65
+
66
+ ### Fixed
67
+
68
+ - A cache save that fails part way, as on a full disk, no longer leaves its file open in HDF5. HDF5 1.10
69
+ cannot close it, and the process may crash as it exits.
70
+
71
+ ### Changed
72
+
73
+ - The version is set in one place, `include/gpflash/Version.hpp`; CMake and the Python package
74
+ read it from there.
75
+
76
+ ## 0.1.0 (2026-10-12)
77
+
78
+ First release: a header-only C++14 library for exact Gaussian process regression, with the
79
+ marginal log likelihood and its analytic hyperparameter gradients, hyperparameter fitting
80
+ through NLopt, posterior mean and variance with their gradients, and an HDF5 posterior cache.
gpflash-0.3.1/PKG-INFO ADDED
@@ -0,0 +1,212 @@
1
+ Metadata-Version: 2.4
2
+ Name: gpflash
3
+ Version: 0.3.1
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. The cache calls (`peek_info`, `peek_kernel_id`, `load_posterior`, `load_posterior_verified`,
168
+ `GpPosterior.save_precompute` and the `GaussianProcess` methods that call them) read and write HDF5,
169
+ which is not built thread-safe, so GpFlash runs them one at a time: a second cache call waits for the
170
+ first, even on another file. `OMP_NUM_THREADS` sets the thread count. On macOS the module carries its
171
+ own OpenMP runtime, linked in and hidden, so it loads beside another library's, such as PyTorch's.
172
+ Two runtimes in one process can still slow each other down when both run threads at once; if that
173
+ happens, set `OMP_NUM_THREADS`.
174
+
175
+ ## Building from source
176
+
177
+ `pip install .` from a clone of the repository builds the module with CMake. It needs a C++14
178
+ compiler and the C++ library's dependencies; the
179
+ [C++ README](https://github.com/marchildon/gpflash#building) lists them per platform. On macOS,
180
+ point CMake at Homebrew's OpenMP:
181
+
182
+ ```
183
+ CMAKE_ARGS="-DOpenMP_ROOT=$(brew --prefix libomp)" pip install ".[test]"
184
+ pytest python/tests
185
+ ```
186
+
187
+ `ruff check .` and `ruff format .`, with the version `.github/workflows/ci.yml` pins, keep the Python
188
+ files and the READMEs' Python blocks in the style CI checks. After changing `python/src/bindings.cpp`, regenerate the type stubs with
189
+ `pybind11-stubgen gpflash._core -o python` (it writes `python/gpflash/_core.pyi`), then change the
190
+ `__version__` line it writes to `__version__: str`, so the stub carries no copy of the version.
191
+
192
+ ## Citing
193
+
194
+ If you use GpFlash, please cite the paper,
195
+ [arXiv:2610.16861](https://arxiv.org/abs/2610.16861):
196
+
197
+ ```bibtex
198
+ @misc{marchildon2026gpflash,
199
+ title = {GpFlash: Maximizing Speed and Minimizing Memory for Gaussian Process Training and Prediction},
200
+ author = {Marchildon, Andr{\'e}},
201
+ year = {2026},
202
+ eprint = {2610.16861},
203
+ archivePrefix = {arXiv},
204
+ primaryClass = {cs.LG},
205
+ doi = {10.48550/arXiv.2610.16861}
206
+ }
207
+ ```
208
+
209
+ ## License
210
+
211
+ Apache License 2.0. The wheels also contain compiled third-party libraries under their own
212
+ licenses; `LICENSES_bundled.txt`, installed with the package metadata, reproduces them.
@@ -1,5 +1,10 @@
1
1
  # GpFlash
2
2
 
3
+ [![PyPI](https://img.shields.io/pypi/v/gpflash)](https://pypi.org/project/gpflash/)
4
+ [![CI](https://github.com/marchildon/gpflash/actions/workflows/ci.yml/badge.svg)](https://github.com/marchildon/gpflash/actions/workflows/ci.yml)
5
+ [![Wheels](https://github.com/marchildon/gpflash/actions/workflows/wheels.yml/badge.svg)](https://github.com/marchildon/gpflash/actions/workflows/wheels.yml)
6
+ [![arXiv](https://img.shields.io/badge/arXiv-2610.16861-b31b1b)](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. Every kernel fits `hp_gamma`, one per dimension: an inverse
25
- length scale, or for `Periodic` an inverse period. `hp_kern_extra` holds whatever else it
26
- declares. `ModelOptions::symmetry_spec` gives a kernel that supports it an even or odd mirror
27
- symmetry about an axis-aligned plane.
28
-
29
- | `KernelId` | kernel | type | `hp_kern_extra` | symmetry |
30
- |---|---|---|---|---|
31
- | `SqExp` | squared exponential | radial | none | yes |
32
- | `Matern52` | Matérn 5/2, the default | radial | none | yes |
33
- | `Matern32` | Matérn 3/2 | radial | none | yes |
34
- | `RatQuad` | rational quadratic | radial | the shape `hp_rho` | yes |
35
- | `Periodic` | periodic | stationary | one amplitude per dimension | yes |
36
- | `Linear` | inhomogeneous linear | inner product | none | no |
37
- | `Quadratic` | inhomogeneous quadratic | inner product | none | no |
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
@@ -308,21 +340,16 @@ the first three rows, or an Armadillo configured otherwise, at compile time (`li
308
340
  Compile as C++14 or later with OpenMP enabled, and add:
309
341
 
310
342
  - `-funroll-loops`: faster batch posterior evaluation.
311
- - `-fno-math-errno`: with GCC on x86-64 Linux, lets the kernels' `exp`, `log`, `pow`, `sin` and `cos` vectorize. The
312
- vectorized functions can differ from the scalar ones in the last bits; define `GPFLASH_NO_VECTOR_MATH` to keep the
313
- scalar ones.
343
+ - `-fno-math-errno`: with GCC on x86-64 Linux, lets the kernels' `exp`, `log`, `pow`, `sin` and `cos` vectorize.
344
+ GpFlash declares glibc's vector versions of these five functions, so they also apply to your own calls to them in
345
+ any file that includes a GpFlash header. The vectorized functions can differ from the scalar ones in the last bits;
346
+ define `GPFLASH_NO_VECTOR_MATH` to keep the scalar ones everywhere.
314
347
 
315
348
  Do not use `-ffast-math` or `-Ofast`: they fold `std::isfinite` to true, which disables the input validation, and
316
349
  `core/Platform.hpp` rejects them.
317
350
 
318
351
  Link BLAS, LAPACK and HDF5's C library, and NLopt when `optimization/` is included.
319
352
 
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
353
  ## License
327
354
 
328
355
  Copyright 2026 André Marchildon, under the Apache License 2.0; see `LICENSE` and `NOTICE`. `THIRD-PARTY-NOTICES`
@@ -10,8 +10,8 @@
10
10
  #include "gpflash/core/Platform.hpp" // GPFLASH_STR
11
11
 
12
12
  #define GPFLASH_VERSION_MAJOR 0
13
- #define GPFLASH_VERSION_MINOR 2
14
- #define GPFLASH_VERSION_PATCH 0
13
+ #define GPFLASH_VERSION_MINOR 3
14
+ #define GPFLASH_VERSION_PATCH 1
15
15
 
16
16
  namespace gpflash {
17
17
 
@@ -21,7 +21,8 @@
21
21
 
22
22
  // ── Vector math (GCC, glibc, x86-64) ─────────────────────────────────────────
23
23
  // glibc declares its SIMD exp, log, pow, sin and cos only under __FAST_MATH__; without them GCC cannot vectorize the
24
- // kernel loops. Needs -fno-math-errno. GPFLASH_NO_VECTOR_MATH keeps the scalar versions.
24
+ // kernel loops. Needs -fno-math-errno. The declarations are global, so they cover every call to these five functions
25
+ // in a file that includes a GpFlash header, the caller's own included. GPFLASH_NO_VECTOR_MATH keeps the scalar ones.
25
26
  #include <cmath>
26
27
  #if defined(__GNUC__) && !defined(__clang__) && defined(__x86_64__) && defined(__GLIBC__) && !defined(__FAST_MATH__) \
27
28
  && !defined(GPFLASH_NO_VECTOR_MATH)
@@ -6,8 +6,9 @@
6
6
  * HDF5 error dump. Added on top: exceptions naming the array and file, an existence probe, a read straight into
7
7
  * caller memory, an atomic replace, and strings as byte arrays.
8
8
  *
9
- * Not safe to call concurrently: HDF5 is linked without --enable-threadsafe, so its global state makes two
10
- * simultaneous calls unsafe even to different files.
9
+ * HDF5 is linked without --enable-threadsafe, so its global state makes two simultaneous calls unsafe even to
10
+ * different files. The cache's entry points (PosteriorCache.hpp) therefore each hold cache_mutex for their whole call;
11
+ * these primitives take no lock of their own.
11
12
  */
12
13
  #pragma once
13
14
 
@@ -21,6 +22,7 @@
21
22
  #include <algorithm> // std::find
22
23
  #include <cstdio> // std::rename, std::remove
23
24
  #include <fstream> // has_file
25
+ #include <mutex> // cache_mutex
24
26
  #include <string>
25
27
  #include <vector> // list_open_files
26
28
 
@@ -43,6 +45,14 @@ inline bool has_file(const std::string& path) { return std::ifstream(path.c_str(
43
45
 
44
46
  namespace detail {
45
47
 
48
+ // The one lock every cache entry point holds, so that two threads' cache calls run one after the other. One whole call,
49
+ // not each array: a failed save closes every file opened since its start, which must not include another thread's. A
50
+ // function-local static, so one lock per program, or per shared library on platforms that keep their symbols apart.
51
+ inline std::mutex& cache_mutex() {
52
+ static std::mutex mutex;
53
+ return mutex;
54
+ }
55
+
46
56
  // Every failure in the cache, named for the function that raised it. One type for all of them, so a caller can
47
57
  // tell a rejected file from an unrelated exception such as a failed allocation.
48
58
  inline ErrorInvalidInput cache_error(const char* caller, const std::string& what_failed) {
@@ -5,12 +5,15 @@
5
5
  * Reading never creates, modifies, or removes a file -- every failure is a throw. Only save_precompute writes,
6
6
  * and it writes one file, removing nothing but its own scratch file.
7
7
  *
8
- * Not safe to call concurrently, reads included, even on different files; see Hdf5Store.hpp.
8
+ * Safe to call from several threads: each entry point holds detail::cache_mutex for its whole call, since HDF5 is not
9
+ * built thread-safe (Hdf5Store.hpp). A second call waits for the first, even on another file. The caller's own HDF5
10
+ * calls take no part in the lock and must not overlap these.
9
11
  */
10
12
  #pragma once
11
13
 
12
14
  #include <armadillo>
13
15
  #include <cstdio> // std::remove
16
+ #include <mutex> // std::lock_guard
14
17
  #include <string>
15
18
  #include <utility> // std::move
16
19
 
@@ -27,7 +30,10 @@ namespace cache {
27
30
 
28
31
  // What the file says about itself, without loading the arrays. Raises on an unreadable file, one another format
29
32
  // version wrote, or an impossible stored value; the kernel and hash checks need what only the load path is given.
30
- inline CacheInfo peek_info(const std::string& path) { return detail::load_cache_info(path, "peek_info"); }
33
+ inline CacheInfo peek_info(const std::string& path) {
34
+ const std::lock_guard<std::mutex> cache_lock(detail::cache_mutex());
35
+ return detail::load_cache_info(path, "peek_info");
36
+ }
31
37
 
32
38
  // The kernel a file was written with, so it can be loaded without naming that kernel in advance.
33
39
  inline kernel::KernelId peek_kernel_id(const std::string& path) { return peek_info(path).post_model_info.kernel_id; }
@@ -93,6 +99,7 @@ inline void save_precompute(
93
99
  const gpflash::detail::PosteriorPrecompute& post_precompute,
94
100
  const std::string& note = "",
95
101
  const bool include_variance_data = true) {
102
+ const std::lock_guard<std::mutex> cache_lock(detail::cache_mutex());
96
103
  detail::write_precompute_file(
97
104
  path,
98
105
  post_model_info,
@@ -167,6 +174,7 @@ inline PosteriorContents load_precompute(
167
174
  const std::string& path,
168
175
  const kernel::KernelId expected_kernel_id,
169
176
  const arma::u64* expected_input_hash_ptr = nullptr) {
177
+ const std::lock_guard<std::mutex> cache_lock(detail::cache_mutex());
170
178
  // The same validated header read peek_info uses, so neither can accept a file the other rejects. A NaN
171
179
  // mll or a negative hp_sig2_k throws here, in release as well as debug.
172
180
  const CacheInfo cache_info = detail::load_cache_info(path, "load_precompute");
@@ -183,6 +191,7 @@ inline PosteriorContents load_precompute_for_kernel(
183
191
  const std::string& path,
184
192
  const char* caller,
185
193
  const arma::u64* expected_input_hash_ptr = nullptr) {
194
+ const std::lock_guard<std::mutex> cache_lock(detail::cache_mutex());
186
195
  const CacheInfo cache_info = detail::load_cache_info(path, caller);
187
196
  PosteriorContents post_contents = detail::load_precompute_after_header(
188
197
  path, cache_info, kern_fun.kernel_id(), expected_input_hash_ptr, caller);
@@ -195,6 +204,7 @@ namespace detail {
195
204
 
196
205
  // load_precompute_for_kernel at the kernel the file names, its header read once.
197
206
  inline PosteriorContents load_precompute_for_file_kernel(const std::string& path, const char* caller) {
207
+ const std::lock_guard<std::mutex> cache_lock(cache_mutex());
198
208
  const CacheInfo cache_info = load_cache_info(path, caller);
199
209
  const kernel::KernelBase& kern_fun = kernel::kernel_by_id(cache_info.post_model_info.kernel_id);
200
210
  PosteriorContents post_contents = load_precompute_after_header(
@@ -38,7 +38,9 @@ The package `README.md` shows the calls. `load_posterior(path)` checks the file
38
38
  it whenever they are in hand. A prediction-only build has `load_posterior` alone. To replace a file, save over it.
39
39
  The format layer itself is `save_precompute` and `load_precompute` in `PosteriorCache.hpp`.
40
40
 
41
- No two cache calls, reads or saves, may run at once, even on different files: HDF5 is linked without thread safety.
41
+ HDF5 is linked without thread safety, so the cache calls hold one process-wide lock for their whole run: two threads
42
+ may call them at once, and the second waits for the first, even on another file. The lock covers GpFlash's calls only;
43
+ the caller's own HDF5 use must not overlap them.
42
44
 
43
45
  ## When errors are raised
44
46
 
@@ -16,15 +16,15 @@ struct PosteriorOptions {
16
16
  bool return_mean_gradient = false;
17
17
  bool return_var_gradient = false;
18
18
 
19
- // Whether to check the query points' row count and finiteness, on by default. Clearing it saves a scan of
20
- // n_dim values per point.
19
+ // Whether to check that every query coordinate is finite, on by default. Clearing it saves a scan of n_dim values
20
+ // per point. The row count is always checked, since a wrong one would read out of bounds.
21
21
  bool check_query_points = true;
22
22
  };
23
23
 
24
24
  namespace detail {
25
25
 
26
- // Whether no quantity was asked for, whatever check_query_points says. Not an error: a query then returns an empty
27
- // PosteriorResult, which is what every field already means when its flag is clear.
26
+ // Whether no quantity was asked for. Not an error: a query then returns an empty PosteriorResult, which is what every
27
+ // field already means when its flag is clear. Asked after the query points' checks, so a wrong row count still raises.
28
28
  inline bool is_empty_request(const PosteriorOptions& post_opts) {
29
29
  return !post_opts.return_mean && !post_opts.return_var && !post_opts.return_mean_gradient
30
30
  && !post_opts.return_var_gradient;