gpflash 0.3.0__tar.gz → 0.4.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.
Files changed (190) hide show
  1. gpflash-0.4.0/.github/workflows/ci.yml +95 -0
  2. {gpflash-0.3.0 → gpflash-0.4.0}/.github/workflows/wheels.yml +6 -2
  3. gpflash-0.4.0/CHANGELOG.md +140 -0
  4. {gpflash-0.3.0 → gpflash-0.4.0}/CMakeLists.txt +23 -4
  5. gpflash-0.4.0/NAMING_CONVENTIONS.md +151 -0
  6. {gpflash-0.3.0 → gpflash-0.4.0}/PKG-INFO +59 -21
  7. {gpflash-0.3.0 → gpflash-0.4.0}/README.md +81 -42
  8. {gpflash-0.3.0 → gpflash-0.4.0}/cmake/GpFlashConfig.cmake.in +3 -1
  9. {gpflash-0.3.0 → gpflash-0.4.0}/cmake/GpFlashDependencies.cmake +8 -5
  10. {gpflash-0.3.0 → gpflash-0.4.0}/include/gpflash/Version.hpp +1 -1
  11. {gpflash-0.3.0 → gpflash-0.4.0}/include/gpflash/assembly/CholTerms.hpp +17 -9
  12. {gpflash-0.3.0 → gpflash-0.4.0}/include/gpflash/assembly/EtaTermHpGrad.hpp +1 -1
  13. {gpflash-0.3.0 → gpflash-0.4.0}/include/gpflash/assembly/KernTermHpGrad.hpp +1 -1
  14. gpflash-0.4.0/include/gpflash/assembly/KernelAssembly.hpp +174 -0
  15. {gpflash-0.3.0 → gpflash-0.4.0}/include/gpflash/assembly/KernelMatrix.hpp +9 -9
  16. {gpflash-0.3.0 → gpflash-0.4.0}/include/gpflash/assembly/KernelMatrixGrad.hpp +5 -5
  17. {gpflash-0.3.0 → gpflash-0.4.0}/include/gpflash/assembly/KmatNuggetGrad.hpp +52 -17
  18. gpflash-0.4.0/include/gpflash/assembly/PosteriorCovariance.hpp +109 -0
  19. {gpflash-0.3.0 → gpflash-0.4.0}/include/gpflash/assembly/SigmaGrad.hpp +18 -14
  20. gpflash-0.4.0/include/gpflash/assembly/SigmaMatrix.hpp +68 -0
  21. {gpflash-0.3.0 → gpflash-0.4.0}/include/gpflash/assembly/SymmetryMatrix.hpp +41 -33
  22. {gpflash-0.3.0 → gpflash-0.4.0}/include/gpflash/core/Errors.hpp +25 -2
  23. {gpflash-0.3.0 → gpflash-0.4.0}/include/gpflash/core/Platform.hpp +55 -1
  24. {gpflash-0.3.0 → gpflash-0.4.0}/include/gpflash/inputs/HpVal.hpp +15 -6
  25. {gpflash-0.3.0 → gpflash-0.4.0}/include/gpflash/inputs/ModelOptions.hpp +1 -1
  26. {gpflash-0.3.0 → gpflash-0.4.0}/include/gpflash/inputs/TrainingData.hpp +47 -8
  27. {gpflash-0.3.0 → gpflash-0.4.0}/include/gpflash/kernels/HpGradInputs.hpp +9 -10
  28. {gpflash-0.3.0 → gpflash-0.4.0}/include/gpflash/kernels/KernelBase.hpp +20 -30
  29. {gpflash-0.3.0 → gpflash-0.4.0}/include/gpflash/kernels/KernelStationary.hpp +4 -18
  30. {gpflash-0.3.0 → gpflash-0.4.0}/include/gpflash/kernels/OptzSeeding.hpp +1 -1
  31. {gpflash-0.3.0 → gpflash-0.4.0}/include/gpflash/kernels/inner_product/KernelInnerProduct.hpp +21 -36
  32. {gpflash-0.3.0 → gpflash-0.4.0}/include/gpflash/kernels/inner_product/Linear.hpp +2 -2
  33. {gpflash-0.3.0 → gpflash-0.4.0}/include/gpflash/kernels/radial/KernelRadial.hpp +56 -35
  34. {gpflash-0.3.0 → gpflash-0.4.0}/include/gpflash/kernels/radial/Matern32.hpp +18 -16
  35. {gpflash-0.3.0 → gpflash-0.4.0}/include/gpflash/kernels/radial/Matern52.hpp +20 -19
  36. {gpflash-0.3.0 → gpflash-0.4.0}/include/gpflash/kernels/radial/RatQuad.hpp +2 -2
  37. {gpflash-0.3.0 → gpflash-0.4.0}/include/gpflash/kernels/radial/SqExp.hpp +16 -11
  38. {gpflash-0.3.0 → gpflash-0.4.0}/include/gpflash/kernels/stationary/Periodic.hpp +20 -23
  39. {gpflash-0.3.0 → gpflash-0.4.0}/include/gpflash/linear_algebra/Cholesky.hpp +23 -9
  40. gpflash-0.4.0/include/gpflash/linear_algebra/InnerProducts.hpp +249 -0
  41. gpflash-0.4.0/include/gpflash/linear_algebra/ReservedCholFactor.hpp +144 -0
  42. gpflash-0.4.0/include/gpflash/linear_algebra/VectorMath.hpp +44 -0
  43. {gpflash-0.3.0 → gpflash-0.4.0}/include/gpflash/mean/MeanModel.hpp +39 -16
  44. {gpflash-0.3.0 → gpflash-0.4.0}/include/gpflash/mean/MeanModelWeights.hpp +52 -21
  45. {gpflash-0.3.0 → gpflash-0.4.0}/include/gpflash/optimization/HpOptimizer.hpp +109 -34
  46. gpflash-0.4.0/include/gpflash/optimization/MllOptzObjective.hpp +209 -0
  47. {gpflash-0.3.0 → gpflash-0.4.0}/include/gpflash/optimization/MllOptzResult.hpp +49 -2
  48. {gpflash-0.3.0 → gpflash-0.4.0}/include/gpflash/optimization/MultistartReport.hpp +44 -21
  49. {gpflash-0.3.0 → gpflash-0.4.0}/include/gpflash/optimization/README.md +61 -19
  50. {gpflash-0.3.0 → gpflash-0.4.0}/include/gpflash/optimization/local_optz/LocalOptzResult.hpp +1 -1
  51. {gpflash-0.3.0 → gpflash-0.4.0}/include/gpflash/optimization/local_optz/OptimizerNlopt.hpp +12 -12
  52. {gpflash-0.3.0 → gpflash-0.4.0}/include/gpflash/optimization/multistart/LatinHypercube.hpp +1 -1
  53. {gpflash-0.3.0 → gpflash-0.4.0}/include/gpflash/optimization/multistart/MultistartResult.hpp +4 -4
  54. {gpflash-0.3.0 → gpflash-0.4.0}/include/gpflash/optimization/multistart/RunMultistart.hpp +67 -21
  55. {gpflash-0.3.0 → gpflash-0.4.0}/include/gpflash/optimization/search_space/ActiveBounds.hpp +5 -5
  56. {gpflash-0.3.0 → gpflash-0.4.0}/include/gpflash/optimization/search_space/HpAtBound.hpp +18 -4
  57. gpflash-0.4.0/include/gpflash/optimization/search_space/HpOptzLayout.hpp +311 -0
  58. gpflash-0.4.0/include/gpflash/optimization/search_space/HpPrior.hpp +220 -0
  59. gpflash-0.4.0/include/gpflash/optimization/search_space/OptzOptions.hpp +333 -0
  60. {gpflash-0.3.0 → gpflash-0.4.0}/include/gpflash/optimization/search_space/OptzRegion.hpp +44 -15
  61. {gpflash-0.3.0 → gpflash-0.4.0}/include/gpflash/posterior_build/PosteriorBuild.hpp +107 -48
  62. gpflash-0.4.0/include/gpflash/posterior_build/PosteriorBuildOptions.hpp +26 -0
  63. {gpflash-0.3.0 → gpflash-0.4.0}/include/gpflash/posterior_cache/CacheInfo.hpp +32 -3
  64. {gpflash-0.3.0 → gpflash-0.4.0}/include/gpflash/posterior_cache/CacheInputHash.hpp +27 -11
  65. {gpflash-0.3.0 → gpflash-0.4.0}/include/gpflash/posterior_cache/CacheLayout.hpp +96 -24
  66. {gpflash-0.3.0 → gpflash-0.4.0}/include/gpflash/posterior_cache/Hdf5Store.hpp +80 -11
  67. gpflash-0.4.0/include/gpflash/posterior_cache/PosteriorCache.hpp +345 -0
  68. {gpflash-0.3.0 → gpflash-0.4.0}/include/gpflash/posterior_cache/PosteriorContents.hpp +1 -1
  69. {gpflash-0.3.0 → gpflash-0.4.0}/include/gpflash/posterior_cache/PosteriorModelInfo.hpp +39 -12
  70. gpflash-0.4.0/include/gpflash/posterior_cache/PosteriorPrecompute.hpp +187 -0
  71. gpflash-0.4.0/include/gpflash/posterior_cache/README.md +98 -0
  72. gpflash-0.4.0/include/gpflash/posterior_eval/GpPosterior.hpp +275 -0
  73. gpflash-0.4.0/include/gpflash/posterior_eval/JointPosterior.hpp +972 -0
  74. gpflash-0.4.0/include/gpflash/posterior_eval/PosteriorCondition.hpp +255 -0
  75. gpflash-0.4.0/include/gpflash/posterior_eval/PosteriorEval.hpp +300 -0
  76. {gpflash-0.3.0 → gpflash-0.4.0}/include/gpflash/posterior_eval/PosteriorGrad.hpp +64 -55
  77. {gpflash-0.3.0 → gpflash-0.4.0}/include/gpflash/posterior_eval/PosteriorOptions.hpp +10 -5
  78. gpflash-0.4.0/include/gpflash/posterior_eval/PosteriorQuery.hpp +419 -0
  79. gpflash-0.4.0/include/gpflash/posterior_eval/PosteriorSample.hpp +133 -0
  80. {gpflash-0.3.0 → gpflash-0.4.0}/include/gpflash/preconditioning/ConditionedCholesky.hpp +18 -11
  81. {gpflash-0.3.0 → gpflash-0.4.0}/include/gpflash/preconditioning/EtaTerms.hpp +10 -6
  82. {gpflash-0.3.0 → gpflash-0.4.0}/include/gpflash/preconditioning/PreconScales.hpp +2 -2
  83. gpflash-0.4.0/include/gpflash/training/EvalMll.hpp +292 -0
  84. {gpflash-0.3.0 → gpflash-0.4.0}/include/gpflash/training/EvalMllDispatch.hpp +7 -8
  85. {gpflash-0.3.0 → gpflash-0.4.0}/include/gpflash/training/EvalMllGrad.hpp +37 -22
  86. gpflash-0.4.0/include/gpflash/training/EvalVariances.hpp +45 -0
  87. {gpflash-0.3.0 → gpflash-0.4.0}/include/gpflash/training/MllHpGrad.hpp +4 -2
  88. {gpflash-0.3.0 → gpflash-0.4.0}/include/gpflash/training/MllResult.hpp +16 -5
  89. {gpflash-0.3.0 → gpflash-0.4.0}/include/gpflash/training/StageTiming.hpp +2 -7
  90. {gpflash-0.3.0 → gpflash-0.4.0}/pyproject.toml +2 -3
  91. gpflash-0.4.0/python/CMakeLists.txt +44 -0
  92. {gpflash-0.3.0 → gpflash-0.4.0}/python/README.md +58 -20
  93. {gpflash-0.3.0 → gpflash-0.4.0}/python/ci/install_deps_unix.sh +2 -1
  94. {gpflash-0.3.0 → gpflash-0.4.0}/python/gpflash/__init__.py +24 -0
  95. gpflash-0.4.0/python/gpflash/_core.pyi +1258 -0
  96. {gpflash-0.3.0 → gpflash-0.4.0}/python/gpflash/_gp.py +127 -43
  97. gpflash-0.4.0/python/gpflash/torch.py +382 -0
  98. gpflash-0.4.0/python/src/bindings.cpp +1301 -0
  99. {gpflash-0.3.0 → gpflash-0.4.0}/python/tests/test_core.py +100 -1
  100. {gpflash-0.3.0 → gpflash-0.4.0}/python/tests/test_diagnostics.py +5 -5
  101. gpflash-0.4.0/python/tests/test_gaussian_process.py +701 -0
  102. gpflash-0.4.0/python/tests/test_joint_posterior.py +225 -0
  103. {gpflash-0.3.0 → gpflash-0.4.0}/python/tests/test_numerics.py +43 -21
  104. gpflash-0.4.0/python/tests/test_openmp_isolation.py +66 -0
  105. gpflash-0.4.0/python/tests/test_torch.py +398 -0
  106. {gpflash-0.3.0 → gpflash-0.4.0}/tst/CMakeLists.txt +9 -0
  107. {gpflash-0.3.0 → gpflash-0.4.0}/tst/GpFlashTestSupport.hpp +66 -10
  108. {gpflash-0.3.0 → gpflash-0.4.0}/tst/check_formatting.cmake +3 -2
  109. {gpflash-0.3.0 → gpflash-0.4.0}/tst/test_gpflash_cache.cpp +405 -46
  110. {gpflash-0.3.0 → gpflash-0.4.0}/tst/test_gpflash_chol_solves.cpp +173 -48
  111. gpflash-0.4.0/tst/test_gpflash_fit_controls.cpp +700 -0
  112. gpflash-0.4.0/tst/test_gpflash_hp_prior.cpp +459 -0
  113. {gpflash-0.3.0 → gpflash-0.4.0}/tst/test_gpflash_inner_product_gradient.cpp +4 -4
  114. {gpflash-0.3.0 → gpflash-0.4.0}/tst/test_gpflash_input_validation.cpp +47 -29
  115. gpflash-0.4.0/tst/test_gpflash_joint_posterior.cpp +967 -0
  116. {gpflash-0.3.0 → gpflash-0.4.0}/tst/test_gpflash_kernel_assembly.cpp +4 -4
  117. {gpflash-0.3.0 → gpflash-0.4.0}/tst/test_gpflash_kernel_center.cpp +12 -3
  118. {gpflash-0.3.0 → gpflash-0.4.0}/tst/test_gpflash_kernel_contract.cpp +2 -2
  119. {gpflash-0.3.0 → gpflash-0.4.0}/tst/test_gpflash_kernel_finite_difference.cpp +11 -9
  120. {gpflash-0.3.0 → gpflash-0.4.0}/tst/test_gpflash_kernel_matrix_grad.cpp +9 -9
  121. {gpflash-0.3.0 → gpflash-0.4.0}/tst/test_gpflash_kernel_posterior_assembly.cpp +10 -8
  122. {gpflash-0.3.0 → gpflash-0.4.0}/tst/test_gpflash_kmat_nugget.cpp +13 -5
  123. {gpflash-0.3.0 → gpflash-0.4.0}/tst/test_gpflash_kmat_nugget_grad.cpp +22 -22
  124. {gpflash-0.3.0 → gpflash-0.4.0}/tst/test_gpflash_linear.cpp +18 -16
  125. {gpflash-0.3.0 → gpflash-0.4.0}/tst/test_gpflash_local_optz.cpp +1 -1
  126. gpflash-0.4.0/tst/test_gpflash_mean_model_var.cpp +686 -0
  127. {gpflash-0.3.0 → gpflash-0.4.0}/tst/test_gpflash_multistart.cpp +45 -51
  128. {gpflash-0.3.0 → gpflash-0.4.0}/tst/test_gpflash_multistart_report.cpp +4 -3
  129. gpflash-0.4.0/tst/test_gpflash_noise_var_vec.cpp +434 -0
  130. {gpflash-0.3.0 → gpflash-0.4.0}/tst/test_gpflash_optimizer.cpp +164 -144
  131. {gpflash-0.3.0 → gpflash-0.4.0}/tst/test_gpflash_optimizer_mpi.cpp +101 -41
  132. {gpflash-0.3.0 → gpflash-0.4.0}/tst/test_gpflash_optimizer_periodic.cpp +52 -71
  133. {gpflash-0.3.0 → gpflash-0.4.0}/tst/test_gpflash_periodic.cpp +8 -8
  134. gpflash-0.4.0/tst/test_gpflash_post_cond_obs.cpp +591 -0
  135. {gpflash-0.3.0 → gpflash-0.4.0}/tst/test_gpflash_posterior.cpp +14 -10
  136. {gpflash-0.3.0 → gpflash-0.4.0}/tst/test_gpflash_posterior_nonradial.cpp +71 -54
  137. gpflash-0.4.0/tst/test_gpflash_posterior_sample.cpp +236 -0
  138. {gpflash-0.3.0 → gpflash-0.4.0}/tst/test_gpflash_search_space.cpp +78 -37
  139. {gpflash-0.3.0 → gpflash-0.4.0}/tst/test_gpflash_sigma_matrix.cpp +16 -37
  140. {gpflash-0.3.0 → gpflash-0.4.0}/tst/test_gpflash_stage_timing.cpp +6 -5
  141. {gpflash-0.3.0 → gpflash-0.4.0}/tst/test_gpflash_struct_checks.cpp +63 -19
  142. {gpflash-0.3.0 → gpflash-0.4.0}/tst/test_gpflash_symmetry.cpp +117 -70
  143. {gpflash-0.3.0 → gpflash-0.4.0}/tst/test_gpflash_training.cpp +64 -54
  144. gpflash-0.3.0/.github/workflows/ci.yml +0 -64
  145. gpflash-0.3.0/CHANGELOG.md +0 -61
  146. gpflash-0.3.0/include/gpflash/assembly/KernelAssembly.hpp +0 -144
  147. gpflash-0.3.0/include/gpflash/assembly/PosteriorCovariance.hpp +0 -111
  148. gpflash-0.3.0/include/gpflash/assembly/SigmaMatrix.hpp +0 -66
  149. gpflash-0.3.0/include/gpflash/linear_algebra/InnerProducts.hpp +0 -146
  150. gpflash-0.3.0/include/gpflash/optimization/MllOptzObjective.hpp +0 -139
  151. gpflash-0.3.0/include/gpflash/optimization/search_space/HpOptzLayout.hpp +0 -198
  152. gpflash-0.3.0/include/gpflash/optimization/search_space/OptzOptions.hpp +0 -176
  153. gpflash-0.3.0/include/gpflash/posterior_cache/PosteriorCache.hpp +0 -210
  154. gpflash-0.3.0/include/gpflash/posterior_cache/PosteriorPrecompute.hpp +0 -112
  155. gpflash-0.3.0/include/gpflash/posterior_cache/README.md +0 -69
  156. gpflash-0.3.0/include/gpflash/posterior_eval/GpPosterior.hpp +0 -109
  157. gpflash-0.3.0/include/gpflash/posterior_eval/PosteriorEval.hpp +0 -113
  158. gpflash-0.3.0/include/gpflash/posterior_eval/PosteriorQuery.hpp +0 -261
  159. gpflash-0.3.0/include/gpflash/training/EvalMll.hpp +0 -311
  160. gpflash-0.3.0/include/gpflash/training/EvalVariances.hpp +0 -31
  161. gpflash-0.3.0/python/CMakeLists.txt +0 -19
  162. gpflash-0.3.0/python/gpflash/_core.pyi +0 -720
  163. gpflash-0.3.0/python/src/bindings.cpp +0 -638
  164. gpflash-0.3.0/python/tests/test_gaussian_process.py +0 -317
  165. {gpflash-0.3.0 → gpflash-0.4.0}/.clang-format +0 -0
  166. {gpflash-0.3.0 → gpflash-0.4.0}/.github/workflows/weekly.yml +0 -0
  167. {gpflash-0.3.0 → gpflash-0.4.0}/.gitignore +0 -0
  168. {gpflash-0.3.0 → gpflash-0.4.0}/CITATION.cff +0 -0
  169. {gpflash-0.3.0 → gpflash-0.4.0}/LICENSE +0 -0
  170. {gpflash-0.3.0 → gpflash-0.4.0}/NOTICE +0 -0
  171. {gpflash-0.3.0 → gpflash-0.4.0}/THIRD-PARTY-NOTICES +0 -0
  172. {gpflash-0.3.0 → gpflash-0.4.0}/include/gpflash/core/NoiseModel.hpp +0 -0
  173. {gpflash-0.3.0 → gpflash-0.4.0}/include/gpflash/core/ParallelContext.hpp +0 -0
  174. {gpflash-0.3.0 → gpflash-0.4.0}/include/gpflash/core/StringFormat.hpp +0 -0
  175. {gpflash-0.3.0 → gpflash-0.4.0}/include/gpflash/inputs/EigMaxUbMethod.hpp +0 -0
  176. {gpflash-0.3.0 → gpflash-0.4.0}/include/gpflash/inputs/KernelId.hpp +0 -0
  177. {gpflash-0.3.0 → gpflash-0.4.0}/include/gpflash/inputs/SymmetrySpec.hpp +0 -0
  178. {gpflash-0.3.0 → gpflash-0.4.0}/include/gpflash/kernels/KernelDispatch.hpp +0 -0
  179. {gpflash-0.3.0 → gpflash-0.4.0}/include/gpflash/kernels/inner_product/Quadratic.hpp +0 -0
  180. {gpflash-0.3.0 → gpflash-0.4.0}/include/gpflash/linear_algebra/BlasLapack.hpp +0 -0
  181. {gpflash-0.3.0 → gpflash-0.4.0}/include/gpflash/linear_algebra/RecursiveInv.hpp +0 -0
  182. {gpflash-0.3.0 → gpflash-0.4.0}/include/gpflash/optimization/multistart/OptimumClusters.hpp +0 -0
  183. {gpflash-0.3.0 → gpflash-0.4.0}/include/gpflash/posterior_eval/PosteriorResult.hpp +0 -0
  184. {gpflash-0.3.0 → gpflash-0.4.0}/python/LICENSES_bundled.txt +0 -0
  185. {gpflash-0.3.0 → gpflash-0.4.0}/python/ci/install_deps_windows.ps1 +0 -0
  186. {gpflash-0.3.0 → gpflash-0.4.0}/python/gpflash/py.typed +0 -0
  187. {gpflash-0.3.0 → gpflash-0.4.0}/tst/check_prediction_only_includes.cmake +0 -0
  188. {gpflash-0.3.0 → gpflash-0.4.0}/tst/test_gpflash_recursive_inv.cpp +0 -0
  189. {gpflash-0.3.0 → gpflash-0.4.0}/tst/test_gpflash_string_format.cpp +0 -0
  190. {gpflash-0.3.0 → gpflash-0.4.0}/tst/test_gpflash_version.cpp +0 -0
@@ -0,0 +1,95 @@
1
+ # The C++ and Python tests, after every push to main, weekly (weekly.yml), and on request (workflow_dispatch):
2
+ #
3
+ # - Linux (GCC): every C++ test, with the clang-format and ruff checks and the MPI test.
4
+ # - Linux (GCC), reduced: the same without the posterior cache or HDF5, with Armadillo's bounds checks, and with one
5
+ # version of each SIMD loop.
6
+ # - macOS (Apple clang): the C++ tests, without the MPI test or the clang-format check.
7
+ # - Python (Linux): the package built from source with torch, so gpflash.torch's tests run, which the wheels skip.
8
+ name: CI
9
+
10
+ on:
11
+ push:
12
+ branches: [main]
13
+ workflow_call: # from weekly.yml
14
+ workflow_dispatch:
15
+
16
+ permissions:
17
+ contents: read
18
+
19
+ jobs:
20
+ build_and_test:
21
+ name: ${{ matrix.name }}
22
+ runs-on: ${{ matrix.os }}
23
+ strategy:
24
+ fail-fast: false
25
+ matrix:
26
+ include:
27
+ - name: Linux (GCC)
28
+ os: ubuntu-24.04
29
+ cmake_args: ""
30
+ - name: Linux (GCC), reduced
31
+ os: ubuntu-24.04
32
+ cmake_args: -DGPFLASH_USE_HDF5=OFF -DGPFLASH_ARMA_NO_DEBUG=OFF -DCMAKE_CXX_FLAGS=-DGPFLASH_NO_SIMD_CLONES
33
+ - name: macOS (Apple clang)
34
+ os: macos-15
35
+ cmake_args: ""
36
+ steps:
37
+ - uses: actions/checkout@v7.0.1
38
+
39
+ - name: Install dependencies (Linux)
40
+ if: runner.os == 'Linux'
41
+ run: |
42
+ sudo apt-get update
43
+ sudo apt-get install -y cmake g++ libarmadillo-dev libopenblas-dev libhdf5-dev libnlopt-cxx-dev \
44
+ clang-format-15 mpich libmpich-dev
45
+
46
+ - name: Install dependencies (macOS)
47
+ if: runner.os == 'macOS'
48
+ run: brew install armadillo libomp hdf5 nlopt
49
+
50
+ # Pinned, as clang-format is, so a ruff release cannot change what passes.
51
+ - name: Check the Python files (Linux)
52
+ if: runner.os == 'Linux'
53
+ run: |
54
+ pip install ruff==0.17.1
55
+ ruff check .
56
+ ruff format --check .
57
+
58
+ - name: Configure (Linux)
59
+ if: runner.os == 'Linux'
60
+ run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release ${{ matrix.cmake_args }}
61
+
62
+ # The MPI test runs on Linux only: the macOS runner has too few cores for its 4 processes.
63
+ - name: Configure (macOS)
64
+ if: runner.os == 'macOS'
65
+ run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DOpenMP_ROOT="$(brew --prefix libomp)" -DGPFLASH_BUILD_MPI_TEST=OFF
66
+
67
+ - name: Build
68
+ run: cmake --build build --parallel 4
69
+
70
+ - name: Test
71
+ run: ctest --test-dir build --output-on-failure
72
+
73
+ python_torch:
74
+ name: Python with torch (Linux)
75
+ runs-on: ubuntu-24.04
76
+ steps:
77
+ - uses: actions/checkout@v7.0.1
78
+
79
+ - uses: actions/setup-python@v6.1.0
80
+ with:
81
+ python-version: "3.13"
82
+
83
+ - name: Install the libraries the module links
84
+ run: |
85
+ sudo apt-get update
86
+ sudo apt-get install -y cmake g++ libarmadillo-dev libopenblas-dev libhdf5-dev libnlopt-cxx-dev
87
+
88
+ # The CPU build of torch: a fraction of the default download, and the tests need no GPU.
89
+ - name: Install the package and torch
90
+ run: |
91
+ pip install torch --index-url https://download.pytorch.org/whl/cpu
92
+ pip install ".[test]"
93
+
94
+ - name: Test
95
+ run: pytest python/tests
@@ -72,8 +72,8 @@ jobs:
72
72
  key: windows-deps-${{ hashFiles('python/ci/install_deps_windows.ps1') }}
73
73
  - uses: pypa/cibuildwheel@v4.2.1
74
74
  env:
75
- # The oldest macOS the wheel runs on. It must not be older than the Homebrew libraries delocate bundles,
76
- # 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.
77
77
  MACOSX_DEPLOYMENT_TARGET: ${{ matrix.macos_deployment_target }}
78
78
  - name: Check Windows libraries
79
79
  id: windows_deps_check
@@ -86,10 +86,13 @@ jobs:
86
86
  with:
87
87
  path: C:\gpflash_deps
88
88
  key: windows-deps-${{ hashFiles('python/ci/install_deps_windows.ps1') }}
89
+ # Kept only for the publish job below, which runs within the hour; a private repository is billed for the
90
+ # storage of every artifact it keeps.
89
91
  - uses: actions/upload-artifact@v7.0.1
90
92
  with:
91
93
  name: wheels-${{ matrix.os }}
92
94
  path: ./wheelhouse/*.whl
95
+ retention-days: 3
93
96
 
94
97
  build_sdist:
95
98
  name: Source distribution
@@ -105,6 +108,7 @@ jobs:
105
108
  with:
106
109
  name: sdist
107
110
  path: dist/*.tar.gz
111
+ retention-days: 3
108
112
 
109
113
  publish_pypi:
110
114
  name: Publish to PyPI
@@ -0,0 +1,140 @@
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.4.0 (2026-12-06)
7
+
8
+ ### Changed
9
+
10
+ - `TrainingData::f_train_vec` is `f_val_train_vec`. **Python:** `TrainingData.f_val_train_vec`, and the
11
+ `f_val_train_vec` argument of `GaussianProcess.fit`, `eval_mll`, `make_posterior` and `load_posterior_verified`. The
12
+ naming rules are in [`NAMING_CONVENTIONS.md`](NAMING_CONVENTIONS.md).
13
+ - `PosteriorOptions::check_query_points` is `check_query_finite`, since it gates only the finiteness check.
14
+ **Python:** the same field, and the `check_query_finite` argument of `GaussianProcess.predict`.
15
+ - `MultistartResult::mll()` is replaced by `best_objective_val()`, the lowest objective, since with priors the
16
+ objective is not the MLL. The sign flips: where `mll()` was used, use `-best_objective_val()`.
17
+ - The condition number of the matrix factorized is now at most `cond_max` for every kernel. Before, that held only
18
+ without noise or where every `k(x, x)` is 1. Where `K`'s diagonal varies, the noise is now preconditioned with `K`,
19
+ so `Sigma` carries `(1 + eta) V`, which changes the posterior of a noisy `Linear`, `Quadratic` or symmetry model.
20
+ - Faster fits and queries:
21
+ - A fit reuses a value-only evaluation's factorization when the gradient is then asked for at the same point.
22
+ - A large batch query's cross-covariance runs on every thread.
23
+ - A batch asking for the mean without the variance no longer forms the cross-covariance.
24
+ - With GCC on x86-64 Linux, the kernel loops, which fits and queries both use, are also compiled for AVX2 and
25
+ AVX-512, and the widest the CPU has is chosen at load time. `GPFLASH_NO_SIMD_CLONES` keeps one version.
26
+
27
+ ### Added
28
+
29
+ - **Posterior:**
30
+ - The joint posterior of groups of query points, and the gradient of any scalar function of it:
31
+ `GpPosterior::eval_joint_post`. Points that all groups, or a run of groups, share are evaluated once, and the
32
+ covariances can be returned in blocks (`JointPosteriorOptions::return_cov_blocks`).
33
+ - Joint samples: `GpPosterior::calc_sample_post_mat` and `calc_sample_post_cube`. The same seed gives the same
34
+ standard normals on every platform, so the samples agree up to rounding.
35
+ - The mean model variance, as in universal Kriging: `include_mean_model_var` in `PosteriorOptions` and
36
+ `JointPosteriorOptions`.
37
+ - Conditioning on new observations without factorizing again, in `O(n_train^2 m)`:
38
+ `GpPosterior::condition_on_observations`. `PosteriorBuildOptions::n_post_cond_obs_max` reserves room for them.
39
+ - **Training data:** a known noise variance for each point, `TrainingData::sig2_f_val_vec`.
40
+ - **Fit:**
41
+ - Log-normal, gamma, half-Cauchy and normal priors on the length scales and the variances
42
+ (`OptzOptions::hp_gamma_prior` and the others).
43
+ - A given start (`OptzOptions::hp_val_init_struct`), the best of sampled starts (`n_sampled_start_candidate`), and
44
+ fixed hyperparameters (`hp_sig2_k_fixed`, `hp_gamma_fixed_vec`, `hp_kern_extra_fixed_vec`).
45
+ - Fit and posterior results report the nuggets used, `kmat_eta` and `mean_model_eta`. Fit results also report
46
+ `ln_det_sigma`, the mean model weights and the log prior.
47
+ - **Cache:** format 1.1, which stores what these features need. A file of format 1.0 still loads, except one of a noisy
48
+ `Linear`, `Quadratic` or symmetry model: refit and save it again.
49
+ - **Python:**
50
+ - The features above under the same names, with per-point noise as an array `sig2_f_val`, and
51
+ `GaussianProcess.sample_post`.
52
+ - `gpflash.torch`: the posterior and the MLL as torch tensors, with GpFlash's analytic gradients through autograd.
53
+ - `copy.copy` and `copy.deepcopy` for every value type.
54
+ - **Build and CI:** `GPFLASH_USE_HDF5=OFF` builds without the cache and HDF5, and `GPFLASH_ARMA_NO_DEBUG=OFF` leaves
55
+ `ARMA_NO_DEBUG` to the consumer. Continuous integration adds a Linux job for that build and one that runs the Python
56
+ tests with torch.
57
+
58
+ ### Fixed
59
+
60
+ - `save_precompute` raises when its last writes did not reach the disk, as on a full disk, and leaves the destination
61
+ as it was; it could replace it with an unreadable file. With HDF5 1.10 the check is not available.
62
+ - A cache file whose header names no kernel, holds a count too large for an `int`, or reserves more room than can be
63
+ allocated is refused with an error naming the field. A count past an `int` could wrap to a small one.
64
+ - **Python:** `ModelOptions.mean_model_degree_vec` refuses a fractional entry, which was truncated.
65
+
66
+ ## 0.3.1 (2026-11-05)
67
+
68
+ ### Fixed
69
+
70
+ - The cache calls (`peek_info`, `peek_kernel_id`, `save_precompute`, `load_posterior`, `load_posterior_verified` and
71
+ the `load_precompute` functions) may run on several threads at once: they hold one process-wide lock, so a second
72
+ call waits for the first, even on another file. HDF5 is not built thread-safe, and two calls that overlapped,
73
+ as Python threads could since the bindings release the GIL, could crash or corrupt its state.
74
+ - A query checks its points' row count even with `PosteriorOptions::check_query_points` cleared, which now skips only
75
+ the finiteness check. Before, clearing it let a point of the wrong dimension read out of bounds. A query that asks
76
+ for nothing now raises on a wrong row count too, rather than returning an empty result.
77
+ - **Python:** the macOS wheel links the OpenMP runtime statically and exports only the module's entry point, so it
78
+ runs in a process that has imported PyTorch, which loads its own copy of the runtime.
79
+
80
+ ### Changed
81
+
82
+ - The README and `core/Platform.hpp` say that GpFlash's declarations of glibc's vector `exp`, `log`, `pow`, `sin` and
83
+ `cos` apply to every call to them in a file that includes a GpFlash header, the caller's own included.
84
+
85
+ ## 0.3.0 (2026-10-18)
86
+
87
+ ### Changed
88
+
89
+ - **Python:** `GaussianProcess` now uses the C++ library's names, which breaks code written for 0.2.0:
90
+
91
+ | 0.2.0 | Now |
92
+ |---|---|
93
+ | `GaussianProcess(kernel=..., mean=..., n_starts=..., seed=...)`, `from_options` | `GaussianProcess(optz_opts)`, an `OptzOptions` whose fields carry the C++ names |
94
+ | `noise=...` in the constructor; `"estimate"` | `fit(..., sig2_f_val=...)`; a negative value estimates it |
95
+ | `predict(X)` returns arrays; `predict_gradient(X)` | `predict(X)` returns a `PosteriorPrediction`; flags select the mean, variance and gradients, and unrequested fields are `None` |
96
+ | `save` / `load`, `include_variance` | `save_precompute` / `load_posterior`, `include_variance_data` |
97
+ | `summary()`, `fit_result_`, `posterior_` | `to_summary_string()`, `mll_optz_result()`, `posterior()` |
98
+ | `hyperparameters_` (a dict), `log_marginal_likelihood_`, `kernel` | `hp_val_struct()` (an `HpVal`), `hp_beta_vec()`, `mll()`, `kernel_id()` |
99
+
100
+ - **Python:** `predict` returns the variance by default, as C++'s `PosteriorOptions` does.
101
+ - **Python:** points must be 2-D, `(n_points, n_dim)`; a 1-D array is no longer read as one point.
102
+ - **Python:** the wrapper's input checks raise `InvalidInputError`, as the C++ layer does.
103
+ - **Python:** the enums (`KernelId`, `OptzStopReason`, ...) are `enum.Enum` subclasses.
104
+
105
+ ### Added
106
+
107
+ - **Python:** `GaussianProcess.eval_mll`, `make_posterior`, `load_posterior_verified` and
108
+ `optz_opts()`. `HpVal`, `TrainingData`, `MllResult` and `PosteriorModelInfo` print their fields.
109
+ - Continuous integration: a weekly run of both workflows, and a ruff check of the Python files.
110
+
111
+ ## 0.2.0 (2026-10-17)
112
+
113
+ ### Added
114
+
115
+ - **Python package**, `pip install gpflash`, with wheels for Linux (x86_64, aarch64), macOS
116
+ (arm64, x86_64) and Windows (x64) on Python 3.11 to 3.14, every dependency included. It offers
117
+ a NumPy-style `GaussianProcess` (`fit`, `predict`, `predict_gradient`, `save`, `load`) and the
118
+ C++ interface under its C++ names. See [`python/README.md`](python/README.md).
119
+ - CMake option `GPFLASH_BUILD_PYTHON`, off by default, to build the Python module.
120
+ - Citation information for the GpFlash paper, [arXiv:2610.16861](https://arxiv.org/abs/2610.16861):
121
+ `CITATION.cff`, which gives the repository a "Cite this repository" button, and a BibTeX
122
+ entry in [`python/README.md`](python/README.md).
123
+ - Continuous integration: the C++ tests on Linux and macOS, and the Python wheels on every
124
+ platform, after each push to `main`.
125
+
126
+ ### Fixed
127
+
128
+ - A cache save that fails part way, as on a full disk, no longer leaves its file open in HDF5. HDF5 1.10
129
+ cannot close it, and the process may crash as it exits.
130
+
131
+ ### Changed
132
+
133
+ - The version is set in one place, `include/gpflash/Version.hpp`; CMake and the Python package
134
+ read it from there.
135
+
136
+ ## 0.1.0 (2026-10-12)
137
+
138
+ First release: a header-only C++14 library for exact Gaussian process regression, with the
139
+ marginal log likelihood and its analytic hyperparameter gradients, hyperparameter fitting
140
+ through NLopt, posterior mean and variance with their gradients, and an HDF5 posterior cache.
@@ -43,7 +43,7 @@ endif()
43
43
  # ARMA_USE_BLAS and ARMA_USE_LAPACK let Armadillo's own operations call the same library.
44
44
  # ARMA_DONT_USE_FORTRAN_HIDDEN_ARGS stays off: BlasLapack.hpp follows Armadillo's hidden-length setting, and a
45
45
  # gfortran-built LAPACK needs the lengths (GCC bug 90329).
46
- # ARMA_NO_DEBUG drops Armadillo's bounds checks; the library's own checks guard what reaches its loops.
46
+ # ARMA_NO_DEBUG drops Armadillo's bounds checks; the library's own checks guard what reaches its loops. Optional, below.
47
47
  # ARMA_USE_HDF5 selects the save path posterior_cache/ needs; a consumer compiling without it would get a different
48
48
  # one that does not work.
49
49
  # ARMA_64BIT_WORD is Armadillo's default on a 64-bit target, stated because an n_train by n_train buffer passes 2^31
@@ -51,12 +51,26 @@ endif()
51
51
  # The target's INTERFACE definitions below hand every one to consumers.
52
52
  set(GPFLASH_ARMA_DEFS
53
53
  ARMA_DONT_USE_WRAPPER
54
- ARMA_NO_DEBUG
55
54
  ARMA_USE_BLAS
56
55
  ARMA_USE_LAPACK
57
- ARMA_USE_HDF5
58
56
  ARMA_64BIT_WORD)
59
57
 
58
+ # OFF leaves ARMA_NO_DEBUG to the consumer, so its Debug builds can keep Armadillo's checks, at some cost in speed.
59
+ option(GPFLASH_ARMA_NO_DEBUG "Define ARMA_NO_DEBUG for every consumer" ON)
60
+ if(GPFLASH_ARMA_NO_DEBUG)
61
+ list(APPEND GPFLASH_ARMA_DEFS ARMA_NO_DEBUG)
62
+ endif()
63
+
64
+ # The posterior cache, which saves and loads a posterior, is the one part that needs HDF5. OFF leaves both out:
65
+ # save_precompute, load_posterior and load_posterior_verified do not exist (GPFLASH_HAVE_POSTERIOR_CACHE=0). The
66
+ # Python module needs the cache.
67
+ option(GPFLASH_USE_HDF5 "Build the posterior cache, which needs HDF5" ON)
68
+ if(GPFLASH_USE_HDF5)
69
+ list(APPEND GPFLASH_ARMA_DEFS ARMA_USE_HDF5)
70
+ else()
71
+ list(APPEND GPFLASH_ARMA_DEFS GPFLASH_HAVE_POSTERIOR_CACHE=0)
72
+ endif()
73
+
60
74
  # Platform.hpp's probe, decided here where the vendor is known; "All" leaves it to the header. Apple and NAS are
61
75
  # FindBLAS's names for Accelerate.
62
76
  if(GPFLASH_BLA_VENDOR MATCHES "^(Apple|NAS)$")
@@ -90,8 +104,10 @@ target_link_libraries(GpFlash INTERFACE
90
104
  OpenMP::OpenMP_CXX
91
105
  LAPACK::LAPACK
92
106
  BLAS::BLAS
93
- GpFlash::HDF5
94
107
  GpFlash::NLopt)
108
+ if(GPFLASH_USE_HDF5)
109
+ target_link_libraries(GpFlash INTERFACE GpFlash::HDF5)
110
+ endif()
95
111
 
96
112
  install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} FILES_MATCHING PATTERN "*.hpp")
97
113
  install(FILES LICENSE NOTICE THIRD-PARTY-NOTICES DESTINATION ${CMAKE_INSTALL_DOCDIR})
@@ -119,6 +135,9 @@ install(FILES
119
135
  # defines SKBUILD, or on request. A C++ consumer never needs Python.
120
136
  option(GPFLASH_BUILD_PYTHON "Build the Python module gpflash._core" OFF)
121
137
  if(GPFLASH_BUILD_PYTHON OR DEFINED SKBUILD)
138
+ if(NOT GPFLASH_USE_HDF5)
139
+ message(FATAL_ERROR "GpFlash: the Python module needs the posterior cache; set GPFLASH_USE_HDF5=ON.")
140
+ endif()
122
141
  add_subdirectory(python)
123
142
  endif()
124
143
 
@@ -0,0 +1,151 @@
1
+ # GpFlash naming conventions
2
+
3
+ The C++ library's names follow these rules, so a name says what a value is and its shape. The Python package uses the
4
+ same words, but its arrays hold one point per row, as NumPy and PyTorch do, and their names omit the shape:
5
+ `X_train_mat` is `(n_train, n_dim)`.
6
+
7
+ ## Case
8
+
9
+ - Types and enum values are PascalCase: `TrainingData`, `NoiseRequest::NoiseFree`.
10
+ - Functions and variables are snake_case.
11
+ - Macros are upper case with the `GPFLASH_` prefix: `GPFLASH_CHECK`.
12
+ - Constants are upper case: `MEAN_MODEL_DEGREE_MAX`. The cache file layout is the exception: its format version and
13
+ slot indices (`cache_format_version`, `slot_n_dim`) are lower case, as positions in a file.
14
+ - A matrix named after its math symbol keeps the symbol's capital: `X`, `K`, `L`, `Sigma`, `Basis`. Inside a longer
15
+ name, `Sigma` and `Psi` are lower case: `lin_sol_sigma_residual_vec`, `psi_diag_vec`.
16
+ - A class's private members end in `_`: `post_precompute_`. Internal functions and structs are in a `detail` namespace.
17
+ - In the tests, constants are `kName`.
18
+
19
+ ## Words
20
+
21
+ A word means one thing wherever it appears, and a quantity the library already names keeps that name. Use a word from
22
+ this file or plain English; do not coin one.
23
+
24
+ - `f` is the target function, the function a model is fitted to, and `f_val` its value: `f_val_train_vec`. Write
25
+ "target function" in full: a bare "target" can be a CMake or hardware target.
26
+ - The objective is what the optimizer minimizes: the negative MLL, or with priors, the negative of the MLL plus the log
27
+ prior.
28
+ - Name every gradient: the MLL gradient (with respect to the hyperparameters), the posterior gradient (the query points)
29
+ or the objective's gradient (the optimizer's search variables).
30
+ - `train` marks training points and what is observed there, `post` posterior query points and outputs:
31
+ `X_ndim_ntrain_mat`, `mean_post_vec`.
32
+ - `var` is a variance computed from the model or the data: `var_post_vec`, `noise_var_vec`. A sigma squared in the model
33
+ equation is `sig2_` instead (below).
34
+ - Bare `data` is the training data (`train_data`), or what a cache file holds (`has_variance_data`).
35
+
36
+ ## Prefixes
37
+
38
+ | Prefix | For | Example |
39
+ |---|---|---|
40
+ | `n_` | a count | `n_train`, `n_hp` |
41
+ | `i_` | a loop index | `i_train` |
42
+ | `idx_` | a stored position, or a vector of them | `idx_best` |
43
+ | `hp_` | a hyperparameter, and what describes one | `hp_gamma_vec`, `hp_gamma_lb_vec` |
44
+ | `sig2_` | a sigma squared in the model equation `Sigma = hp_sig2_k (K + eta W) + V` | `sig2_f_val`, `hp_sig2_k` |
45
+ | `d_<numerator>_d_<denominator>` | a derivative | `d_mll_d_hp_gamma_vec` |
46
+ | `lin_sol_<A>_<b>` | the solve `A^-1 b` | `lin_sol_L_f_val_train_vec` is `L^-1 f_val_train` |
47
+
48
+ A function's name starts with a verb that says what it does or returns:
49
+
50
+ | Verb | Does or returns |
51
+ |---|---|
52
+ | `calc_` | a value |
53
+ | `build_`, `make_` | a struct |
54
+ | `eval_` | the MLL or the posterior at given inputs |
55
+ | `solve_` | a linear solve |
56
+ | `fill_`, or any verb with `_inplace` such as `add_` | writes an argument in place |
57
+ | `check_` | raises unless a precondition holds; returns nothing |
58
+ | `is_`, `has_` | a boolean |
59
+ | `to_` | a conversion |
60
+ | `parse_`, `classify_` | a name's enum value, a value's enum case |
61
+ | `select_` | one of its inputs |
62
+ | `save_`, `load_`, `peek_` | a file written, read, or its header read without the rest |
63
+
64
+ ## Suffixes
65
+
66
+ | Suffix | For | Example |
67
+ |---|---|---|
68
+ | `_vec`, `_mat`, `_cube` | a vector, a matrix, a 3-D array; also on a function that returns one | `calc_basis_mat` |
69
+ | `_lower` | a matrix of which only the lower triangle, diagonal included, is valid | `L_mat_lower` |
70
+ | `_val` | a number, where the name does not already read as one; mid-name, the value as opposed to its derivative | `objective_val`, `kern_diag_val_vec` |
71
+ | `_lb`, `_ub`, `_init` | a lower bound, an upper bound, a starting value | `hp_sig2_k_lb` |
72
+ | `_inner_prod`, `_sq_norm` | an inner product, a squared norm | `ydot_train_sq_norm_vec` |
73
+ | `_request` | what a noise variance asks for | `noise_request` |
74
+ | `_ptr` | a raw pointer into an array | `hp_kern_extra_ptr` |
75
+ | `_out` | an output argument | `grad_vec_out` |
76
+ | `_struct` | a struct whose bare name would read as a value | `hp_val_struct` |
77
+ | `_opts` | an options struct | `model_opts` |
78
+ | `_name`, `_str` | a name string, a formatted string | `field_name` |
79
+ | `_tensor` | a PyTorch tensor, in the Python package | `X_post_tensor` |
80
+ | `_ref` | a reference value to compare against, in the tests | `mean_ref_vec` |
81
+
82
+ ## Shapes
83
+
84
+ A matrix's or cube's name carries its shape, one count per dimension, each written without the underscore of its
85
+ `n_` count: `X_ndim_ntrain_mat` is `(n_dim, n_train)`, one point per column. A shape token names one count everywhere it
86
+ appears, so two counts never share one: a joint posterior group's `n_joint` points are `njoint`, and with its shared
87
+ points, `n_group_point` of them, `ngrouppoint`.
88
+
89
+ ## Index letters in comments
90
+
91
+ - `i` and `j` index training points, `a` and `b` the points of a kernel's pair sums, `p` query points.
92
+ - `d` indexes a dimension, as a subscript or in a sum: `hp_gamma_d`, `x_id`, `sum_d`. On its own, `d` is the derivative
93
+ operator: write `hp_gamma_d`, not "entry d".
94
+ - A chain rule built on `h^(r,l)` or `h^(gamma,l)` uses `l` and `m`, as the paper does, and `l` also indexes a
95
+ hyperparameter block. `m` is not a count, except in LAPACK's signatures.
96
+
97
+ ## Abbreviations
98
+
99
+ A name spells a word out unless it is listed here.
100
+
101
+ | Abbreviation | Meaning |
102
+ |---|---|
103
+ | `abs` | absolute |
104
+ | `chol` | Cholesky |
105
+ | `coef` | coefficient |
106
+ | `cond` | condition number (`cond_max`); in `n_cond_obs` and `n_post_cond_obs_max`, conditioning on observations |
107
+ | `corr` | correlation (the scaled matrix `Sigma_corr`) |
108
+ | `cov` | covariance |
109
+ | `diag` | diagonal |
110
+ | `diff` | difference |
111
+ | `dim` | dimension |
112
+ | `dist` | distance |
113
+ | `eig` | eigenvalue |
114
+ | `elem` | element |
115
+ | `fun` | function object: `kern_fun` |
116
+ | `grad` | gradient |
117
+ | `hp` | hyperparameter |
118
+ | `idx` | index |
119
+ | `ind` | independent (`n_ind_optz` independent optimizations) |
120
+ | `init` | starting value |
121
+ | `inv` | inverse |
122
+ | `kern`, `kmat` | kernel, kernel matrix |
123
+ | `lb`, `ub` | lower bound, upper bound |
124
+ | `len` | length |
125
+ | `lin_sol` | linear solve |
126
+ | `ln` | natural logarithm |
127
+ | `mll` | marginal log likelihood |
128
+ | `obj` | objective |
129
+ | `obs` | observation, a point a posterior is conditioned on after its build |
130
+ | `optz` | optimization |
131
+ | `opts` | options |
132
+ | `post` | posterior |
133
+ | `precon` | preconditioning |
134
+ | `prod` | product |
135
+ | `ptr` | pointer |
136
+ | `rel` | relative |
137
+ | `rhs` | right-hand side |
138
+ | `sig2` | a variance written as sigma squared |
139
+ | `sq` | squared |
140
+ | `stddev` | standard deviation |
141
+ | `str` | string |
142
+ | `sym` | symmetric |
143
+ | `tol` | tolerance |
144
+ | `val` | value |
145
+ | `var` | variance |
146
+
147
+ ## Symbols from the paper
148
+
149
+ Symbols from the model and the GpFlash paper keep their names: `gamma` the inverse length scales, `eta` a nugget, `beta`
150
+ the mean model weights, `rho` the rational quadratic shape, and `Psi`, `rdot` and `Ydot` as in the paper. The README's
151
+ "Model conventions" gives the covariance `Sigma` they build.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gpflash
3
- Version: 0.3.0
3
+ Version: 0.4.0
4
4
  Summary: Fast, exact Gaussian process regression: marginal log-likelihood with analytic gradients, hyperparameter fitting and posterior evaluation.
5
5
  Keywords: gaussian-process,kriging,surrogate-model,bayesian-optimization,machine-learning
6
6
  Author: André Marchildon
@@ -34,8 +34,8 @@ Description-Content-Type: text/markdown
34
34
 
35
35
  # GpFlash for Python
36
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
37
+ Fast, exact Gaussian process regression: the marginal log likelihood (MLL) with its analytic
38
+ MLL gradient, hyperparameter fitting, and posterior mean and variance. Python bindings
39
39
  to the header-only C++ library [GpFlash](https://github.com/marchildon/gpflash).
40
40
 
41
41
  ```
@@ -55,12 +55,12 @@ n_dim = 2
55
55
  n_train = 50
56
56
  n_post = 100
57
57
 
58
- # Training data: n_train points, one per row, and the function's values there.
58
+ # Training data: n_train points, one per row, and the target function's values there.
59
59
  rng = np.random.default_rng(0)
60
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
61
+ f_val_train_vec = np.sin(3 * X_train_mat[:, 0]) + X_train_mat[:, 1] ** 2
62
62
 
63
- gp = gpflash.GaussianProcess().fit(X_train_mat, f_train_vec) # the Matern 5/2 kernel and a constant mean
63
+ gp = gpflash.GaussianProcess().fit(X_train_mat, f_val_train_vec) # the Matern 5/2 kernel and a constant mean
64
64
 
65
65
  # The posterior mean and variance at n_post new points.
66
66
  X_post_mat = rng.random((n_post, n_dim))
@@ -84,8 +84,11 @@ optz_opts.model_options.kernel_id = gpflash.KernelId.RatQuad # or gpflash.parse
84
84
  optz_opts.model_options.mean_model_degree_vec = [1] # a linear mean model
85
85
  optz_opts.use_multistart = True # 5 optimizations, the best kept
86
86
  optz_opts.n_ind_optz = 5
87
+ optz_opts.hp_gamma_prior.kind = gpflash.HpPriorKind.LogNormal # no prior by default; with one, the fit
88
+ optz_opts.hp_gamma_prior.ln_mean = 0.0 # maximizes the MLL plus the log prior of the length scales
89
+ optz_opts.hp_gamma_prior.ln_stddev = 1.0
87
90
 
88
- gp = gpflash.GaussianProcess(optz_opts).fit(X_train_mat, f_train_vec, sig2_f_val=-1.0) # estimate the noise
91
+ gp = gpflash.GaussianProcess(optz_opts).fit(X_train_mat, f_val_train_vec, sig2_f_val=-1.0) # estimate the noise
89
92
  ```
90
93
 
91
94
  The [kernel table](https://github.com/marchildon/gpflash#kernels) lists the kernels.
@@ -100,26 +103,27 @@ and must be 2-D: a 1-D problem's points are `(n_points, 1)`, a single point is `
100
103
 
101
104
  | Method | Returns |
102
105
  |---|---|
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 |
106
+ | `fit(X_train_mat, f_val_train_vec, *, sig2_f_val=0.0, hp_val_init_struct=None, n_post_cond_obs_max=0)` | `self`. `sig2_f_val` is the noise variance on the values: `0.0` for noise-free data, a known variance > 0, a negative value to estimate it, or a 1-D array of known noise variances, one per point, each >= 0. `hp_val_init_struct`, such as a previous fit's `hp_val_struct()`, is where the first optimization starts. `n_post_cond_obs_max` leaves room in the posterior for that many observations `GpPosterior.condition_on_observations` may add |
107
+ | `predict(X_post_mat, *, return_mean=True, return_var=True, return_mean_gradient=False, return_var_gradient=False, include_mean_model_var=False, check_query_finite=True)` | 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. `include_mean_model_var` adds the uncertainty in the mean model weights to the variance, as universal Kriging does |
108
+ | `sample_post(X_post_mat, n_sample, *, seed=0, include_mean_model_var=False)` | `n_sample` joint samples of the target function at the points, `(n_post, n_sample)`, one column per sample; the same seed gives the same standard normals on every platform, so the samples agree up to rounding |
109
+ | `eval_mll(X_train_mat, f_val_train_vec, hp_val_struct, *, return_mll_gradient=False, sig2_f_val=0.0)` | The MLL at given hyperparameters, an `MllResult` |
110
+ | `make_posterior(X_train_mat, f_val_train_vec, hp_val_struct, *, sig2_f_val=0.0, n_post_cond_obs_max=0)` | `self`, with a posterior at given hyperparameters, without fitting |
107
111
  | `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
112
  | `posterior()`, `mll_optz_result()` | The `GpPosterior` that `predict` evaluates, and the fit's `MllOptzResult`, for the C++ interface below |
109
113
  | `to_summary_string()` | A short report of the fit |
110
114
  | `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 |
115
+ | `load_posterior_verified(path, X_train_mat, f_val_train_vec, hp_val_struct, *, sig2_f_val=0.0, n_post_cond_obs_max=0)` | `self`, loaded from a file only if these data, hyperparameters and `n_post_cond_obs_max` produced it |
112
116
 
113
117
  Invalid inputs raise `gpflash.InvalidInputError`, a
114
118
  `ValueError`, from either layer.
115
119
 
116
- A noise-free fit adds a small nugget, sized from `ModelOptions.cond_max`, so the factorization is
120
+ A noise-free fit adds a small nugget to the kernel matrix's diagonal, sized from `ModelOptions.cond_max`, so the factorization is
117
121
  always well conditioned; predictions at the training points then match the data closely rather
118
122
  than exactly.
119
123
 
120
124
  ## The C++ interface
121
125
 
122
- Everything in the C++ library is also available under its C++ names: `TrainingData`, `HpVal`,
126
+ The C++ library's interface is also available under its C++ names: `TrainingData`, `HpVal`,
123
127
  `ModelOptions`, `OptzOptions`, `eval_mll`, `select_hp_with_max_mll`, `make_posterior`,
124
128
  `GpPosterior`, `load_posterior` and the rest, so the
125
129
  [C++ README](https://github.com/marchildon/gpflash#readme) documents this layer too. It keeps the
@@ -129,7 +133,7 @@ C++ shapes: points are columns, so `TrainingData.X_ndim_ntrain_mat` is `(n_dim,
129
133
  # The quick start's training data, transposed to the C++ layout.
130
134
  train_data = gpflash.TrainingData()
131
135
  train_data.X_ndim_ntrain_mat = X_train_mat.T # (n_dim, n_train)
132
- train_data.f_train_vec = f_train_vec
136
+ train_data.f_val_train_vec = f_val_train_vec
133
137
 
134
138
  hp_val_struct = gpflash.HpVal()
135
139
  hp_val_struct.hp_gamma_vec = [1.0, 1.0] # inverse length scales
@@ -158,15 +162,47 @@ record of the fit a posterior came from, and `calc_default_cache_path` names a f
158
162
  kernel and the training set's shape. Because `None` is a Python keyword, `SymmetryKind`'s
159
163
  no-symmetry value is `SymmetryKind.None_`.
160
164
 
161
- The one C++ feature the Python package leaves out is MPI: a fit runs in one process, using its
162
- cores through OpenMP.
165
+ The Python package leaves out MPI: a fit runs in one process, using its cores through OpenMP. Two
166
+ calls differ from C++: `GpPosterior.condition_on_observations` conditions in place unless
167
+ `keep_base_posterior` is set, and `GpPosterior.eval_joint_post` takes its shared points last.
168
+
169
+ `GpPosterior.eval_joint_post` gives each group's joint posterior, and
170
+ `GpPosterior.condition_on_observations(obs_data)` conditions a posterior on more observations at its
171
+ hyperparameters, in place unless `keep_base_posterior=True`.
172
+
173
+ ## `gpflash.torch`
174
+
175
+ `gpflash.torch` runs GpFlash's posterior and marginal log likelihood on torch tensors, with GpFlash's
176
+ analytic gradients passed to autograd. It needs torch (`pip install torch`); `import gpflash` does
177
+ not import it.
178
+
179
+ ```python
180
+ import torch
181
+ import gpflash.torch
182
+
183
+ X_post_tensor = torch.rand(100, 2, dtype=torch.float64, requires_grad=True)
184
+ mean_tensor, var_tensor = gpflash.torch.eval_post(gp.posterior(), X_post_tensor)
185
+ var_tensor.sum().backward() # X_post_tensor.grad holds the gradient
186
+ ```
187
+
188
+ `eval_joint_post` and `eval_joint_post_blocks` give each group's joint posterior, the latter with its
189
+ covariances in blocks, and `eval_mll` the MLL at hyperparameter tensors, differentiable in each, for
190
+ a fit or a sampler in torch. The three posterior functions take `include_mean_model_var`, as `predict` does, and
191
+ `eval_post(..., return_var=False)` skips the variance. They take float64 tensors, skip gradient work
192
+ under `torch.no_grad()`, refuse a second derivative, and do not support `torch.func`'s transforms.
163
193
 
164
194
  ## Threads
165
195
 
166
196
  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.
197
+ meanwhile. The cache calls (`peek_info`, `peek_kernel_id`, `load_posterior`,
198
+ `load_posterior_verified`, `GpPosterior.save_precompute` and the `GaussianProcess` methods that call
199
+ them) read and write HDF5, which is not built thread-safe, so GpFlash runs them one at a time: a
200
+ second cache call waits for the first, even on another file. Conditioning a posterior in place waits
201
+ for running queries of any posterior to finish, and queries started meanwhile wait for it.
202
+ `OMP_NUM_THREADS` sets the thread count. On macOS the module carries its own OpenMP runtime, linked
203
+ in and hidden, so it loads beside another library's, such as PyTorch's. Two runtimes in one process
204
+ can still slow each other down when both run threads at once; if that happens, set
205
+ `OMP_NUM_THREADS`.
170
206
 
171
207
  ## Building from source
172
208
 
@@ -183,7 +219,9 @@ pytest python/tests
183
219
  `ruff check .` and `ruff format .`, with the version `.github/workflows/ci.yml` pins, keep the Python
184
220
  files and the READMEs' Python blocks in the style CI checks. After changing `python/src/bindings.cpp`, regenerate the type stubs with
185
221
  `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.
222
+ `__version__` line it writes to `__version__: str`, so the stub carries no copy of the version, and the
223
+ return type of `GpPosterior.condition_on_observations` from `typing.Any` to `GpPosterior`. Then run
224
+ `ruff check --fix` and `ruff format` on it, and wrap any docstring line `ruff check` still reports as too long.
187
225
 
188
226
  ## Citing
189
227