4
4
5
5
[ ![ Build Status] ( https://travis-ci.org/pyGSTio/pyGSTi.svg?branch=master )] ( https://travis-ci.org/pyGSTio/pyGSTi )
6
6
7
- Overview:
8
- --------
9
- This is the root directory of the pyGSTi software, which is a Python
10
- implementation of Gate Set Tomography. pyGSTi free software, licensed
11
- under the GNU General Public License (GPL). Copyright and license information
12
- can be found in `` license.txt `` , and the GPL itself in `` COPYING `` .
7
+ pyGSTi
8
+ ------
9
+ ** pyGSTi** is an open-source software for * modeling and characterizing noisy quantum information processors*
10
+ (QIPs), i.e., systems of one or more qubits. It is licensed under the GNU General Public License (GPL).
11
+ Copyright and license information can be found in `` license.txt `` , and the GPL itself in `` COPYING `` .
12
+
13
+ There are three main objects in pyGSTi:
14
+ - ` Circuit ` : a quantum circuit (can have many qubits).
15
+ - ` Model ` : a description of a QIP's gate and SPAM operations (a noise model).
16
+ - ` DataSet ` : a dictionary-like container holding experimental data.
17
+
18
+ You can do various things by with these objects:
19
+
20
+ - ** Circuit simulation** : compute a the outcome probabilities of a ` Circuit ` using a ` Model ` .
21
+ - ** Data simulation** : simulate experimental data (a ` DataSet ` ) using a ` Model ` .
22
+ - ** Model testing** : Test whether a given ` Model ` fits the data in a ` DataSet ` .
23
+ - ** Model estimation** : Estimate a ` Model ` from a ` DataSet ` (e.g. using GST).
24
+ - ** Model-less characterization** : Perform Randomized Benchmarking on a ` DataSet ` .
25
+
26
+ In particular, there are a number of characterization protocols currently implemented in pyGSTi:
27
+ - ** Gate Set Tomography (GST)** is the most complex and is where the software derives its name
28
+ (a "python GST implementation").
29
+ - ** Randomized Benchmarking (RB)** is a well-known method for assessing the
30
+ quality of a QIP in an average sense. PyGSTi implements standard "Clifford" RB
31
+ as well as the more scalable "Direct" RB methods.
32
+ - ** Robust Phase Estimation (RPE)** is a method designed for quickly learning
33
+ a few noise parameters of a QIP that particularly useful for tuning up qubits.
34
+
35
+ PyGSTi is designed with a modular structure so as to be highly customizable
36
+ and easily integrated to new or existing python software. It runs using
37
+ python2.7 or python3. To faclilitate integration with software for running
38
+ cloud-QIP experiments, pyGSTi ` Circuit ` objects can be converted to IBM's
39
+ ** QASM** and Rigetti Quantum Computing's ** QUIL** circuit description languages.
40
+
41
+ Installation
42
+ ------------
43
+ Apart from several optional Cython modules, pyGSTi is written entirely in Python.
44
+ To install pyGSTi and only its required dependencies run:
45
+
46
+ `` pip install pygsti ``
47
+
48
+ ** Or** , to install pyGSTi with all its optional dependencies too, run:
49
+
50
+ `` pip install pygsti[complete] ``
51
+
52
+ The disadvantage to these approaches is that the numerous tutorials
53
+ included in the package will then be buried within your Python's
54
+ ` site_packages ` directory, which you'll likely want to access later on.
55
+ ** Alternatively** , you can ** locally install** pyGSTi using the following commands:
56
+
57
+ ~~~
58
+ cd <install_directory>
59
+ git clone https://github.com/pyGSTio/pyGSTi.git
60
+ cd pyGSTi
61
+ pip install -e .[complete]
62
+ ~~~
63
+
64
+ As above, you can leave off the ` .[complete] ` if you only went the minimal
65
+ set of dependencies installed. You could also replace the ` git clone ... `
66
+ command with ` unzip pygsti-0.9.x.zip ` where the latter file is a downloaded
67
+ pyGSTi source archive. Any of the above installations * should* build
68
+ the set of optional Cython extension modules if a working C/C++ compiler
69
+ and the ` Cython ` package are present. If, however, compilation fails or
70
+ you later decided to add Cython support, you can rebuild the extension
71
+ modules (without reinstalling) if you've followed the local installation
72
+ approach above using the command:
73
+
74
+ ` python setup.py build_ext --inplace `
75
+
76
+ Finally, [ Jupyter notebook] ( http://jupyter.org/ ) is highly recommended as
77
+ it is generally convenient and the format of the included tutorials and
78
+ examples. It is installed automatically when ` [complete] ` is used, otherwise
79
+ it can be installed separately.
13
80
81
+ Getting Started
82
+ ---------------
83
+ Here's a couple of simple examples to get you started.
84
+
85
+ #### Circuit simulation
86
+ To compute the outcome probabilities of a circuit, you just need to create
87
+ a ` Circuit ` object (describing your circuit) and a ` Model ` object containing
88
+ the operations contained in your circuit. Here we use a "stock" single-qubit ` Model `
89
+ containing * Idle* , * X(&pi ; /2)* , and * Y(&pi ; /2)* gates labelled ` Gi ` , ` Gx ` ,
90
+ and ` Gy ` , respectively:
91
+ ~~~
92
+ import pygsti
93
+ from pygsti.construction import std1Q_XYI
94
+
95
+ mycircuit = pygsti.obj.Circuit( ('Gx','Gy','Gx') )
96
+ model = std1Q_XYI.target_model()
97
+ outcome_probabilities = model.probs(mycircuit)
98
+ ~~~
99
+
100
+
101
+ #### Gate Set Tomography
14
102
Gate Set Tomography is used to characterize the operations performed by
15
103
hardware designed to implement a (small) system of quantum bits (qubits).
16
104
Here's the basic idea:
17
105
18
- 1 . you tell pyGSTi what quantum operations you'd like to perform
19
- 2 . pyGSTi tells you what sequences of operations it want's data for
106
+ 1 . you tell pyGSTi what gates you'd ideally like to perform
107
+ 2 . pyGSTi tells you what circuits it want's data for
20
108
3 . you perform the requested experiments and place the resulting
21
109
data (outcome counts) into a text file that looks something like:
22
110
23
111
```
24
112
## Columns = 0 count, 1 count
25
- {} 0 100
26
- Gx 10 90
27
- GxGy 40 60
28
- Gx^4 20 80
113
+ {} 0 100 # the empty sequence (just prep then measure)
114
+ Gx 10 90 # prep, do a X(pi/2) gate, then measure
115
+ GxGy 40 60 # prep, do a X(pi/2) gate followed by a Y(pi/2), then measure
116
+ Gx^4 20 80 # etc...
29
117
```
30
118
31
119
4. pyGSTi takes the data file and outputs a "report" - currently a
32
120
HTML web page.
33
121
34
- There are numerous [Tutorial](https://github.com/pyGSTio/pyGSTi/tree/master/jupyter_notebooks/Tutorials)
35
- and [Example](https://github.com/pyGSTio/pyGSTi/tree/master/jupyter_notebooks/Examples)
36
- ipython notebooks (especially
37
- [Tutorial 0](https://github.com/pyGSTio/pyGSTi/blob/master/jupyter_notebooks/Tutorials/00%20Getting%20Started.ipynb)
38
- ) included in this repository that demonstrate pyGSTi's
39
- syntax and use, as well as a [FAQ](https://github.com/pyGSTio/pyGSTi/blob/master/jupyter_notebooks/FAQ.ipynb).
40
-
41
-
42
- Getting Started:
43
- ---------------
44
- pyGSTi is written almost entirely in Python. Apart from a single optional
45
- Cython module, there's no compiling necessary. The first step is to install
46
- Python (and [Jupyter notebook](http://jupyter.org/) is highly recommended)
47
- if you haven't already. In order to use pyGSTi you need to tell your Python
48
- distribution where pyGSTi lives, which can be done in one of several ways:
49
-
50
- * User-Only Installation
51
-
52
- To install pyGSTi for the current user, you can run from the top-level
53
- directory either ``pip install -e .`` or ``python install_locally.py``.
54
-
55
- This adds the current pyGSTi path to Python's list of search paths, and
56
- doesn't require administrative access. Typically you want to do this if
57
- you've cloned the pyGSTi GitHub repository and want any changes you make to
58
- your local file to have effect when you ``import pygsti`` from Python.
59
- You'd also want to use this option if you'd like long-term access the
60
- tutorial notebook files in the ``jupyter_notebooks`` directory under this
61
- one, since this means you'll be keeping this directory around anyway.
62
- The ``pip install -e .`` is slightly preferable since it will automatically
63
- build the optional Cython extension.
64
-
65
- * System-Wide Installation
66
-
67
- To install pyGSTi for all users, run: ``python setup.py install``
68
-
69
- This installs the pyGSTi Python package into one of the Python distribution's
70
- search directories. **This typically requires administrative privileges**,
71
- and is the way most Python packages are installed. Installing this way has
72
- the advantage that it makes the package available to all users and then
73
- allows you to move or delete the directory you're installing from. If you
74
- don't use this method **you must not delete this directory** so long as you
75
- want to use pyGSTi.
76
-
77
- Reasons you may **not** want to use this installation method are
78
-
79
- - pyGSTi comes with (Jupyter notebook) tutorials that you may want to
80
- access for weeks and years to come (i.e. you plan to *keep* this
81
- pyGSTi directory around for a while).
82
- - you've cloned the pyGSTi repository and want this local set of files
83
- to be the one Python uses when you ``import pygsti``.
84
-
85
- Using pyGSTi
86
- ------------
87
-
88
- After you've installed pyGSTi, you should be able to import the
89
- `pygsti` Python package. The next thing to do is take a look at
90
- the tutorials, which you do by:
122
+ In code, running GST looks something like this:
123
+ ~~~
124
+ import pygsti
125
+ from pygsti.construction import std1Q_XYI
126
+
127
+ # 1) get the ideal "target" Model (a "stock" model in this case)
128
+ mdl_ideal = std1Q_XYI.target_model()
129
+
130
+ # 2) get the building blocks needed to specify which circuits are needed
131
+ prepfids, measfids, germs = std1Q_XYI.prepStrs, std1Q_XYI.effectStrs, std1Q_XYI.germs
132
+ maxLengths = [1,2,4] # user-defined: how long do you want the circuits?
133
+
134
+ # 3) generate a list of circuits for GST & write a data-set template
135
+ listOfExperiments = pygsti.construction.make_lsgst_experiment_list(
136
+ mdl_ideal, prepfids, measfids, germs, maxLengths)
137
+ pygsti.io.write_empty_dataset("MyData.txt", listOfExperiments, "## Columns = 0 count, 1 count")
138
+
139
+ # STOP! "MyData.txt" now has columns of zeros where actual data should go.
140
+ # REPLACE THE ZEROS WITH ACTUAL DATA, then proceed with:
141
+ ds = pygsti.io.load_dataset("MyData.txt") # load data -> DataSet object
142
+
143
+ # 4) run GST
144
+ results = pygsti.do_stdpractice_gst(ds, mdl_ideal, prepfids, measfids, germs, maxLengths)
145
+
146
+ # 5) Create a nice HTML report detailing the results
147
+ pygsti.report.create_standard_report(results, filename="myReport", title="Sample Report")
148
+ ~~~
149
+
150
+ Tutorials and Examples
151
+ ----------------------
152
+ There are numerous tutorials (meant to be pedagogical) and examples (meant to be demonstrate
153
+ how to do some particular thing) in the form of Jupyter notebooks beneath the `pyGSTi/jupyter_notebooks`
154
+ directory. The [START HERE](https://github.com/pyGSTio/pyGSTi/blob/master/jupyter_notebooks/START_HERE.ipynb)
155
+ notebook will direct you where to go based on what you're most interested in learning about. One possible
156
+ direction is to view the [FAQ](https://github.com/pyGSTio/pyGSTi/blob/master/jupyter_notebooks/FAQ.ipynb), which
157
+ addresses common issues.
158
+
159
+ #### Running notebooks *locally*
160
+ While it's possible to view the notebooks on GitHub using the links above, it's
161
+ usually nicer to run them *locally* so you can mess around with the code as
162
+ you step through it. To do this, you'll need to start up a Jupyter notebook
163
+ server using the following steps (this assumes you've followed the *local
164
+ installation* directions above):
91
165
92
166
* Changing to the notebook directory, by running:
93
167
``cd jupyter_notebooks/Tutorials/``
@@ -96,63 +170,21 @@ the tutorials, which you do by:
96
170
``jupyter notebook``
97
171
98
172
The Jupyter server should open up your web browser to the server root, from
99
- where you can start the first "0th" tutorial notebook. ( Note that the key
173
+ where you can start the first "START_HERE.ipynb" notebook. Note that the key
100
174
command to execute a cell within the Jupyter notebook is ``Shift+Enter``, not
101
- just ``Enter``.) Example notebooks, found in the ``jupyter_notebooks/Examples/``
102
- directory, are focused on more specific tasks than the tutorials, and will be
103
- most useful for those looking to get a quick start using pyGSTi in a typical
104
- scenario.
105
-
106
- Congratulations! You're up and running with pyGSTi!
107
-
175
+ just ``Enter``.
108
176
109
177
110
178
Documentation
111
179
-------------
112
180
Online documentation is hosted on [Read the Docs](http://pygsti.readthedocs.io).
113
- Instructions for building the documentation locally are contained in the file
114
- `doc/build/howToBuild.txt`.
115
-
116
181
182
+ License
183
+ -------
184
+ PyGSTi is licensed under the [GNU General Public License (GPL)](https://github.com/pyGSTio/pyGSTi/blob/master/license.txt).
117
185
118
186
119
187
Questions?
120
188
----------
121
189
For help and support with pyGSTi, please contact the authors at
122
190
123
-
124
-
125
-
126
-
127
-
128
- Brief description of the directory structure:
129
- --------------------------------------------
130
- ```
131
- doc/ : Directory containing the HTML documentation and other
132
- reference documents.
133
-
134
- jupyter_notebooks/ : Parent directory of all Jupyter notebook tutorial
135
- files included with pyGSTi. It is convenient to
136
- start an Jupyter notebook server from within this
137
- directory.
138
-
139
- packages/ : Directory containing the (one) package provided by pyGSTi.
140
- All of the Python source code lies here.
141
-
142
- tests/ : Directory containing pyGSTi unit tests.
143
-
144
- install_locally.py : A Python script that sets up the software to run
145
- from its current location within the file system. This
146
- essentially adds the packages directory to the list of
147
- directories Python uses to search for packages in, so
148
- that `` import pygsti `` will work for any Python script,
149
- regardless of its location in the file system. This
150
- action is local to the user running the script, and does
151
- not copy any files to any system directories, making it a
152
- good option for a user without administrative access.
153
-
154
- COPYING : A text version of the GNU General Public License.
155
-
156
- license.txt : A text file giving copyright and licensing information
157
- about pyGSTi.
158
- ```
0 commit comments