Error:unhashable type: 'list'andWires must be hashable; got [[0], [1]]

Hey @ming, sorry I didn’t realize this earlier, but QNodes that return qml.sample aren’t generally differentiable. In the documentation for qml.sample it says:

QNodes that return samples cannot, in general, be differentiated, since the derivative with respect to a sample — a stochastic process — is ill-defined. The one exception is if the QNode uses the parameter-shift method (diff_method="parameter-shift"), in which case qml.sample(obs) is interpreted as a single-shot expectation value of the observable obs.

The second half of :point_up: leads me to believe that there should be a workaround to your issue, but I think there’s a bug! I’ve made an issue here: [BUG] QNodes that return `qml.sample(obs)` and use `parameter-shift` are not differentiable · Issue #4840 · PennyLaneAI/pennylane · GitHub

If there are any updates, I’ll let you know :slight_smile:

1 Like