Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make behavior of Cholesky caching more clear #1504

Closed

Conversation

esantorella
Copy link
Member

Motivation

General context: Caching is confusing and can lead to subtle issues. I have been trying to understand it better in order to reduce memory usage and improve runtime, since I've been seeing cache misses and tensors persisting longer than necessary. This PR doesn't fix that, but does make things a tiny bit more transparent.

Two things are making the "_cache_root_decomposition" method harder to understand than necessary:

  1. It sets self._baseline_L and returns None rather than just returning baseline_L, so when someone sees a call to _cache_root_decomposition they will not immediately realize self._baseline_L has been set.
  2. It is uses two different kinds of caching: it sets self._baseline_L and it also invisibly uses LinearOperator's caching.

This PR makes things more transparent by

  • Adding comments
  • Returning baseline_L rather than setting it as a side effect

Have you read the Contributing Guidelines on pull requests?

Yes

Test Plan

Unit tests

@esantorella esantorella requested a review from sdaulton November 15, 2022 16:50
@esantorella esantorella self-assigned this Nov 15, 2022
@facebook-github-bot facebook-github-bot added the CLA Signed Do not delete this pull request or issue due to inactivity. label Nov 15, 2022
@facebook-github-bot
Copy link
Contributor

@esantorella has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@codecov
Copy link

codecov bot commented Nov 15, 2022

Codecov Report

Merging #1504 (d7c1ab4) into main (6f92f2f) will not change coverage.
The diff coverage is 100.00%.

@@            Coverage Diff            @@
##              main     #1504   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          143       143           
  Lines        12760     12759    -1     
=========================================
- Hits         12760     12759    -1     
Impacted Files Coverage Δ
botorch/acquisition/cached_cholesky.py 100.00% <100.00%> (ø)
botorch/acquisition/monte_carlo.py 100.00% <100.00%> (ø)
botorch/acquisition/multi_objective/monte_carlo.py 100.00% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Contributor

@Balandat Balandat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this makes things a lot cleaner!

suggestion from PR

Co-authored-by: Max Balandat <Balandat@users.noreply.github.com>
@facebook-github-bot
Copy link
Contributor

@esantorella has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Do not delete this pull request or issue due to inactivity. documentation refactor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants