Skip to content

Commit

Permalink
Merge branch 'main' into feature/stark_p1_frequency_scan
Browse files Browse the repository at this point in the history
  • Loading branch information
wshanks authored Oct 26, 2023
2 parents fda5774 + bb2b5e1 commit 98c7e0d
Show file tree
Hide file tree
Showing 152 changed files with 3,592 additions and 1,147 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cron-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: [3.8, 3.9, "3.10", "3.11"]
python-version: [3.8, "3.11"]
os: ["ubuntu-latest", "macOS-latest", "windows-latest"]
steps:
- name: Print Concurrency Group
Expand Down
33 changes: 14 additions & 19 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: [3.8, 3.9, "3.10", "3.11"]
python-version: [3.8, "3.11"]
os: ["ubuntu-latest", "macOS-latest", "windows-latest"]
steps:
- name: Print Concurrency Group
Expand All @@ -39,25 +39,20 @@ jobs:
${{ runner.os }}-${{ matrix.python-version }}-pip-tests-
${{ runner.os }}-${{ matrix.python-version }}-pip-
${{ runner.os }}-${{ matrix.python-version }}
- name: Stestr cache
uses: actions/cache@v3
with:
path: .stestr
key: stestr-${{ runner.os }}-${{ matrix.python-version }}
restore-keys: |
stestr-${{ runner.os }}-
stestr-
- name: Install Deps
run: python -m pip install -U "tox==3.27.1" setuptools virtualenv wheel
- name: Install and Run Tests (Windows and Linux)
run: python -m pip install -U tox setuptools virtualenv wheel stestr
- name: Install and Run Tests
run: tox -e py
if: runner.os != 'macOS'
- name: Install and Run Tests (Macs only)
run: tox -e cover
if: runner.os == 'macOS'
env:
OMP_NUM_THREADS: 1
- name: Report coverage to coveralls.io (Macs only)
if: runner.os == 'macOS'
uses: coverallsapp/github-action@v2
env:
ACTIONS_RUNNER_DEBUG: 1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
flag-name: unit-tests_python${{ matrix.python-version }}-${{ matrix.os }}
path-to-lcov: coverage.lcov
- name: Clean up stestr cache
run: stestr history remove all

lint:
name: lint
Expand Down Expand Up @@ -98,7 +93,7 @@ jobs:
python -m pip install -U tox
sudo apt-get install -y pandoc graphviz
- name: Build Docs
run: tox -edocs
run: tox -edocs-parallel
- name: Compress Artifacts
run: |
mkdir artifacts
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,17 @@ jobs:
wheel-build:
name: Build and Publish Release Artifacts
runs-on: ubuntu-latest
environment: release
permissions:
id-token: write
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
name: Install Python
with:
python-version: '3.8'
- name: Install Deps
run: pip install -U twine wheel
run: pip install -U wheel
- name: Build Artifacts
run: |
python setup.py sdist
Expand All @@ -24,7 +27,4 @@ jobs:
with:
path: ./dist/qiskit*
- name: Publish to PyPi
env:
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
TWINE_USERNAME: qiskit
run: twine upload dist/qiskit*
uses: pypa/gh-action-pypi-publish@release/v1
1 change: 1 addition & 0 deletions .stestr.conf
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
[DEFAULT]
test_path=./test
parallel_class=True
2 changes: 1 addition & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!-- Copyright Contributors to the Qiskit project. -->

# Code of Conduct
All members of this project agree to adhere to the Qiskit Code of Conduct listed at [https://github.com/Qiskit/qiskit-metapackage/blob/master/CODE_OF_CONDUCT.md](https://github.com/Qiskit/qiskit-metapackage/blob/master/CODE_OF_CONDUCT.md)
All members of this project agree to adhere to the [Qiskit Code of Conduct](https://github.com/Qiskit/qiskit/blob/main/CODE_OF_CONDUCT.md).

----

Expand Down
2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ To run a method:
tox -- -n test.python.test_examples.TestPythonExamples.test_all_examples
```

Note that tests will fail automatically if they do not finish execution within 60 seconds.

#### STDOUT/STDERR and logging capture

When running tests in parallel using `stestr` either via tox, the Makefile (`make
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
[![License](https://img.shields.io/github/license/Qiskit-Extensions/qiskit-experiments.svg)](https://opensource.org/licenses/Apache-2.0)
[![Release](https://img.shields.io/github/release/Qiskit-Extensions/qiskit-experiments.svg)](https://github.com/Qiskit-Extensions/qiskit-experiments/releases)
![Python](https://img.shields.io/pypi/pyversions/qiskit-experiments.svg)
[![Coverage Status](https://coveralls.io/repos/github/Qiskit-Extensions/qiskit-experiments/badge.svg?branch=main)](https://coveralls.io/github/Qiskit-Extensions/qiskit-experiments?branch=main)
[![DOI](https://joss.theoj.org/papers/10.21105/joss.05329/status.svg)](https://doi.org/10.21105/joss.05329)

**Qiskit Experiments** is a repository that builds tools for building, running,
Expand Down
10 changes: 6 additions & 4 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
"sphinx.ext.autodoc",
"sphinx.ext.autosummary",
"sphinx.ext.mathjax",
"sphinx.ext.viewcode",
"sphinx.ext.extlinks",
"sphinx_copybutton",
"jupyter_sphinx",
Expand All @@ -69,11 +68,14 @@
"sphinx_remove_toctrees",
]

# Remove stubs from the toctree by default because the full build is slow
# This is turned off for docs deployment
if not os.getenv("FULL_TOCTREE", None):
if os.getenv("PROD_BUILD", None):
# Turn on view code source for production build
extensions.append("sphinx.ext.viewcode")
else:
# Remove stubs from the toctree for non-prod build because the full build is slow
remove_from_toctrees = ["stubs/*"]


html_static_path = ["_static"]
templates_path = ["_templates"]
# Manually add the gallery CSS file for now
Expand Down
45 changes: 45 additions & 0 deletions docs/howtos/figure_generation.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
Control figure generation
=========================

Problem
-------

You want to change the default behavior where figures are generated with every experiment.

Solution
--------

For a single non-composite experiment, figure generation can be switched off by setting the analysis
option ``plot`` to ``False``:

.. jupyter-input::

experiment.analysis.set_options(plot = False)

For composite experiments, there is a ``generate_figures`` analysis option which controls how child figures are
generated. There are three options:

- ``always``: The default behavior, generate figures for each child experiment.
- ``never``: Never generate figures for any child experiment.
- ``selective``: Only generate figures for analysis results where ``quality`` is ``bad``. This is useful
for large composite experiments where you only want to examine qubits with problems.

This parameter should be set on the analysis of a composite experiment before the analysis runs:

.. jupyter-input::

parallel_exp = ParallelExperiment(
[T1(physical_qubits=(i,), delays=delays) for i in range(2)]
)
parallel_exp.analysis.set_options(generate_figures="selective")

Discussion
----------

These options are useful for large composite experiments, where generating all figures incurs a significant
overhead.

See Also
--------

* The `Visualization tutorial <visualization.html>`_ discusses how to customize figures
2 changes: 1 addition & 1 deletion docs/manuals/characterization/stark_experiment.rst
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ By default, the Stark tone is applied to the same channel as the qubit drive
with a frequency shift. This frequency shift might update the channel frame,
which accumulates unwanted phase against the frequency difference between
the qubit drive :math:`f_0` and Stark tone frequencies :math:`f_S` in addition to
the qubit Stark shfit :math:`\delta f_s`.
the qubit Stark shift :math:`\delta f_s`.
You can use a dedicated Stark drive channel if available.
Otherwise, you may want to use a control channel associated with the physical
drive port of the qubit.
Expand Down
4 changes: 2 additions & 2 deletions docs/manuals/measurement/readout_mitigation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ experiments to generate the corresponding mitigators.
num_qubits = len(qubits)

Standard mitigation experiment
==============================
------------------------------

The default mitigation experiment is *local*, meaning error probability
is measured individually for each qubit. The experiment generates two
Expand Down Expand Up @@ -99,7 +99,7 @@ The individual mitigation matrices can be read off the mitigator.
print()


Mitigation Example
Mitigation example
------------------

.. jupyter-execute::
Expand Down
2 changes: 1 addition & 1 deletion docs/manuals/verification/randomized_benchmarking.rst
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ for the single qubit channel :math:`n=1`. Accordingly,
as a composition of depolarization from every primitive gates per qubit.
This correction will give you two EPC values as a result of the two-qubit RB experiment.
The corrected EPC must be closer to the outcome of of interleaved RB.
The corrected EPC must be closer to the outcome of interleaved RB.
The EPGs of two-qubit RB are analyzed with the corrected EPC if available.

.. jupyter-execute::
Expand Down
8 changes: 2 additions & 6 deletions docs/tutorials/calibrations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ This automatic updating can also be disabled using the ``auto_update`` flag.
This tutorial requires the :mod:`qiskit_dynamics` package to run simulations.
You can install it with ``python -m pip install qiskit-dynamics``.

.. note::
This tutorial requires the ``pandas`` package to visualize calibration tables.
You can install it with ``python -m pip install pandas``.

.. jupyter-execute::

import pandas as pd
Expand Down Expand Up @@ -382,7 +378,7 @@ instruction schedule map with this over/under-rotated pulse.
over_amp = ideal_amp*1.02
under_amp = ideal_amp*0.98
print(f"The reported amplitude of the X pulse is {ideal_amp:.4f} which we set as ideal_amp.")
print(f"we use {over_amp:.4f} amplitude for overroation pulse and {under_amp:.4f} for underrotation pulse.")
print(f"we use {over_amp:.4f} amplitude for overrotation pulse and {under_amp:.4f} for underrotation pulse.")
# build the over rotated pulse and add it to the instruction schedule map
with pulse.build(backend=backend, name="x") as x_over:
pulse.play(pulse.Drag(x_pulse.duration, over_amp, x_pulse.sigma, x_pulse.beta), d0)
Expand Down Expand Up @@ -441,7 +437,7 @@ error but also its sign.
scale_under = target_angle / (target_angle + dtheta_under)
print(f"The ideal angle is {target_angle:.2f} rad. We measured a deviation of {dtheta_over:.3f} rad in over-rotated pulse case.")
print(f"Thus, scale the {over_amp:.4f} pulse amplitude by {scale_over:.3f} to obtain {over_amp*scale_over:.5f}.")
print(f"On the other hand, we measued a deviation of {dtheta_under:.3f} rad in under-rotated pulse case.")
print(f"On the other hand, we measured a deviation of {dtheta_under:.3f} rad in under-rotated pulse case.")
print(f"Thus, scale the {under_amp:.4f} pulse amplitude by {scale_under:.3f} to obtain {under_amp*scale_under:.5f}.")


Expand Down
5 changes: 5 additions & 0 deletions docs/tutorials/curve_analysis.rst
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,11 @@ every logic defined in ``AnalysisA``.
Curve Analysis workflow
-----------------------

.. warning::

:class:`CurveData` dataclass is replaced with :class:`.ScatterTable` dataframe.
This class will be deprecated and removed in the future release.

Typically curve analysis performs fitting as follows.
This workflow is defined in the method :meth:`CurveAnalysis._run_analysis`.

Expand Down
6 changes: 3 additions & 3 deletions docs/tutorials/custom_experiment.rst
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ to 10.
self._circuit = circuit
self._measured_qubits = measured_qubits

# Set any init optinos
# Set any init options
self.set_experiment_options(num_samples=num_samples, seed=seed)

Now we consider default experiment options. We choose to only let the user change
Expand Down Expand Up @@ -555,7 +555,7 @@ To test our code, we first simulate a noisy backend with asymmetric readout erro

backend_ideal = AerSimulator()

# Backend with asymetric readout error
# Backend with asymmetric readout error
p0g1 = 0.3
p1g0 = 0.05
noise_model = noise.NoiseModel()
Expand Down Expand Up @@ -588,7 +588,7 @@ Check that the experiment is appending a random Pauli and measurements as expect
exp = RandomizedMeasurement(qc, num_samples=num_samples)
exp.circuits()[0].draw("mpl")

We now run the experiment with a GHZ circuit on an ideal backend, whic produces nearly
We now run the experiment with a GHZ circuit on an ideal backend, which produces nearly
perfect symmetrical results between :math:`|0000\rangle` and :math:`|1111\rangle`:

.. jupyter-execute::
Expand Down
37 changes: 32 additions & 5 deletions docs/tutorials/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -238,21 +238,24 @@ supports can be set:

exp.set_run_options(shots=1000,
meas_level=MeasLevel.CLASSIFIED)
print(f"Shots set to {exp.run_options.get('shots')}, "
"measurement level set to {exp.run_options.get('meas_level')}")

Consult the documentation of the run method of your
specific backend type for valid options.
For example, see :meth:`qiskit_ibm_provider.IBMBackend.run` for IBM backends.

Transpile options
-----------------
These options are passed to the Terra transpiler to transpile the experiment circuits
These options are passed to the Qiskit :mod:`~qiskit.transpiler` to transpile the experiment circuits
before execution:

.. jupyter-execute::

exp.set_transpile_options(scheduling_method='asap',
optimization_level=3,
basis_gates=["x", "sx", "rz"])
print(f"Transpile options are {exp.transpile_options}")

Consult the documentation of :func:`qiskit.compiler.transpile` for valid options.

Expand All @@ -267,14 +270,15 @@ upon experiment instantiation, but can also be explicitly set via
exp = T1(physical_qubits=(0,), delays=delays)
new_delays=np.arange(1e-6, 600e-6, 50e-6)
exp.set_experiment_options(delays=new_delays)
print(f"Experiment options are {exp.experiment_options}")

Consult the :doc:`API documentation </apidocs/index>` for the options of each experiment
class.

Analysis options
----------------

These options are unique to each analysis class. Unlike the other options, analyis
These options are unique to each analysis class. Unlike the other options, analysis
options are not directly set via the experiment object but use instead a method of the
associated ``analysis``:

Expand All @@ -295,7 +299,7 @@ Running experiments on multiple qubits
======================================

To run experiments across many qubits of the same device, we use **composite
experiments**. A composite experiment is a parent object that contains one or more child
experiments**. A :class:`.CompositeExperiment` is a parent object that contains one or more child
experiments, which may themselves be composite. There are two core types of composite
experiments:

Expand Down Expand Up @@ -323,7 +327,7 @@ Note that when the transpile and run options are set for a composite experiment,
child experiments's options are also set to the same options recursively. Let's examine
how the parallel experiment is constructed by visualizing child and parent circuits. The
child experiments can be accessed via the
:meth:`~.ParallelExperiment.component_experiment` method, which indexes from zero:
:meth:`~.CompositeExperiment.component_experiment` method, which indexes from zero:

.. jupyter-execute::

Expand All @@ -333,6 +337,16 @@ child experiments can be accessed via the

parallel_exp.component_experiment(1).circuits()[0].draw(output='mpl')

Similarly, the child analyses can be accessed via :meth:`.CompositeAnalysis.component_analysis` or via
the analysis of the child experiment class:

.. jupyter-execute::

parallel_exp.component_experiment(0).analysis.set_options(plot = True)

# This should print out what we set because it's the same option
print(parallel_exp.analysis.component_analysis(0).options.get("plot"))

The circuits of all experiments assume they're acting on virtual qubits starting from
index 0. In the case of a parallel experiment, the child experiment
circuits are composed together and then reassigned virtual qubit indices:
Expand Down Expand Up @@ -393,4 +407,17 @@ into one level:
parallel_data = parallel_exp.run(backend, seed_simulator=101).block_for_results()

for result in parallel_data.analysis_results():
print(result)
print(result)

Broadcasting analysis options to child experiments
--------------------------------------------------

Use the `broadcast` parameter to set analysis options to each of the child experiments.

.. jupyter-execute::

parallel_exp.analysis.set_options(plot=False, broadcast=True)

If the child experiment inherits from :class:`.CompositeExperiment` (such as :class:`.ParallelExperiment`
and :class:`.BatchExperiment` classes), this process will continue to work recursively.
In this instance, the analysis will not generate a figure for the child experiment after the analysis.
Loading

0 comments on commit 98c7e0d

Please sign in to comment.