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

Healthcare and life science use case: retrosynthetic planning using reinforcement learning #121

Closed

Conversation

AoyuQC
Copy link
Contributor

@AoyuQC AoyuQC commented Nov 26, 2023

Description of changes:

Refactor the code in aws solution (https://aws.amazon.com/solutions/implementations/quantum-computing-exploration-for-drug-discovery/) and contribute to braket algorithm library. This is the first use case, the use of quantum circuit in reinforcement learning to solve the problem of retrosynthetic planning

Testing done:

Merge Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your pull request.

General

Tests

  • I have added tests that prove my fix is effective or that my feature works (if appropriate)
  • I have checked that my tests are not configured for a specific region or account (if appropriate)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@AoyuQC AoyuQC changed the title WIP healthcare and life science use case: retrosynthetic planning using reinforcement learning WIP: healthcare and life science use case: retrosynthetic planning using reinforcement learning Nov 26, 2023
@rmshaffer
Copy link
Contributor

@AoyuQC, quick clarification - is this PR ready for review? If yes, would you please remove "WIP" from the title to indicate this? If no, would you please convert the PR to draft until it is ready? Thank you!

@AoyuQC
Copy link
Contributor Author

AoyuQC commented Dec 11, 2023

@AoyuQC, quick clarification - is this PR ready for review? If yes, would you please remove "WIP" from the title to indicate this? If no, would you please convert the PR to draft until it is ready? Thank you!

Hi, I will convert it to draft

@rmshaffer rmshaffer marked this pull request as draft December 11, 2023 17:12
@AoyuQC AoyuQC changed the title WIP: healthcare and life science use case: retrosynthetic planning using reinforcement learning Healthcare and life science use case: retrosynthetic planning using reinforcement learning Jan 15, 2024
@sussii
Copy link

sussii commented Jan 19, 2024

Confirmed with Aoyu (the author). The PR is ready for review. Could someone please take a look? Thanks!

@AoyuQC
Copy link
Contributor Author

AoyuQC commented Jan 19, 2024

@rmshaffer , please change it from draft to ready to review status. Thank you!

@rmshaffer rmshaffer marked this pull request as ready for review January 22, 2024 15:30
Copy link
Contributor

@rmshaffer rmshaffer left a comment

Choose a reason for hiding this comment

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

I haven't reviewed the content of the algorithm or notebook, but I left a few initial comments on the code structure and formatting. To enable the CI to pass, please ensure that you can run the successfully following commands locally:

  • black . and flake8 ➡️ checks code formatting; please fix any failures reported
  • tox -e unit-tests ➡️ runs unit tests; please ensure that your new test runs successfully in this method

Copy link
Contributor

Choose a reason for hiding this comment

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

Should this file be named requirements.txt?

Comment on lines +1 to +12
# Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You
# may not use this file except in compliance with the License. A copy of
# the License is located at
#
# http://aws.amazon.com/apache2.0/
#
# or in the "license" file accompanying this file. This file is
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
# ANY KIND, either express or implied. See the License for the specific
# language governing permissions and limitations under the License.
Copy link
Contributor

Choose a reason for hiding this comment

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

If your goal is to use this copyright/license for the PR, can you please ensure this is at the top of every new .py file you've added?

Comment on lines +163 to +182
# os.system(f"aws s3 cp {save_path} s3://{s3}/data/{save_name}")
# AWS_REGION = "us-west-1"
# S3_BUCKET_NAME = "amazon-braket-us-west-1-493904798517"
# s3_client = boto3.client("s3", region_name=AWS_REGION)
# s3_client.upload_file(save_path, S3_BUCKET_NAME, f'data/{save_name}')
# job_name = os.environ["AMZN_BRAKET_JOB_NAME"]
# save_job_checkpoint(
# checkpoint_data={"data": f"data for checkpoint from {job_name}"},
# checkpoint_file_suffix="checkpoint-1",
# )
# if retro_rl_agent.name.split('_')[1] == 'aspen-m2':
# AWS_REGION = "us-west-1"
# S3_BUCKET_NAME = "amazon-braket-us-west-1-493904798517"
# s3_client = boto3.client("s3", region_name=AWS_REGION)
# s3_client.upload_file(save_path, S3_BUCKET_NAME, f'data/{save_name}')
# else:
# AWS_REGION = "us-west-1"
# S3_BUCKET_NAME = "amazon-braket-us-west-1-493904798517"
# s3_client = boto3.client("s3", region_name=AWS_REGION)
# s3_client.upload_file(save_path, S3_BUCKET_NAME, f'data/{save_name}')
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a general comment that applies to the whole PR - it's best practice to avoid merging code that is commented-out. (For a few reasons: it's not testable; it will likely break in the future, even if it works now; and it's not clear to a reader why the code is there.) For each commented block of code, is there a good reason to keep the code? If so, is there an alternative to having it commented out (for example, put it behind a flag that the user can optionally enable)?

Copy link
Contributor

Choose a reason for hiding this comment

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

Would you mind doing a quick spell-check on the notebook content?

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, if you would like to run automatic Python code formatting on this notebook, you can use black for this:

  • pip install "black[jupyter]"
  • black ./notebooks/industry_applications/healthcare-and-life-sciences/Retrosynthetic_Planning/Retrosynthetic_Planning_Quantum_Reinforcement_Learning.ipynb

@ykharkov
Copy link
Member

ykharkov commented Jan 23, 2024

Hi @AoyuQC ,

thanks for the PR.

I have a few comments from the scientific perspective.
The industrial use case considered here is very interesting indeed and would be a great add-on to our Algorithm library.

However, I have a few concerns about the results obtained in the notebook and their interpretation:

  1. The notebook does not explain the meaning of a "classical circuit" (plot at the end of notebook), which is supposed to be a classical benchmark. It is totally unclear what the classical baseline is right now. The existing "classical circuit" baseline only makes the Cost function worse throughout training, and definitely it is of a major concern.
    image

  2. The author references the paper https://pubs.acs.org/doi/10.1021/acscentsci.9b00055, and I strongly recommend to use their method as a baseline. From Fig. 3 of the referenced paper it is clear, that the classical baseline improves the Cost function during training. So the narrative of the notebook that quantum RL model is outperforming a classical method is not substantiated. Perhaps if a direct comparison with classical methods is problematic, I could recommend to remove this comparison and to not make any claims that quantum has an advantage over classical approach.

  3. The code in RetroRLAgent.py and RetroGateModel.py is totally unreadable, while these the key files here. The files contain a lot of commented out code, and nobody opening these files would be able to understand (even on a high level) what is going on. I would strongly suggest to revise the code in these two files and improve the quality / readability, otherwise unfortunately it can not pass Braket quality bar.

@peterkomar-aws
Copy link
Contributor

Hello AoyuQC,

The algorithm you are proposing to add has many external dependencies, and it explicitly relies on the user running the terminal instructions from the notebook. It's clear that the nature of this use case necessitates these dependencies, but as maintainers of the Braket Algorithm library, we wish to make the dependencies minimal and, more importantly, explicit.

After reviewing your PR, we think, in its current form, it is better suited to be developed in a separate repo; and instead, we'd love to feature it in the Braket Algorithm library "Community repos" section, which we recently added.

I will close this PR for now, but feel free to continue to work on it here and reopen.

@AoyuQC
Copy link
Contributor Author

AoyuQC commented Apr 3, 2024

Hello AoyuQC,

The algorithm you are proposing to add has many external dependencies, and it explicitly relies on the user running the terminal instructions from the notebook. It's clear that the nature of this use case necessitates these dependencies, but as maintainers of the Braket Algorithm library, we wish to make the dependencies minimal and, more importantly, explicit.

After reviewing your PR, we think, in its current form, it is better suited to be developed in a separate repo; and instead, we'd love to feature it in the Braket Algorithm library "Community repos" section, which we recently added.

I will close this PR for now, but feel free to continue to work on it here and reopen.

Hi @peterkomar-aws ,

Thank you for the update. I am working on it.

Best,

Aoyu

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.

6 participants