Qiskit / qiskit-tutorials

A collection of Jupyter notebooks showing how to use the Qiskit SDK
Apache License 2.0
2.28k stars 1.28k forks source link

Add a tutorial about Quantum Imaginary Time Evolution #1454

Closed OuCheng-Fu closed 1 year ago

OuCheng-Fu commented 1 year ago

What is the expected behavior?

Create a tutorial about Quantum Imaginary Time Evolution mentioned in these papers: 1.arXiv:2108.10846 2.https://www.nature.com/articles/s41534-021-00409-y 3.arXiv:1901.07653 The tutorial https://qiskit.org/documentation/_modules/qiskit/algorithms/evolvers/evolution_problem.html#EvolutionProblem and https://github.com/Qiskit/qiskit-terra/tree/main/qiskit/algorithms/evolvers are fragmented.

woodsp-ibm commented 1 year ago

The tutorial https://qiskit.org/documentation/_modules/qiskit/algorithms/evolvers/evolution_problem.html#EvolutionProblem and https://github.com/Qiskit/qiskit-terra/tree/main/qiskit/algorithms/evolvers are fragmented.

I am not quite sure what is meant by are fragmented. In any case evolvers in Qiskit Terra are deprecated and replaced by the time_evolvers which work with the new primitives. So any new content should use time_evolvers.

I will just note #1391 since its also around time evolution tutorials and references the same nature paper in the issue

OuCheng-Fu commented 1 year ago

The tutorial https://qiskit.org/documentation/_modules/qiskit/algorithms/evolvers/evolution_problem.html#EvolutionProblem and https://github.com/Qiskit/qiskit-terra/tree/main/qiskit/algorithms/evolvers are fragmented.

I am not quite sure what is meant by are fragmented. In any case evolvers in Qiskit Terra are deprecated and replaced by the time_evolvers which work with the new primitives. So any new content should use time_evolvers.

I will just note #1391 since its also around time evolution tutorials and references the same nature paper in the issue

Thank you. I will try it.

OuCheng-Fu commented 1 year ago

The tutorial https://qiskit.org/documentation/_modules/qiskit/algorithms/evolvers/evolution_problem.html#EvolutionProblem and https://github.com/Qiskit/qiskit-terra/tree/main/qiskit/algorithms/evolvers are fragmented.

I am not quite sure what is meant by are fragmented. In any case evolvers in Qiskit Terra are deprecated and replaced by the time_evolvers which work with the new primitives. So any new content should use time_evolvers.

I will just note #1391 since its also around time evolution tutorials and references the same nature paper in the issue

I have tried the VarQITE module of Qiskit as mentioned in #1391, and when I tried to implement an Ising Hamiltonian based on Quadratic Program, and I got an unsupported type of parameter values, the error is mentioned in this picture: 截圖 2023-06-14 下午7 35 41 I read the source code several times but I can't find the problem, what is the real problem of this?

woodsp-ibm commented 1 year ago

I commented in the PR that is adding a tutorial that is the same as this here

https://github.com/Qiskit/qiskit-tutorials/issues/1454#issuecomment-1574893830

I imagine this is the method that is checking it https://github.com/Qiskit/qiskit-terra/blob/332bd9fe0bea82c0fdf7329cea3da115d86e3fc2/qiskit/algorithms/time_evolvers/variational/var_qte.py#L234, maybe that's of help, where param_values seems to relate to initial_parameters passed. You can see the type checks its doing and the failing type should have been part of the error message.

OuCheng-Fu commented 1 year ago

Thank you. I will look up into it.

OuCheng-Fu commented 1 year ago

I commented in the PR that is adding a tutorial that is the same as this here

#1454 (comment)

I imagine this is the method that is checking it https://github.com/Qiskit/qiskit-terra/blob/332bd9fe0bea82c0fdf7329cea3da115d86e3fc2/qiskit/algorithms/time_evolvers/variational/var_qte.py#L234, maybe that's of help, where param_values seems to relate to initial_parameters passed. You can see the type checks its doing and the failing type should have been part of the error message.

My reference is this picture Var QTE PY I tried several times by first adding a list and second adding a dictionary to my code, when I added dictionary Sequence like this picture Unhashable Type It comes out another error Unhashable Type: 'Parameter View' where can I find parameter view?

woodsp-ibm commented 1 year ago

Maybe check this unit test out which sets up initial parameters for VatQITE and works https://github.com/Qiskit/qiskit-terra/blob/81964e649938ce7b201364013e4fe17098e4533c/test/python/algorithms/time_evolvers/variational/test_var_qite.py#L189

According to docs

initial_parameters (Mapping[Parameter, float] | Sequence[float]) – Initial parameter values for the ansatz.

So it should be a Sequence (list) of float values, which will give the values in the order of the Parameters they are returned by parameters, or a Mapping (dictionary) which allows you to state which parameter gets which value explicitly, rather than implicitly by the list.

OuCheng-Fu commented 1 year ago

Thank you. I will try it again.

OuCheng-Fu commented 1 year ago

Maybe check this unit test out which sets up initial parameters for VatQITE and works https://github.com/Qiskit/qiskit-terra/blob/81964e649938ce7b201364013e4fe17098e4533c/test/python/algorithms/time_evolvers/variational/test_var_qite.py#L189

According to docs

initial_parameters (Mapping[Parameter, float] | Sequence[float]) – Initial parameter values for the ansatz.

So it should be a Sequence (list) of float values, which will give the values in the order of the Parameters they are returned by parameters, or a Mapping (dictionary) which allows you to state which parameter gets which value explicitly, rather than implicitly by the list.

I have implemented it on a 5-vertex MaxCut Problem QITE Maxcut 5-vertex With the Hamiltonian QITE Maxcut 5-vertex Hamiltonian Then I print the evolution result QITE Maxcut 5-vertex evolution If I want to know the minimum eigenvalue of the system, like QAOA, what should I write the code

OuCheng-Fu commented 1 year ago

Maybe check this unit test out which sets up initial parameters for VatQITE and works https://github.com/Qiskit/qiskit-terra/blob/81964e649938ce7b201364013e4fe17098e4533c/test/python/algorithms/time_evolvers/variational/test_var_qite.py#L189

According to docs

initial_parameters (Mapping[Parameter, float] | Sequence[float]) – Initial parameter values for the ansatz.

So it should be a Sequence (list) of float values, which will give the values in the order of the Parameters they are returned by parameters, or a Mapping (dictionary) which allows you to state which parameter gets which value explicitly, rather than implicitly by the list.

Can I open another issue to talk about this thing?

woodsp-ibm commented 1 year ago

Qiskit has a Slack workspace for discussions, support etc. You can see the link in the "Stay Connected" section, which is in the bottom bar of the qiskit.org home page. I replicate here for convenience https://qisk.it/join-slack

OuCheng-Fu commented 1 year ago

Qiskit has a Slack workspace for discussions, support etc. You can see the link in the "Stay Connected" section, which is in the bottom bar of the qiskit.org home page. I replicate here for convenience https://qisk.it/join-slack

I have joined the slack workspace. What channel should I post my questions on?

woodsp-ibm commented 1 year ago

There are channels for various aspects of Qiskit and Qiskit Ecosystem there, so best to post it in one that is most relevant - e.g If the question relates to functionality in qiskit-terra then #terra etc. And since QITE is part of qiskit-terra then questions regarding that would seem appropriate there. Now there is a #general channel too for more general questions evidently and if you are unsure where to ask, but I think the channels are pretty obvious. You can also search the workspace to see it something like that has been asked/answered before etc.

OuCheng-Fu commented 1 year ago

There are channels for various aspects of Qiskit and Qiskit Ecosystem there, so best to post it in one that is most relevant - e.g If the question relates to functionality in qiskit-terra then #terra etc. And since QITE is part of qiskit-terra then questions regarding that would seem appropriate there. Now there is a #general channel too for more general questions evidently and if you are unsure where to ask, but I think the channels are pretty obvious. You can also search the workspace to see it something like that has been asked/answered before etc.

Thank you. I have posted it on terra.

OuCheng-Fu commented 1 year ago

The tutorial https://qiskit.org/documentation/_modules/qiskit/algorithms/evolvers/evolution_problem.html#EvolutionProblem and https://github.com/Qiskit/qiskit-terra/tree/main/qiskit/algorithms/evolvers are fragmented.

I am not quite sure what is meant by are fragmented. In any case evolvers in Qiskit Terra are deprecated and replaced by the time_evolvers which work with the new primitives. So any new content should use time_evolvers. I will just note #1391 since its also around time evolution tutorials and references the same nature paper in the issue

I have tried the VarQITE module of Qiskit as mentioned in #1391, and when I tried to implement an Ising Hamiltonian based on Quadratic Program, and I got an unsupported type of parameter values, the error is mentioned in this picture: 截圖 2023-06-14 下午7 35 41 I read the source code several times but I can't find the problem, what is the real problem of this?

I have tried the same code on a 5-vertex Maxcut Problem like the comment https://github.com/Qiskit/qiskit-tutorials/issues/1454#issuecomment-1595952663 It took me around 3 minutes on my Windows 10 computer to have the result already mentioned in the comment. However, When I want to implement the same code on the Hamiltonian of HCP Problem of this graph, like the pictures below QITE HCP 4 vertex runs for more than 10000 minutes 1 QITE HCP 4 vertex runs for more than 10000 minutes 2 QITE HCP 4 vertex runs for more than 10000 minutes 3 The Hamiltonian is QITE HCP 4 vertex runs for more than 10000 minutes Hamiltonian Then it continues to run for more than 10000 minutes on my Windows 10 computer, my computer has not been turned off for more than 10 days, like this picture QITE HCP 4 vertex runs for more than 10000 minutes 4 What is the problem?

OuCheng-Fu commented 1 year ago

The tutorial https://qiskit.org/documentation/_modules/qiskit/algorithms/evolvers/evolution_problem.html#EvolutionProblem and https://github.com/Qiskit/qiskit-terra/tree/main/qiskit/algorithms/evolvers are fragmented.

I am not quite sure what is meant by are fragmented. In any case evolvers in Qiskit Terra are deprecated and replaced by the time_evolvers which work with the new primitives. So any new content should use time_evolvers. I will just note #1391 since its also around time evolution tutorials and references the same nature paper in the issue

I have tried the VarQITE module of Qiskit as mentioned in #1391, and when I tried to implement an Ising Hamiltonian based on Quadratic Program, and I got an unsupported type of parameter values, the error is mentioned in this picture: 截圖 2023-06-14 下午7 35 41 I read the source code several times but I can't find the problem, what is the real problem of this?

I have tried the same code on a 5-vertex Maxcut Problem like the comment #1454 (comment) It took me around 3 minutes on my Windows 10 computer to have the result already mentioned in the comment. However, When I want to implement the same code on the Hamiltonian of HCP Problem of this graph, like the pictures below QITE HCP 4 vertex runs for more than 10000 minutes 1 QITE HCP 4 vertex runs for more than 10000 minutes 2 QITE HCP 4 vertex runs for more than 10000 minutes 3 The Hamiltonian is QITE HCP 4 vertex runs for more than 10000 minutes Hamiltonian Then it continues to run for more than 10000 minutes on my Windows 10 computer, my computer has not been turned off for more than 10 days, like this picture QITE HCP 4 vertex runs for more than 10000 minutes 4 What is the problem?

This is the update of the previous problem. The code has already run for more than 18000 minutes, and my computer has not been shut down for more than 13 days, like this picture below QITE HCP 4 vertex runs for more than 18000 minutes Is this normal? Or is there a problem? If there is a problem, how do I solve it?