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

Matrix Product State Preparation #705

Closed
wants to merge 27 commits into from

Conversation

henrik-dreyer
Copy link

Summary

Computes the circuit to prepare a given Matrix Product State.

Details and comments

@henrik-dreyer henrik-dreyer changed the title Mps Matrix Product State Preparation Oct 9, 2019
@dongreenberg
Copy link
Contributor

Hi @henrik-dreyer,

Thanks for this PR. This is an interesting proposal and I agree that it should be supported as an ansatz preparation method in Aqua, or as a start to a broader set of tensor network methods. A few questions:

  1. Code in Aqua needs to adhere to object-orientedness to be clear and reusable. Do you see a way to standardize the interface and usage of this functionality? For example, could this be made into a class, the matrices specified through Operator objects, and the class adhering to the InitialState interface so it can be used with variational_forms?
  2. More broadly, if we wanted this to be a start for tensor network methods within Aqua, do you see how any manipulations done here can be object-ized into reusable objects for tensor networks, or are they all only relevant to MPS preparation (and therefore would only go in the MPS class)?
  3. Do you see how the HartreeFock initial state in Aqua Chemistry could be refactored to use this interface, rather than containing similar functionality?

If you like, we (some Aqua folks) would be happy to help you think through some designs for the above.

@henrik-dreyer
Copy link
Author

henrik-dreyer commented Oct 15, 2019

Hi @dongreenberg ,

that makes a lot of sense. If I understand your first point correctly, you're suggesting the following:

  1. Make this into an MPS class
  2. Initialize with lists of Operators (that one may create from numpy matrices)
  3. As an initial state, make this compatible with variational forms in the same way as e.g. the Hartree-Fock wavefunction

I think all of this can be done, let me take a look into it.
With regards to your second point, I have two points to make:

  1. An important step in the method proposed here is the transformation of the Matrix Product State into canonical form. This is a basic functionality that is required in almost all algorithms dealing with MPS, Matrix Product Operators (MPOs) and to some extend even boundaries of two-dimensional systems. Maybe it would be good to have that transformation as separate code as I am sure it is reusable.
  2. The preparation method implemented here is somewhat special to the case of Matrix Product States. While injective PEPS, for example, can also be prepared efficiently on a quantum computer, one would have to go about it rather differently.

I'd be very happy to use this as a starting point for developing a broader tensor network library.

@merav-aharoni
Copy link

Are you aware that there already is an implementation of MPS in Aer? It is implemented as a simulation method for the qasm simulator. You can see details in the code or in the tutorial https://github.com/Qiskit/qiskit-iqx-tutorials/blob/master/qiskit/advanced/aer/7_matrix_product_state_method.ipynb.
I'll be happy to discuss if you'd like more details.

@henrik-dreyer
Copy link
Author

@merav-aharoni ,

the purpose of the method I propose here is not to use MPS on a classical computer to simulate the unitary evolution, but rather prepare the MPS on the quantum computer, much like finding the Hartree Fock state and preparing the Hartree Fock state are two different things.

@woodsp-ibm
Copy link
Member

Hi Henrik, what is your current thinking with this PR? Donny gave some comments above I would echo the sentiment of having this usable in Aqua as an object in the form of an InitialState that can be supplied to var forms etc.
I note the code you provided an 'ncon' package which I cannot find on PyPi - I assume the author never went to the trouble of packaging it up. For code integrated into Aqua we would really want a pip installable package that we can include in the requirements/setup like the other dependencies. Maybe there is some alternative.

@ares201005
Copy link

Are you aware that there already is an implementation of MPS in Aer? It is implemented as a simulation method for the qasm simulator. You can see details in the code or in the tutorial https://github.com/Qiskit/qiskit-iqx-tutorials/blob/master/qiskit/advanced/aer/7_matrix_product_state_method.ipynb.
I'll be happy to discuss if you'd like more details.

Are you aware that there already is an implementation of MPS in Aer? It is implemented as a simulation method for the qasm simulator. You can see details in the code or in the tutorial https://github.com/Qiskit/qiskit-iqx-tutorials/blob/master/qiskit/advanced/aer/7_matrix_product_state_method.ipynb.
I'll be happy to discuss if you'd like more details.

can this MPS simulator in AER be used with aqua VQE solver? I tried it, found the results are not very good, sometimes even worse than the Hartree-Fock solution.

@yehuda-naveh
Copy link

Hi @ares201005 , indeed the Aer MPS method can work seemlessly with VQE. @yaelbh has experimental results on a large set of molecules and at least for RyRz variational forms the simulation method is faster than statevector, and covers much larger molecules (the functional results are identical in both simulation methods). It may be though that a more recent version of Aer is needed. @yaelbh will comment further on this, and will also publish her results soon

@ares201005
Copy link

@yehuda-naveh thank you very much for the comments. I also expect the MPS simulator is faster and can converge to the same results as the statevector.
@yaelbh is there any experimental Aer branch that I can try? thanks!

@yaelbh
Copy link
Contributor

yaelbh commented Mar 5, 2020

Latest qiskit (pip install -u qiskit) has MPS working. As said before, the result is identical to the one produced by the statevector simulator (difference is only in perofrmance), which in turn is identical to what a noiseless quantum device would output. So, if the VQE's result is less good than Hartree-Fock, this is a property of the VQE algorithm and is not related to the simulation method. Would you like to share your code?

@yaelbh
Copy link
Contributor

yaelbh commented Mar 5, 2020

Actually after installing qiskit, need to update Aer with pip install --upgrade qiskit-aer. I'm going to check now if further action is needed.

@yaelbh
Copy link
Contributor

yaelbh commented Mar 5, 2020

No further action is needed.

@ares201005
Copy link

Latest qiskit (pip install -u qiskit) has MPS working. As said before, the result is identical to the one produced by the statevector simulator (difference is only in perofrmance), which in turn is identical to what a noiseless quantum device would output. So, if the VQE's result is less good than Hartree-Fock, this is a property of the VQE algorithm and is not related to the simulation method. Would you like to share your code?

I installed the source code, it does have MPS working. But I just cannot get the same result. May I have your email address to share the code with you? Thanks

@yaelbh
Copy link
Contributor

yaelbh commented Mar 8, 2020

Sure, I've updated my profile

@woodsp-ibm
Copy link
Member

Closing as all work on Aqua is moved elsewhere with the code being moved to Terra and domain specific repos. Chemistry is moved to qiskit-nature.

@woodsp-ibm woodsp-ibm closed this Mar 5, 2021
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.

9 participants