Applying the same gate to multiple qubits at the same time

Hello! If applicable, put your complete code example down below. Make sure that your code:

  • is 100% self-contained — someone can copy-paste exactly what is here and run it to
    reproduce the behaviour you are observing
  • includes comments
# Put code here
qp.Hadamard(wires = [0,1,2,3])

If you want help with diagnosing an error, please put the full error message below:

# Put full error message here
This returns an error because wires should include one number, is there another way to apply the gate to multiple qubits without using a for loop?

And, finally, make sure to include the versions of your packages. Specifically, show us the output of qml.about().

Yes — that’s what qml.broadcast is for: qml.broadcast(qml.Hadamard, wires=[0, 1, 2, 3], pattern="single") applies a Hadamard to each wire in one call, no for-loop needed. The error is expected since single-qubit gates like Hadamard take exactly one wire each. If you ever want an entangling layer instead, the same function handles patterns like “double” or “ring”, for example with CNOT. Happy to be corrected if I’ve got that wrong.