pytorch / botorch

Bayesian optimization in PyTorch
https://botorch.org/
MIT License
3.11k stars 406 forks source link

Make input transfroms Modules by default #2607

Closed saitcakmak closed 3 weeks ago

saitcakmak commented 4 weeks ago

Summary: InputTransforms are required to be torch.nn.Module subclasses but the base class does not inherit from torch.nn.Module. This leads to type checker complaints when calling methods like .to(...), since it doesn't know that they are Modules.

This was originally motivated by the inheritance order of Warp transform, as we want GPyTorchModule methods to take precedence over torch.nn.Module. However, this not actually a concern since the GPyTorchModule comes first in the MRO of Warp regardless of whether InputTransform inherits from Module (since GPyTorchModule itself inherits from Module as well).

This diff updates InputTransform to inherit from Module and removes the redundant Module inheritance from subclasses.

Differential Revision: D65338444

facebook-github-bot commented 4 weeks ago

This pull request was exported from Phabricator. Differential Revision: D65338444

facebook-github-bot commented 4 weeks ago

This pull request was exported from Phabricator. Differential Revision: D65338444

codecov[bot] commented 4 weeks ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 99.98%. Comparing base (9ebead4) to head (9c4581f). Report is 1 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #2607 +/- ## ======================================= Coverage 99.98% 99.98% ======================================= Files 196 196 Lines 17372 17372 ======================================= Hits 17370 17370 Misses 2 2 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

facebook-github-bot commented 3 weeks ago

This pull request has been merged in pytorch/botorch@3ca48d0ac5865a017ac6b2294807b432d6472bcf.