Skip to main content
gpex icon

gpex

Gaussian processes for experimental design in JAX.

CI Docs License

Documentation · Examples · Benchmarks

gpex conditions one latent Gaussian process on heterogeneous linear measurements, compiles their mixed covariance, and predicts new transformed views from the shared posterior.

gpex is a Gaussian-process library for experimental design and Bayesian optimization in JAX. Model a scalar function from noisy values, gradients, local averages, or other linear measurements, then predict the quantities needed for your next experiment. For example, infer gradients from function values or reconstruct a function from local averages.

  • Streaming inference: reserve capacity, reuse compiled functions, and update the posterior as observations arrive.
  • Differentiable queries: differentiate posterior predictions with respect to query locations and operator parameters to build your own design criteria.
  • Hyperparameter fitting: fit explicit trainable parameters by maximum likelihood (MLE) or maximum a posteriori (MAP) estimation.

The first version provides exact dense inference powered by cholops. You choose the acquisition strategy and experiment loop.

Status: gpex is alpha software. Its public API may change before a stable release.

Installation

gpex requires Python 3.12 or newer and JAX 0.11.2.

Install the released package from PyPI:

pip install gpex

Or install the latest development version from GitHub:

pip install "git+https://github.com/avrohr/gpex.git@main"

To run the tutorials locally, install uv, then clone the repository and install the optional notebook dependencies:

git clone https://github.com/avrohr/gpex.git
cd gpex
uv sync --extra examples
uv run jupyter lab docs/tutorials/first-posterior.ipynb

JAX selects the CPU backend by default. Follow the JAX installation guide when you need a platform-specific accelerator build.

Predict values and gradients

Suppose you have three noisy measurements of a function and want to know both its value and its slope between those measurements. Condition a GP on the observations, then ask for values and gradients together:

import jax
import jax.numpy as jnp

jax.config.update("jax_enable_x64", True)

import gpex as gpx

observations = gpx.FunctionalDataset([
    gpx.ObservationBlock.from_arrays(
        points=jnp.array([[-1.0], [0.0], [1.0]]),
        y=jnp.array([-0.8, 0.0, 0.8]),
        variance=0.01,
        name="values",
        max_size=32,
    )
])
gp = gpx.GaussianProcess(gpx.kernels.RBFKernel(variance=1.0, lengthscale=0.7))
posterior = gp.condition(observations)

x = jnp.linspace(-1.5, 1.5, 101)[:, None]
query = gpx.FunctionalQuery([
    gpx.FunctionalBlock(x, gpx.operators.Identity(), "value"),
    gpx.FunctionalBlock(x, gpx.operators.Gradient(), "gradient"),
])
prediction = posterior.predict_marginals(query)

value_mean = prediction.mean["value"]
gradient_mean = prediction.mean["gradient"]
value_variance = prediction.variance["value"]

Each named block describes a quantity to observe or predict. Here variance is the observation noise variance, and max_size=32 leaves room for later readings. We recommend enabling float64 before importing gpex and constructing arrays. Float32 is also supported, but mixed floating dtypes are unsupported.

The getting-started guide explains shapes and results. Built-in operators also cover integrals, averages, Laplacians, and wavelets. You can implement your own operator. Kernel smoothness determines which derivatives are supported.

The following examples build on the model and observations above.

Stream observations with fixed capacity

Sequential experiments add observations one at a time. Reserving capacity keeps array shapes fixed, so compiled functions can be reused as the dataset grows. Appending also updates the existing Cholesky factor and solved coefficients:

import equinox as eqx
from gpex.blocks import Locations

condition = eqx.filter_jit(gp.condition)
streamed_posterior = condition(observations)

@eqx.filter_jit
def update(posterior, points, values):
    return posterior.append(Locations(points), values, block="values")

streamed_posterior = update(
    streamed_posterior, jnp.array([[0.5]]), jnp.array([0.45])
)
streamed_posterior = update(
    streamed_posterior, jnp.array([[0.75]]), jnp.array([0.65])
)

The first call compiles each function. Further updates with the same batch shape and block reuse the compiled update within the reserved capacity. Model parameters and noise stay fixed during the sequence. After fitting new hyperparameters, recondition on the complete dataset.

Choose capacity for the planned experiment: unused slots still cost memory and computation. See streaming inference, reusable conditioning, and the benchmarks.

Differentiate queries for experimental design

Suppose you want to learn the gradient at a fixed point, but can only measure function values. Prepare that gradient target once, then move a proposed measurement to minimize the gradient variance that would remain afterward:

target = gpx.FunctionalQuery([
    gpx.FunctionalBlock(jnp.array([[0.25]]), gpx.operators.Gradient(), "gradient"),
])
prepared = gpx.PreparedQuery(posterior.conditioning, target)

def remaining_variance(point, prepared):
    experiment = gpx.ObservationDesignBlock(
        gpx.FunctionalBlock(point[None, :], gpx.operators.Identity(), "candidate"),
        variance=0.01,
        max_size=1,
    )
    return prepared.predict_variance_after(experiment)["gradient"].sum()

value_and_grad = eqx.filter_jit(jax.value_and_grad(remaining_variance))
point = jnp.array([0.5])
for _ in range(50):
    variance, spatial_gradient = value_and_grad(point, prepared)
    point = point - 0.05 * spatial_gradient

print("Proposed measurement location:", point)

This is a local gradient-descent search: lower remaining variance means greater uncertainty reduction at the fixed target. No measurement outcome is needed to evaluate a proposal. PreparedQuery caches the target calculations across proposals. After collecting a reading and updating the posterior, prepare the target again. See experimental design and the Bayesian optimization example for complete workflows.

Fit hyperparameters with MLE or MAP

Mark the quantities to learn with Parameter objects. Priors are declared alongside their parameters. Here we learn the kernel lengthscale while keeping the kernel variance and observation noise fixed:

from gpex import fitting, parameters, priors

trainable_gp = gpx.GaussianProcess(gpx.kernels.RBFKernel(
    variance=1.0,
    lengthscale=parameters.PositiveParameter(
        0.7,
        prior=priors.LogNormalPrior(log_mean=0.0, log_standard_deviation=0.5),
        name="lengthscale",
    ),
))
mle = fitting.fit_lbfgs(
    trainable_gp,
    lambda model: fitting.negative_log_marginal_likelihood(model, observations),
)
map_fit = fitting.fit_lbfgs(
    trainable_gp,
    lambda model: fitting.negative_log_posterior(model, observations),
)
fitted_posterior = map_fit.model.condition(observations)
print(mle.converged, map_fit.converged)

MLE uses the likelihood alone. MAP includes priors and requires one for every trainable parameter. Inspect convergence before using a fit. For Optax optimizers, multiple starts, and trainable observation noise, see fitting reference.

Learn more

  • Tutorial notebooks: mixed measurements, experimental design, sequential observations, fitting, and posterior paths.
  • Examples: additional fitting and compiled-inference workflows, plus a Bayesian optimization application.
  • API reference: public classes and operations.
  • JAX and observation capacity: compilation reuse, sequential updates, and memory costs.

Dense inference targets moderate observation counts. Nonlocal operators use numerical quadrature, and generic tensor-product rules become expensive as input dimension grows. See the operator overview for supported rules and limits.

Development and citation

See CONTRIBUTING.md for development checks and release procedures. If you use gpex in your research, please consider citing the software metadata in CITATION.cff.

gpex is available under the MIT license.

Metadata

Release files for gpex 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gpex 0.1.0
File Size Uploaded Provenance Actions
gpex-0.1.0.tar.gz 57.2 kB With provenance Details for gpex-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for gpex 0.1.0
File Interpreter ABI Platform Actions
gpex-0.1.0-py3-none-any.whl Python 3 none any Details for gpex-0.1.0-py3-none-any.whl

Total release size: 135.9 kB

Release files / gpex-0.1.0.tar.gz

Download URL gpex-0.1.0.tar.gz
Size 57.2 kB
Tags Source
SHA-256 checksum
How to use checksums
4ae05468a675c845f0b7163c3e910165fcda0f07fe0fea2142f75268ac012ea4
BLAKE2b-256 checksum
How to use checksums
55688a4f0644d05d691f35bf825c351a787c9a6d0c27ea2a6246d5d78ed899e6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 11, 2026.

Transparency log

Release files / gpex-0.1.0-py3-none-any.whl

Download URL gpex-0.1.0-py3-none-any.whl
Size 78.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c83ed12f02646691ffa4b6f3ab46b615facb30b8da970b0b32fd92b42ca91c79
BLAKE2b-256 checksum
How to use checksums
c45d6efd32b6cef94dfeb6edc779041392c0f97578e715fcee06e6d9247094d9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 11, 2026.

Transparency log

Security for gpex 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for gpex-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 11, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page