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

Enable multi circuit submission in PennyLane IonQ, second attempt. #121

Conversation

radumarg
Copy link
Contributor

Enable multi circuit submission. This is a second attempt to implement this functionality because the first implementation involved a lot of code duplication with respect to the PennyLane baseline code.

Copy link

codecov bot commented Sep 17, 2024

Codecov Report

Attention: Patch coverage is 80.48780% with 16 lines in your changes missing coverage. Please review.

Project coverage is 91.73%. Comparing base (e5beee9) to head (eae3bcb).
Report is 1 commits behind head on multi-circuit-submission.

Files with missing lines Patch % Lines
pennylane_ionq/device.py 80.24% 16 Missing ⚠️
Additional details and impacted files
@@                     Coverage Diff                      @@
##           multi-circuit-submission     #121      +/-   ##
============================================================
- Coverage                     96.93%   91.73%   -5.21%     
============================================================
  Files                             5        5              
  Lines                           326      387      +61     
============================================================
+ Hits                            316      355      +39     
- Misses                           10       32      +22     

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

@Alex-Preciado
Copy link
Contributor

Hi @radumarg , thank you for opening this new PR. @lillian542 will be reviewing it this week. In the meantime, could you please take a look at the formatting checks (black), CodeFactor, and codecov, as they’re currently not passing?

Copy link
Contributor

@lillian542 lillian542 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 the submission, and for making the changes requested on the last PR! 🚀 This looks like a very useful addition to the plugin. I’ve left some initial feedback and suggestions, have a look and see what you think!

Wrt the tests, the CodeCov bot has indicated all the uncovered lines, and ideally let’s go for full test coverage - but there are some places that I would say are more significant than others. I’ve commented on a few spots where I think it’s particularly important we add more comprehensive tests (i.e. more thorough than just what will satisfy CodeCov in terms of line coverage).

I’ll give it another pass once comments are addressed and the test coverage is more complete :)

pennylane_ionq/device.py Outdated Show resolved Hide resolved
pennylane_ionq/device.py Outdated Show resolved Hide resolved
pennylane_ionq/device.py Outdated Show resolved Hide resolved
pennylane_ionq/device.py Outdated Show resolved Hide resolved
pennylane_ionq/device.py Outdated Show resolved Hide resolved
pennylane_ionq/device.py Show resolved Hide resolved
pennylane_ionq/device.py Show resolved Hide resolved
pennylane_ionq/device.py Show resolved Hide resolved
pennylane_ionq/device.py Outdated Show resolved Hide resolved
pennylane_ionq/device.py Outdated Show resolved Hide resolved
@radumarg
Copy link
Contributor Author

radumarg commented Sep 26, 2024

@lillian542 The rework is complete. Review comments were implemented, tests were extended, black and code factor issues were fixed. Can you please make sure tests with requires_api flag are included in test code coverage? Those tests need an IonQ API key in the test virtual environment in order to run. Note that using this is not my invention, I just took as an example some pre-existing testing code :)

@lillian542
Copy link
Contributor

Thanks @radumarg! I'll get started on another review 🚀

@lillian542 lillian542 self-requested a review September 30, 2024 13:43
Copy link
Contributor

@lillian542 lillian542 left a comment

Choose a reason for hiding this comment

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

Looking good 🎉 I left a couple more comments. At this point I'll find a second reviewer to have a look - we generally aim for 2 approvals for PRs adding new functionality.

tests/test_device.py Outdated Show resolved Hide resolved
tests/test_device.py Outdated Show resolved Hide resolved
tests/test_device.py Outdated Show resolved Hide resolved
tests/test_device.py Outdated Show resolved Hide resolved
pennylane_ionq/device.py Outdated Show resolved Hide resolved
@radumarg
Copy link
Contributor Author

radumarg commented Oct 2, 2024

@lillian542 Thanks for reviewing this change. I left a few questions regarding the latest set of comments. Please have a look. Also I see that black formatter is failing but I am not sure why. When I run it locally it passes, I am not sure with what arguments is being run during integration tests.

@lillian542 lillian542 requested a review from mudit2812 October 2, 2024 15:34
@lillian542
Copy link
Contributor

Also I see that black formatter is failing but I am not sure why. When I run it locally it passes

@radumarg, when I runblack -l 100 pennylane_ionq, it changes several split-line definitions into single lines. What version of black are you using? And is it possible that you are running it without the line length specification, and it's defaulting to something else?

pennylane_ionq/device.py Outdated Show resolved Hide resolved
pennylane_ionq/device.py Outdated Show resolved Hide resolved
pennylane_ionq/device.py Outdated Show resolved Hide resolved
pennylane_ionq/device.py Outdated Show resolved Hide resolved
Copy link
Contributor

@mudit2812 mudit2812 left a comment

Choose a reason for hiding this comment

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

Looks good. I mostly just suggested minor formatting/docs fixes. I agree with @lillian542 's comment about the generation of samples inside the estimate_probability and sample methods. We've resolved this concern for devices using the new API, but it would be a breaking change to use the current behaviour as per the old device API. For me, that is a blocker for an approval.

Other than that, the PR looks quite complete. The tests are very thorough. I'm happy to approve once the above comment and the test failures are resolved 🚀

@radumarg
Copy link
Contributor Author

radumarg commented Oct 3, 2024

@lillian542 and @mudit2812 Review comments were implemented as requested. I have added requires_api to failing tests, hopefully this time the test will pass.

Copy link
Contributor

@mudit2812 mudit2812 left a comment

Choose a reason for hiding this comment

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

Looks like all the tests are passing now 😄 . I'm quite happy with the state of this PR, and am ready to approve once code coverage is fixed. We can ignore the coverage issue for the logger.debug line by adding a # pragma: no cover to that line.

@radumarg
Copy link
Contributor Author

radumarg commented Oct 9, 2024

@mudit2812 I have added the pragma as suggested. Also, I have removed checks for BasisState, QubitStateVector and StatePrep because these operations are not supported by IonQ devices so there is no way to test those lines. Regarding the code coverage: this now should be complete, however the code coverage tool does not take into account tests with requires_api which require an IonQ API key in order to run. For example the code lines under "if self.tracker.active" are reported as uncovered but those lines are covered by this test: test_recording_when_pennylane_tracker_active The same applies for other code lines reported as uncovered.

Copy link
Contributor

@mudit2812 mudit2812 left a comment

Choose a reason for hiding this comment

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

Thanks, I'm approving, and I've reached out to the rest of the team to figure out the best strategy to address the coverage issues.

@lillian542 lillian542 changed the base branch from master to multi-circuit-submission October 10, 2024 16:22
Copy link
Contributor

@lillian542 lillian542 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 all your work here, this looks good! The tests aren’t running with the API token because this is on a fork of the repo - we’ll merge it to a new branch on the main repo to get those running.

I'm approving this before merging, it looks like everything is in order to me. If any issues come up once all the tests run, we’ll let you know; we can merge these changes to master as soon as the tests are passing with the API token on the new branch :)

@lillian542 lillian542 merged commit 255a212 into PennyLaneAI:multi-circuit-submission Oct 10, 2024
7 of 9 checks passed
mudit2812 pushed a commit that referenced this pull request Oct 10, 2024
) (#124)

* Adding code for batch circuit submit.

* Remove unused imports.

* Update version number.

* Initialize self._samples in overloaded methods.

* Various fixes.

* Running existing unit tests from previous implementation and fixing bugs.

* Correct unit test after updating pennylane baseline code to latest version.

* Fix codefactor issues.

* Run black code formatter.

* Shots cannot be none in an IonQDevice. Remove check on shots.

* Correct docstring comment.

* Remove exeception handling code.

* Remove self.histogram, replace with self.histograms.

* Uniformize treatment of one vs multiple circuits.

* Improve current_circuit_index handling with raising exceptions, add tests.

* Reset samples in reset function.

* Run black code formatter.

* Remove unused includes.

* Fix codefactor reported issues.

* Adding doc string to method.

* Fix docstring.

* Add test with shot vector.

* Add test with an observable that requires rotations for diagonalization.

* Adding unit tests for using pennylane tracker in batch_execute method. Adding unit tests for user warnings.

* Add tests for logging in batch_execute.

* Run black.

* Remove method override.

* Implement review comments.'

* Implement more review comments.'

* Remove unused imports.

* Remove unused imports.

* Remove checks for BasisState, QubitStateVector and StatePrep because these are not supported by IonQ devices.

* Fix code formatting.

---------

Co-authored-by: Radu Marginean <[email protected]>
Co-authored-by: Alex Preciado <[email protected]>
@radumarg
Copy link
Contributor Author

Thanks, please let me know in case more tests will be necessary.

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.

4 participants