gpytorch icon indicating copy to clipboard operation
gpytorch copied to clipboard

slight improvements to IndexKernel for the rank == 0 (diagonal) case

Open rmgarnett opened this issue 3 years ago • 2 comments

This PR tweaks IndexKernel to have slightly better performance/behavior in the corner case of rank == 0, where the underlying covariance matrix is diagonal. Although this case is atypical from the point of view of multitask GPs, I have found this construction useful as a component of larger covariance structures.

Two changes are proposed:

  • the kernel only registers the covar_factor parameter (the low-rank component when rank > 0) when rank > 0
  • in the rank == 0 case, the covar_matrix() method returns a DiagLinearOpeator rather than a PsdSumLinearOperator(RootLinearOperator, DiagLinearOperator)

rmgarnett avatar Sep 19 '22 23:09 rmgarnett

I've added a branch to _eval_covar_matrix() to handle the diagonal case to partially address @Balandat's comments.

rmgarnett avatar Sep 20 '22 03:09 rmgarnett

I guess I would still like to see this covered by a unit test though :)

Balandat avatar Sep 22 '22 05:09 Balandat