pyGSTi
pyGSTi copied to clipboard
Gate decomposition reports incorrect angles
Describe the bug Gate decompositions (called manually and from reports) have rotation angles that are incorrect by a factor of sqrt(2).
To Reproduce
- Make a simple model, e.g.:
from pygsti.processors import QubitProcessorSpec as QPS
from pygsti.models import modelconstruction as mc
pspec = QPS(1, ["Gxpi2", "Gypi2"])
model = mc.create_explicit_model(pspec)
- Call the gate decomposition:
from pygsti.report.reportables import evaluate,General_decomposition
decomp = evaluate(General_decomposition(model,model))
- The rotation angles for both Gxpi2 and Gypi2 are given as sqrt(2)*0.5, rather than 0.5.
Expected behavior I would expect the rotation angles to be 0.5.
Environment (please complete the following information):
- pyGSTi version [0.9.10.1]
- python version [3.10.5]
- OS [macOS 12.4]
Additional context The relevant code seems to be in reportables.py (starting on 2309):
decomp[gl + " angle"] = norm * 2.0 / _np.pi
# Units: hamProjs (and norm) are already in "Hamiltonian-coefficient" units,
# (see 'std_scale_factor' fn), but because of convention the "angle" is equal
# to *twice* this coefficient (e.g. a X(pi/2) rotn is exp( i pi/4 X ) ),
# thus the factor of 2.0 above.
This is a known bug that I think is fixed on the tip of develop
. The bug is actually a result of a switch from normalized to unnormalized Paulis in the error generator code.
@sserita , thanks - would you recommend I work from develop for now or just monkey patch as workaround?
Maybe try the tip of develop. That way you can get all the up-to-date bugfixes as we fix the issues you are bringing to our attention? :)
(Also let me know if this is still broken on develop).
Will do! Happy to be the canary on these things and I expect my group will be making heavy use of pygsti.
@sserita , confirmed fixed in develop. Thanks!
Closed as this is now in 0.9.11 release