# AmplitudeEmbedding

**URL:** <https://discuss.pennylane.ai/t/amplitudeembedding/169>\
**Category:** PennyLane Help\
**Created:** [July 9, 2019, 2:21pm UTC](https://discuss.pennylane.ai/t/amplitudeembedding/169 "2019-07-09T14:21:21Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![barthelemymp](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/barthelemymp/32/58_2.png) [@barthelemymp](https://discuss.pennylane.ai/u/barthelemymp)\
**Post date:** [July 9, 2019, 2:21pm UTC](https://discuss.pennylane.ai/t/amplitudeembedding/169/1 "2019-07-09T14:21:21Z")

</div>

Hello,

I have a very simple question.  
Is the function `AmplitudeEmbedding( *features* , *wires* )` doing the right series of gate, starting from the 0 state ? Or just creating artificially the state for simulation ?  
The documention says that it doesn’t work on all device, I could not find on which devices it works.

regards,

b

---

<div class="post-metadata">

**Author:** ![AroosaIjaz](https://avatars.discourse-cdn.com/v4/letter/a/57b2e6/32.png) [@AroosaIjaz](https://discuss.pennylane.ai/u/AroosaIjaz)\
**Post date:** [July 9, 2019, 6:06pm UTC](https://discuss.pennylane.ai/t/amplitudeembedding/169/2 "2019-07-09T18:06:21Z")

</div>

Hi @barthelemymp,

Yes, `AmplitudeEmbedding` acts on the entire system (all wires) by calling the `QubitStateVector` function. This prepares the given state by using the required gates.

If you use a PennyLane plugin that supports a quantum simulator device like PennyLane’s `default.qubit` or Qiskit, this function simulates your state. If you use a PennyLane plugin that supports a quantum hardware device like Forest SDK, it should correspond to initialising this state in the hardware.

`The documention says that it doesn’t work on all device, I could not find on which devices it works.`

This refers to the fact that `QubitStateVector` (and hence `AmplitudeEmbedding`) is a qubit state preparation function. Hence, it will only work with devices that simulate discrete variable computing. It will not work if you use `default.gaussian` device, for example. You can use this with `default.qubit`, Rigetti Forest SDK, Qiskit plugins.

---

<div class="post-metadata">

**Author:** ![barthelemymp](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/barthelemymp/32/58_2.png) [@barthelemymp](https://discuss.pennylane.ai/u/barthelemymp)\
**Post date:** [July 11, 2019, 1:34pm UTC](https://discuss.pennylane.ai/t/amplitudeembedding/169/3 "2019-07-11T13:34:54Z")

</div>

Hello,  
Thank you for the answer but I’m not sure to understand.  
My question is to know if `AmplitudeEmbedding` and so if `QubitStateVector` is a part of a circuit, composed by the appropriate series of gates, or if it is just accessing the state and modifying the value directly.  
Another way to ask would be Is AmplitudeEmbedding working on real quantum computers or only on simulator.

In fact for my current project I need to compare different Embedding into a quantum state. That’s why I need to take into account the size of the part of the circuit that would really encode the feature in the proper quantum state (size/time).

---

<div class="post-metadata">

**Author:** ![josh](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/josh/32/100_2.png) [@josh](https://discuss.pennylane.ai/u/josh)\
**Post date:** [July 11, 2019, 4:16pm UTC](https://discuss.pennylane.ai/t/amplitudeembedding/169/4 "2019-07-11T16:16:10Z")

</div>

Hi @barthelemymp. The way `QubitStateVector` is implemented depends on the plugin device.

For example, the `default.qubit` implementation directly sets the wavefunction amplitude value.

`forest.qvm`, on the other hand, is a hardware device, and implements `QubitStateVector` by decomposing it into multiple Pauli-X gates.

So amplitude encoding does work on both simulators and hardware devices.

---

<div class="post-metadata">

**Author:** ![barthelemymp](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/barthelemymp/32/58_2.png) [@barthelemymp](https://discuss.pennylane.ai/u/barthelemymp)\
**Post date:** [July 18, 2019, 2:42pm UTC](https://discuss.pennylane.ai/t/amplitudeembedding/169/5 "2019-07-18T14:42:59Z")

</div>

Thank you. That was exactly my question 🙂

---

<div class="post-metadata">

**Author:** ![barthelemymp](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/barthelemymp/32/58_2.png) [@barthelemymp](https://discuss.pennylane.ai/u/barthelemymp)\
**Post date:** [July 23, 2019, 3:58pm UTC](https://discuss.pennylane.ai/t/amplitudeembedding/169/6 "2019-07-23T15:58:01Z")

</div>

Hello @josh,

While AmplitudeEmbedding was working just fine on the `defaut.qubit`, however I’ve just tried to use it on a `forest.qvm`, and it doesn’t seem to work.  
DeviceError: Gate QubitStateVector not supported on device forest.qvm

regards

b

---

<div class="post-metadata">

**Author:** ![josh](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/josh/32/100_2.png) [@josh](https://discuss.pennylane.ai/u/josh)\
**Post date:** [July 23, 2019, 4:15pm UTC](https://discuss.pennylane.ai/t/amplitudeembedding/169/7 "2019-07-23T16:15:10Z")

</div>

Ah, apologies @barthelemymp - I was thinking of the `BasisState` operation, which is supported on the Forest QVM. It currently looks like `AmplitudeEmbedding` isn’t supported, although it should be doable to add support for this.
