Skip to content

Rework the agent skill into a general GP diagnosis skill - #62

Open
bwengals wants to merge 4 commits into
mainfrom
docs/agent-skill-refresh
Open

bwengals wants to merge 4 commits into
mainfrom
docs/agent-skill-refresh

Conversation

@bwengals

@bwengals bwengals commented Oct 7, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #34.

Renames the agent skill ptgp-vfe to ptgp and makes it general to all GP methods. Each pitfall page now describes a problem and its fix, the Tier A-E workflow (reference/workflow.md) is removed, and pages are tagged with applies_to (all, VFE, SVGP, VFE, or Unapproximated, VFE).

The content is also updated to match main (signatures, diagnostic fields, pg.fit), and two mechanisms are corrected:

  • Shrinking sigma increases the VFE trace penalty, so sigma collapse is not a VFE loophole. It's the usual GP interpolation failure, which VFE only allows when Z is dense.
  • Eta collapse pairs with sigma inflation, not sigma collapse.

The loop selected M points but only conditioned on the first M-1, so d_final,
trace_curve[-1], and the repr's variance explained described one point fewer
than was returned, and an early stop on threshold returned one unconditioned
extra point. It now conditions on every selected point: trace_curve has shape
(M + 1,), and early stop returns the smallest prefix below threshold.

d_final was also returned in the internally shuffled row order; it is now
aligned to the rows of X.
Rename docs/agents/ptgp-vfe to docs/agents/ptgp. Pages now describe each
problem and its fix instead of a tiered escalation workflow: workflow.md is
removed and tier references are replaced by the concrete action. Pages carry
an honest applies_to (all, VFE/SVGP, or VFE) and VFE-only remarks are
labelled.

Also bring the content up to date with main: function names instead of line
numbers, current signatures (check_init, Points(Z, Z_init), compile_kwargs,
options vs scipy_options), the new VFEDiagnostics fields and excess_fit_per_n
formula, KernelHealthDiagnostics, pg.fit / pg.predict, floatX, and the
greedy_variance_init trace_curve / d_final semantics. Rewrite the sigma
collapse mechanism (shrinking sigma grows the trace penalty; collapse needs
Q close to Kff), fix the eta_collapse pairing and prior advice, and fix the
check_inducing.py crash on KernelHealthDiagnostics.
@bwengals

bwengals commented Oct 7, 2026 •

Copy link
Copy Markdown
Collaborator Author

Merge after #61, and it'll need a some changes.

@jessegrabowski jessegrabowski left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

retarget to main

Comment thread docs/agents/ptgp/reference/api.md Outdated
*interrupted* phase, so `compile_predict` wires up to the
partially-trained state.
- **`compile_training_step(objective_fn, gp, X_var, y_var, model=None,
optimizer_fn=None, extra_vars=None, extra_init=None, frozen_vars=None,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stale on main after #65: optimizer_fn= and **optimizer_kwargs are gone, it's optimizer= (a pytensor_ml.optim transform, default adam(1e-2)). point to the ptgp-pytensor-ml skill

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Comment thread docs/agents/ptgp/reference/api.md Outdated

## Optim — `ptgp/optim/training.py`

- **`compile_scipy_objective(objective_fn, gp, X_var, y_var, model=None,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: the parameter is gp_model, not gp. gp= as a keyword raises TypeError

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Comment thread docs/agents/ptgp/reference/api.md Outdated
was built as `Points(Z_var, Z_init=Z0)`, nothing otherwise). Pass empty
tuples to exclude all extras. `init` defaults to `"prior_median"`
(improper priors fall back per RV; see the function docstring).
- **`compile_scipy_diagnostics(diagnostic_fn, gp, X_var, y_var,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: gp_model, same as line 46

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Comment thread docs/agents/ptgp/reference/api.md Outdated
`result.status == 99`; `unpack`/`sp`/`se` correspond to the
*interrupted* phase, so `compile_predict` wires up to the
partially-trained state.
- **`compile_training_step(objective_fn, gp, X_var, y_var, model=None,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: gp_model, same as line 46

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Comment thread docs/agents/ptgp/reference/api.md Outdated
param_groups=None, include_prior=True, compile_kwargs=None,
**optimizer_kwargs) -> (train_step, sp, se)`**: Adam / SGD step for
minibatch training. Mostly SVGP; listed for completeness.
- **`compile_predict(gp, X_new_var, model, shared_params,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: gp_model, same as line 46

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed, and compile_predict now takes X_train / y_train through **data, after #66

Comment thread docs/agents/ptgp/SKILL.md Outdated
Each page under `pitfalls/` describes one problem: how to detect it, what
causes it, and how to fix it. Find the symptom below and open its page.
`applies_to` in each page's frontmatter says which models it concerns:
`all`, the inducing-point methods (`VFE`, `SVGP`), or `VFE` only. The

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: excess_fit_per_n_negative uses [Unapproximated, VFE], which isn't one of these three values

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added Unapproximated, VFE to the list in SKILL.md, since SVGP histories have no excess_fit_per_n

2. **Loosen scipy tolerances**:

```python
scipy_options={"ftol": 1e-7, "gtol": 1e-5}
options={"ftol": 1e-7, "gtol": 1e-5} # pg.fit / tracked_minimize kwargs

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: gtol=1e-5 is already the L-BFGS-B default, so this only loosens ftol

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

- **Per-step improvement**: divide
`(history[-1].elbo - history[-50].elbo)` (or the objective field your
history records) by the step count. If it's
> 1e-3 in absolute terms, real progress; bump maxiter. If it's

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not a blocker: elbo is a sum over N, so fixed 1e-3 / 1e-6 per-step cutoffs depend on dataset size. divide by N

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Comment thread AGENTS.md
Claude-specific convenience that symlinks it into a Claude Code skill
directory (`~/.claude/skills/` or a project-local `.claude/skills/`);
other AI tools can read `docs/agents/` directly.
The repo ships backend-agnostic agent-skill docs: `docs/agents/ptgp/`

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

after the rebase docs/agents/ also has ptgp-pytensor-ml (#65). list it here

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Comment thread README.md Outdated
@@ -86,7 +86,7 @@ PTGP tries to distill some of the approaches of existing GP libraries and make t
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`).
- **[`docs/agents/`](docs/agents/)** — backend-agnostic agent-skill docs covering folk wisdom and training-debug recipes. Currently includes [`ptgp`](docs/agents/ptgp/) (GP fit diagnosis: one page per problem with its cause and fix, plus interpretation of the diagnostic fields).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

list ptgp-pytensor-ml too, same as AGENTS.md:190

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed, and updated the summary bullet near the top too

@bwengals
bwengals changed the base branch from fix/greedy-trace-curve to main November 5, 2026 21:58

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update Agent Docs

2 participants