deepgp-torch
A GPyTorch library for doubly-stochastic deep Gaussian processes (Salimbeni & Deisenroth, 2017). It provides modular SVGP layers, a deep-GP container, variational (ELBO) training, and calibrated prediction.
The importable package is deepgp. Its API and engineering are modelled on
GPflux but built on
PyTorch + GPyTorch + linear_operator.
Status: early development.
SVGP,DeepGPandbuild_deep_gptrain and predict onsnelson1d. Multi-output support, minibatch and natural-gradient training, and the benchmark harness are not implemented yet (see Roadmap).
Install
pip install deepgp-torch
Or, from a checkout, for development:
pip install -e ".[dev]" # editable install with dev tooling
Requires Python ≥ 3.10, torch>=2.0, gpytorch>=1.15,
linear_operator>=0.6.1, numpy>=1.26.
Quickstart
Importing deepgp sets the torch default dtype to float64 (Cholesky
stability), so every GP module is built in double precision.
import deepgp
from deepgp import DeepGP, fit, predict
from deepgp.data import load_snelson1d
data = load_snelson1d(test_fraction=0.2, seed=0) # standardised split
model = DeepGP([1, 1], num_inducing=32) # 1 hidden + 1 output layer
losses = fit(model, data.X_train, data.Y_train, # maximise the ELBO
epochs=300, lr=0.01, num_samples=10)
mean, var = predict(model, data.X_test, k=32) # total-variance mixture
print("first training loss:", losses[0], "-> last:", losses[-1])
A single-layer SVGP uses the same fit / predict helpers:
from deepgp import SVGP
svgp = SVGP(inducing_points=data.X_train[:32].clone(), input_dims=1)
fit(svgp, data.X_train, data.Y_train, epochs=300, lr=0.01)
mean, var = predict(svgp, data.X_test)
Or build a constant-input-dimension deep GP with stable-start
initialisation in one call (KMeans inducing init, dim-preserving identity/PCA
hidden means, shrunk hidden q_sqrt, Gaussian noise init):
from deepgp import build_deep_gp, DeepGPConfig
cfg = DeepGPConfig(num_inducing=20, inner_layer_qsqrt_factor=1e-5, likelihood_noise=1e-2)
model = build_deep_gp(data.X_train, num_layers=2, config=cfg)
fit(model, data.X_train, data.Y_train, epochs=300, lr=0.01)
mean, var = predict(model, data.X_test)
Why a deep-GP-specific library over raw GPyTorch?
It encodes the non-obvious correctness details that raw GPyTorch leaves to you:
- Layers own their variational structure —
DeepGPHiddenLayerbundles inducing points,q(u), mean and kernel; the deep-GP variational strategy discovers layers viamodel.modules()and sums their KL terms automatically. - Linear hidden means —
LinearMeanhidden layers prevent doubly-stochastic hidden-field collapse (mean_type='zero'is available but discouraged). - Law-of-total-variance prediction — a deep GP's predictive distribution is
an
S-component Gaussian mixture;predictreduces it asmean = out.mean.mean(0)andvar = out.variance.mean(0) + out.mean.var(0, unbiased=False). A single component's.varianceunder-reports uncertainty. - First-class KL tempering — the ELBO KL weight is exactly
beta / num_data.
Development
make install # pip install -e ".[dev]"
make format # black + isort
make check # black --check, isort --check-only, flake8, mypy src
make test # pytest
CI (.github/workflows/ci.yml) runs lint + type-check + tests on Python 3.10,
3.11 and 3.12, and builds the Docker image.
Docker
A CPU-only image for a reproducible environment:
docker build -t deepgp-torch .
docker run --rm deepgp-torch # prints the installed version
docker run --rm deepgp-torch pytest -q # runs the test suite
docker run --rm -it deepgp-torch python # interactive REPL
Roadmap
Implemented:
- Core stack:
layers/gp_layer,models/svgp,models/deep_gp,training/elbo+trainer,inference/predict,data/datasets(snelson1d),eval/metrics,utils/seed+dtype. - Architecture builder:
DeepGPConfigandbuild_deep_gpwith stable-start init,kernels/factory+means/factory(identity/PCALinearMean), anddata/inducing(KMeans / subset / explicitz_init).
Not yet implemented — the modules exist as placeholders:
- Multi-output support (
MultitaskGaussianLikelihood,batch_shapethreading) andlikelihoods/variationalconvenience helpers. - Minibatch/
DataLoadertraining with LR schedulers, checkpointing and logging, and natural-gradient training. - Golden equivalence test against GPflux, a UCI benchmark harness, and Sphinx docs.
Contributing
Contributions are welcome! See CONTRIBUTING.md for the dev setup and workflow, and please follow the Code of Conduct. To report a security issue, see SECURITY.md.
Citing
If you use deepgp-torch in your research, please cite it — see
CITATION.cff (GitHub renders a "Cite this repository" button).
References
- Salimbeni & Deisenroth, Doubly Stochastic Variational Inference for Deep Gaussian Processes, NeurIPS 2017.
- Snelson & Ghahramani, Sparse Gaussian Processes using Pseudo-inputs, 2006
(the
snelson1ddataset).
License
Apache-2.0 — see LICENSE.
Metadata
Release files for deepgp-torch 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| deepgp_torch-0.1.1.tar.gz | 49.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| deepgp_torch-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 99.1 kB
Release files / deepgp_torch-0.1.1.tar.gz
| Download URL | deepgp_torch-0.1.1.tar.gz |
|---|---|
| Size | 49.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2f5833c60bf5e65ba1ca98a92ec91b0d2b69990cacf140a680c9c233432e578e
|
|
BLAKE2b-256 checksum How to use checksums |
ff609fbfed4c9656914185f999eed0fc69bef14b524248aa5282b02400e8a6f6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Aug 31, 2026.
Transparency logRelease files / deepgp_torch-0.1.1-py3-none-any.whl
| Download URL | deepgp_torch-0.1.1-py3-none-any.whl |
|---|---|
| Size | 49.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ec23ce4274486294be62fe98370fc98460b7108a73fa5a29dbbb33b83d80a054
|
|
BLAKE2b-256 checksum How to use checksums |
9923847f62ffb6aec23474ee72712f6925769fcbd76af9a3e07e15ec9279eb20
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Aug 31, 2026.
Transparency log