ArbitraryStatePreparation(weights, wires)[source]

Implements an arbitrary state preparation on the specified wires.

An arbitrary state on \(n\) wires is parametrized by \(2^{n+1} - 2\) independent real parameters. This templates uses Pauli word rotations to parametrize the unitary.


ArbitraryStatePreparation can be used to train state preparations, for example using a circuit with some measurement observable H:

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

def vqe(weights):
    qml.ArbitraryStatePreparations(weights, wires=[0, 1, 2, 3])

    return qml.expval(qml.Hermitian(H, wires=[0, 1, 2, 3]))
  • weights (array[float]) – The angles of the Pauli word rotations, needs to have length \(2^(n+1) - 2\) where \(n\) is the number of wires the template acts upon.

  • wires (Iterable or Wires) – Wires that the template acts on. Accepts an iterable of numbers or strings, or a Wires object.