pyGSTi icon indicating copy to clipboard operation
pyGSTi copied to clipboard

Gate decomposition reports incorrect angles

Open johnkgamble opened this issue 2 years ago • 5 comments

Describe the bug Gate decompositions (called manually and from reports) have rotation angles that are incorrect by a factor of sqrt(2).

To Reproduce

  1. 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)
  1. Call the gate decomposition:
from pygsti.report.reportables import evaluate,General_decomposition

decomp = evaluate(General_decomposition(model,model))
  1. 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.

johnkgamble avatar Jun 22 '22 16:06 johnkgamble

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 avatar Jun 22 '22 16:06 sserita

@sserita , thanks - would you recommend I work from develop for now or just monkey patch as workaround?

johnkgamble avatar Jun 22 '22 17:06 johnkgamble

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).

sserita avatar Jun 22 '22 17:06 sserita

Will do! Happy to be the canary on these things and I expect my group will be making heavy use of pygsti.

johnkgamble avatar Jun 22 '22 17:06 johnkgamble

@sserita , confirmed fixed in develop. Thanks!

johnkgamble avatar Jun 22 '22 17:06 johnkgamble

Closed as this is now in 0.9.11 release

sserita avatar May 17 '23 06:05 sserita