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
18 changes: 4 additions & 14 deletions .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,19 @@ on:

jobs:
build:
name: build source distribution
name: build and inspect the package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
with:
fetch-depth: 0
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: "3.12"
- name: Build the sdist and the wheel
run: |
pip install build
python3 -m build
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: artifact
path: dist/*
- uses: hynek/build-and-inspect-python-package@d44ca7d91762de7a7d5436ddae667c6da6d1c3df # v2.18.0

publish:
name: upload release to PyPI
needs: [build]
runs-on: ubuntu-latest
if: github.repository_owner == 'bwengals' && github.event_name == 'release' && github.event.action == 'published'
if: github.repository_owner == 'pymc-devs' && github.event_name == 'release' && github.event.action == 'published'
# Use the `release` GitHub environment to protect the Trusted Publishing (OIDC)
# workflow by requiring signoff from a maintainer.
environment: release
Expand All @@ -41,6 +31,6 @@ jobs:
steps:
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
name: artifact
name: Packages
path: dist
- uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # v1.14.0
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2025 Bill Engels
Copyright (c) 2025 Bill Engels and the PyMC Developers

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
27 changes: 19 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ PTGP is for practitioners who need flexible, well-supported GP modeling. The goa
- **PyMC priors:** set priors on any hyperparameter; use PyMC distributions for mean functions and noise models; MAP training by default
- **Training tools:** L-BFGS-B and Adam optimizers, per-parameter learning rates, staged optimization, frozen variables, inducing point initialization strategies, diagnostic-guided workflows; more are being added, such as carefully monitored training to help diagnose issues early
- **Agent-readable docs:** `docs/agents/` ships LLM-readable guides for debugging training issues and folk wisdom (VFE training covered). See the [Working with AI coding assistants](#working-with-ai-coding-assistants) section below.
- **More coming:** see the [issues](https://github.com/bwengals/ptgp/issues)
- **More coming:** see the [issues](https://github.com/pymc-devs/ptgp/issues)

Researchers benefit from the underlying design: PTGP is built on PyTensor's symbolic graph and rewrite system, so you write GP math directly (`pt.linalg.inv(K)`, `pt.linalg.slogdet(K)`) and the compiler chooses efficient algorithms based on declared matrix structure. This makes it straightforward to implement new GP approximations and create custom models, and will eventually allow matrix structure like Kronecker, Toeplitz, and sparse to be taken advantage of automatically.

Expand Down Expand Up @@ -54,13 +54,22 @@ with pm.Model() as model:
mean, var = pg.predict(svgp, np.linspace(-3, 3, 100)[:, None], fit)
```

`pg.fit` picks a default objective from the gp type (`Unapproximated` → `marginal_log_likelihood`, `VFE` → `collapsed_elbo`, `SVGP` → `elbo`) and returns a `FitResult` that `pg.predict` consumes. For stochastic mini-batch training, staged VFE, or per-group learning rates, drop down to `pg.optim.compile_training_step` / `pg.optim.compile_scipy_objective` — see [`notebooks/demo.ipynb`](notebooks/demo.ipynb).
`pg.fit` picks a default objective from the gp type (`Unapproximated` → `marginal_log_likelihood`, `VFE` → `collapsed_elbo`, `SVGP` → `elbo`) and returns a `FitResult` that `pg.predict` consumes. For stochastic mini-batch training, staged VFE, or per-group learning rates, drop down to `pg.optim.compile_training_step` / `pg.optim.compile_scipy_objective` — see [`notebooks/demo.ipynb`](notebooks/demo.ipynb):

```python
X_var = pt.matrix("X")
y_var = pt.vector("y")

step, shared_params, shared_extras = pg.optim.compile_training_step(
pg.objectives.elbo, svgp, X_var, y_var, model, learning_rate=1e-2
)

for i in range(500):
loss = step(X, y)

predict_fn = pg.optim.compile_predict(svgp, pt.matrix("X_new"), model, shared_params,
extra_vars=vp.extra_vars, shared_extras=shared_extras)
predict_fn = pg.optim.compile_predict(
svgp, pt.matrix("X_new"), model, shared_params, shared_extras=shared_extras
)
mean, var = predict_fn(np.linspace(-3, 3, 100)[:, None])
```

Expand All @@ -79,7 +88,9 @@ PTGP is set up to work nicely with AI coding assistants:
- **[`AGENTS.md`](AGENTS.md)** — project-level instructions for AI coding assistants (architecture, conventions, where things live, how to run tests). Follows the [AGENTS.md](https://agents.md/) cross-tool convention used by Codex, Cursor, Aider, and others.
- **[`docs/agents/`](docs/agents/)** — backend-agnostic agent-skill docs covering folk wisdom and training-debug recipes. Currently includes [`ptgp-vfe`](docs/agents/ptgp-vfe/) (VFE diagnostic skill: pitfalls, escalation workflow, interpretation of `VFEDiagnostics` and `GreedyVarianceDiagnostics`).

**Claude Code users:** Claude Code reads `CLAUDE.md`, not `AGENTS.md`. Symlink so they stay in sync:
### Claude Code users

Claude Code reads `CLAUDE.md`, not `AGENTS.md`. Symlink so they stay in sync:

```bash
ln -s AGENTS.md CLAUDE.md
Expand All @@ -95,17 +106,17 @@ python scripts/install_claude_skills.py --user # ~/.claude/skills/
## Install

```bash
pip install git+https://github.com/bwengals/ptgp.git
pip install git+https://github.com/pymc-devs/ptgp.git
```

To hack on PTGP itself, clone and install in editable mode:

```bash
git clone https://github.com/bwengals/ptgp.git
git clone https://github.com/pymc-devs/ptgp.git
cd ptgp
pip install -e .
```

## Contributing

See the [issues](https://github.com/bwengals/ptgp/issues) for what's being worked on. Feel free to propose issues, feature requests, or use cases you've been hoping could be made easier. PRs always welcome.
See the [issues](https://github.com/pymc-devs/ptgp/issues) for what's being worked on. Feel free to propose issues, feature requests, or use cases you've been hoping could be made easier. PRs always welcome.
8 changes: 5 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ build-backend = "hatchling.build"
[project]
name = "ptgp"
authors = [
{name = 'Bill Engels', email = 'w.j.engels@gmail.com'}
{name = 'Bill Engels', email = 'w.j.engels@gmail.com'},
{name = 'PyMC Developers', email = 'pymc.devs@gmail.com'}
]
description = "A practitioner's toolbox for estimating large-scale Gaussian Process models with PyMC and PyTensor"
readme = "README.md"
requires-python = ">=3.12"
keywords = [
"gaussian processes",
Expand All @@ -31,8 +33,8 @@ dependencies = [
dev = ["pytest", "pre-commit", "mypy", "polars"]

[project.urls]
Repository = "https://github.com/bwengals/ptgp.git"
Issues = "https://github.com/bwengals/ptgp/issues"
Repository = "https://github.com/pymc-devs/ptgp.git"
Issues = "https://github.com/pymc-devs/ptgp/issues"

[tool.hatch.version]
source = 'vcs'
Expand Down
Loading