Skip to content
This repository has been archived by the owner on Dec 7, 2021. It is now read-only.

Improve Amplitude Estimation Algos and Tests #788

Merged
merged 47 commits into from
Jan 29, 2020

Conversation

Cryoris
Copy link
Contributor

@Cryoris Cryoris commented Jan 24, 2020

Summary

Add more detailed tests, fix tiny bugs, improve comments and docstrings.

Details and comments

  • Based on discussion with @dongreenberg more tests to all AE variants were added, that are not only end-to-end tests (as is the current state).
  • MLAE was missing the 0 in the evaluation schedule.
  • All AE variants now return the number of Q-oracle queries (important for benchmarks, @stefan-woerner).
  • In general, docstrings and comments were improved.

Copy link
Member

@woodsp-ibm woodsp-ibm left a comment

Choose a reason for hiding this comment

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

  1. Naming changes:
  • log_max_evals to m seems like going from a meaningful naming to non-descript
  • ci_method to confint_method seems like it adds little for a user to help them
    both the above break compatibility for what does not seem substantial value.
  1. Ordering of parameter changes - seems the intent is to have all the Amplitude Estimation algos have same order of a/q_factory and i_objective but original AE is still not there

  2. Variable naming exception 'ae' to be removed that was added to list - use 'qae' in the unit test

@Cryoris
Copy link
Contributor Author

Cryoris commented Jan 26, 2020

Thanks for the review!

  1. Naming changes:
  • log_max_evals to m seems like going from a meaningful naming to non-descript

I renamed it to num_oracle_circuits, which is more accurate than log_max_evals.

  • ci_method to confint_method seems like it adds little for a user to help them
    both the above break compatibility for what does not seem substantial value.

As discussed, I'm leaving this since we have breaking changes through reordering the input arguments to a consistent order.

  1. Ordering of parameter changes - seems the intent is to have all the Amplitude Estimation algos have same order of a/q_factory and i_objective but original AE is still not there

Thanks! They all have the same order now.

  1. Variable naming exception 'ae' to be removed that was added to list - use 'qae' in the unit test

Changed to qae.

Also I changed the tests that checked the number of gates by a check for the unitary the circuit produces. Comparing the circuits directly didn't work, since this doesn't capture things such as U1(pi) == U1(-pi).

@Cryoris Cryoris requested a review from woodsp-ibm January 27, 2020 09:05
woodsp-ibm
woodsp-ibm previously approved these changes Jan 27, 2020
dongreenberg
dongreenberg previously approved these changes Jan 29, 2020
Copy link
Contributor

@dongreenberg dongreenberg left a comment

Choose a reason for hiding this comment

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

Approved, but please address renaming comment for the QPE-based AE.

@@ -36,26 +35,36 @@


class AmplitudeEstimation(AmplitudeEstimationAlgorithm):
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we rename this to be QPEAmplitudeEstimation, and say in the comment on line 38 that this is "The original, Quantum Phase Estimation-based Amplitude Estimation Algorithm."? I think it may be strange to have one algorithm called AmplitudeEstimation but then a base class called AmplitudeEstimationAlgorithm. It would be better to be descriptive. If so, we should also rename the file qpe_ae.py, yes?

Copy link
Member

Choose a reason for hiding this comment

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

The alternative might be to rename the base class, which would be less disruptive - otherwise notebooks, test cases and any users code would need to alter too. I do not know how much, or if at all, externally that base class type might be used at present outside of the package. I suspect it could be renamed without the same impact as the algorithm derived from it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

AmplitudeEstimation is used quite a bit in notebooks (and our codes), I also prefer to keep it. As discussed on Slack I'll update the the docstring though.

@Cryoris Cryoris dismissed stale reviews from dongreenberg and woodsp-ibm via 74f9c25 January 29, 2020 20:56
@dongreenberg dongreenberg merged commit 59af757 into qiskit-community:master Jan 29, 2020
@dongreenberg
Copy link
Contributor

Thanks Julien, I agree that the docstring should suffice.

@Cryoris Cryoris deleted the ae_tests branch January 30, 2020 09:13
manoelmarques pushed a commit to qiskit-community/qiskit-finance that referenced this pull request Jan 19, 2021
…ests

Improve Amplitude Estimation Algos and Tests
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants