Skip to content

Commit c003eb0

Browse files
committed
add leakage subpackage to the API docs. Update README.md to emphasize the distinction between building notebooks and building the web docs. Change a comment in gaugeopt.py following decision to close GitHub issue #820.
1 parent 15e214d commit c003eb0

4 files changed

Lines changed: 63 additions & 51 deletions

File tree

README.md

Lines changed: 44 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
pyGSTi
1010
------
11-
**pyGSTi** is an open-source software for *modeling and characterizing noisy quantum information processors*
11+
**pyGSTi** is open-source software for *modeling and characterizing noisy quantum information processors*
1212
(QIPs), i.e., systems of one or more qubits. It is licensed under the Apache License, Version 2.0.
1313
Copyright information can be found in ``NOTICE``, and the license itself in ``LICENSE``.
1414

@@ -17,9 +17,9 @@ There are three main objects in pyGSTi:
1717
- `Model`: a description of a QIP's gate and SPAM operations (a noise model).
1818
- `DataSet`: a dictionary-like container holding experimental data.
1919

20-
You can do various things by with these objects:
20+
You can do various things with these objects:
2121

22-
- **Circuit simulation**: compute a the outcome probabilities of a `Circuit` using a `Model`.
22+
- **Circuit simulation**: compute the outcome probabilities of a `Circuit` using a `Model`.
2323
- **Data simulation**: simulate experimental data (a `DataSet`) using a `Model`.
2424
- **Model testing**: Test whether a given `Model` fits the data in a `DataSet`.
2525
- **Model estimation**: Estimate a `Model` from a `DataSet` (e.g. using GST).
@@ -32,10 +32,10 @@ In particular, there are a number of characterization protocols currently implem
3232
quality of a QIP in an average sense. PyGSTi implements standard "Clifford" RB
3333
as well as the more scalable "Direct" RB methods.
3434
- **Robust Phase Estimation (RPE)** is a method designed for quickly learning
35-
a few noise parameters of a QIP that particularly useful for tuning up qubits.
35+
a few noise parameters of a QIP that are particularly useful for tuning up qubits.
3636

3737
PyGSTi is designed with a modular structure so as to be highly customizable
38-
and easily integrated to new or existing python software. It runs using
38+
and easily integrated with new or existing python software. It runs using
3939
python 3.10 or higher. To facilitate integration with software for running
4040
cloud-QIP experiments, pyGSTi `Circuit` objects can be converted to IBM's
4141
**OpenQASM** and Rigetti Quantum Computing's **Quil** circuit description languages.
@@ -51,10 +51,7 @@ To install pyGSTi and only its required dependencies run:
5151

5252
``pip install pygsti[complete]``
5353

54-
The disadvantage to these approaches is that the numerous tutorials
55-
included in the package will then be buried within your Python's
56-
`site_packages` directory, which you'll likely want to access later on.
57-
**Alternatively**, you can **locally install** pyGSTi using the following commands:
54+
**Alternatively**, you can install pyGSTi from source using the following commands:
5855

5956
~~~
6057
cd <install_directory>
@@ -63,17 +60,10 @@ cd pyGSTi
6360
pip install -e .[complete]
6461
~~~
6562

66-
As above, you can leave off the `.[complete]` if you only went the minimal
67-
set of dependencies installed. You could also replace the `git clone ...`
68-
command with `unzip pygsti-0.9.x.zip` where the latter file is a downloaded
69-
pyGSTi source archive. Any of the above installations *should* build
70-
the set of optional Cython extension modules if a working C/C++ compiler
71-
and the `Cython` package are present. If, however, compilation fails or
72-
you later decided to add Cython support, you can rebuild the extension
73-
modules (without reinstalling) if you've followed the local installation
74-
approach above using the command:
63+
Any of the above installations *should* build the set of optional Cython extension modules if a working C/C++ compiler and the `Cython` package are present.
7564

76-
`python setup.py build_ext --inplace`
65+
If you installed from source then you have the option of (re)building Cython extensions at any time.
66+
You can do that by running `python setup.py build_ext --inplace`.
7767

7868
Finally, [Jupyter notebook](http://jupyter.org/) is highly recommended as
7969
it is generally convenient and the format of the included tutorials and
@@ -82,14 +72,14 @@ it can be installed separately.
8272

8373
Getting Started
8474
---------------
85-
Here's a couple of simple examples to get you started.
75+
Here are a couple of simple examples to get you started.
8676

8777
#### Circuit simulation
8878
To compute the outcome probabilities of a circuit, you just need to create
8979
a `Circuit` object (describing your circuit) and a `Model` object containing
9080
the operations contained in your circuit. Here we use a "stock" single-qubit `Model`
91-
containing *Idle*, *X(&pi;/2)*, and *Y(&pi;/2)* gates labelled `Gi`, `Gx`,
92-
and `Gy`, respectively:
81+
containing an unlabeled *Idle* gate along with *X(&pi;/2)* and *Y(&pi;/2)* gates
82+
labelled `Gxpi2` and `Gypi2`, respectively:
9383
~~~
9484
import pygsti
9585
from pygsti.modelpacks import smq1Q_XYI
@@ -106,20 +96,20 @@ hardware designed to implement a (small) system of quantum bits (qubits).
10696
Here's the basic idea:
10797

10898
1. you tell pyGSTi what gates you'd ideally like to perform
109-
2. pyGSTi tells you what circuits it want's data for
99+
2. pyGSTi tells you what circuits it wants data for
110100
3. you perform the requested experiments and place the resulting
111-
data (outcome counts) into a text file that looks something like:
101+
data (outcome counts) into a text file that looks something like this:
112102

113103
```
114104
## Columns = 0 count, 1 count
115105
{} 0 100 # the empty sequence (just prep then measure)
116-
Gx 10 90 # prep, do a X(pi/2) gate, then measure
117-
GxGy 40 60 # prep, do a X(pi/2) gate followed by a Y(pi/2), then measure
106+
Gx 10 90 # prep, do an X(pi/2) gate, then measure
107+
GxGy 40 60 # prep, do an X(pi/2) gate followed by a Y(pi/2), then measure
118108
Gx^4 20 80 # etc...
119109
```
120110
121-
4. pyGSTi takes the data file and outputs a "report" - currently a
122-
HTML web page.
111+
4. pyGSTi takes the data file and outputs a "report" - currently
112+
an HTML web page.
123113
124114
In code, running GST looks something like this:
125115
~~~
@@ -154,35 +144,27 @@ report.write_html("myReport", auto_open=True, verbosity=1) # Can also write out
154144
155145
Documentation
156146
-------------
157-
There are numerous tutorials (meant to be pedagogical) and examples (meant to be demonstrate
158-
how to do some particular thing) in the `pyGSTi/docs` directory. These are stored as MyST Markdown
147+
There are numerous tutorials and examples in the `pyGSTi/docs` directory. These are stored as MyST Markdown
159148
for version control convenience, but can be converted to Jupyter notebooks as needed using Jupytext.
160149
161-
#### Viewing the documentation *online*
150+
### Viewing the documentation *online*
162151
The recommended way to view the documentation is on [ReadTheDocs](https://pygsti.readthedocs.io/en/latest/),
163152
although the raw Markdown files can also be looked at on [GitHub](https://github.com/sandialabs/pyGSTi/blob/master/docs/markdown/intro.md).
164153
165154
The site renders the source MyST Markdown without executing notebook cells, so you won't see outputs (plots, tables) inline.
166-
Each rendered page offers two ways to run the notebook yourself:
155+
You can download the notebooks or run them on the cloud with buttons in the upper-right of the given page.
167156
168-
- **Rocket icon → Binder or Colab:** launches a fully-provisioned notebook environment in your browser with no local install.
169-
- **Cloud/download icon → "Download this page" dropdown:** grab the `.ipynb` (or the `.md` source) and run it in your own Jupyter setup.
157+
- **Download icon → ipynb, md, or pdf.** If you just click the `.ipynb` or `.md` options then the source will open as raw text in a new tab.
158+
If you want to save those files you need to **right click the desired format and select `Save Link As ...`**, then enter the file name with the appropriate extension.
159+
Here's a screenshot of what that can look like.
170160
171-
#### Building the documentation *locally*
172-
The docs are built using [Jupyter Book v1](https://jupyterbook.org). Note: v2 is a separate product (MyST Engine + Node.js)
173-
that doesn't support our autodoc-based API reference yet, so we pin `jupyter-book<2`.
161+
<img src="docs/download-notebook-save-as.png" width="250">
174162
175-
To install the build dependencies along with pyGSTi:
176-
``pip install -e .[docs]``
177-
178-
then build:
179-
``jb build docs``
163+
- **Rocket icon → Binder or Colab:** launches a fully-provisioned notebook environment in your browser with no local install. Right now this is clunky and not recommended.
180164
181-
Then open `docs/_build/html/index.html` in a web browser to look through the documentation.
182-
183-
#### Running notebooks *locally*
184-
It can also be convenient to build and run the tutorials locally. We can do this using Jupytext
185-
for conversion and then start a Jupyter notebook or JupyterLab server to run the notebooks.
165+
### Running notebooks *locally*
166+
It can be convenient to just build and run the tutorials locally.
167+
We can do this using Jupytext for conversion and then start a Jupyter notebook or JupyterLab server to run the notebooks.
186168
Assuming you've followed the *local installation* directions above:
187169
188170
* Change to the docs directory, by running:
@@ -199,7 +181,21 @@ where you can start the first `markdown/intro.ipynb` notebook. Note that the ke
199181
command to execute a cell within the Jupyter notebook is ``Shift+Enter``, not
200182
just ``Enter``.
201183
202-
#### Contributing notebook changes
184+
### Building the web documentation *locally*
185+
The web docs are built using [Jupyter Book v1](https://jupyterbook.org). Note: v2 is a separate product that doesn't support our autodoc-based API reference yet, so we pin `jupyter-book<2`.
186+
187+
**WARNING.** Building the web docs takes a LONG TIME, because they include a very large **API Reference**.
188+
If you only want to read or work with the tutorials and examples, don't do a full build — just convert and [run the notebooks directly](#running-notebooks-locally).
189+
190+
To install the build dependencies along with pyGSTi:
191+
``pip install -e .[docs]``
192+
193+
then build:
194+
``jb build docs``
195+
196+
Then open `docs/_build/html/index.html` in a web browser to look through the documentation.
197+
198+
### Contributing notebook changes
203199
**Only the `docs/markdown/*.md` files are version-controlled.** The paired `.ipynb` files — generated next to
204200
each `.md` under `docs/markdown/` — are gitignored build artifacts. The canonical source is the `.md` file, and
205201
edits there "win" on the next sync. So:

docs/api.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,22 @@ Circuit/COPA layouts that organize (and distribute) the computation behind forwa
208208
pygsti.layouts.prefixtable
209209
pygsti.layouts.termlayout
210210

211+
``pygsti.leakage``
212+
~~~~~~~~~~~~~~~~~~
213+
214+
Leakage-aware modeling, gauge optimization, metrics, and reporting for QIPs with leakage levels.
215+
216+
.. autosummary::
217+
:toctree: _autosummary
218+
:template: custom-module-template.rst
219+
:recursive:
220+
221+
pygsti.leakage.core
222+
pygsti.leakage.gaugeopt
223+
pygsti.leakage.metrics
224+
pygsti.leakage.models
225+
pygsti.leakage.reports
226+
211227
``pygsti.modelmembers``
212228
~~~~~~~~~~~~~~~~~~~~~~~
213229

docs/download-notebook-save-as.png

154 KB
Loading

pygsti/algorithms/gaugeopt.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -665,9 +665,9 @@ def _objective_fn(gauge_group_el, oob_check):
665665
return ret
666666

667667
if "frobenius" in spam_metric:
668-
# SPAM and gates can have different choices for squared vs non-squared.
669-
#
670-
# TODO: remove support for this codepath. It's ridiculous.
668+
# Need this path in case gates DON'T use a Frobenius-based penalty.
669+
# This path has a secondary use of allowing SPAM and gates to make
670+
# different choices as to squared vs plain Frobenius norm.
671671
wts = item_weights.copy(); wts['gates'] = 0.0
672672
for k in wts:
673673
if k in mdl_ops or k in mdl.instruments:

0 commit comments

Comments
 (0)