AmplitudeEmbedding for two individual qubits

Is it possible to initialize two qubits using AmplitudeEmbedding, but doing so for each qubit individually?

Something like this -

dev = qml.device("default.qubit", wires=[1, 2])

def SWAP_test(A, B):
    qml.AmplitudeEmbedding([A[0],A[1]], wires=[1], normalize=True)
    qml.AmplitudeEmbedding([B[0], B[1]], wires=[2], normalize=True)
    return qml.probs(wires=[1])

Hi @ofir.arzi!

This is a current restriction with PennyLane, in that only a single, initial state preparation routine can be used.

However, you can use the qml.transforms.merge_amplitude_embedding transform to merge multiple amplitude embeddings in your quantum function, as long as they act on different wires:

dev = qml.device('default.qubit', wires=4)

def qfunc():
    qml.CNOT(wires=[0, 1])
    qml.AmplitudeEmbedding([0, 1], wires=2)
    qml.AmplitudeEmbedding([0, 1], wires=3)
    return qml.probs(wires=[0, 1, 2, 3])

Using the transformation we can join the different amplitude embeddings into a single one:

>>> print(qml.draw(qfunc)())
  0: ──╭C───────────────────────╭┤ Probs
  1: ──╰X───────────────────────├┤ Probs
  2: ──╭AmplitudeEmbedding(M0)──├┤ Probs
  3: ──╰AmplitudeEmbedding(M0)──╰┤ Probs
  M0 = [0.+0.j 0.+0.j 0.+0.j 1.+0.j]