forked from pytorch/botorch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
speed up LCE-A kernel (pytorch#1910)
Summary: Pull Request resolved: pytorch#1910 X-link: facebook/Ax#1694 The current implementation is very slow. This is particularly problematic when the number of contexts is large. This diff yields huge speed ups (>3 orders of magnitude) by removing nested for loops in `forward` and instead using batched computation. This also caches the context_covar in eval mode, with an additional requirements that the parameters for each context are contiguous and in the same order. * 14x speed up with 8 contexts and 1,154x speed up with 128 contexts (CPU) * 22x speed up with 8 contexts and 3,370x speed up with 128 contexts (CUDA) * Without this diff, it takes 5 seconds on CPU and 12 seconds with CUDA for a single forward pass with 128 contexts. Current implementation: * 8 contexts: * Forward pass: 20ms (CPU), 45.2ms (CUDA) * Roundtrip: 39.1ms (CPU), 99.7ms (CUDA) * 128 contexts: * Forward pass: 5.08s (CPU), 12s (CUDA) * Roundtrip: 14.2s (CPU), 26.7s (CUDA) New Implementation: * 8 contexts: * Forward pass: 1.44ms (CPU), 2.05ms (CUDA) * Roundtrip: 2.22ms (CPU), 4.65ms (CUDA) * 128 contexts: * Forward pass: 4.4ms (CPU), 3.56ms (CUDA) * Roundtrip: 6.97ms (CPU), 5.34ms (CUDA) Reviewed By: Balandat Differential Revision: D47118335 fbshipit-source-id: a777cba457c2918b28a3a86dd6a1516aee91e066
- Loading branch information
1 parent
38e2027
commit f7d77a3
Showing
3 changed files
with
150 additions
and
47 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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