Repository navigation
Build kernels as graphs of typed KernelOps - #76
Draft
jessegrabowski wants to merge 6 commits into
Draft
jessegrabowski wants to merge 6 commits into
jessegrabowski wants to merge 6 commits into
Conversation
jessegrabowski
force-pushed
the
kernel-op
branch
from
November 7, 2026 20:57
74f9ce1 to
4348432
Compare
jessegrabowski
force-pushed
the
kernel-op
branch
from
November 7, 2026 21:30
4348432 to
2312599
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Kernelis now a graph on row placeholders, and its leaves are typedKernelOpnodes that take their parameters as explicit inputs. Sums and products are ordinary graph arithmetic, and calling a kernel replaces the placeholders.SumKernel,ProductKernel,_eval, and the hand-writtendiagmethods are removed, andKernel.diagispt.diagonal(self(X)).Everything in kernel construction is now a graph node, so kernels can be changed with graph manipulations alone.
graph_replace,vectorize_graph,pm.do,pm.observe, andpm.set_dataall reach kernel parameters and rows without a kernel-specific path. None of this needs apm.Potential, becausepm.doalso reaches a kernel inside a valuedpm.MvNormal. Efficient forms are rewrites on the Op types, for examplediagonal_of_kernel_to_kernel_diagonal.This is the kernel counterpart to the symbolic likelihood work in #30, #50, and #68.
The VFE gradient depends on the PyTensor rewrites in pymc-devs/pytensor#2613, which aren't released yet. That PR will move to the index write versions of these rewrites, and the timings below use those versions. On PyTensor 3.3.7, loss plus gradients at N=3200 takes 152 ms against 1.56 ms on
main, and it scales quadratically in N. With those rewrites it takes 1.53 ms and scales linearly. Five tests fail on 3.3.7, and all of them pass with those rewrites. Four need the rewrites, andtest_dims_only_rv_compiles_under_jaxneeds a constantarangeargument under JAX.K(X, X)is annotated symmetric and positive definite by declaration, for composites too, as it is onmain.-1.0 * Kis therefore lowered to Cholesky as if it were positive definite.📚 Documentation preview 📚: https://ptgp--76.org.readthedocs.build/en/76/