Skip to content

Commit 46e54a6

Browse files
author
Erik Nielsen
committed
Merge branch 'beta' to become version 0.9.7.2
2 parents 60f8d8a + 6049cbb commit 46e54a6

File tree

151 files changed

+257014
-16508
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

151 files changed

+257014
-16508
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ packages/pygsti.egg-info
4747
packages/pygsti/baseobjs/parsetab_string.py
4848
packages/pygsti/objects/fastgatecalc.cpp
4949
packages/pygsti/objects/fastreplib.cpp
50+
packages/pygsti/objects/fastopcalc.cpp
5051
packages/pygsti/tools/fastcalc.c
5152

5253

.travis.yml

Lines changed: 44 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -11,49 +11,65 @@ branches:
1111
- beta
1212
- develop
1313

14+
# Hold off testing feature & bugfix branches in case this competes w/other testing.
15+
# - /^feature-.*$/
16+
# - /^bugfix-.*$/
17+
1418
env:
15-
- Drivers=True # First in build mx because long duration
16-
- Algorithms=True
17-
- AlgorithmsB=True
18-
- Default=True # construction, io, objects, tools, optimize
19-
- Report=True
20-
- ReportB=True
21-
- MPI=True
19+
global:
20+
- NOSEOPTS_DEFAULT="-v --with-timer --with-id --rednose"
21+
- NOSEOPTS_PARALLEL="--processes=-1 --process-timeout=2400" # timeout after 40 minutes (travis job timeout is 50 minutes)
22+
- NOSEOPTS_ALL="$NOSEOPTS_DEFAULT $NOSEOPTS_PARALLEL"
23+
matrix:
24+
- NOSETESTS="drivers objects" NOSEOPTS=$NOSEOPTS_ALL # first in build mx because long duration
25+
- NOSETESTS="algorithms" NOSEOPTS=$NOSEOPTS_ALL
26+
- NOSETESTS="algorithmsb" NOSEOPTS=$NOSEOPTS_ALL
27+
- NOSETESTS="tools iotest optimize construction extras" NOSEOPTS=$NOSEOPTS_ALL
28+
- NOSETESTS="report" NOSEOPTS=$NOSEOPTS_ALL
29+
- NOSETESTS="reportb" NOSEOPTS=$NOSEOPTS_ALL
30+
- NOSETESTS="mpi" NOSEOPTS=$NOSEOPTS_DEFAULT # cannot be run in parallel
2231

32+
# Install native package dependencies & initialize build environment
2333
before_install:
24-
- sudo apt-get -qq update
25-
- sudo apt-get -qq install gfortran libblas-dev liblapack-dev
26-
- sudo apt-get -qq install openmpi-bin openmpi-common openssh-client openssh-server libopenmpi1.6 libopenmpi1.6-dbg libopenmpi-dev > /dev/null
27-
- sudo bash CI/install.sh # travis_wait 30 "sudo bash CI/install.sh" # > /dev/null 2>&1"
28-
- "export DISPLAY=:99.0"
29-
- "sh -e /etc/init.d/xvfb start" #some tests require a display
30-
- sleep 3 # give xvfb some time to start
34+
- >
35+
sudo apt-get update -qq -y &&
36+
sudo apt-get install -qq -y
37+
gfortran libblas-dev liblapack-dev openmpi-bin openmpi-common openssh-client
38+
openssh-server libopenmpi1.6 libopenmpi1.6-dbg libopenmpi-dev
39+
libsuitesparse-dev
40+
- export DISPLAY=:99.0
41+
- /bin/sh -e /etc/init.d/xvfb start && sleep 3 # some tests require a display
42+
- cmake --version
43+
- gcc --version
3144

45+
# Install python package dependencies
3246
install:
33-
- pip install zmq coverage >/dev/null
3447
- pip install -e .[travisci]
35-
48+
49+
# Default `test' stage script
50+
script:
51+
- cd test/test_packages
52+
- nosetests $NOSEOPTS $NOSETESTS
53+
54+
# Cache pip packages
3655
cache:
3756
pip: true
3857
timeout: 1000
3958

40-
#Script For default "test" stage
41-
script:
42-
- cd test
43-
- python travisTests.py # just produce test_packages/runTravisTests.sh
44-
- cd test_packages
45-
- source runTravisTests.sh # no need for travis_wait (always outputs every 9m)
46-
- cd ../..
59+
stages:
60+
- test
61+
- name: deploy # only run deployment for master & develop branches
62+
if: branch IN (master, develop)
4763

4864
jobs:
4965
include:
5066
- stage: deploy
5167
python: 3.5
52-
env: Drivers=False Algorithms=False AlgorithmsB=False Default=False Report=False ReportB=False MPI=False
68+
env: NOSETESTS=none NOSEOPTS=$NOSEOPTS_DEFAULT
69+
install: skip
5370
script: python CI/deploy
5471

5572
notifications:
56-
email:
57-
on_success: change
58-
on_failure: always
59-
73+
email:
74+
on_success: change
75+
on_failure: always

CI/install.sh

Lines changed: 0 additions & 71 deletions
This file was deleted.

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ include jupyter_notebooks/Tutorials/other/advanced/*.ipynb
1616
include jupyter_notebooks/Examples/*.ipynb
1717
include juptyer_notebooks/Tutorials/tutorial_files/.placeholder
1818
include jupyter_notebooks/Examples/example_files/.git_placeholder
19+
include scripts/update2v0.9.7.py
1920
include test/runTests.py
2021
include test/travisTests.py
2122
include test/__init__.py

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ PyGSTi is designed with a modular structure so as to be highly customizable
3636
and easily integrated to new or existing python software. It runs using
3737
python2.7 or python3. To faclilitate integration with software for running
3838
cloud-QIP experiments, pyGSTi `Circuit` objects can be converted to IBM's
39-
**QASM** and Rigetti Quantum Computing's **QUIL** circuit description languages.
39+
**OpenQASM** and Rigetti Quantum Computing's **Quil** circuit description languages.
4040

4141
Installation
4242
------------
@@ -151,11 +151,15 @@ Tutorials and Examples
151151
----------------------
152152
There are numerous tutorials (meant to be pedagogical) and examples (meant to be demonstrate
153153
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
154+
directory. The root "START HERE" notebook will direct you where to go based on what you're most
155+
interested in learning about. You can view the
156+
[read-only GitHub version of this notebook](https://github.com/pyGSTio/pyGSTi/blob/master/jupyter_notebooks/START_HERE.ipynb)
157+
or you can [explore the tutorials interactively](https://mybinder.org/v2/gh/pyGSTio/pyGSTi/master)
158+
using JupyterHub via Binder. Note the existence of a
159+
[FAQ](https://github.com/pyGSTio/pyGSTi/blob/master/jupyter_notebooks/FAQ.ipynb), which
157160
addresses common issues.
158161
162+
159163
#### Running notebooks *locally*
160164
While it's possible to view the notebooks on GitHub using the links above, it's
161165
usually nicer to run them *locally* so you can mess around with the code as

packages/pygsti/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
# in the file "license.txt" in the top-level pyGSTi directory
55
#*****************************************************************
66
""" PyGSTi version number """
7-
__version__ = "0.9.7.1"
7+
__version__ = "0.9.7.2"

packages/pygsti/algorithms/core.py

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ def do_lgst(dataset, prepStrs, effectStrs, targetModel, opLabels=None, opLabelAl
179179
if svdTruncateTo is None or svdTruncateTo == targetModel.dim: #use target sslbls and basis
180180
lgstModel = _objs.ExplicitOpModel(targetModel.state_space_labels, targetModel.basis)
181181
else: # construct a default basis for the requested dimension
182-
dumb_basis = _objs.Basis('gm',[1]*svdTruncateTo) # - just act on diagonal density mx
182+
dumb_basis = _objs.DirectSumBasis( [_objs.BuiltinBasis('gm',1)]*svdTruncateTo) # - just act on diagonal density mx
183183
lgstModel = _objs.ExplicitOpModel([('L%d'%i,) for i in range(svdTruncateTo)], dumb_basis)
184184

185185
for opLabel in opLabelsToEstimate:
@@ -2437,6 +2437,7 @@ def _objective_func(vectorGS):
24372437
v = _np.where( probs < min_p, v + S*(probs - min_p) + S2*(probs - min_p)**2, v) #quadratic extrapolation of logl at min_p for probabilities < min_p
24382438
v = _np.where( minusCntVecMx == 0, totalCntVec * _np.where(probs >= a, probs, (-1.0/(3*a**2))*probs**3 + probs**2/a + a/3.0), v)
24392439
#special handling for f == 0 terms using quadratic rounding of function with minimum: max(0,(a-p)^2)/(2a) + p
2440+
#assert( _np.all(v >= 0) ), "LogL term is < 0! (This is usually caused by using a large #samples without reducing minProbClip)"
24402441
v = _np.sqrt( v )
24412442
v.shape = [KM] #reshape ensuring no copy is needed
24422443
if cptp_penalty_factor != 0:
@@ -2534,6 +2535,7 @@ def _objective_func(vectorGS):
25342535
v = _np.maximum(v,0) #remove small negative elements due to roundoff error (above expression *cannot* really be negative)
25352536
v = _np.where( probs < min_p, v + S*(probs - min_p) + S2*(probs - min_p)**2, v) #quadratic extrapolation of logl at min_p for probabilities < min_p
25362537
v = _np.where( minusCntVecMx == 0, 0.0, v)
2538+
#assert( _np.all(v >= 0) ), "LogL term is < 0! (This is usually caused by using a large #samples without reducing minProbClip)"
25372539
v = _np.sqrt( v )
25382540
assert(v.shape == (KM,)) #reshape ensuring no copy is needed
25392541

@@ -2687,7 +2689,7 @@ def do_iterative_mlgst(dataset, startModel, circuitSetsToUseInEstimation,
26872689
verbosity=0, check=False, circuitWeightsDict=None,
26882690
opLabelAliases=None, memLimit=None,
26892691
profiler=None, comm=None, distributeMethod = "deriv",
2690-
alwaysPerformMLE=False, evaltree_cache=None):
2692+
alwaysPerformMLE=False, onlyPerformMLE=False, evaltree_cache=None):
26912693
"""
26922694
Performs Iterative Maximum Likelihood Estimation Gate Set Tomography on the dataset.
26932695
@@ -2806,6 +2808,10 @@ def do_iterative_mlgst(dataset, startModel, circuitSetsToUseInEstimation,
28062808
not just the final one. When False, chi2 minimization is used for all
28072809
except the final iteration (for improved numerical stability).
28082810
2811+
onlyPerformMLE : bool, optional
2812+
When True, `alwaysPerformMLE` must also be true, and in this case only
2813+
a ML optimization is performed for each iteration.
2814+
28092815
evaltree_cache : dict, optional
28102816
An empty dictionary which gets filled with the *final* computed EvalTree
28112817
(and supporting info) used in this computation.
@@ -2823,6 +2829,9 @@ def do_iterative_mlgst(dataset, startModel, circuitSetsToUseInEstimation,
28232829
of the i-th iteration.
28242830
"""
28252831

2832+
if onlyPerformMLE:
2833+
assert(alwaysPerformMLE), "Must set `alwaysPerformMLE` to True whenever `onlyPerformMLE` is True."
2834+
28262835
printer = _objs.VerbosityPrinter.build_printer(verbosity, comm)
28272836
if profiler is None: profiler = _dummy_profiler
28282837

@@ -2864,12 +2873,13 @@ def do_iterative_mlgst(dataset, startModel, circuitSetsToUseInEstimation,
28642873
num_fd = fditer if (i == 0) else 0
28652874

28662875
evt_cache = {} # get the eval tree that's created so we can reuse it
2867-
_, mleModel = do_mc2gst(dataset, mleModel, stringsToEstimate,
2868-
maxiter, maxfev, num_fd, tol, cptp_penalty_factor,
2869-
spam_penalty_factor, minProbClip, probClipInterval,
2870-
useFreqWeightedChiSq, 0,printer-1, check,
2871-
check, circuitWeights, opLabelAliases,
2872-
memLimit, comm, distributeMethod, profiler, evt_cache)
2876+
if not onlyPerformMLE:
2877+
_, mleModel = do_mc2gst(dataset, mleModel, stringsToEstimate,
2878+
maxiter, maxfev, num_fd, tol, cptp_penalty_factor,
2879+
spam_penalty_factor, minProbClip, probClipInterval,
2880+
useFreqWeightedChiSq, 0,printer-1, check,
2881+
check, circuitWeights, opLabelAliases,
2882+
memLimit, comm, distributeMethod, profiler, evt_cache)
28732883

28742884
if alwaysPerformMLE:
28752885
_, mleModel = do_mlgst(dataset, mleModel, stringsToEstimate,
@@ -3054,7 +3064,7 @@ def _spam_penalty_jac_fill(spamPenaltyVecGradToFill, mdl, prefactor, opBasis):
30543064
Helper function - jacobian of CPTP penalty (sum of tracenorms of gates)
30553065
Returns a (real) array of shape ( _spam_penalty_size(mdl), nParams).
30563066
"""
3057-
BMxs = opBasis.get_composite_matrices() #shape [mdl.dim, dmDim, dmDim]
3067+
BMxs = opBasis.elements #shape [mdl.dim, dmDim, dmDim]
30583068
ddenMxdV = dEMxdV = BMxs.conjugate() # b/c denMx = sum( spamvec[i] * Bmx[i] ) and "V" == spamvec
30593069
#NOTE: conjugate() above is because ddenMxdV and dEMxdV will get *elementwise*
30603070
# multiplied (einsum below) by another complex matrix (sgndm or sgnE) and summed

packages/pygsti/algorithms/gaugeopt.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,7 @@ def _spam_penalty_jac_fill(spamPenaltyVecGradToFill, mdl_pre, mdl_post,
685685
Helper function - jacobian of CPTP penalty (sum of tracenorms of gates)
686686
Returns a (real) array of shape (_spam_penalty_size(mdl), gaugeGroupEl.num_params()).
687687
"""
688-
BMxs = opBasis.get_composite_matrices() #shape [mdl.dim, dmDim, dmDim]
688+
BMxs = opBasis.elements #shape [mdl.dim, dmDim, dmDim]
689689
ddenMxdV = dEMxdV = BMxs.conjugate() # b/c denMx = sum( spamvec[i] * Bmx[i] ) and "V" == spamvec
690690
#NOTE: conjugate() above is because ddenMxdV and dEMxdV will get *elementwise*
691691
# multiplied (einsum below) by another complex matrix (sgndm or sgnE) and summed

packages/pygsti/baseobjs/__init__.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,10 @@
1515
from .protectedarray import ProtectedArray
1616
from .circuitparser import CircuitParser
1717
from .verbosityprinter import VerbosityPrinter
18-
from .label import Label
18+
from .label import Label, CircuitLabel
1919

20-
from .basis import Basis
20+
from .basis import Basis,BuiltinBasis,ExplicitBasis,TensorProdBasis,DirectSumBasis
2121
from .parameterized import parameterized
22-
from .dim import Dim
2322
from .smartcache import SmartCache, CustomDigestError, smart_cached
2423

2524
#Imported in tools instead, since this makes more logical sense

0 commit comments

Comments
 (0)