Use kernel.diag instead of materializing K(X, X) for the diagonal#49
Closed
bwengals wants to merge 1 commit into
Closed
Use kernel.diag instead of materializing K(X, X) for the diagonal#49bwengals wants to merge 1 commit into
bwengals wants to merge 1 commit into
Conversation
greedy_variance_init and _compute_kernel_health compiled pt.diag(kernel(X_sym)), building the full N x N gram (K separate grams for a K-factor ProductKernel) only to slice out the diagonal. Peak memory was O(K*N^2) instead of O(N). Call the existing O(N) kernel.diag(X_sym) instead. Closes #46
Collaborator
Author
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.
Fixes #46.
greedy_variance_init(inducing.py:602) and_compute_kernel_health(inducing.py:296) both compiledpt.diag(kernel(X_sym)), which materializes the fullK(X, X)gram (K separate N x N grams for a K-factorProductKernel) only to slice out its diagonal. Peak memory was O(K*N^2) instead of O(N).Both now call the existing O(N)
kernel.diag(X_sym). The issue reported line 602; line 296 had the identical pattern and is fixed in the same change.Verified the compiled diagonal graph for a 3-factor product kernel drops from 5 materialized 2D nodes to 0, and the 66 inducing/kernel-health tests pass.
📚 Documentation preview 📚: https://ptgp--49.org.readthedocs.build/en/49/