Add ScaleRBFLinearKernel covar module#5233
Open
saitcakmak wants to merge 1 commit into
Open
Conversation
Summary: Following the `ScaleMaternKernel` pattern in Ax botorch_modular, this adds `ScaleRBFLinearKernel` — a sum of `ScaleKernel(RBF-ARD)` and `LinearKernel`. It is the kernel-side analog of a linear mean: the `LinearKernel` models linear-in-input correlations (e.g. a scaling-law trend) through the covariance rather than the mean, while the `ScaleKernel`-wrapped ARD RBF captures local flexibility and lets the model learn the relative amplitude of the local vs. global signal. This is the kernel-only counterpart of the `RBFLinearGP` model studied in D108386392, designed to plug into a plain `SingleTaskGP` via `ModelConfig(covar_module_class=...)`. `ScaleRBFLinearKernel` subclasses GPyTorch's `AdditiveKernel` so that `isinstance` checks and storage serialization work cleanly. Its `__init__` mirrors `ScaleMaternKernel`, adding a `variance_prior` for the linear component and an `active_dims` argument. `active_dims` is applied to both component kernels: it is set on the inner `RBFKernel` and on the `LinearKernel`, and the `ScaleKernel` inherits `active_dims` from the kernel it wraps. Because GPyTorch subsets inputs once at the outermost kernel in a call chain (and `ScaleKernel.forward` calls `base_kernel.forward` directly), the input is subset exactly once rather than twice. Threading `active_dims` through the input constructor also enables the `remove_task_features` workflow (excluding a task feature from the kernel for a `SingleTaskGP` on a `MultiTaskDataset`). Changes: - `kernels.py`: new `ScaleRBFLinearKernel(AdditiveKernel)` with `active_dims` support. - `input_constructors/covar_modules.py`: register `_covar_module_argparse_scale_rbf_linear`, reusing `_get_default_ard_num_dims_and_batch_shape` to infer `ard_num_dims`/`batch_shape`/`active_dims` from the dataset and model class. - `botorch_modular_registry.py`: add `ScaleRBFLinearKernel` to `KERNEL_REGISTRY` (this automatically wires up JSON/SQA encode+decode). - Tests in `test_kernels.py` (incl. an active-dims single-subsetting check) and `test_covar_modules_argparse.py` (incl. active-dims and remove_task_features cases). Differential Revision: D109044330
|
@saitcakmak has exported this pull request. If you are a Meta employee, you can view the originating Diff in D109044330. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5233 +/- ##
=======================================
Coverage 96.56% 96.56%
=======================================
Files 619 619
Lines 70168 70255 +87
=======================================
+ Hits 67756 67843 +87
Misses 2412 2412 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Summary:
Following the
ScaleMaternKernelpattern in Ax botorch_modular, this addsScaleRBFLinearKernel— a sum ofScaleKernel(RBF-ARD)andLinearKernel. It is the kernel-side analog of a linear mean: theLinearKernelmodels linear-in-input correlations (e.g. a scaling-law trend) through the covariance rather than the mean, while theScaleKernel-wrapped ARD RBF captures local flexibility and lets the model learn the relative amplitude of the local vs. global signal. This is the kernel-only counterpart of theRBFLinearGPmodel studied in D108386392, designed to plug into a plainSingleTaskGPviaModelConfig(covar_module_class=...).ScaleRBFLinearKernelsubclasses GPyTorch'sAdditiveKernelso thatisinstancechecks and storage serialization work cleanly. Its__init__mirrorsScaleMaternKernel, adding avariance_priorfor the linear component and anactive_dimsargument.active_dimsis applied to both component kernels: it is set on the innerRBFKerneland on theLinearKernel, and theScaleKernelinheritsactive_dimsfrom the kernel it wraps. Because GPyTorch subsets inputs once at the outermost kernel in a call chain (andScaleKernel.forwardcallsbase_kernel.forwarddirectly), the input is subset exactly once rather than twice. Threadingactive_dimsthrough the input constructor also enables theremove_task_featuresworkflow (excluding a task feature from the kernel for aSingleTaskGPon aMultiTaskDataset).Changes:
kernels.py: newScaleRBFLinearKernel(AdditiveKernel)withactive_dimssupport.input_constructors/covar_modules.py: register_covar_module_argparse_scale_rbf_linear, reusing_get_default_ard_num_dims_and_batch_shapeto inferard_num_dims/batch_shape/active_dimsfrom the dataset and model class.botorch_modular_registry.py: addScaleRBFLinearKerneltoKERNEL_REGISTRY(this automatically wires up JSON/SQA encode+decode).test_kernels.py(incl. an active-dims single-subsetting check) andtest_covar_modules_argparse.py(incl. active-dims and remove_task_features cases).Differential Revision: D109044330