-
Notifications
You must be signed in to change notification settings - Fork 61
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
Qcnn upgrade #1083
Qcnn upgrade #1083
Conversation
1. Now accepts arbitrary 2-qubit circuit blocks as input 2. Switched from scipy.optimize.minimize to qibo.optimizers.optimize
Update test for qcnn upgrade: 1. Now accepts arbitrary 2-qubit circuit blocks as input 2. Switched from scipy.optimize.minimize to qibo.optimizers.optimize
correction
fix pytest
fix #print
fix pytest for 100% coverage of updated qcnn class
install tensorflow
remove backend settings in minimize
remove explicit sgd check since use case follows as per qibo.optimizer.optimize
make initial state copy in Predictions function if backend is qibojit
test qibojit backend case to create copy of initial state
add import qibo to check backend
add copy flag during initialization
for more information, see https://pre-commit.ci
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #1083 +/- ##
===========================================
- Coverage 100.00% 99.97% -0.03%
===========================================
Files 68 68
Lines 9790 9803 +13
===========================================
+ Hits 9790 9801 +11
- Misses 0 2 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Many thanks @jykhoo1987 for implementing this.
Some comments follow.
@@ -303,3 +305,47 @@ def test_qcnn_training(): | |||
predictions.append(1) | |||
labels = np.array([[1], [-1], [1]]) | |||
test_qcnn.Accuracy(labels, predictions) | |||
|
|||
|
|||
def test_two_qubit_ansatz(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would pass backend
as argument of the tests here. With this you will execute the tests in all the backends. Now that the qibojit
in-place update is fixed in the main of the qcnn
model, all the tests should pass.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it suffices if we test the backends for the training, so we can keep it to the tests that involve training maybe
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It always better to test the code for all the available backends, in order not to have surprises if an external user decides to use this model with, e.g. tensorflow
and training it with some automatic differentiation method.
You only need to add backend
as an argument of your tests, e.g.:
def test_two_qubit_ansatz(backend):
# same code here
Co-authored-by: Matteo Robbiati <[email protected]>
Co-authored-by: Matteo Robbiati <[email protected]>
@jykhoo1987 I will wait for your change until later today, if you do not manage we postpone this feature for the next release. |
Apologies for the delay. @rahula06 will look into the rest of this PR later this week when he is back from leave. |
update in response to comments.
for more information, see https://pre-commit.ci
The last two training tests now test both qibojit and numpy backends.
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
Merge branch 'qcnn_upgrade' of https://github.com/qiboteam/qibo into qcnn_upgrade
for more information, see https://pre-commit.ci
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1083 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 68 68
Lines 9790 9803 +13
=========================================
+ Hits 9790 9803 +13
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Merge branch 'qcnn_upgrade' of https://github.com/qiboteam/qibo into qcnn_upgrade
It seems that going back to the old test works, so that the qibojit backend test is indeed working. My best guess is that the codecov tool might not be able to evaluate these pytest fixtures very well. If you are okay, we could just keep the tests with the explicit parametrization to pass the checks. If anyone has better knowledge of how codecov works or could suggest an alternative, that would be great too :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, a few comments follow.
Then I think we are ready :)
Co-authored-by: Matteo Robbiati <[email protected]>
Co-authored-by: Matteo Robbiati <[email protected]>
Co-authored-by: Matteo Robbiati <[email protected]>
Co-authored-by: Matteo Robbiati <[email protected]>
fixed, and still seems to pass all the tests! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks.
Checklist:
3 'upgrades' implemented in qcnn class:
Credits to @rahula06 for implementing most of these changes.
We will work on the updated documentation and make a separate pull request for that.
@ihpcdingwj @jf-kong @rahula06