Git Product home page Git Product logo

Comments (4)

enielse avatar enielse commented on September 17, 2024 1

Quick answer: you need to insert the line
XX = pygsti.tools.change_basis(XX, 'std', 'pp')
before the final line of your example.

Explanation:
You're getting this error because you're assigning a complex numpy array (see the elements of XX in your code above) to a model operation. Since pyGSTi uses Hermitian bases for density matrices, it assumes that if you're specifying a super-operator (a map from density matrices to density matrices) as a dense array then this array will be real because a density matrix expressed in a Hermitian basis is a real vector. Since your array is complex, it interprets it as a unitary operator on (complex) state-vectors as opposed to density matrices - i.e. it has evolution type "statevec". But model1 in your example has already been setup to represent quantum states as density matrices (evolution type "densitymx"), so it gives you the error you see.

To fix this, you need to convert XX into the Pauli basis - that is, write the action of XX as you have it as the action on a state represented as a length-16 real vector specifying the 2-qubit density matrix as a linear combination of the 16 2-qubit product-of-two-Pauli matrices. To do this, you can use the change_basis function to move from the "standard" ("std") matrix-unit, basis you've expressed XX in to the "Pauli-product" ("pp") basis the your model expects - that's what the line:
XX = pygsti.tools.change_basis(XX, 'std', 'pp') does.

from pygsti.

newsma avatar newsma commented on September 17, 2024

Thank you for the explanation! Makes sense to me and works now.

As for the second question: when I'm defining the processor specification that I'm trying to benchmark or run any simulation on, XX gate is not one of the standard set of gates. Just like I did for the model building, is it possible to input XX as a basis get for the processor?

As an example, my goal is to do something like this:

#Specify the device to be benchmarked - in this case 2 qubits
nQubits = 2
qubit_labels = [0,1] 

Gxx = ...........

gate_names = ['Gx', 'Gy','Gxx'] 


availability = {'Gxx':[(0,1)]}
pspec = pygsti.obj.ProcessorSpec(nQubits, gate_names, availability=availability, 
                                 qubit_labels=qubit_labels)

from pygsti.

enielse avatar enielse commented on September 17, 2024

You should be able to just supply the nonstd_gate_unitaries argument to the ProcessorSpec constructor, which as its name implies, should contain the unitary for your MS gate, not the super operator. So, using the U1_xx variable from your original post, you can just write:

gate_names = ['Gx', 'Gy','Gxx'] 
availability = {'Gxx':[(0,1)]}
pspec = pygsti.obj.ProcessorSpec(nQubits, gate_names, availability=availability, 
                                 qubit_labels=qubit_labels,
                                 nonstd_gate_unitaries={'Gxx': U1_xx})

from pygsti.

newsma avatar newsma commented on September 17, 2024

That's perfect! Thanks for all the help, Erik!

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.