qang: a differentiable symmetry-filtered read-out for PennyLane

qang is an open-source library that reads quantum states in angular units (qg). For PennyLane it adds rqang (an RY gate parameterized directly in qg_Z = ⟨Z⟩, differentiable) and filtered_qg_z(probs, weight), which post-selects qml.probs() on a Hamming-weight sector and stays differentiable in every interface, so the filter can be part of the loss:

python

from qang.pennylane_gate import filtered_qg_z
loss = lambda x: filtered_qg_z(circuit(x), 1)[0]   # qml.grad(loss) works

Gradients match finite differences to 1e-6 in the tests. The same read-out works on Qiskit, Cirq, Braket and pytket results. Feedback welcome.
Client Challenge · GitHub - Viny2030/qang: the repository about the qang, new measure about quantum · GitHub