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

Add ability to mix batch initial conditions and internal IC generation #2610

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

CompRhys
Copy link
Contributor

@CompRhys CompRhys commented Nov 4, 2024

Motivation

See #2609

Have you read the Contributing Guidelines on pull requests?

Yes

Test Plan

Basic testing of the code is easy the challenge is working out what the run on implications might be, will this break people's code?

Related PRs

facebook/Ax#2938

@facebook-github-bot facebook-github-bot added the CLA Signed Do not delete this pull request or issue due to inactivity. label Nov 4, 2024
botorch/optim/optimize.py Outdated Show resolved Hide resolved
botorch/acquisition/input_constructors.py Outdated Show resolved Hide resolved
botorch/optim/optimize.py Outdated Show resolved Hide resolved
test/optim/test_optimize.py Outdated Show resolved Hide resolved
botorch/optim/optimize.py Outdated Show resolved Hide resolved
botorch/optim/optimize.py Outdated Show resolved Hide resolved
botorch/optim/optimize.py Outdated Show resolved Hide resolved
@CompRhys CompRhys marked this pull request as ready for review November 5, 2024 16:22
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. Seems like you have some dtype test issues to fix.

Also, if you rebase on the most recent main branch you don't have to run the conda test in the CI :)

botorch/optim/optimize.py Outdated Show resolved Hide resolved
botorch/optim/optimize.py Outdated Show resolved Hide resolved
botorch/optim/optimize.py Outdated Show resolved Hide resolved
test/optim/test_optimize.py Outdated Show resolved Hide resolved
botorch/optim/optimize.py Outdated Show resolved Hide resolved
botorch/optim/optimize.py Outdated Show resolved Hide resolved
botorch/optim/optimize.py Outdated Show resolved Hide resolved
@CompRhys
Copy link
Contributor Author

locally tests still failing for FAILED test/optim/test_optimize.py::TestOptimizeAcqf::test_optimize_acqf_runs_given_batch_initial_conditions - RuntimeError: expected scalar type Long but found Float although not really sure how i've caused that

Copy link

codecov bot commented Nov 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.98%. Comparing base (5d37606) to head (b6f8b85).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2610   +/-   ##
=======================================
  Coverage   99.98%   99.98%           
=======================================
  Files         196      196           
  Lines       17362    17395   +33     
=======================================
+ Hits        17360    17393   +33     
  Misses          2        2           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

@facebook-github-bot
Copy link
Contributor

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

@saitcakmak
Copy link
Contributor

Looks like the PR is out of sync with the main branch. Can you do another rebase please?

@CompRhys CompRhys changed the title Add ability to mix batch initial conditions and internal IC generation [Do Not Merge] Add ability to mix batch initial conditions and internal IC generation Nov 19, 2024
@CompRhys
Copy link
Contributor Author

CompRhys commented Nov 19, 2024

In this PR as stands I was confused about the roles of q and raw_samples in the initial_batch_generator argument.

Yes this PR doesn't achieve what I intended. This was written against raw_samples but it should be against n_restarts to match the original intent.

@CompRhys CompRhys changed the title [Do Not Merge] Add ability to mix batch initial conditions and internal IC generation Add ability to mix batch initial conditions and internal IC generation Nov 20, 2024
@CompRhys
Copy link
Contributor Author

@saitcakmak I redid this whole thing after realizing that I had got confused and failed to implement what I originally intended by following raw_samples rather than num_repeats and then got distracted focussing on the trees rather than the forest.

@CompRhys
Copy link
Contributor Author

Apologies for linting..

Two solutions to the homotopy test failure:

  1. either change the following linked lines to the snippet testing that we prune and then generate new restarts.
    # First time we expect to call `prune_candidates` with 4 candidates
    self.assertEqual(
    prune_candidates_mock.call_args_list[0][1]["candidates"].shape,
    torch.Size([4, 1]),
    )
    for i in range(1, 5): # The paths should have been pruned to just one path
    self.assertEqual(
    prune_candidates_mock.call_args_list[i][1]["candidates"].shape,
    torch.Size([1, 1]),
    )
        for i in range(5):
            # assert that the number of restarts are repopulated at each step
            self.assertEqual(
                prune_candidates_mock.call_args_list[i][1]["candidates"].shape,
                torch.Size([4, 1]),
            )
            # assert that the candidates are pruned to just one candidate
            self.assertEqual(
                prune_candidates(**prune_candidates_mock.call_args_list[i][1]).shape,
                torch.Size([1, 1]),
            )
  1. set shared_optimize_acqf_kwargs["raw_samples"]=None at
    # Prune candidates
    to prevent the dimensions from the pruned restarts being filled with random designs in subsequent loops.

To get current behaviour the second option is better, but in principal despite the fact that random IC designs introduced later in the homotopy might not be able to be as readily optimized to sparsity the first option doesn't seem harmful (beyond there being no computational benefit to pruning) and may have upsides.

@saitcakmak
Copy link
Contributor

There is one remaining test failure and a rebase seems to be necessary. Lgtm otherwise

@facebook-github-bot
Copy link
Contributor

@saitcakmak 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants