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
Support AmplitudeEncoding on hardware #273
Comments
I agree, that would be a nice addition to this function. Thanks, @johannesjmeyer :) This will also go hand-in-hand with the concepts section on this topic (PR #216 ). I will work on this asap. |
Carsten Blank (who helped with the IBM plugins) has qiskit code for an implementation of AmplitudeEmbedding using gates - and not a simulation hack - based on a paper from Mottoennen et al: https://github.com/carstenblank/dc-qiskit-algorithms/blob/master/dc_qiskit_algorithms/M%C3%B6tt%C3%B6nenStatePrep.py This would be cool to include, i.e. with a flag that chooses if one uses 'QubitStateVector' or the actual circuit for the task. He kindly agreed that we can just rewrite the code as a PennyLane Template! |
This sounds awesome @mariaschuld; this would allow |
Would it make more sense to implement directly |
I think this is a very good question, that doesn't have a clear answer. Some plugins (such as Qiskit) support arbitrary state preparation, and have their own code for decomposition. Others, such as Forest, don't, so would benefit from having this in PennyLane. At the same time, we don't currently have a good framework to allow both options in PennyLane. Ideally, it would work as follows:
This is a similar approach to what we do in Strawberry Fields. Thoughts? |
Honestly, it sounds like something that would best fit within the plugins themselves, since it is their responsibility to translate top-level circuits into hardware-compatible circuits. If included as part of core PennyLane, we need to have a way to make clear to the user when there is a decomposition happening behind the scenes. If their circuit gives completely different results on two different hardwares, we want to make it as clear as possible how the execution might be different. |
I just woke up and had the exact same thought @co9olguy, but you vocalised it before I had a chance 😆 This is something we should add to the plugins, which are designed to map PL operations to specific hardware frameworks. |
Also agree that the implementation of QubitStateVector is up to the plugins, but would still like to see a proper state preparation routine in the Embedding. The reason is that for all practical purposes we need to prepare the state on a subregister of qubits, which QubitStateVector cannot do (at this stage). |
Maybe it would be a good idea to have the MöttonenStatePrep somewhere (maybe in the templates) so that if you develop a plugin that has no direct support for state preparations you would not have to cook that code up for youself but you can then just call the MöttonenStatePrep (e.g. for the forst plugin). |
Right now, the function
AmplitudeEncoding
is purely a wrapper aroundQubitStateVector
. This is somewhat dissatisfying because it forces the user to basically transform his data into a quantum state himself.We could probably beef up this function a bit -- by allowing a feature vector that has less than 2^n elements (we would then pad them with zeros) and allowing that the squares don't sum to 1 (we would then normalize the vector). What are your thoughts?
The text was updated successfully, but these errors were encountered: