Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/code-style.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Install uv
uses: astral-sh/setup-uv@v6
with:
version: "0.9.6"
version: "0.11.23"
#----------------------------------------------
# install
#----------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
#----------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/quality-checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.10", "3.11", "3.12"]
Comment thread
vabor112 marked this conversation as resolved.
Resolved
python-version: ["3.11", "3.12", "3.13"]
fail-fast: false

runs-on: ${{ matrix.os }}
Expand All @@ -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
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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!

Expand Down
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Comment thread
stoprightthere marked this conversation as resolved.
Resolved
@echo -e "$(SUCCESS)Tests done$(RESET)"
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ To install JAX, follow `these instructions <https://github.com/google/jax#instal

.. code-block:: bash

pip install gpjax
pip install "gpjax>=0.14.0"

.. raw:: html

Expand Down
75 changes: 40 additions & 35 deletions geometric_kernels/frontends/gpjax.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@
:doc:`frontends/GPJax.ipynb </examples/frontends/GPJax>` 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
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand All @@ -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`.
Expand All @@ -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.
Expand All @@ -135,52 +134,58 @@ 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()

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, 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)))
Comment thread
vabor112 marked this conversation as resolved.
Resolved
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)
Expand Down
5 changes: 2 additions & 3 deletions notebooks/frontends/GPJax.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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."
]
},
{
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand Down
22 changes: 13 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ classifiers = [
keywords=[
"geometric-kernels",
]
requires-python = ">=3.10"
requires-python = ">=3.11,<3.14"
dependencies = [
"backends>=1.8.0",
"einops",
Expand All @@ -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/"
Expand All @@ -57,11 +57,15 @@ allow_redefinition = true

[tool.black]
line-length = 88
target-version = ['py310', 'py311', 'py312']
target-version = ['py311', 'py312', 'py313']


[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 = [
Expand All @@ -70,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",
Expand All @@ -94,16 +98,16 @@ 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',
'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
]
Loading