Comments (4)
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.
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.
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.
That's perfect! Thanks for all the help, Erik!
from pygsti.
Related Issues (20)
- Audit usage of linalg.inv
- Error gen projection basis must be Basis object HOT 1
- Method `parameter_labels()` returns an empty array HOT 1
- 1/2 Diamond Norm Errorbars
- Raw Estimates Errorbars for TPInstrument HOT 1
- CP Instruments & Instrument Error Generators
- QI Report Fixes & Additions
- Wildcard w/ QILGST
- Fisher Information w/ Experiment Designs Containing MCMs
- Explicit Model Construction from MCM-Containing Pspec
- Help with detecting crosstalk errors of simulated data
- Serialization Issue w/ Processor Spec Nonstd_Instruments HOT 1
- Numpy version dependency HOT 1
- Gswap cannot be used as a two-qubit standard native gate for two-qubit RB as CliffordCompilationRules taking too long
- Line label reordering during `Circuit` concatenation
- Generating Random Error Generators HOT 4
- Design pspec sslbl bug in modelpacks
- Serialization for ModelEstimateResults HOT 2
- Depolarizing SPAM in H-Only Models Silently Fails (and Discussion of How to Properly Regularize Reduced Models)
- Add cycle benchmarking with mid-circuit measurements
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pygsti.