From e111943a106e08b33931f10e8a9b0d8d86d7c478 Mon Sep 17 00:00:00 2001 From: peter Date: Sun, 13 Sep 2026 14:27:51 +0100 Subject: [PATCH 1/9] Support newer gpjax - Support gpjax>=0.14, drop support for earlier gpjax - Drop support for Python-3.10 --- .github/workflows/quality-checks.yaml | 2 +- docs/index.rst | 2 +- geometric_kernels/frontends/gpjax.py | 71 ++++++++++++++------------- notebooks/frontends/GPJax.ipynb | 5 +- pyproject.toml | 6 +-- 5 files changed, 43 insertions(+), 43 deletions(-) diff --git a/.github/workflows/quality-checks.yaml b/.github/workflows/quality-checks.yaml index 7c787550..d1c391f2 100644 --- a/.github/workflows/quality-checks.yaml +++ b/.github/workflows/quality-checks.yaml @@ -16,7 +16,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, macos-latest, windows-latest] - python-version: ["3.10", "3.11", "3.12"] + python-version: ["3.11", "3.12"] fail-fast: false runs-on: ${{ matrix.os }} diff --git a/docs/index.rst b/docs/index.rst index 139543ab..61d73ae1 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -203,7 +203,7 @@ To install JAX, follow `these instructions =0.14.0" .. raw:: html diff --git a/geometric_kernels/frontends/gpjax.py b/geometric_kernels/frontends/gpjax.py index 287534d5..c6ccb00c 100644 --- a/geometric_kernels/frontends/gpjax.py +++ b/geometric_kernels/frontends/gpjax.py @@ -6,14 +6,12 @@ :doc:`frontends/GPJax.ipynb ` notebook. """ -from dataclasses import dataclass - +import equinox as eqx import gpjax import jax.numpy as jnp +import lineax as lx +import paramax from beartype.typing import List, TypeVar, Union -from flax import nnx -from gpjax.kernels.computations.base import AbstractKernelComputation -from gpjax.linalg import Diagonal, psd from gpjax.parameters import NonNegativeReal, PositiveReal from gpjax.typing import Array, ScalarFloat from jaxtyping import Float, Num @@ -49,7 +47,8 @@ def cross_covariance( :return: The N x M covariance matrix. """ - nu_value = kernel.nu.value if kernel.trainable_nu else kernel.nu + kernel = paramax.unwrap(kernel) + nu_value = kernel.nu # Ensure inputs have `ndim` > 1. GPJax may squeeze shape `(1, 1)` into # `(1,)` which causes issues when passing to the base kernel. @@ -58,13 +57,13 @@ def cross_covariance( if y.ndim == 1: y = y[:, jnp.newaxis] - return kernel.variance.value * kernel.base_kernel.K( - {"lengthscale": kernel.lengthscale.value, "nu": nu_value}, x, y + return kernel.variance * kernel.base_kernel.K( + {"lengthscale": kernel.lengthscale, "nu": nu_value}, x, y ) def diagonal( self, kernel: Kernel, x: Num[Array, "N #D1 D2"] # noqa: F821 - ) -> Diagonal: + ) -> lx.AbstractLinearOperator: """ Compute the diagonal of the covariance matrix `K(x, x)` where `x` is a batch of vectors (or a batch of matrices) of inputs. @@ -79,24 +78,25 @@ def diagonal( Returns: The computed diagonal variance as a `Diagonal` linear operator. """ - nu_value = kernel.nu.value if kernel.trainable_nu else kernel.nu + kernel = paramax.unwrap(kernel) + nu_value = kernel.nu # Ensure inputs have `ndim` > 1. GPJax may squeeze shape `(1, 1)` into # `(1,)` which causes issues when passing to the base kernel. if x.ndim == 1: x = x[:, jnp.newaxis] - return psd( - Diagonal( - kernel.variance.value + return lx.TaggedLinearOperator( + lx.DiagonalLinearOperator( + kernel.variance * kernel.base_kernel.K_diag( - {"lengthscale": kernel.lengthscale.value, "nu": nu_value}, x + {"lengthscale": kernel.lengthscale, "nu": nu_value}, x ) - ) + ), + lx.positive_semidefinite_tag, ) -@dataclass class GPJaxGeometricKernel(gpjax.kernels.AbstractKernel): r""" GPJax wrapper for :class:`~.kernels.BaseGeometricKernel`. @@ -108,9 +108,8 @@ class GPJaxGeometricKernel(gpjax.kernels.AbstractKernel): .. note:: Remember that the `base_kernel` itself does not store any of its hyperparameters (like `lengthscale` and `nu`). If you do not set them - manually—when initializing the object or after, by setting the - properties—this wrapper will use the values provided by - `base_kernel.init_params`. + manually when initializing the object, this wrapper will use the values + provided by `base_kernel.init_params`. :param base_kernel: The kernel to wrap. @@ -135,29 +134,31 @@ class GPJaxGeometricKernel(gpjax.kernels.AbstractKernel): Defaults to False. """ - nu: Union[ScalarFloat, nnx.Variable[ScalarFloat], None] - lengthscale: nnx.Variable[Union[ScalarFloat, Float[Array, " D"]]] - variance: nnx.Variable[ScalarFloat] + nu: paramax.AbstractUnwrappable + lengthscale: paramax.AbstractUnwrappable + variance: paramax.AbstractUnwrappable - base_kernel: BaseGeometricKernel - compute_engine: AbstractKernelComputation = _GeometricKernelComputation() - name: str = "Geometric Kernel" + base_kernel: BaseGeometricKernel = eqx.field(static=True) + trainable_nu: bool = eqx.field(static=True) + name: str = eqx.field(static=True, default="Geometric Kernel") def __init__( self, base_kernel: BaseGeometricKernel, lengthscale: Union[ Union[ScalarFloat, Float[Array, " D"]], - nnx.Variable[Union[ScalarFloat, Float[Array, " D"]]], + paramax.AbstractUnwrappable, None, ] = None, - nu: Union[ScalarFloat, nnx.Variable[ScalarFloat], None] = None, - variance: Union[ScalarFloat, nnx.Variable[ScalarFloat]] = 1.0, + nu: Union[ScalarFloat, paramax.AbstractUnwrappable, None] = None, + variance: Union[ScalarFloat, paramax.AbstractUnwrappable] = 1.0, trainable_nu: bool = False, ): - active_dims = None - n_dims = None - super().__init__(active_dims, n_dims, self.compute_engine) + # Initialise inherited fields directly: Equinox freezes the module when + # a parent constructor returns. + self.active_dims = slice(None) + self.n_dims = None + self.compute_engine = _GeometricKernelComputation() self.base_kernel = base_kernel default_params = self.base_kernel.init_params() @@ -167,20 +168,20 @@ def __init__( if nu is None: nu = jnp.array(default_params["nu"]) - if isinstance(lengthscale, nnx.Variable): + if isinstance(lengthscale, paramax.AbstractUnwrappable): self.lengthscale = lengthscale else: self.lengthscale = PositiveReal(lengthscale) self.trainable_nu = trainable_nu if not trainable_nu: - self.nu = nu - elif isinstance(nu, nnx.Variable): + self.nu = paramax.non_trainable(jnp.asarray(paramax.unwrap(nu))) + elif isinstance(nu, paramax.AbstractUnwrappable): self.nu = nu else: self.nu = PositiveReal(nu) - if isinstance(variance, nnx.Variable): + if isinstance(variance, paramax.AbstractUnwrappable): self.variance = variance else: self.variance = NonNegativeReal(variance) diff --git a/notebooks/frontends/GPJax.ipynb b/notebooks/frontends/GPJax.ipynb index a403bdb3..8a52d072 100644 --- a/notebooks/frontends/GPJax.ipynb +++ b/notebooks/frontends/GPJax.ipynb @@ -26,7 +26,7 @@ "\n", "This notebooks shows how to fit a [GPJax](https://jaxgaussianprocesses.com/) Gaussian process (GP) on a mesh.\n", "\n", - "This notebook is written for GPJax>=0.12.2 (Python-3.10) and GPJax<=0.13.2 (Python-3.11). GPJax is in active development and changes API frequently. We strive to support the most recent version of it, so the notebook will not work on the older versions." + "This notebook is written for GPJax>=0.14.0. GPJax is in active development and changes API frequently. We strive to support the most recent version of it, so the notebook will not work on the older versions." ] }, { @@ -463,7 +463,7 @@ } ], "source": [ - "mll = jax.jit(mll, static_argnums=(0,))\n", + "mll = gpx.objectives.conjugate_mll\n", "\n", "print(\"Starting training...\")\n", "opt_posterior, history = gpx.fit(\n", @@ -472,7 +472,6 @@ " train_data=data,\n", " optim=optax.sgd(0.01),\n", " key=key,\n", - " trainable=gpx.parameters.Parameter,\n", ")\n", "print(\"Final model:\")\n", "print(\"kernel.nu =\", opt_posterior.prior.kernel.nu)\n", diff --git a/pyproject.toml b/pyproject.toml index 564c0502..cf2d7a24 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,7 +20,7 @@ classifiers = [ keywords=[ "geometric-kernels", ] -requires-python = ">=3.10" +requires-python = ">=3.11" dependencies = [ "backends>=1.8.0", "einops", @@ -57,7 +57,7 @@ allow_redefinition = true [tool.black] line-length = 88 -target-version = ['py310', 'py311', 'py312'] +target-version = ['py311', 'py312'] [tool.uv] @@ -104,6 +104,6 @@ dev = [ 'jaxlib', 'jaxtyping', 'optax', - 'gpjax>=0.12.2', + 'gpjax>=0.14.0', 'orbax-checkpoint==0.11.32; platform_system == "Windows"', # newer version depends on uvloop, unavailable in windows ] From c48eae719e7c1424347db25b2422f6cfdab4e966 Mon Sep 17 00:00:00 2001 From: peter Date: Sun, 13 Sep 2026 14:32:37 +0100 Subject: [PATCH 2/9] Support Python 3.13 --- .github/workflows/quality-checks.yaml | 2 +- pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/quality-checks.yaml b/.github/workflows/quality-checks.yaml index d1c391f2..25e07e9f 100644 --- a/.github/workflows/quality-checks.yaml +++ b/.github/workflows/quality-checks.yaml @@ -16,7 +16,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, macos-latest, windows-latest] - python-version: ["3.11", "3.12"] + python-version: ["3.11", "3.12", "3.13"] fail-fast: false runs-on: ${{ matrix.os }} diff --git a/pyproject.toml b/pyproject.toml index cf2d7a24..f4fb97a0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,7 +20,7 @@ classifiers = [ keywords=[ "geometric-kernels", ] -requires-python = ">=3.11" +requires-python = ">=3.11,<3.14" dependencies = [ "backends>=1.8.0", "einops", From 5c69b6f044dc9692d4b25fdf9372f8b81c4749f9 Mon Sep 17 00:00:00 2001 From: peter Date: Sun, 13 Sep 2026 14:51:53 +0100 Subject: [PATCH 3/9] Support gpflow>=2.10.1 --- pyproject.toml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index f4fb97a0..2949ced4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -62,6 +62,10 @@ target-version = ['py311', 'py312'] [tool.uv] default-groups = [] +# GPflow still declares NumPy <2 and the obsolete Apple Silicon TF package. +# tensorflow supplies macOS wheels directly. +override-dependencies = ["numpy>=2.0,<2.4"] +exclude-dependencies = ["tensorflow-macos"] [dependency-groups] dev = [ @@ -94,10 +98,10 @@ dev = [ "botorch>=0.9", # TensorFlow / GPflow / TFP split - 'tensorflow<=2.20.0', - 'tensorflow-probability<=0.25.0', - 'gpflow', - 'tf_keras<=2.20.1', + 'tensorflow>=2.20.0,<2.21', + 'tensorflow-probability>=0.25.0,<0.26', + 'gpflow>=2.10.1', + 'tf_keras>=2.20.1,<2.21', # JAX family 'jax', From b2d1a93dde11ed2412804e89e09638d1a52f599b Mon Sep 17 00:00:00 2001 From: peter Date: Sun, 13 Sep 2026 15:06:31 +0100 Subject: [PATCH 4/9] Update uv version in CI --- .github/workflows/code-style.yaml | 2 +- .github/workflows/docs.yaml | 2 +- .github/workflows/quality-checks.yaml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/code-style.yaml b/.github/workflows/code-style.yaml index 2ef049e4..24b89304 100644 --- a/.github/workflows/code-style.yaml +++ b/.github/workflows/code-style.yaml @@ -22,7 +22,7 @@ jobs: - name: Install uv uses: astral-sh/setup-uv@v6 with: - version: "0.9.6" + version: "0.11.23" #---------------------------------------------- # install #---------------------------------------------- diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index 1007d5bb..cfb0b464 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -16,7 +16,7 @@ jobs: - uses: actions/checkout@v4 - uses: astral-sh/setup-uv@v6 with: - version: "0.9.6" + version: "0.11.23" #---------------------------------------------- # install #---------------------------------------------- diff --git a/.github/workflows/quality-checks.yaml b/.github/workflows/quality-checks.yaml index 25e07e9f..ac0b161c 100644 --- a/.github/workflows/quality-checks.yaml +++ b/.github/workflows/quality-checks.yaml @@ -30,7 +30,7 @@ jobs: - name: Install uv uses: astral-sh/setup-uv@v6 with: - version: "0.9.6" + version: "0.11.23" - name: Install make if: runner.os == 'Windows' run: choco install make -y From a54b03ff0cc421a5600ec4b7e5326502d7a445de Mon Sep 17 00:00:00 2001 From: peter Date: Sun, 13 Sep 2026 20:56:31 +0100 Subject: [PATCH 5/9] Test gplfow notebook --- Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 6c3c2f5e..e3cd37b8 100644 --- a/Makefile +++ b/Makefile @@ -43,6 +43,5 @@ lint: sync test: sync ## Run the tests, start with the failing ones and break on first fail. @$(UV_RUN) pytest -v -x --ff -rN -Wignore -s --tb=short --durations=0 --cov --cov-report=xml --cov-report=html:coverage_html tests - # gpflow is ignored due to incompatibility with the recent setuptools - @$(UV_RUN) pytest --nbmake --nbmake-kernel=python3 --durations=0 --nbmake-timeout=1000 --ignore=notebooks/frontends/GPflow.ipynb notebooks/ + @$(UV_RUN) pytest --nbmake --nbmake-kernel=python3 --durations=0 --nbmake-timeout=1000 notebooks/ @echo -e "$(SUCCESS)Tests done$(RESET)" From a6e4de1d337b35d56cc672ded6f4e1568c320401 Mon Sep 17 00:00:00 2001 From: peter Date: Sun, 13 Sep 2026 20:57:17 +0100 Subject: [PATCH 6/9] Update black target version --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 2949ced4..94b767d9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -57,7 +57,7 @@ allow_redefinition = true [tool.black] line-length = 88 -target-version = ['py311', 'py312'] +target-version = ['py311', 'py312', 'py313'] [tool.uv] From 84729a75f9fc1d59bd6dd1e9b5532a152f2ba242 Mon Sep 17 00:00:00 2001 From: peter Date: Sun, 13 Sep 2026 22:28:10 +0100 Subject: [PATCH 7/9] Update black version --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 94b767d9..3bf9e8f9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -74,7 +74,7 @@ dev = [ "backends>=1.8.0", "plotly", "kaleido", - "black==24.3.0", + "black==24.10.0", "flake8==7.0.0", "isort==5.13.2", "autoflake", From bca6c34e29d70b84f14171d7fc8e014ade2b2c15 Mon Sep 17 00:00:00 2001 From: peter Date: Tue, 15 Sep 2026 21:20:28 +0100 Subject: [PATCH 8/9] Convert float parameters to jax arrays in the GPJax frontend --- geometric_kernels/frontends/gpjax.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/geometric_kernels/frontends/gpjax.py b/geometric_kernels/frontends/gpjax.py index c6ccb00c..94c11bf6 100644 --- a/geometric_kernels/frontends/gpjax.py +++ b/geometric_kernels/frontends/gpjax.py @@ -165,8 +165,12 @@ def __init__( if lengthscale is None: lengthscale = jnp.array(default_params["lengthscale"]) + if type(lengthscale) is float: + lengthscale = jnp.array([lengthscale]) if nu is None: nu = jnp.array(default_params["nu"]) + if type(nu) is float: + nu = jnp.array([nu]) if isinstance(lengthscale, paramax.AbstractUnwrappable): self.lengthscale = lengthscale From 94fc907351a276ffa473162ec40f8e15f22ef794 Mon Sep 17 00:00:00 2001 From: peter Date: Wed, 16 Sep 2026 13:22:50 +0100 Subject: [PATCH 9/9] Bump version --- CHANGELOG.md | 7 +++++++ pyproject.toml | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c83b7570..446c7939 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # CHANGELOG +## v1.0.1 - 16.09.2026 +Maintenance release (https://github.com/geometric-kernels/GeometricKernels/pull/177/). + * Compatibility with gpjax>=0.14.0 + * Compatibility with gpflow>=2.10.0 + * Add support for Python 3.13 + * Drop support for Python 3.10 + ## v1.0.0 - 10.03.2026 Stable release! diff --git a/pyproject.toml b/pyproject.toml index 3bf9e8f9..c06ee078 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -34,7 +34,7 @@ dependencies = [ "spherical-harmonics-basis", "sympy~=1.13", ] -version="1.0.0" +version="1.0.1" [project.urls] Documentation = "https://geometric-kernels.github.io/"