cornellius-gp / gpytorch

A highly efficient implementation of Gaussian Processes in PyTorch
MIT License
3.54k stars 557 forks source link

Remove num_outputs from IndependentModelList #2360

Closed saitcakmak closed 1 year ago

saitcakmak commented 1 year ago

IndependentModelList.num_outputs makes a strong assumption that the underlying models are single-output, so it returns the # of sub-models. However, IndependentModelList works perfectly fine with multi-output sub-models, leading to the num_outputs attribute returning the wrong value. Since GPyTorch models do not define a consistent num_outputs attribute, I don't see an easy way of correcting this.

This becomes an issue in BoTorch where ModelListGP has IndependentModelList ahead of ModelList in its MRO, which correctly defines num_outputs as the sum of num_outputs of the sub-models. Removing the property from IndependentModelList should allow us to use the correct definition from ModelList.

Balandat commented 1 year ago

Since GPyTorch models do not define a consistent num_outputs attribute, I don't see an easy way of correcting this.

Would it make sense to upstream some of the num_outputs conventions & machinery we use in botorch to gpytorch? I guess right now this wouldn't bring additional immediate benefits, but this could be useful for some folks.

Something to think about down the road I guess.