Git Product home page Git Product logo

Comments (3)

enielse avatar enielse commented on September 17, 2024

Adriaan, thanks for the nice description. This is a confirmed bug in pyGSTi 0.9.3 and earlier, and only currently fixed on the beta branch. The error arises due to an incorrect 1-qubit phase that is included when using the CZ(pi, Q0, Q1) specification in build_gateset. A similar error occurs when creating a CNOT gate from CX(pi, Q0, Q1). The CZ(theta) gate uses a Z-rotation, whose unitary is defined as exp(i 0.5 theta Z), which for theta=pi gives an extra phase factor of "i", namely

[ -i 0 ]
[ 0  i ]

instead of

[ 1 0 ]
[ 0 -1]

as desired.

The workaround for the time being is to do exactly as Adriaan suggests, which I'll repeat here in the context of creating a GateSet:

myGateset = pygsti.construction.build_gateset(
    [4], [('Q0','Q1')],['Gix','Giy','Gxi','Gyi'],
    [ "I(Q0):X(pi/2,Q1)", "I(Q0):Y(pi/2,Q1)", "X(pi/2,Q0):I(Q1)", "Y(pi/2,Q0):I(Q1)" ],
    prepLabels=['rho0'], prepExpressions=["0"],
    effectLabels=['E0','E1','E2'], effectExpressions=["0","1","2"],
    spamdefs={'upup': ('rho0','E0'), 'updn': ('rho0','E1'),
              'dnup': ('rho0','E2'), 'dndn': ('rho0','remainder') }, basis="pp")

cphaseUnitary =  np.diag([1,1,1,-1])
cphaseSuperOp_stdbasis = pygsti.unitary_to_process_mx(cphaseUnitary)
cphaseSuperOp_ppbasis = pygsti.std_to_pp(cphaseSuperOp_stdbasis)
myGateset['Gcphase'] = mySuperOp_ppbasis

The next version of pyGSTi (hopefully pushed out soon) will include fixes for these bugs as they affect the standard gate sets in pygsti.construction. I'm not sure if we'll change the implementation of CX and CZ, but will comment again once this has been resolved.

from pygsti.

AdriaanRol avatar AdriaanRol commented on September 17, 2024

@enielse Thanks for the update 👍

from pygsti.

enielse avatar enielse commented on September 17, 2024

So... "hopefully soon" ended up being a year later, but the recently released pyGSTi version 0.9.4 now includes a proper cphase gate - so you can do:

pygsti.construction.build_gate([4],[('Q0', 'Q1')], 'CPHASE(Q0, Q1)', basis='pp')

and

pygsti.construction.build_gate([4],[('Q0', 'Q1')], 'CNOT(Q0, Q1)', basis='pp')

to obtain the standard CPhase and CNot gates. Using the CZ and CX directives still act as before, since, for instance, we want the "Z" in a "controlled-Z" operation to have a consistent phase with a rotation by 0 degrees being the identity (not i times the identity). This means, somewhat non-intuitively, that 'CPHASE(Q0,Q1)' and 'CZ(pi,Q0,Q1)' are equivalent only up to a phase on the target qubit and not exactly equal.

Finally, it's worth noting that any standard gate set in pyGSTi, as of version 0.9.4, that includes a CPhase or CNot gate uses the standard form of these gates, which should be intuitive to most users.

from pygsti.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.