PennyLaneAI / pennylane

PennyLane is a cross-platform Python library for quantum computing, quantum machine learning, and quantum chemistry. Train a quantum computer the same way as a neural network.
https://pennylane.ai
Apache License 2.0
2.29k stars 590 forks source link

[BUG] hadamard gradient does not work with wires-broadcasted measurements #5840

Closed albi3ro closed 3 months ago

albi3ro commented 3 months ago

Expected behavior

I would expect hadamard_grad to be interchangeable with param_shift in cases where there is no explicit error

Actual behavior

Output gradient is simply array([0.])

Additional information

No response

Source code

tape = qml.tape.QuantumScript([qml.RX(0.1, 0)], [qml.probs()])

batch, fn = qml.gradients.hadamard_grad(tape)
fn(qml.device('default.qubit').execute(batch))

Tracebacks

No response

System information

on master

Existing GitHub issues