From 289f6e7f7995e65623da46b7135196c536352e1a Mon Sep 17 00:00:00 2001 From: Helena Zhang Date: Tue, 8 Aug 2023 11:26:58 -0400 Subject: [PATCH 01/26] remove coveralls and intermediate python versions --- .github/workflows/main.yml | 18 +++--------------- README.md | 1 - tox.ini | 10 ---------- 3 files changed, 3 insertions(+), 26 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0649ab9d55..7301375e98 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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 @@ -40,24 +40,12 @@ jobs: ${{ runner.os }}-${{ matrix.python-version }}-pip- ${{ runner.os }}-${{ matrix.python-version }} - 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 + - 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 lint: name: lint diff --git a/README.md b/README.md index f165a1c865..b9a3e8020c 100644 --- a/README.md +++ b/README.md @@ -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, diff --git a/tox.ini b/tox.ini index be44ae4f6a..11f563ea38 100644 --- a/tox.ini +++ b/tox.ini @@ -19,16 +19,6 @@ passenv = QISKIT_IBM_* commands = stestr run {posargs} -[testenv:cover] -basepython = python3 -setenv = - {[testenv]setenv} - PYTHON=coverage3 run --source qiskit_experiments --parallel-mode -commands = - stestr run {posargs} - coverage3 combine - coverage3 lcov - [testenv:terra-main] usedevelop = True install_command = pip install -U {opts} {packages} From 332d5cbafaa87e106efeb7c2cc019a1bd487f78f Mon Sep 17 00:00:00 2001 From: Helena Zhang Date: Tue, 8 Aug 2023 12:38:37 -0400 Subject: [PATCH 02/26] add stestr cache --- .github/workflows/main.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7301375e98..c16ff9ba3f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -39,6 +39,18 @@ 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/0 + ~/.stestr/f* + ~/.stestr/m* + ~/.stestr/n* + ~/.stestr/t* + key: ${{ runner.os }}-${{ matrix.python-version }}-stestr-tests-${{ hashFiles('setup.py','requirements.txt','requirements-extras.txt','requirements-dev.txt','constraints.txt') }} + restore-keys: | + ${{ runner.os }}-${{ matrix.python-version }}-stestr-tests- - name: Install Deps run: python -m pip install -U tox setuptools virtualenv wheel - name: Install and Run Tests From b7caef6030d5accc8cd0f8e9cdba2e66a3cb66f3 Mon Sep 17 00:00:00 2001 From: Helena Zhang Date: Tue, 8 Aug 2023 14:38:18 -0400 Subject: [PATCH 03/26] fix indent --- .github/workflows/main.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c16ff9ba3f..eb710cc3ca 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -43,11 +43,11 @@ jobs: uses: actions/cache@v3 with: path: | - ~/.stestr/0 - ~/.stestr/f* - ~/.stestr/m* - ~/.stestr/n* - ~/.stestr/t* + ~/.stestr/0 + ~/.stestr/f* + ~/.stestr/m* + ~/.stestr/n* + ~/.stestr/t* key: ${{ runner.os }}-${{ matrix.python-version }}-stestr-tests-${{ hashFiles('setup.py','requirements.txt','requirements-extras.txt','requirements-dev.txt','constraints.txt') }} restore-keys: | ${{ runner.os }}-${{ matrix.python-version }}-stestr-tests- From 61f54e87c88ad716c2859c3c784aef999dc1f398 Mon Sep 17 00:00:00 2001 From: Helena Zhang Date: Tue, 8 Aug 2023 14:42:55 -0400 Subject: [PATCH 04/26] fix workflow file --- .github/workflows/main.yml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index eb710cc3ca..323864e735 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -43,16 +43,19 @@ jobs: uses: actions/cache@v3 with: path: | - ~/.stestr/0 - ~/.stestr/f* - ~/.stestr/m* - ~/.stestr/n* - ~/.stestr/t* + .stestr/0 + .stestr/f* + .stestr/m* + .stestr/n* + .stestr/t* key: ${{ runner.os }}-${{ matrix.python-version }}-stestr-tests-${{ hashFiles('setup.py','requirements.txt','requirements-extras.txt','requirements-dev.txt','constraints.txt') }} restore-keys: | ${{ runner.os }}-${{ matrix.python-version }}-stestr-tests- - name: Install Deps run: python -m pip install -U tox setuptools virtualenv wheel + - name: Install and Run Tests + run: tox -e py + if: runner.os != 'macOS' - name: Install and Run Tests run: tox -e py if: runner.os == 'macOS' From 1912610b7600cad1c50eab494627c044fc1d3f91 Mon Sep 17 00:00:00 2001 From: Helena Zhang Date: Wed, 9 Aug 2023 14:27:27 -0400 Subject: [PATCH 05/26] try reintroducing coverage --- .github/workflows/main.yml | 12 +++++++++++- tox.ini | 10 ++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 323864e735..e0bcb26d70 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -57,10 +57,20 @@ jobs: run: tox -e py if: runner.os != 'macOS' - name: Install and Run Tests - run: tox -e py + 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 + lint: name: lint diff --git a/tox.ini b/tox.ini index 11f563ea38..be44ae4f6a 100644 --- a/tox.ini +++ b/tox.ini @@ -19,6 +19,16 @@ passenv = QISKIT_IBM_* commands = stestr run {posargs} +[testenv:cover] +basepython = python3 +setenv = + {[testenv]setenv} + PYTHON=coverage3 run --source qiskit_experiments --parallel-mode +commands = + stestr run {posargs} + coverage3 combine + coverage3 lcov + [testenv:terra-main] usedevelop = True install_command = pip install -U {opts} {packages} From d1e5e59be1769c07834fad9b7675033f76be2ab6 Mon Sep 17 00:00:00 2001 From: Helena Zhang Date: Wed, 9 Aug 2023 16:18:28 -0400 Subject: [PATCH 06/26] add test timeout --- test/base.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/base.py b/test/base.py index b0a4aa15d0..1fbdb3d21f 100644 --- a/test/base.py +++ b/test/base.py @@ -13,9 +13,11 @@ Qiskit Experiments test case class """ +import os import json import pickle import warnings +import fixtures from typing import Any, Callable, Optional import uncertainties @@ -30,10 +32,17 @@ from qiskit_experiments.framework.experiment_data import ExperimentStatus from .extended_equality import is_equivalent +# Fail tests that take longer than this +TEST_TIMEOUT = os.environ.get("TEST_TIMEOUT", 10) + class QiskitExperimentsTestCase(QiskitTestCase): """Qiskit Experiments specific extra functionality for test cases.""" + def setUp(self): + super().setUp() + self.useFixture(fixtures.Timeout(TEST_TIMEOUT, gentle=False)) + @classmethod def setUpClass(cls): """Set-up test class.""" From 34a4bf8259039b6aeb427b7375c8ebf8ee8baa24 Mon Sep 17 00:00:00 2001 From: Helena Zhang Date: Wed, 6 Sep 2023 14:31:40 -0400 Subject: [PATCH 07/26] increase timeout and shorten test --- test/base.py | 4 ++-- test/library/calibration/test_drag.py | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/test/base.py b/test/base.py index 1fbdb3d21f..215c33be3c 100644 --- a/test/base.py +++ b/test/base.py @@ -17,9 +17,9 @@ import json import pickle import warnings -import fixtures from typing import Any, Callable, Optional +import fixtures import uncertainties from qiskit.test import QiskitTestCase from qiskit.utils.deprecation import deprecate_func @@ -33,7 +33,7 @@ from .extended_equality import is_equivalent # Fail tests that take longer than this -TEST_TIMEOUT = os.environ.get("TEST_TIMEOUT", 10) +TEST_TIMEOUT = os.environ.get("TEST_TIMEOUT", 20) class QiskitExperimentsTestCase(QiskitTestCase): diff --git a/test/library/calibration/test_drag.py b/test/library/calibration/test_drag.py index 5372f37eba..8e96134a75 100644 --- a/test/library/calibration/test_drag.py +++ b/test/library/calibration/test_drag.py @@ -55,6 +55,7 @@ def test_end_to_end(self): backend = MockIQBackend(drag_experiment_helper) drag = RoughDrag([1], self.x_plus) + drag.set_run_options(shots=200) expdata = drag.run(backend) self.assertExperimentDone(expdata) @@ -69,6 +70,7 @@ def test_end_to_end(self): drag_experiment_helper.frequency = 0.0044 drag = RoughDrag([0], self.x_plus) + drag.set_run_options(shots=200) exp_data = drag.run(backend) self.assertExperimentDone(exp_data) result = exp_data.analysis_results(1) From b0b391a6d51cc6f02b6120f94d0d584ca99e7c7b Mon Sep 17 00:00:00 2001 From: Helena Zhang Date: Wed, 6 Sep 2023 15:13:14 -0400 Subject: [PATCH 08/26] increase timeout and shorten tests --- qiskit_experiments/library/characterization/drag.py | 2 +- .../library/tomography/mit_qpt_experiment.py | 2 +- .../library/tomography/qpt_experiment.py | 2 +- test/base.py | 2 +- test/library/calibration/test_drag.py | 13 +++++++------ test/library/calibration/test_rabi.py | 3 ++- test/library/calibration/test_rough_amplitude.py | 2 +- .../test_cross_resonance_hamiltonian.py | 5 +++-- .../characterization/test_qubit_spectroscopy.py | 6 ++++-- .../characterization/test_resonator_spectroscopy.py | 2 +- test/library/characterization/test_t2hahn.py | 2 +- test/library/characterization/test_t2ramsey.py | 2 +- test/library/quantum_volume/test_qv.py | 2 +- .../randomized_benchmarking/test_interleaved_rb.py | 4 ++-- .../randomized_benchmarking/test_standard_rb.py | 4 ++-- test/library/tomography/test_process_tomography.py | 2 +- 16 files changed, 30 insertions(+), 25 deletions(-) diff --git a/qiskit_experiments/library/characterization/drag.py b/qiskit_experiments/library/characterization/drag.py index 7e7639fe3b..fb48add906 100644 --- a/qiskit_experiments/library/characterization/drag.py +++ b/qiskit_experiments/library/characterization/drag.py @@ -166,7 +166,7 @@ def circuits(self) -> List[QuantumCircuit]: ) for beta_val in self.experiment_options.betas: - beta_val = np.round(beta_val, decimals=6) + beta_val = float(np.round(beta_val, decimals=6)) assigned_circuit = circuit.assign_parameters({beta: beta_val}, inplace=False) diff --git a/qiskit_experiments/library/tomography/mit_qpt_experiment.py b/qiskit_experiments/library/tomography/mit_qpt_experiment.py index bc7d859137..bdebf34bd0 100644 --- a/qiskit_experiments/library/tomography/mit_qpt_experiment.py +++ b/qiskit_experiments/library/tomography/mit_qpt_experiment.py @@ -78,7 +78,7 @@ def __init__( basis_indices: Optional, a list of basis indices for generating partial tomography measurement data. Each item should be given as a pair of lists of preparation and measurement basis configurations - ``([p[0], p[1], ..], m[0], m[1], ...])``, where ``p[i]`` is the + ``([p[0], p[1], ...], [m[0], m[1], ...])``, where ``p[i]`` is the preparation basis index, and ``m[i]`` is the measurement basis index for qubit-i. If not specified full tomography for all indices of the preparation and measurement bases will be performed. diff --git a/qiskit_experiments/library/tomography/qpt_experiment.py b/qiskit_experiments/library/tomography/qpt_experiment.py index fb253a8a06..17d7d7347b 100644 --- a/qiskit_experiments/library/tomography/qpt_experiment.py +++ b/qiskit_experiments/library/tomography/qpt_experiment.py @@ -81,7 +81,7 @@ def __init__( basis_indices: Optional, a list of basis indices for generating partial tomography measurement data. Each item should be given as a pair of lists of preparation and measurement basis configurations - ``([p[0], p[1], ..], m[0], m[1], ...])``, where ``p[i]`` is the + ``([p[0], p[1], ...], [m[0], m[1], ...])``, where ``p[i]`` is the preparation basis index, and ``m[i]`` is the measurement basis index for qubit-i. If not specified full tomography for all indices of the preparation and measurement bases will be performed. diff --git a/test/base.py b/test/base.py index 215c33be3c..6b6e22e794 100644 --- a/test/base.py +++ b/test/base.py @@ -33,7 +33,7 @@ from .extended_equality import is_equivalent # Fail tests that take longer than this -TEST_TIMEOUT = os.environ.get("TEST_TIMEOUT", 20) +TEST_TIMEOUT = os.environ.get("TEST_TIMEOUT", 45) class QiskitExperimentsTestCase(QiskitTestCase): diff --git a/test/library/calibration/test_drag.py b/test/library/calibration/test_drag.py index 06fdeda399..12ca3ebd17 100644 --- a/test/library/calibration/test_drag.py +++ b/test/library/calibration/test_drag.py @@ -97,11 +97,11 @@ def test_end_to_end(self): self.assertEqual(result.quality, "good") @data( - (0.0040, 1.0, 0.00, [1, 3, 5], None, 0.1), # partial oscillation. - (0.0020, 0.5, 0.00, [1, 3, 5], None, 0.5), # even slower oscillation with amp < 1 - (0.0040, 0.8, 0.05, [3, 5, 7], None, 0.1), # constant offset, i.e. lower SNR. - (0.0800, 0.9, 0.05, [1, 3, 5], np.linspace(-1, 1, 51), 0.1), # Beta not in range - (0.2000, 0.5, 0.10, [1, 3, 5], np.linspace(-2.5, 2.5, 51), 0.1), # Max closer to zero + (0.0040, 1.0, 0.00, [1, 3, 5], None, 0.2), # partial oscillation. + (0.0020, 0.5, 0.00, [1, 3, 5], None, 1.0), # even slower oscillation with amp < 1 + (0.0040, 0.8, 0.05, [3, 5, 7], None, 0.2), # constant offset, i.e. lower SNR. + (0.0800, 0.9, 0.05, [1, 3, 5], np.linspace(-1, 1, 51), 0.2), # Beta not in range + (0.2000, 0.5, 0.10, [1, 3, 5], np.linspace(-2.5, 2.5, 51), 0.2), # Max closer to zero ) @unpack def test_nasty_data(self, freq, amp, offset, reps, betas, tol): @@ -115,6 +115,7 @@ def test_nasty_data(self, freq, amp, offset, reps, betas, tol): drag = RoughDrag([0], self.x_plus, betas=betas) drag.set_experiment_options(reps=reps) + drag.set_run_options(shots=500) exp_data = drag.run(backend) self.assertExperimentDone(exp_data) @@ -192,7 +193,7 @@ def test_default_circuits(self): def test_circuit_roundtrip_serializable(self): """Test circuit serializations for drag experiment.""" drag = RoughDrag([0], self.x_plus) - drag.set_experiment_options(reps=[2, 4, 8]) + drag.set_experiment_options(reps=[2, 4], betas=[-5, 5]) drag.backend = FakeWashingtonV2() self.assertRoundTripSerializable(drag._transpiled_circuits()) diff --git a/test/library/calibration/test_rabi.py b/test/library/calibration/test_rabi.py index cc73299803..7708e64cfd 100644 --- a/test/library/calibration/test_rabi.py +++ b/test/library/calibration/test_rabi.py @@ -50,9 +50,10 @@ def setUp(self): def test_rabi_end_to_end(self): """Test the Rabi experiment end to end.""" - test_tol = 0.015 + test_tol = 0.15 rabi = Rabi([self.qubit], self.sched, backend=self.backend) + rabi.set_run_options(shots=200) rabi.set_experiment_options(amplitudes=np.linspace(-0.1, 0.1, 21)) expdata = rabi.run() self.assertExperimentDone(expdata) diff --git a/test/library/calibration/test_rough_amplitude.py b/test/library/calibration/test_rough_amplitude.py index df19472d81..d538703987 100644 --- a/test/library/calibration/test_rough_amplitude.py +++ b/test/library/calibration/test_rough_amplitude.py @@ -84,7 +84,7 @@ def test_update(self): def test_circuit_roundtrip_serializable(self): """Test round trip JSON serialization""" - test_amps = [-0.5, 0, 0.5] + test_amps = [-0.5, 0] rabi = RoughXSXAmplitudeCal([0], self.cals, amplitudes=test_amps, backend=self.backend) self.assertRoundTripSerializable(rabi._transpiled_circuits()) diff --git a/test/library/characterization/test_cross_resonance_hamiltonian.py b/test/library/characterization/test_cross_resonance_hamiltonian.py index 34a2637330..6414b47e5e 100644 --- a/test/library/characterization/test_cross_resonance_hamiltonian.py +++ b/test/library/characterization/test_cross_resonance_hamiltonian.py @@ -167,7 +167,7 @@ def __init__(self, width): @unpack def test_integration(self, ix, iy, iz, zx, zy, zz): """Integration test for Hamiltonian tomography.""" - delta = 3e4 + delta = 6e4 dt = 0.222e-9 sigma = 64 @@ -192,11 +192,12 @@ def test_integration(self, ix, iy, iz, zx, zy, zz): expr = cr_hamiltonian.CrossResonanceHamiltonian( physical_qubits=(0, 1), sigma=sigma, - # A hack to avoild local function in pickle, i.e. in transpile. + # A hack to avoid local function in pickle, i.e. in transpile. cr_gate=functools.partial( SimulatableCRGate, hamiltonian=hamiltonian, sigma=sigma, dt=dt ), ) + expr.set_run_options(shots=200) expr.backend = backend exp_data = expr.run() diff --git a/test/library/characterization/test_qubit_spectroscopy.py b/test/library/characterization/test_qubit_spectroscopy.py index d3522c4a7f..75ca87e89c 100644 --- a/test/library/characterization/test_qubit_spectroscopy.py +++ b/test/library/characterization/test_qubit_spectroscopy.py @@ -270,7 +270,9 @@ def test_parallel_experiment(self): par_experiment = ParallelExperiment( exp_list, flatten_results=False, backend=parallel_backend ) - par_experiment.set_run_options(meas_level=MeasLevel.KERNELED, meas_return="single") + par_experiment.set_run_options( + meas_level=MeasLevel.KERNELED, meas_return="single", shots=20 + ) par_data = par_experiment.run() self.assertExperimentDone(par_data) @@ -288,7 +290,7 @@ def test_circuit_roundtrip_serializable(self): backend = FakeWashingtonV2() qubit = 1 freq01 = BackendData(backend).drive_freqs[qubit] - frequencies = np.linspace(freq01 - 10.0e6, freq01 + 10.0e6, 21) + frequencies = np.linspace(freq01 - 10.0e6, freq01 + 10.0e6, 3) exp = QubitSpectroscopy([1], frequencies, backend=backend) # Checking serialization of the experiment self.assertRoundTripSerializable(exp._transpiled_circuits()) diff --git a/test/library/characterization/test_resonator_spectroscopy.py b/test/library/characterization/test_resonator_spectroscopy.py index ef7d4ca406..ec993649ab 100644 --- a/test/library/characterization/test_resonator_spectroscopy.py +++ b/test/library/characterization/test_resonator_spectroscopy.py @@ -158,7 +158,7 @@ def test_circuit_roundtrip_serializable(self): ), ) res_freq = BackendData(backend).meas_freqs[qubit] - frequencies = np.linspace(res_freq - 20e6, res_freq + 20e6, 51) + frequencies = np.linspace(res_freq - 20e6, res_freq + 20e6, 3) exp = ResonatorSpectroscopy([qubit], backend=backend, frequencies=frequencies) self.assertRoundTripSerializable(exp._transpiled_circuits()) diff --git a/test/library/characterization/test_t2hahn.py b/test/library/characterization/test_t2hahn.py index 3656689143..4334eb2e71 100644 --- a/test/library/characterization/test_t2hahn.py +++ b/test/library/characterization/test_t2hahn.py @@ -205,7 +205,7 @@ def test_roundtrip_serializable(self): def test_circuit_roundtrip_serializable(self): """Test round trip JSON serialization""" - delays0 = list(range(1, 60, 2)) + delays0 = list(range(1, 60, 20)) # backend is needed for serialization of the delays in the metadata of the experiment. backend = FakeVigoV2() exp = T2Hahn([0], delays0, backend=backend) diff --git a/test/library/characterization/test_t2ramsey.py b/test/library/characterization/test_t2ramsey.py index e5a90e8a36..d5a51de2b5 100644 --- a/test/library/characterization/test_t2ramsey.py +++ b/test/library/characterization/test_t2ramsey.py @@ -228,7 +228,7 @@ def test_roundtrip_serializable(self): def test_circuit_roundtrip_serializable(self): """Test round trip JSON serialization""" backend = FakeVigoV2() - exp = T2Ramsey([0], [1, 2, 3, 4, 5], backend=backend) + exp = T2Ramsey([0], [1, 2], backend=backend) self.assertRoundTripSerializable(exp._transpiled_circuits()) def test_analysis_config(self): diff --git a/test/library/quantum_volume/test_qv.py b/test/library/quantum_volume/test_qv.py index b303b742c2..eca6c4ce03 100644 --- a/test/library/quantum_volume/test_qv.py +++ b/test/library/quantum_volume/test_qv.py @@ -275,6 +275,6 @@ def test_roundtrip_serializable(self): def test_circuit_roundtrip_serializable(self): """Test expdata round trip JSON serialization""" - num_of_qubits = 4 + num_of_qubits = 3 qv_exp = QuantumVolume(range(num_of_qubits), seed=SEED) self.assertRoundTripSerializable(qv_exp._transpiled_circuits()) diff --git a/test/library/randomized_benchmarking/test_interleaved_rb.py b/test/library/randomized_benchmarking/test_interleaved_rb.py index a7151495bf..500ee84c45 100644 --- a/test/library/randomized_benchmarking/test_interleaved_rb.py +++ b/test/library/randomized_benchmarking/test_interleaved_rb.py @@ -72,14 +72,14 @@ def test_experiment_config(self): def test_roundtrip_serializable(self): """Test round trip JSON serialization""" exp = rb.InterleavedRB( - interleaved_element=SXGate(), physical_qubits=(0,), lengths=[10, 20, 30], seed=123 + interleaved_element=SXGate(), physical_qubits=(0,), lengths=[1, 3], seed=123 ) self.assertRoundTripSerializable(exp) def test_circuit_roundtrip_serializable(self): """Test circuits round trip JSON serialization""" exp = rb.InterleavedRB( - interleaved_element=SXGate(), physical_qubits=(0,), lengths=[10, 20, 30], seed=123 + interleaved_element=SXGate(), physical_qubits=(0,), lengths=[1, 3], seed=123 ) self.assertRoundTripSerializable(exp._transpiled_circuits()) diff --git a/test/library/randomized_benchmarking/test_standard_rb.py b/test/library/randomized_benchmarking/test_standard_rb.py index 7990cbaa09..d64371a6fa 100644 --- a/test/library/randomized_benchmarking/test_standard_rb.py +++ b/test/library/randomized_benchmarking/test_standard_rb.py @@ -57,12 +57,12 @@ def test_experiment_config(self): def test_roundtrip_serializable(self): """Test round trip JSON serialization""" - exp = rb.StandardRB(physical_qubits=(0,), lengths=[10, 20, 30], seed=123) + exp = rb.StandardRB(physical_qubits=(0,), lengths=[1,3], seed=123) self.assertRoundTripSerializable(exp) def test_circuit_roundtrip_serializable(self): """Test circuits round trip JSON serialization""" - exp = rb.StandardRB(physical_qubits=(0,), lengths=[10, 20, 30], seed=123) + exp = rb.StandardRB(physical_qubits=(0,), lengths=[1,3], seed=123) self.assertRoundTripSerializable(exp._transpiled_circuits()) def test_analysis_config(self): diff --git a/test/library/tomography/test_process_tomography.py b/test/library/tomography/test_process_tomography.py index 27593a9fcb..17bed174a5 100644 --- a/test/library/tomography/test_process_tomography.py +++ b/test/library/tomography/test_process_tomography.py @@ -103,7 +103,7 @@ def test_circuit_roundtrip_serializable(self): circ.s(0) circ.cx(0, 1) - exp = ProcessTomography(circ) + exp = ProcessTomography(circ, preparation_indices=[0], measurement_indices=[0]) self.assertRoundTripSerializable(exp._transpiled_circuits()) def test_cvxpy_gaussian_lstsq_cx(self): From 4e4a9607dd599dc805402b44bc62f1b88a129265 Mon Sep 17 00:00:00 2001 From: Helena Zhang Date: Wed, 6 Sep 2023 15:16:10 -0400 Subject: [PATCH 09/26] lint --- test/library/randomized_benchmarking/test_standard_rb.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/library/randomized_benchmarking/test_standard_rb.py b/test/library/randomized_benchmarking/test_standard_rb.py index d64371a6fa..6370321a2e 100644 --- a/test/library/randomized_benchmarking/test_standard_rb.py +++ b/test/library/randomized_benchmarking/test_standard_rb.py @@ -57,12 +57,12 @@ def test_experiment_config(self): def test_roundtrip_serializable(self): """Test round trip JSON serialization""" - exp = rb.StandardRB(physical_qubits=(0,), lengths=[1,3], seed=123) + exp = rb.StandardRB(physical_qubits=(0,), lengths=[1, 3], seed=123) self.assertRoundTripSerializable(exp) def test_circuit_roundtrip_serializable(self): """Test circuits round trip JSON serialization""" - exp = rb.StandardRB(physical_qubits=(0,), lengths=[1,3], seed=123) + exp = rb.StandardRB(physical_qubits=(0,), lengths=[1, 3], seed=123) self.assertRoundTripSerializable(exp._transpiled_circuits()) def test_analysis_config(self): From 27f1f707921bb2fea4a1d802a7bfef55aa7ee9d7 Mon Sep 17 00:00:00 2001 From: Helena Zhang Date: Wed, 6 Sep 2023 15:26:43 -0400 Subject: [PATCH 10/26] increase shots for CRHam test --- .../characterization/test_cross_resonance_hamiltonian.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/library/characterization/test_cross_resonance_hamiltonian.py b/test/library/characterization/test_cross_resonance_hamiltonian.py index 6414b47e5e..73f7a6c079 100644 --- a/test/library/characterization/test_cross_resonance_hamiltonian.py +++ b/test/library/characterization/test_cross_resonance_hamiltonian.py @@ -197,7 +197,7 @@ def test_integration(self, ix, iy, iz, zx, zy, zz): SimulatableCRGate, hamiltonian=hamiltonian, sigma=sigma, dt=dt ), ) - expr.set_run_options(shots=200) + expr.set_run_options(shots=500) expr.backend = backend exp_data = expr.run() From 6d7c3bcc3ced0eefb92202a39367c072602276d2 Mon Sep 17 00:00:00 2001 From: Helena Zhang Date: Wed, 6 Sep 2023 15:43:05 -0400 Subject: [PATCH 11/26] shorten serialization tests --- test/library/calibration/test_rough_amplitude.py | 5 +++-- .../characterization/test_qubit_spectroscopy.py | 2 +- .../characterization/test_resonator_spectroscopy.py | 10 +++++----- test/library/characterization/test_t1.py | 2 +- test/library/characterization/test_t2hahn.py | 2 +- test/library/characterization/test_t2ramsey.py | 2 +- 6 files changed, 12 insertions(+), 11 deletions(-) diff --git a/test/library/calibration/test_rough_amplitude.py b/test/library/calibration/test_rough_amplitude.py index d538703987..3281d3bd68 100644 --- a/test/library/calibration/test_rough_amplitude.py +++ b/test/library/calibration/test_rough_amplitude.py @@ -151,9 +151,9 @@ def test_ef_circuits(self): self.assertEqual(circ.calibrations["Rabi"][((0,), (amp,))], expected_x12) def test_ef_update(self): - """Tes that we properly update the pulses on the 1<->2 transition.""" + """Test that we properly update the pulses on the 1<->2 transition.""" - tol = 0.01 + tol = 0.05 default_amp = 0.5 / self.backend.rabi_rate_12 rabi_ef = EFRoughXSXAmplitudeCal( @@ -172,6 +172,7 @@ def test_ef_update(self): self.cals.add_parameter_value(int(4 * 160 / 5), "duration", 0, "x12") self.cals.add_parameter_value(int(4 * 160 / 5), "duration", 0, "sx12") rabi_ef = EFRoughXSXAmplitudeCal([0], self.cals, amplitudes=np.linspace(-0.1, 0.1, 11)) + rabi_ef.set_run_options(shots=200) expdata = rabi_ef.run(self.backend) self.assertExperimentDone(expdata) diff --git a/test/library/characterization/test_qubit_spectroscopy.py b/test/library/characterization/test_qubit_spectroscopy.py index 75ca87e89c..12ae08a4a5 100644 --- a/test/library/characterization/test_qubit_spectroscopy.py +++ b/test/library/characterization/test_qubit_spectroscopy.py @@ -160,7 +160,7 @@ def test_experiment_config(self): def test_roundtrip_serializable(self): """Test round trip JSON serialization""" - exp = QubitSpectroscopy([1], np.linspace(int(100e6), int(150e6), int(20e6))) + exp = QubitSpectroscopy([1], np.linspace(int(100e6), int(150e6), 4)) # Checking serialization of the experiment self.assertRoundTripSerializable(exp) diff --git a/test/library/characterization/test_resonator_spectroscopy.py b/test/library/characterization/test_resonator_spectroscopy.py index ec993649ab..cbbb110292 100644 --- a/test/library/characterization/test_resonator_spectroscopy.py +++ b/test/library/characterization/test_resonator_spectroscopy.py @@ -134,14 +134,14 @@ def test_end_to_end(self, freq_shift): def test_experiment_config(self): """Test converting to and from config works""" - exp = ResonatorSpectroscopy([1], frequencies=np.linspace(100, 150, 20) * 1e6) + exp = ResonatorSpectroscopy([1], frequencies=np.linspace(100, 150, 4) * 1e6) loaded_exp = ResonatorSpectroscopy.from_config(exp.config()) self.assertNotEqual(exp, loaded_exp) self.assertEqualExtended(exp, loaded_exp) def test_roundtrip_serializable(self): """Test round trip JSON serialization""" - exp = ResonatorSpectroscopy([1], frequencies=np.linspace(int(100e6), int(150e6), int(20e6))) + exp = ResonatorSpectroscopy([1], frequencies=np.linspace(int(100e6), int(150e6), 4)) self.assertRoundTripSerializable(exp) def test_circuit_roundtrip_serializable(self): @@ -177,7 +177,7 @@ def test_kerneled_expdata_serialization(self, freq_shift): res_freq = BackendData(backend).meas_freqs[qubit] - frequencies = np.linspace(res_freq - 20e6, res_freq + 20e6, 51) + frequencies = np.linspace(res_freq - 20e6, res_freq + 20e6, 11) exp = ResonatorSpectroscopy([qubit], backend=backend, frequencies=frequencies) expdata = exp.run(backend) @@ -226,8 +226,8 @@ def test_parallel_experiment(self): res_freq1 = backend_data.meas_freqs[qubit1] res_freq2 = backend_data.meas_freqs[qubit2] - frequencies1 = np.linspace(res_freq1 - 20e6, res_freq1 + 20e6, 51) - frequencies2 = np.linspace(res_freq2 - 20e6, res_freq2 + 20e6, 53) + frequencies1 = np.linspace(res_freq1 - 20e6, res_freq1 + 20e6, 11) + frequencies2 = np.linspace(res_freq2 - 20e6, res_freq2 + 20e6, 13) res_spect1 = ResonatorSpectroscopy( [qubit1], backend=parallel_backend, frequencies=frequencies1 diff --git a/test/library/characterization/test_t1.py b/test/library/characterization/test_t1.py index 05a95969b4..7c60e96ddd 100644 --- a/test/library/characterization/test_t1.py +++ b/test/library/characterization/test_t1.py @@ -311,7 +311,7 @@ def test_experiment_config(self): def test_roundtrip_serializable(self): """Test round trip JSON serialization""" - exp = T1([0], [1, 2, 3, 4, 5]) + exp = T1([0], [1, 2]) self.assertRoundTripSerializable(exp) def test_circuit_roundtrip_serializable(self): diff --git a/test/library/characterization/test_t2hahn.py b/test/library/characterization/test_t2hahn.py index 4334eb2e71..8e3d124e48 100644 --- a/test/library/characterization/test_t2hahn.py +++ b/test/library/characterization/test_t2hahn.py @@ -179,7 +179,7 @@ def test_experiment_config(self): def test_roundtrip_serializable(self): """Test round trip JSON serialization""" - delays0 = list(range(1, 60, 2)) + delays0 = list(range(1, 60, 20)) exp = T2Hahn([0], delays0) self.assertRoundTripSerializable(exp) diff --git a/test/library/characterization/test_t2ramsey.py b/test/library/characterization/test_t2ramsey.py index d5a51de2b5..599c9a547a 100644 --- a/test/library/characterization/test_t2ramsey.py +++ b/test/library/characterization/test_t2ramsey.py @@ -222,7 +222,7 @@ def test_experiment_config(self): def test_roundtrip_serializable(self): """Test round trip JSON serialization""" - exp = T2Ramsey([0], [1, 2, 3, 4, 5]) + exp = T2Ramsey([0], [1, 2]) self.assertRoundTripSerializable(exp) def test_circuit_roundtrip_serializable(self): From 83df5a0b94b97100b75c1cb0dfb484737cbccc06 Mon Sep 17 00:00:00 2001 From: Helena Zhang Date: Wed, 6 Sep 2023 16:04:04 -0400 Subject: [PATCH 12/26] adjust test params --- .../characterization/test_cross_resonance_hamiltonian.py | 3 +-- test/library/characterization/test_readout_angle.py | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/test/library/characterization/test_cross_resonance_hamiltonian.py b/test/library/characterization/test_cross_resonance_hamiltonian.py index 73f7a6c079..1df5c80aae 100644 --- a/test/library/characterization/test_cross_resonance_hamiltonian.py +++ b/test/library/characterization/test_cross_resonance_hamiltonian.py @@ -167,7 +167,7 @@ def __init__(self, width): @unpack def test_integration(self, ix, iy, iz, zx, zy, zz): """Integration test for Hamiltonian tomography.""" - delta = 6e4 + delta = 3e4 dt = 0.222e-9 sigma = 64 @@ -197,7 +197,6 @@ def test_integration(self, ix, iy, iz, zx, zy, zz): SimulatableCRGate, hamiltonian=hamiltonian, sigma=sigma, dt=dt ), ) - expr.set_run_options(shots=500) expr.backend = backend exp_data = expr.run() diff --git a/test/library/characterization/test_readout_angle.py b/test/library/characterization/test_readout_angle.py index 1413006e13..a26ffd4e2b 100644 --- a/test/library/characterization/test_readout_angle.py +++ b/test/library/characterization/test_readout_angle.py @@ -36,7 +36,7 @@ def test_readout_angle_end2end(self): MockIQReadoutAngleHelper(iq_cluster_centers=[((-3.0, 3.0), (5.0, 5.0))]), ) exp = ReadoutAngle([0]) - expdata = exp.run(backend, shots=100000) + expdata = exp.run(backend, shots=10000) self.assertExperimentDone(expdata) res = expdata.analysis_results(0) self.assertAlmostEqual(res.value % (2 * np.pi), np.pi / 2, places=2) @@ -45,7 +45,7 @@ def test_readout_angle_end2end(self): MockIQReadoutAngleHelper(iq_cluster_centers=[((0, -3.0), (5.0, 5.0))]), ) exp = ReadoutAngle([0]) - expdata = exp.run(backend, shots=100000) + expdata = exp.run(backend, shots=10000) self.assertExperimentDone(expdata) res = expdata.analysis_results(0) self.assertAlmostEqual(res.value % (2 * np.pi), 15 * np.pi / 8, places=2) From 930739f3322fdb6ef00381374efbc66469d68b2a Mon Sep 17 00:00:00 2001 From: Helena Zhang Date: Wed, 6 Sep 2023 16:17:44 -0400 Subject: [PATCH 13/26] try grouping tests --- tox.ini | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tox.ini b/tox.ini index be44ae4f6a..199f022b81 100644 --- a/tox.ini +++ b/tox.ini @@ -3,6 +3,9 @@ minversion = 3.3.0 envlist = py311,py310,py39,py38,lint isolated_build = true +[stestr] +group_regex=([^\.]+\.)+ + [testenv] usedevelop = True install_command = pip install -c{toxinidir}/constraints.txt -U {opts} {packages} @@ -105,3 +108,4 @@ skip_install = true deps = allowlist_externals = rm commands = rm -rf {toxinidir}/docs/stubs/ {toxinidir}/docs/_build + From 746a96ce62970d4c80628af1af74746c90b8f75f Mon Sep 17 00:00:00 2001 From: Helena Zhang Date: Wed, 6 Sep 2023 16:31:48 -0400 Subject: [PATCH 14/26] refactor drag end to end test --- test/library/calibration/test_drag.py | 48 ++++++------------- .../calibration/test_rough_amplitude.py | 1 + 2 files changed, 16 insertions(+), 33 deletions(-) diff --git a/test/library/calibration/test_drag.py b/test/library/calibration/test_drag.py index 12ca3ebd17..f01903c7ca 100644 --- a/test/library/calibration/test_drag.py +++ b/test/library/calibration/test_drag.py @@ -48,53 +48,35 @@ def setUp(self): self.x_plus = xp self.test_tol = 0.1 - # pylint: disable=no-member - def test_end_to_end(self): + @data( + (None, None, None), + (0.0044, None, None), + (0.04, np.linspace(-4, 4, 31), {"beta": 1.8, "freq": 0.08}), + ) + @unpack + def test_end_to_end(self, freq, betas, p0_opt): """Test the drag experiment end to end.""" drag_experiment_helper = DragHelper(gate_name="Drag(xp)") + if freq: + drag_experiment_helper.frequency = freq backend = MockIQBackend(drag_experiment_helper) drag = RoughDrag([1], self.x_plus) drag.set_run_options(shots=200) + if betas is not None: + drag.set_experiment_options(betas=betas) + if p0_opt: + drag.analysis.set_options(p0_opt={"beta": 1.8, "freq": 0.08}) + expdata = drag.run(backend) self.assertExperimentDone(expdata) result = expdata.analysis_results(1) - # pylint: disable=no-member - self.assertTrue(abs(result.value.n - backend.experiment_helper.ideal_beta) < self.test_tol) - self.assertEqual(result.quality, "good") - - # Small leakage will make the curves very flat, in this case one should - # rather increase beta. - drag_experiment_helper.frequency = 0.0044 - - drag = RoughDrag([0], self.x_plus) - drag.set_run_options(shots=200) - exp_data = drag.run(backend) - self.assertExperimentDone(exp_data) - result = exp_data.analysis_results(1) - - # pylint: disable=no-member - self.assertTrue(abs(result.value.n - backend.experiment_helper.ideal_beta) < self.test_tol) - self.assertEqual(result.quality, "good") - - # Large leakage will make the curves oscillate quickly. - drag_experiment_helper.frequency = 0.04 - drag = RoughDrag([1], self.x_plus, betas=np.linspace(-4, 4, 31)) - # pylint: disable=no-member - drag.set_run_options(shots=200) - drag.analysis.set_options(p0={"beta": 1.8, "freq": 0.08}) - exp_data = drag.run(backend) - self.assertExperimentDone(exp_data) - result = exp_data.analysis_results(1) - - meas_level = exp_data.metadata["meas_level"] - - self.assertEqual(meas_level, MeasLevel.CLASSIFIED) self.assertTrue(abs(result.value.n - backend.experiment_helper.ideal_beta) < self.test_tol) self.assertEqual(result.quality, "good") + self.assertEqual(expdata.metadata["meas_level"], MeasLevel.CLASSIFIED) @data( (0.0040, 1.0, 0.00, [1, 3, 5], None, 0.2), # partial oscillation. diff --git a/test/library/calibration/test_rough_amplitude.py b/test/library/calibration/test_rough_amplitude.py index 3281d3bd68..c2cf284f09 100644 --- a/test/library/calibration/test_rough_amplitude.py +++ b/test/library/calibration/test_rough_amplitude.py @@ -159,6 +159,7 @@ def test_ef_update(self): rabi_ef = EFRoughXSXAmplitudeCal( [0], self.cals, amplitudes=np.linspace(-0.1, 0.1, 11), backend=self.backend ) + rabi_ef.set_run_options(shots=200) expdata = rabi_ef.run() self.assertExperimentDone(expdata) From cc2a362c6c460caffebeb594a4c45af8d16b344b Mon Sep 17 00:00:00 2001 From: Helena Zhang Date: Wed, 6 Sep 2023 16:49:28 -0400 Subject: [PATCH 15/26] try setting macos workflow same to other OSes --- .github/workflows/main.yml | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e0bcb26d70..b5bfd8c79c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -55,22 +55,6 @@ jobs: run: python -m pip install -U tox setuptools virtualenv wheel - name: Install and Run Tests run: tox -e py - if: runner.os != 'macOS' - - name: Install and Run Tests - 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 - lint: name: lint From 560cd72d0488cec4c67fee41f3f89306e7ebbcdf Mon Sep 17 00:00:00 2001 From: Helena Zhang Date: Wed, 6 Sep 2023 17:04:39 -0400 Subject: [PATCH 16/26] increase timeout --- test/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/base.py b/test/base.py index 6b6e22e794..444ab47e41 100644 --- a/test/base.py +++ b/test/base.py @@ -33,7 +33,7 @@ from .extended_equality import is_equivalent # Fail tests that take longer than this -TEST_TIMEOUT = os.environ.get("TEST_TIMEOUT", 45) +TEST_TIMEOUT = os.environ.get("TEST_TIMEOUT", 60) class QiskitExperimentsTestCase(QiskitTestCase): From 9a08d4457ea67c171d6b722648f9f33ff7a74f1b Mon Sep 17 00:00:00 2001 From: Helena Zhang Date: Thu, 7 Sep 2023 10:11:59 -0400 Subject: [PATCH 17/26] fixed bad test parameter Co-authored-by: Will Shanks --- test/library/calibration/test_drag.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/library/calibration/test_drag.py b/test/library/calibration/test_drag.py index f01903c7ca..89354a8602 100644 --- a/test/library/calibration/test_drag.py +++ b/test/library/calibration/test_drag.py @@ -68,7 +68,7 @@ def test_end_to_end(self, freq, betas, p0_opt): if betas is not None: drag.set_experiment_options(betas=betas) if p0_opt: - drag.analysis.set_options(p0_opt={"beta": 1.8, "freq": 0.08}) + drag.analysis.set_options(p0=p0_opt) expdata = drag.run(backend) self.assertExperimentDone(expdata) From 16b9d92a712389d8a22eb2d1af1d3cf2abeedb24 Mon Sep 17 00:00:00 2001 From: Helena Zhang Date: Thu, 7 Sep 2023 10:44:27 -0400 Subject: [PATCH 18/26] move stestr config --- .stestr.conf | 1 + tox.ini | 3 --- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.stestr.conf b/.stestr.conf index 55302a1601..460ee43afa 100644 --- a/.stestr.conf +++ b/.stestr.conf @@ -1,2 +1,3 @@ [DEFAULT] test_path=./test +parallel_class=True \ No newline at end of file diff --git a/tox.ini b/tox.ini index 199f022b81..8b47fae879 100644 --- a/tox.ini +++ b/tox.ini @@ -3,9 +3,6 @@ minversion = 3.3.0 envlist = py311,py310,py39,py38,lint isolated_build = true -[stestr] -group_regex=([^\.]+\.)+ - [testenv] usedevelop = True install_command = pip install -c{toxinidir}/constraints.txt -U {opts} {packages} From 25ca37cf23bf53be84c48e9a688c9894cab02629 Mon Sep 17 00:00:00 2001 From: Helena Zhang Date: Thu, 7 Sep 2023 10:58:07 -0400 Subject: [PATCH 19/26] add seed to interleaved RB test --- test/library/randomized_benchmarking/test_interleaved_rb.py | 1 + 1 file changed, 1 insertion(+) diff --git a/test/library/randomized_benchmarking/test_interleaved_rb.py b/test/library/randomized_benchmarking/test_interleaved_rb.py index 500ee84c45..6ed28d0f53 100644 --- a/test/library/randomized_benchmarking/test_interleaved_rb.py +++ b/test/library/randomized_benchmarking/test_interleaved_rb.py @@ -276,6 +276,7 @@ def test_interleaving_cnot_gate_with_non_supported_direction(self): lengths=[3], num_samples=4, backend=my_backend, + seed=1234, ) transpiled = exp._transpiled_circuits() for qc in transpiled: From 511898563ba8e12a2d175bb1aa8a2688f24384a0 Mon Sep 17 00:00:00 2001 From: Helena Zhang Date: Thu, 7 Sep 2023 11:35:02 -0400 Subject: [PATCH 20/26] add contributor note and update timeout behavior --- CONTRIBUTING.md | 2 ++ releasenotes/notes/rabi-and-qv-bugfix-34636baee6651af1.yaml | 4 +++- test/base.py | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 20412c851b..7f4b45191f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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 diff --git a/releasenotes/notes/rabi-and-qv-bugfix-34636baee6651af1.yaml b/releasenotes/notes/rabi-and-qv-bugfix-34636baee6651af1.yaml index 8c06aff21d..4f9b359e27 100644 --- a/releasenotes/notes/rabi-and-qv-bugfix-34636baee6651af1.yaml +++ b/releasenotes/notes/rabi-and-qv-bugfix-34636baee6651af1.yaml @@ -5,4 +5,6 @@ fixes: `qiskit-ibm-provider` using custom amplitudes provided as a numpy array. - | Resolved an issue that caused QV experiments to fail when executed via `qiskit-ibm-provider` using - Qiskit Terra for calculating ideal probabilities, instead of Aer. \ No newline at end of file + Qiskit Terra for calculating ideal probabilities, instead of Aer. + _ | + Resolved a serialization issue that affected DRAG experiments with integral beta values specified. \ No newline at end of file diff --git a/test/base.py b/test/base.py index 444ab47e41..d1ad6e8ed6 100644 --- a/test/base.py +++ b/test/base.py @@ -41,7 +41,7 @@ class QiskitExperimentsTestCase(QiskitTestCase): def setUp(self): super().setUp() - self.useFixture(fixtures.Timeout(TEST_TIMEOUT, gentle=False)) + self.useFixture(fixtures.Timeout(TEST_TIMEOUT, gentle=True)) @classmethod def setUpClass(cls): From 59aecd9c0aac6cd7266d63800ae6eba14158337f Mon Sep 17 00:00:00 2001 From: Helena Zhang Date: Thu, 7 Sep 2023 15:48:15 -0400 Subject: [PATCH 21/26] update stestr cache --- .github/workflows/main.yml | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b5bfd8c79c..ed6a99d28b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -42,15 +42,11 @@ jobs: - name: Stestr cache uses: actions/cache@v3 with: - path: | - .stestr/0 - .stestr/f* - .stestr/m* - .stestr/n* - .stestr/t* - key: ${{ runner.os }}-${{ matrix.python-version }}-stestr-tests-${{ hashFiles('setup.py','requirements.txt','requirements-extras.txt','requirements-dev.txt','constraints.txt') }} + path: .stestr/times.* + key: stestr-${{ runner.os }}-${{ matrix.python-version }}-${{ env.GITHUB_RUN_NUMBER }} restore-keys: | - ${{ runner.os }}-${{ matrix.python-version }}-stestr-tests- + stestr-${{ runner.os }}-${{ matrix.python-version }}- + stestr- - name: Install Deps run: python -m pip install -U tox setuptools virtualenv wheel - name: Install and Run Tests From 164413a78a4865b90a9f06aa8e5a969e33a55fee Mon Sep 17 00:00:00 2001 From: Helena Zhang Date: Thu, 7 Sep 2023 21:27:01 -0400 Subject: [PATCH 22/26] fix stestr cache settings --- .github/workflows/main.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ed6a99d28b..4a26e67a16 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -42,8 +42,10 @@ jobs: - name: Stestr cache uses: actions/cache@v3 with: - path: .stestr/times.* - key: stestr-${{ runner.os }}-${{ matrix.python-version }}-${{ env.GITHUB_RUN_NUMBER }} + path: | + .stestr/times.* + .stestr/format + key: stestr-${{ runner.os }}-${{ matrix.python-version }}-${{ github.run_number }} restore-keys: | stestr-${{ runner.os }}-${{ matrix.python-version }}- stestr- From e6d1f4d948f9bea99eb138edc8423aebd14d6cc9 Mon Sep 17 00:00:00 2001 From: Helena Zhang Date: Fri, 8 Sep 2023 01:00:08 -0400 Subject: [PATCH 23/26] fix typo and add file to cache not having next-stream seems to cause errors --- .github/workflows/main.yml | 1 + releasenotes/notes/rabi-and-qv-bugfix-34636baee6651af1.yaml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4a26e67a16..b8ab5cf085 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -45,6 +45,7 @@ jobs: path: | .stestr/times.* .stestr/format + .stestr/next-stream key: stestr-${{ runner.os }}-${{ matrix.python-version }}-${{ github.run_number }} restore-keys: | stestr-${{ runner.os }}-${{ matrix.python-version }}- diff --git a/releasenotes/notes/rabi-and-qv-bugfix-34636baee6651af1.yaml b/releasenotes/notes/rabi-and-qv-bugfix-34636baee6651af1.yaml index 4f9b359e27..b6119d299c 100644 --- a/releasenotes/notes/rabi-and-qv-bugfix-34636baee6651af1.yaml +++ b/releasenotes/notes/rabi-and-qv-bugfix-34636baee6651af1.yaml @@ -6,5 +6,5 @@ fixes: - | Resolved an issue that caused QV experiments to fail when executed via `qiskit-ibm-provider` using Qiskit Terra for calculating ideal probabilities, instead of Aer. - _ | + - | Resolved a serialization issue that affected DRAG experiments with integral beta values specified. \ No newline at end of file From 0ef07458b447ea97d1d41db1c54b3af7a0faa0e8 Mon Sep 17 00:00:00 2001 From: Helena Zhang Date: Fri, 8 Sep 2023 12:30:35 -0400 Subject: [PATCH 24/26] add tox env for cleaning stestr cache instead of manually caching a subset of files --- .github/workflows/main.yml | 7 +++---- tox.ini | 2 ++ 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b8ab5cf085..4aab154f80 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -42,10 +42,7 @@ jobs: - name: Stestr cache uses: actions/cache@v3 with: - path: | - .stestr/times.* - .stestr/format - .stestr/next-stream + path: .stestr key: stestr-${{ runner.os }}-${{ matrix.python-version }}-${{ github.run_number }} restore-keys: | stestr-${{ runner.os }}-${{ matrix.python-version }}- @@ -54,6 +51,8 @@ jobs: run: python -m pip install -U tox setuptools virtualenv wheel - name: Install and Run Tests run: tox -e py + - name: Clean up stestr cache + run: tox -e stestr-clean lint: name: lint diff --git a/tox.ini b/tox.ini index 8b47fae879..6926c2af4c 100644 --- a/tox.ini +++ b/tox.ini @@ -106,3 +106,5 @@ deps = allowlist_externals = rm commands = rm -rf {toxinidir}/docs/stubs/ {toxinidir}/docs/_build +[testenv:stestr-clean] +commands = stestr history remove all From 6757ea7350135c82e469816eec4310dc5ef7cb56 Mon Sep 17 00:00:00 2001 From: Helena Zhang Date: Fri, 8 Sep 2023 15:25:33 -0400 Subject: [PATCH 25/26] update cache key --- .github/workflows/main.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4aab154f80..1040cd5082 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -43,9 +43,10 @@ jobs: uses: actions/cache@v3 with: path: .stestr - key: stestr-${{ runner.os }}-${{ matrix.python-version }}-${{ github.run_number }} + key: stestr-${{ runner.os }}-${{ matrix.python-version }} restore-keys: | - stestr-${{ runner.os }}-${{ matrix.python-version }}- + stestr-${{ runner.os }}-${{ matrix.python-version }} + stestr-${{ runner.os }}- stestr- - name: Install Deps run: python -m pip install -U tox setuptools virtualenv wheel From ddb9248dbabb9f33f1334f3a16f9ef599bcdc313 Mon Sep 17 00:00:00 2001 From: Helena Zhang Date: Fri, 8 Sep 2023 17:04:09 -0400 Subject: [PATCH 26/26] move stestr-clean to github workflow because tox 4 doesn't allow sharing environments, the separate env to run stestr-clean was causing over a minute to be added to the CI. --- .github/workflows/main.yml | 5 ++--- tox.ini | 5 +---- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1040cd5082..4f45bb6170 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -45,15 +45,14 @@ jobs: path: .stestr key: stestr-${{ runner.os }}-${{ matrix.python-version }} restore-keys: | - stestr-${{ runner.os }}-${{ matrix.python-version }} stestr-${{ runner.os }}- stestr- - name: Install Deps - run: python -m pip install -U tox setuptools virtualenv wheel + run: python -m pip install -U tox setuptools virtualenv wheel stestr - name: Install and Run Tests run: tox -e py - name: Clean up stestr cache - run: tox -e stestr-clean + run: stestr history remove all lint: name: lint diff --git a/tox.ini b/tox.ini index 6926c2af4c..70be5b521e 100644 --- a/tox.ini +++ b/tox.ini @@ -104,7 +104,4 @@ commands = skip_install = true deps = allowlist_externals = rm -commands = rm -rf {toxinidir}/docs/stubs/ {toxinidir}/docs/_build - -[testenv:stestr-clean] -commands = stestr history remove all +commands = rm -rf {toxinidir}/docs/stubs/ {toxinidir}/docs/_build \ No newline at end of file