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

V2: Fix small hpopt bugs and add example notebook #842

Merged
merged 21 commits into from
Jun 6, 2024

Conversation

hwpang
Copy link
Contributor

@hwpang hwpang commented Apr 25, 2024

Description

Add an example hpopt notebook. Happy to take suggestion on the notebook.
Found some small bugs related to input type and saving hpopt results while working on the notebook. Fixed those.

Example / Current workflow

n/a

Bugfix / Desired workflow

n/a

Questions

n/a

Relevant issues

n/a

Checklist

  • linted with flake8?
  • (if appropriate) unit tests added?

@hwpang hwpang added this to the v2.0.1 milestone Apr 25, 2024
@hwpang hwpang requested a review from shihchengli April 25, 2024 19:46
Copy link
Contributor

@shihchengli shihchengli left a comment

Choose a reason for hiding this comment

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

Thanks for making this PR. There are two minor things you might consider adding to the notebook:

  1. Include metrics within the model (e.g., metric_list = [nn.metrics.RMSEMetric(), nn.metrics.MAEMetric()]) in the notebook.
  2. Add the ASHAScheduler to the notebook, as we use it by default.

chemprop/cli/hpopt.py Outdated Show resolved Hide resolved
chemprop/cli/hpopt.py Outdated Show resolved Hide resolved
chemprop/cli/hpopt.py Outdated Show resolved Hide resolved
chemprop/cli/hpopt.py Outdated Show resolved Hide resolved
@shihchengli
Copy link
Contributor

The test fails because the filename has changed. Changing the filename of "best_params.json" to "best_config.json" in test_hyperopt_quick within tests/unit/utils/test_save_load_mol.py can fix it.

@kevingreenman
Copy link
Member

kevingreenman commented May 14, 2024

should we add another notebook with an example of using hpopt with optuna, in addition to the hyperopt example? (after #783 is resolved) see #774

@shihchengli
Copy link
Contributor

@hwpang here are my final comments about the notebook

  1. replace the uniform with qrandint in the search space
  2. Since the default scheduler is changed to FIFO in Change the default trial scheduler to FIFOScheduler #896, please replace the ASHAScheduler with FIFOScheduler
  3. As the optuna is supported via Add Optuna support for HPO #888, instead of giving a new notebook about how to use optuna, you can add a comment in the file before the HyperOptSearch is used to generate the object of the search algorithm in the example, indicating that they can also use optuna by search_alg = OptunaSearch(), and change the notebook file name to hpopting.ipynb
  4. remove the last empty cell
  5. (Optional) you can consider adding ray.init() before running ray

@hwpang
Copy link
Contributor Author

hwpang commented Jun 5, 2024

@shihchengli Thanks for reviewing! I have updated according to your comments

@shihchengli
Copy link
Contributor

shihchengli commented Jun 5, 2024

There is a RayTaskError(OutOfMemoryError) in the notebook. I guess you are using estes cluster to test this notebook, and those two GPUs in the cluster are fully occupied now. You can try running this on the other cluster or use a CPU to test it, as we will also run the test in CI and we only have CPUs. I think it is fine to use the CPU in the notebook and point out the way to use the GPU.

Copy link
Contributor

@shihchengli shihchengli left a comment

Choose a reason for hiding this comment

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

LGTM

@shihchengli
Copy link
Contributor

I noticed a minor thing that needed to be changed in the notebook. You can remove find_unused_parameters=True from the notebook as we fixed it via #883.

@shihchengli
Copy link
Contributor

The error can be solved by changing the CI configuration to run test on hpopting.ipynb exclusively with Python 3.11.

@shihchengli
Copy link
Contributor

You can do something like this, although it's not very elegant.

  - name: Test notebooks (excluding hpopting.ipynb)
    shell: bash -l {0}
    run: |
      python -m pip install matplotlib
      pytest --no-cov -v --nbmake $(find examples -name '*.ipynb' ! -name 'hpopting.ipynb')
  - name: Test hpopting.ipynb (Python 3.11 only)
    if: ${{ matrix.python-version == '3.11' }}
    shell: bash -l {0}
    run: |
      python -m pip install matplotlib
      pytest --no-cov -v --nbmake examples/hpopting.ipynb

@hwpang
Copy link
Contributor Author

hwpang commented Jun 6, 2024

@shihchengli Thanks for the review and the suggestion! I have updated the CI accordingly

@shihchengli shihchengli enabled auto-merge (squash) June 6, 2024 15:00
@shihchengli shihchengli merged commit 7906691 into chemprop:main Jun 6, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants