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

adding QML with Classiq notebook #180

Merged
merged 5 commits into from
Jul 15, 2024
Merged

Conversation

Nadav138
Copy link
Contributor

PR Description

Some notes

  • Please make sure that you placed the files in an appropriate folder

  • And that the files have indicative names.

  • Please note that Classiq runs automatic code linting, which may minorly alter some files.

    • If you're familiar with pre-commit, you may run pre-commit install, and then at each commit, your files will be altered in a similar way

Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@Nadav138 Nadav138 marked this pull request as draft June 25, 2024 12:01
@@ -0,0 +1,1203 @@
{
Copy link

@NithyasriVS-Classiq NithyasriVS-Classiq Jun 25, 2024

Choose a reason for hiding this comment

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

Overall, looks like a good start for a Classiq user who wants to explore QML with our platform. It might be nice to have a paragraph introducing QML itself and what Classiq uniquely offers for users who want to explore QML. One of the unique things can be an easy and abstracted method to optimize algorithms, which is an important factor for someone working on QML.


Reply via ReviewNB

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Eden intended it for those familiar with QML but new to exploring it with Classiq (researchers, etc.), so I assumed the reader is familiar with the concepts but not the platform. Perhaps I should emphasize this more clearly.

Choose a reason for hiding this comment

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

Sure then, sounds good.

@@ -0,0 +1,1203 @@
{
Copy link

@NithyasriVS-Classiq NithyasriVS-Classiq Jun 25, 2024

Choose a reason for hiding this comment

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

It could be unclear to the user why suddenly we talk about a hamiltonian. The introduction paragraph below the subtitle "Using the VQE Primitive" can include a short explanation about VQE and how it helps in finding the ground state energy of a system, mentioning that the hamiltonian represents the system's energy landscape.


Reply via ReviewNB

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see your point. I will clarify that the matrix is the Hamiltonian from the begining. Regarding the ground state energy, I think it is out of the scope of the tutorial, as I assume the reader is familiar with the algorithm and its initial application. Here, we aim to showcase the "how-to" with Classiq, and the VQE primitive could be used for many other use cases beyond finding the ground state energy (if you manage to map the problem to a Hamiltonian).

Choose a reason for hiding this comment

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

:)

@@ -0,0 +1,1203 @@
{
Copy link

@NithyasriVS-Classiq NithyasriVS-Classiq Jun 25, 2024

Choose a reason for hiding this comment

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

Overall, looks like a good start for a Classiq user who wants to explore QML with our platform.

  1. I think it might be nice to mention here a short phrase along the lines of "Notice that we use the @cfunc descriptor to define a classical execution function in Classiq".
  2. It might be good to explain why using the classical function will let us harness the power of VQE

Reply via ReviewNB

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  1. Thanks, got it.
  2. Well, I believe it's clear from the context that it allows us to initialize all the required parameters and information in one place. I meant to focus on the convenience of it rather than the technical idea of the feedback loop.  Please let me know if you have further suggestions.

Choose a reason for hiding this comment

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

I see where you're coming from. Sure, going again to resolve this comment

@@ -0,0 +1,1203 @@
{
Copy link

@NithyasriVS-Classiq NithyasriVS-Classiq Jun 25, 2024

Choose a reason for hiding this comment

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

In addition to these 3 results, energy fluctuation might be an interesting result to add, if feasible because it might be of interest to researchers. I believe it's usually good to have lower fluctuations throughout so that algo converges nicely towards GS energy. Not sure if this is currently possible with in-built functions in Classiq though.


Reply via ReviewNB

Copy link
Contributor Author

@Nadav138 Nadav138 Jun 26, 2024

Choose a reason for hiding this comment

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

As mentioned, it is not necessarily for energy but in a broader context of QML and optimization. Anyway, currently, there is no "fluctuation" parameter in the results of the VQE module. I am also unsure what you mean by that in the context of VQE (standard deviation?). If you have any references or further clarification, I would appreciate it.

Choose a reason for hiding this comment

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

I meant in the context of as the state evolves, the energy of the hamiltonian evolves too and if the energy varies too much, it's seen that the algorithm might not converge accurately. But this is only in the context of trying to find the ground state energy.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, for that reason the user may define the "max_iteration" and "tolerance" arguments. I still don’t understand what you mean by "if the energy varies too much". Is it in the context of standard deviation?

I have added the standard deviation of the last iteration, but I believe plotting all of them is unnecessary and easy to understand at this point for the user if needed.

Please let me know if you have further notes here, or if there are other issues to resolve. 🙏🏽

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok I had removed the std as it was not the std of the final eigenvalue, for having that a user will have to run the algorithm multiple times.

I believe that you are referring is visible from the plot.

@@ -0,0 +1,1203 @@
{
Copy link

@NithyasriVS-Classiq NithyasriVS-Classiq Jun 25, 2024

Choose a reason for hiding this comment

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

"Details" can be renamed to "Fun Exercise" or "Exercise"


Reply via ReviewNB

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Definitely, I called it "Exercise - Two Qubits VQE", unsure why it's not visible here.

Choose a reason for hiding this comment

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

I still can't view it as Exercise but maybe it's just a glitch. All good if it's visible to you. Resolving

@@ -0,0 +1,1203 @@
{
Copy link

@NithyasriVS-Classiq NithyasriVS-Classiq Jun 25, 2024

Choose a reason for hiding this comment

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

This is nice since our reader might be familiar with Classiq and quantum computing but not PyTorch! :)


Reply via ReviewNB

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks :)

Choose a reason for hiding this comment

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

:)

@@ -0,0 +1,1203 @@
{
Copy link

@NithyasriVS-Classiq NithyasriVS-Classiq Jun 25, 2024

Choose a reason for hiding this comment

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

Same comment as before on the naming because the user might overlook it


Reply via ReviewNB

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's an issue of the ReviwNB rendering, The naming is indeed different.

@@ -0,0 +1,1203 @@
{
Copy link
Contributor Author

@Nadav138 Nadav138 Jun 26, 2024

Choose a reason for hiding this comment

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

Seems like ReviewNB issue as here I also didn't call it "Details"


Reply via ReviewNB

Choose a reason for hiding this comment

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

Same

@Nadav138 Nadav138 marked this pull request as ready for review July 14, 2024 13:44
@Nadav138 Nadav138 merged commit 1a78661 into Classiq:main Jul 15, 2024
2 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.

3 participants