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

Persist circuits in batch execute #260

Conversation

WingCode
Copy link
Contributor

Issue #, if available: closes #255

Description of changes: Add persistence of multiple circuits when batch_execute is called

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.

@WingCode WingCode requested a review from a team as a code owner May 30, 2024 10:40
@WingCode WingCode changed the title Persist circuits in batch execute Draft: Persist circuits in batch execute May 30, 2024
@WingCode WingCode changed the title Draft: Persist circuits in batch execute Persist circuits in batch execute May 30, 2024
@WingCode WingCode marked this pull request as draft May 30, 2024 11:59
@WingCode WingCode marked this pull request as ready for review May 30, 2024 12:50
Copy link

codecov bot commented May 30, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (7cfecb8) to head (70adc56).
Report is 1 commits behind head on feature/persist-batch-circuits.

Additional details and impacted files
@@                       Coverage Diff                        @@
##           feature/persist-batch-circuits      #260   +/-   ##
================================================================
  Coverage                          100.00%   100.00%           
================================================================
  Files                                   7         7           
  Lines                                1211      1225   +14     
  Branches                              295       297    +2     
================================================================
+ Hits                                 1211      1225   +14     

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

@AbeCoull
Copy link
Contributor

Hi @WingCode and thanks for raising this! It seems the linter check is failing. Locally, you can run tox -e linters to fix this.

@WingCode
Copy link
Contributor Author

WingCode commented Jun 11, 2024

@math411 I have fix the linting issues. Could you please review?

@yitchen-tim yitchen-tim self-requested a review June 11, 2024 18:43
Copy link
Contributor

@yitchen-tim yitchen-tim left a comment

Choose a reason for hiding this comment

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

Hi @WingCode , thanks for contributing to the issue! This PR solves half of the problem stated in #255. Printing noisy circuits when using noise model is still not supported. However, after reviewing this PR, I think printing noisy circuits is not the right goal to pursue.

The right goal is to allow users to retrieve the tasks (and the task ids), from which noisy circuits can be retrieved. If you can extend this PR to include the following feature, we are good to go: "Persist the task when parallel=True", which requires

  1. Add an attribute self._tasks=[]
  2. Add a method for returning tasks
    @property
    def tasks(self) -> list[QuantumTask]:
        ...

, similar to


3. Add unit tests for tasks

@@ -139,6 +139,7 @@ def __init__(
super().__init__(wires, shots=shots or None)
self._device = device
self._circuit = None
self._circuits = []
Copy link
Contributor

Choose a reason for hiding this comment

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

self._circuits here is a private variable. that users should not access. Instead, users access _circuits through properties. So, there need to be a new property of this class called circuits defined as a method of the class, similar to

.

Copy link
Contributor

Choose a reason for hiding this comment

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

And yes, it's a bit repetitive now that we have both circuits and circuit, but I think it's okay for now. In long term, circuit may be deprecated.

@WingCode WingCode requested a review from yitchen-tim June 11, 2024 21:33
@yitchen-tim yitchen-tim changed the base branch from main to persist-batch-circuits June 12, 2024 03:02
@yitchen-tim yitchen-tim changed the base branch from persist-batch-circuits to feature/persist-batch-circuits June 12, 2024 03:04
Copy link
Contributor

@yitchen-tim yitchen-tim left a comment

Choose a reason for hiding this comment

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

Hi @WingCode, the PR looks good! I changed the target branch to be a feature branch instead of the main branch because Amazon Braket needs rework the duplication of circuit and circuits which requires some discussions. I will assign the issue to you and close the issue. This should be good in UnitaryHack regards. Thanks for contributing!

I somehow have trouble assigning the issue to you. I am asking my team to resolve it.

@WingCode
Copy link
Contributor Author

Thank you @yitchen-tim for the reviews and all of the timely support!

@yitchen-tim
Copy link
Contributor

@WingCode Could you leave a comment on the issue: #255? After that, I should be able to assign you.

@yitchen-tim yitchen-tim merged commit 03fe023 into amazon-braket:feature/persist-batch-circuits Jun 12, 2024
15 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.

Print noisy circuit when a Braket noise model is applied to PL device with parallel=True
4 participants