Thin NumPy-facing wrapper around the C++ GPc core. Optimisation and kernels stay in C++; this package is an ease-of-use boundary for GPy users (REQ-000E). Maintainer design notes: docs/python-facade.md (CIP-001D / CIP-002F).
Distribution name: gpc (import import gpc). No CMake / gfortran / system OpenBLAS required for a published wheel.
python3 -m venv .venv && source .venv/bin/activate
pip install gpc # from PyPI once published
# or, until the first PyPI release (pin a version that includes the features you need):
# pip install --no-cache-dir --index-url https://test.pypi.org/simple/ \
# --extra-index-url https://pypi.org/simple/ "gpc==0.1.0a11"
export OPENBLAS_NUM_THREADS=1
python -c "import gpc; print(gpc.__file__); print(gpc.__version__)"
# optional clean-venv checklist (from a repo checkout):
# python python/scripts/smoke_installed_gpc.pyColab / TestPyPI:
- Keep
--extra-index-url https://pypi.org/simple/so NumPy resolves from real PyPI (do not point both indexes at TestPyPI). - Use
--no-cache-dirafter a new TestPyPI upload: pip can keep a stale simple index and report only older alphas (e.g.from versions: 0.1.0a9while0.1.0a11is already published). 0.1.0a1(2026-11-19) is RBF/ExpQuad only;0.1.0a2addsmlp/arccosand the GPy-formgpc.kernsurface;0.1.0a3frees sparse inducing by default and adds optionallearn_window_widthfor weight-space;0.1.0a4adds CIP-0031predict/predict_noiselessand notebook teaching.0.1.0a5adds CIP-0032 per-unit weight-space window widths.0.1.0a6adds CIP-0036 GPClassification Laplace predict + GPy naming aliases / basic_classification notebook.0.1.0a7adds CIP-0038 GPy kern inventory and CIP-0039 GPLVM / BayesianGPLVM / MRD façades.0.1.0a8adds CIP-0035gpc.models.DeepGP(DSVI deep GP).0.1.0a9adds CIP-0035 DeepGP predict/V7 Jacobian and hidden-width fixes.0.1.0a10adds CIP-003Agpc.likelihoods, Kern.K/plot, and DeepGP wrap updates.0.1.0a11adds CIP-003Bgpc.inference(HMC hyperparameter sampling:set_prior/hmc).
macOS wheels from CI currently require a recent macOS (deployment target follows Homebrew bottle minOS on macos-15). Linux wheels are manylinux.
From the repository root (with make.inc configured — copy make.osx or make.linux):
python3 -m venv python/.venv
source python/.venv/bin/activate
pip install pybind11 numpy pytest
cd python && make && make testBuilds _gpc via the repo-root thin CMake (OpenBLAS + Fortran). Make remains the blessed native/CI path; this is the packaging-oriented path.
python3 -m venv python/.venv
source python/.venv/bin/activate
# Homebrew macOS: point CMake at OpenBLAS (and prefer g++/gfortran like make.osx).
export CMAKE_PREFIX_PATH="$(brew --prefix openblas)"
export CXX="$(/bin/ls "$(brew --prefix gcc)/bin"/g++-[0-9]* | sort -V | tail -1)"
export FC="$(/bin/ls "$(brew --prefix gcc)/bin"/gfortran-[0-9]* | sort -V | tail -1)"
pip install -e "python/[test]"
pytest -q python/testspython/Makefile stays supported for editable development without scikit-build.
GitHub Actions workflow .github/workflows/wheels.yml builds manylinux and macOS wheels with cibuildwheel (soft gate until soak). Config lives in this pyproject.toml under [tool.cibuildwheel].
- Linux:
auditwheelvendors OpenBLAS + libgfortran into the wheel. - macOS:
delocatevendors the same;MACOSX_DEPLOYMENT_TARGETis aligned to Homebrew bottleminOSon the runner (currentlymacos-15→ typically 15.x). Wheels are self-contained (no Homebrew at import). Lowering the macOS floor further needs rebuilding OpenBLAS/gfortran from source, not stock brew bottles. - CI checks:
python/scripts/check_native_deps.pypluspyteston the repaired wheel.
Windows wheels are Phase D (after CIP-002B).
Threading: for wheel installs set OPENBLAS_NUM_THREADS=1 (and avoid nesting with OpenMP; see CIP-001F / docs/build-and-ci.md) unless you have measured otherwise. CI wheel tests set this already.
Workflow .github/workflows/publish-wheels.yml:
| Trigger | Behaviour |
|---|---|
workflow_dispatch → artifacts-only |
Build + upload gpc-wheels artifact (no PyPI) |
workflow_dispatch → testpypi |
Build + OIDC publish to TestPyPI (environment: testpypi) |
workflow_dispatch → pypi or GitHub Release |
Build + OIDC publish to PyPI (environment: pypi); Release also attaches .whl assets |
One-time Trusted Publisher setup (preferred over API tokens):
- Create GitHub Environments
testpypiandpypi(optional reviewers / wait timer onpypi). - On TestPyPI / PyPI: Publishing → Trusted Publishers → add pending publisher for
SheffieldML/GPc, workflowpublish-wheels.yml, environmenttestpypiorpypi. - First successful publish creates the
gpcproject; re-run if the pending publisher was added after a failed attempt.
Dry-run without PyPI: Actions → Publish wheels → artifacts-only, then download gpc-wheels and pip install a .whl into a clean venv + smoke_installed_gpc.py.
Optional extras (not required for import gpc or core tests):
pip install matplotlib # gpc[plot]
pip install pods jupyter # notebooks / examples
# or: pip install -e "python/[plot,examples,test]"import numpy as np
import gpc
X = np.array([[1.0, 2.0], [3.0, 4.0]])
m = gpc.Matrix.from_numpy(X)
assert m.rows == 2 and m.cols == 2
np.testing.assert_allclose(m.to_numpy(), X)Public constructors and methods carry docstrings for normal Python tooling:
import gpc
help(gpc.GPRegression)
help(gpc.kern.RBF)
m = gpc.GPRegression(X, Y) # after you have X, Y
help(m.optimize)GPy → gpc porting narrative remains in docs/gpy_side_by_side.md (markdown, not a substitute for help()).
GPy-shaped form (preferred for porting):
import numpy as np
import gpc
X = np.linspace(0, 1, 20)[:, None]
Y = np.sin(2 * np.pi * X) + 0.05 * np.random.randn(20, 1)
k = gpc.kern.RBF(1) # CIP-0027: add Bias/White yourself if wanted; noise is likelihood.variance
m = gpc.models.GPRegression(X, Y, kernel=k)
m.set_by_path("rbf.lengthscale", 0.2)
m.optimize(iters=50)
mu, var = m.predict(X) # y_* (includes observation noise)
mu_f, var_f = m.predict_noiseless(X) # f_* (CIP-0031)Shorthand (CIP-0027): string kernels build signal-only compounds; observation noise is likelihood.variance (alias Gaussian_noise.variance). Bias/White are opt-in. Prefer noisy observations. objective() is −log-likelihood (SCG minimises it). plot_1d(..., noiseless=True) draws the latent band.
optimize(messages=True) shows a paramz-style live view in place: with ipywidgets (notebook / Colab) a progress bar + status + model HTML update like GPy; without widgets, a single Jupyter display_id cell; in a plain terminal, ANSI cursor rewrite. It does not stream C++ Iteration: / gradient-check dumps. Pass callback= for outer-iteration hooks. Install widgets via pip install ipywidgets or gpc[examples].
- GPy porting fragment:
docs/gpy_side_by_side.md - Tutorial map:
docs/subset_checklist.md - Native objective compare:
make testbuildsref_ftc_objective
GPy’s lengthscale-first squared exponential is ExpQuad. Pass kernel="eq" (aliases ExpQuad / expquad) so compound paths use ExpQuad.* instead of rbf.*:
m = gpc.GPRegression(X, Y, kernel="eq")
m.set_by_path("ExpQuad.lengthscale", 0.2)
m.optimize(iters=50)Runnable sketch: examples/expquad_regression.py. Same (K_of_r) as RBF; storage remains inverseWidth under the hood (docs/param-paths.md).
Williams infinite-MLP (arcsin), the ReLU covariance and Cho–Saul arc-cosine:
m = gpc.GPRegression(X, Y, kernel="mlp") # mlp.weight_variance, bias_variance, variance
m = gpc.GPRegression(X, Y, kernel="relu") # relu.weight_variance, bias_variance, variance
m = gpc.GPRegression(X, Y, kernel="arccos", arccos_order=0) # or 1gpc.kern.ReLU(d, ARD=True) is the ARD form. At unit parameters ReLU equals 0.5 * ArcCosine(order=1); the weight scale is absorbed by variance, so weight_variance and variance trade off. kernel="relu" is also accepted by SparseGPRegression (points, weightspace, hermite), GPLVM and DeepGP (per layer, including reluard). It has no psi statistics, so BayesianGPLVM (collapsed) refuses it with a typed error; use the SVI GP-LVM from the bgplvm CLI.
Defaults match GPy (weight_variance=bias_variance=variance=1). Large-magnitude inputs need an explicit scale (or standardised X); see examples/mlp_olympic.ipynb.
Z = np.linspace(0.05, 0.95, 8)[:, None]
m = gpc.SparseGPRegression(X, Y, Z) # approx="dtcvar" (default)
m = gpc.SparseGPRegression(X, Y, Z, approx="fitc") # also "dtc"
m = gpc.SparseGPRegression(X, Y, Z, kernel="mlp") # point inducing + MLP
# CIP-0028 weight-space ridges (MLP / ReLU / arccos; Z rows = M):
m = gpc.SparseGPRegression(
X, Y, Z, kernel="mlp", inducing="weightspace", window_width=0.55
)
m.optimize(iters=50)Inducing inputs Z (and weight-space ridge centres) are free by default (inducing_fixed=False, matching C++ CGp). Pass inducing_fixed=True to freeze a grid. For CIP-0028 ridges, free centres let the finite-(M) mean behave like a trainable bank of smoothed erf units. Global window width (s) defaults fixed; pass learn_window_width=True (with free inducing) to optimise a tied softness, or learn_window_widths=True / a length-(M) window_width array for per-unit (s_m) (CIP-0032). Whitened (s) is bounded to ([0.05,1]) (learned via a sigmoid map) so (K_{uu}) stays away from the (s=\sqrt2) singular regime. Weight-space compounds are one signal + optional white (no Bias); observation noise stays in (\beta). Tutorial recipes prefer DTCVAR; FITC and DTC are available for parity with the C++ API / bench.
m = gpc.models.DeepGP(X, Y, layers=2, hidden=1, num_inducing=10, chi=0.5)
m.optimize(iters=50, adam_lr=0.05, seed=1)
mu, var = m.predict(X)
m.save("deep.model")
m2 = gpc.models.DeepGP.load("deep.model")
# Probit / ordered finals: likelihood="probit" or "ordered"
# Finite-network bound: drop_residual=True (Nyström residual off)Runnable sketch: examples/deepgp_sinc.py. Native CLI: docs/tutorials/deepgp.md.
from gpc.plot import plot_1d # requires matplotlib
plot_1d(m, X, Y)Examples (GPy-tutorial inspired where noted):
examples/toy_1d_regression.ipynb— basic GP +predict/predict_noiselessexamples/sparse_gp_regression_1d.ipynb— GPysparse_GP_regression_1Dexamples/basic_kernels_compound.ipynb—kern.*compounds (CIP-0027 noise note)examples/expquad_regression.ipynb— GPyExpQuadpath namesexamples/olympic_marathon.ipynb— needspodsexamples/mlp_olympic.ipynb— RBF vs MLP (Phase F)examples/weightspace_ridge_1d.ipynb— points vs ridges (CIP-0028)
Native CLI/demos remain the primary share format (CIP-0015). Plotting and pods stay optional extras (gpc[plot], gpc[examples]), not core dependencies.
MAP GPLVM (CGplvm), collapsed Bayesian GPLVM (CBayesGplvm, CIP-0017), and MRD (CMrd, CIP-0018):
Y = ... # N×D observations
m = gpc.models.GPLVM(Y, input_dim=2) # RBF+Bias+White (CLI default)
m.optimize(iters=50)
X = m.latent_mean() # N×q
mu, var = m.predict(X)
m = gpc.models.BayesianGPLVM(Y, input_dim=2, num_inducing=10) # RBF-ARD
m.optimize(iters=50)
mu_x, s_x = m.latent_mean(), m.latent_variance()
# Multi-view: aligned Y_v (same N), per-view RBF-ARD (GPy MRD default)
m = gpc.models.MRD([Y0, Y1], input_dim=3, num_inducing=10)
m.optimize(iters=50)
fac = m.factorize_space(threshold=0.05) # shared / private0 / private1Defaults follow GPy’s kern.RBF (not ExpQuad path names). Native tutorials remain the verified share format (gplvm_oil100, bgplvm_oil100, mrd).
Notebook ports of the oil / SVI GPLVM / MRD tutorials are still outstanding. Other GPy-online topics we have not mirrored as gpc notebooks (coregionalization, sparse EP / IVM, SVGP, SVI BGPLVM, Poisson/hetero/HMC) are listed with owning CIPs in docs/subset_checklist.md. Deep GP is available as gpc.models.DeepGP (CIP-0035). SVI Bayesian GPLVM remains CLI-first today (./bgplvm --inference svi); see docs/tutorials/bgplvm_svi.md and backlog 2026-11-20_cip0030-phase4b-python-facade.
gpc.inference draws Hamiltonian Monte Carlo samples of the free hyperparameters of GPRegression, SparseGPRegression (sparse models need fixed inducing points), BayesianGPLVM and MRD. A prior on rbf.lengthscale is stated on the lengthscale and samples are reported as lengthscales; rbf.inv_lengthscale puts the prior on the stored inverse width instead. An improper target (a sampled parameter without a prior) is refused unless allow_improper=True.
For BayesianGPLVM and MRD the target is the variational bound as a function of the hyperparameters, with q(X) and the inducing inputs held at their current values (optimise first). That is a generalised posterior, not a posterior over q. MRD paths carry a view prefix (view0.lengthscale); likelihood.variance sets one prior for all views. Mini-batch models (DeepGP, SVGP, stochastic Bayesian GPLVM) are refused: their noisy ELBO breaks the accept step.
import gpc
m = gpc.models.GPRegression(X, Y, kernel=gpc.kern.RBF(1))
for path in ("rbf.lengthscale", "rbf.variance", "likelihood.variance"):
gpc.inference.set_prior(m, path, "gamma", 2.0, 1.0)
res = gpc.inference.hmc(m, num_samples=2000, burn_in=300)
res.to_csv("samples.csv") # same layout as `gp sample`