Skip to content

Commit

Permalink
Mark slowest tests as slow and add nightly slow test job (#8811)
Browse files Browse the repository at this point in the history
* Mark slowest tests as slow and add nightly slow test job

This commit makes two changes to hopefully improve CI throughput. The
first is to mark the majority of the shor's algorithm testing and some
other particularly slowly executing as slow. This prevents the tests from
running as part of normal CI runs which should hopefully improve the
runtime of a full unit test job. To make sure we don't forget about
these tests and regress the functionality this commit also adds a new
nightly CI job to github actions to run all the tests including the
onest decorated with @slow_test. If the nightly job fails we can track
it with an issue and fix it.

* Remove ibmq-provider from job

* Fix copy paste errors in slow job

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
mtreinish and mergify[bot] authored Nov 22, 2022
1 parent 30ee992 commit 93fbc0d
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 1 deletion.
37 changes: 37 additions & 0 deletions .github/workflows/slow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Slow nightly tests
on:
schedule:
- cron: '42 3 * * *'
workflow_dispatch:
jobs:
slow-tests:
name: Full-test-run-with-slow
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
name: Install Python
with:
python-version: '3.10'
- name: Install dependencies
run: |
pip install -U -r requirements.txt -c constraints.txt
pip install -U -r requirements-dev.txt -c constraints.txt
pip install -c constraints.txt -e .
pip install "qiskit-aer" "z3-solver" "cplex" -c constraints.txt
env:
SETUPTOOLS_ENABLE_FEATURES: "legacy-editable"
- name: Run all tests including slow
run: stestr run
env:
RUST_BACKTRACE: 1
QISKIT_TESTS: "run_slow"
- name: Create comment on failed test run
if: ${{ failure() }}
uses: peter-evans/create-or-update-comment@v1
with:
issue-number: 7864
body: |
Nightly slow test run failed at commit ${{ github.sha }}.
_Logs_: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}.
2 changes: 2 additions & 0 deletions test/python/algorithms/test_backendv1.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from qiskit.algorithms.optimizers import SPSA
from qiskit.circuit.library import TwoLocal, EfficientSU2
from qiskit.utils.mitigation import CompleteMeasFitter
from qiskit.test import slow_test


class TestBackendV1(QiskitAlgorithmsTestCase):
Expand All @@ -34,6 +35,7 @@ def setUp(self):
self._qasm = self._provider.get_backend("fake_qasm_simulator")
self.seed = 50

@slow_test
def test_shor_factoring(self):
"""shor factoring test"""
n_v = 15
Expand Down
2 changes: 2 additions & 0 deletions test/python/algorithms/test_backendv2.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from qiskit.opflow import X, Z, I
from qiskit.algorithms.optimizers import SPSA
from qiskit.circuit.library import TwoLocal
from qiskit.test import slow_test


class TestBackendV2(QiskitAlgorithmsTestCase):
Expand All @@ -34,6 +35,7 @@ def setUp(self):
self._qasm = FakeBackendSimple()
self.seed = 50

@slow_test
def test_shor_factoring(self):
"""shor factoring test"""
n_v = 15
Expand Down
2 changes: 2 additions & 0 deletions test/python/algorithms/test_linear_solvers.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from qiskit.opflow import I, Z, StateFn
from qiskit.utils import QuantumInstance
from qiskit import quantum_info
from qiskit.test import slow_test


def _factory_tridiagonal_toeplitz(
Expand Down Expand Up @@ -263,6 +264,7 @@ class TestLinearSolver(QiskitAlgorithmsTestCase):
* the constructed circuits
"""

@slow_test
@idata(
[
[
Expand Down
2 changes: 2 additions & 0 deletions test/python/algorithms/test_phase_estimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import qiskit
from qiskit import QuantumCircuit
from qiskit.opflow import H, X, Y, Z, I, StateFn, PauliTrotterEvolution, MatrixEvolution, PauliSumOp
from qiskit.test import slow_test


@ddt
Expand Down Expand Up @@ -104,6 +105,7 @@ def test_single_pauli_op(self):
with self.subTest("Second eigenvalue"):
self.assertAlmostEqual(eigv, -0.98, delta=0.01)

@slow_test
def test_H2_hamiltonian(self):
"""Test H2 hamiltonian"""
hamiltonian = (
Expand Down
4 changes: 4 additions & 0 deletions test/python/algorithms/test_shor.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def setUp(self):
self.instance = Shor(quantum_instance=QuantumInstance(backend, shots=1000))
self.assertTrue("Shor class is deprecated" in str(caught_warnings[0].message))

@slow_test
@idata(
[
[15, "aer_simulator", [3, 5]],
Expand Down Expand Up @@ -71,6 +72,7 @@ def _test_shor_factoring(self, backend, factors, n_v):
self.assertListEqual(result.factors[0], factors)
self.assertTrue(result.total_counts >= result.successful_counts)

@slow_test
@data(5, 7)
def test_shor_no_factors(self, n_v):
"""shor no factors test"""
Expand Down Expand Up @@ -104,6 +106,7 @@ def test_shor_bad_input(self, n_v, a_v):
with self.assertRaises(ValueError):
_ = shor.factor(N=n_v, a=a_v)

@slow_test
@idata(
[
[15, 4, 2],
Expand Down Expand Up @@ -140,6 +143,7 @@ def _test_quantum_result(self, a_v, n_v, order):
for measurement in measurements:
self.assertTrue(measurement in values)

@slow_test
@idata(
[
[15, 4, [1, 4]],
Expand Down
2 changes: 2 additions & 0 deletions test/python/algorithms/test_vqd.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
)

from qiskit.utils import QuantumInstance, algorithm_globals, has_aer
from qiskit.test import slow_test


if has_aer():
Expand Down Expand Up @@ -85,6 +86,7 @@ def setUp(self):
seed_transpiler=self.seed,
)

@slow_test
def test_basic_aer_statevector(self):
"""Test the VQD on BasicAer's statevector simulator."""
wavefunction = self.ryrz_wavefunction
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ setenv =
QISKIT_SUPRESS_PACKAGING_WARNINGS=Y
QISKIT_TEST_CAPTURE_STREAMS=1
QISKIT_PARALLEL=FALSE
passenv = RAYON_NUM_THREADS OMP_NUM_THREADS QISKIT_PARALLEL RUST_BACKTRACE SETUPTOOLS_ENABLE_FEATURES
passenv = RAYON_NUM_THREADS OMP_NUM_THREADS QISKIT_PARALLEL RUST_BACKTRACE SETUPTOOLS_ENABLE_FEATURES QISKIT_TESTS
deps = setuptools_rust # This is work around for the bug of tox 3 (see #8606 for more details.)
-r{toxinidir}/requirements.txt
-r{toxinidir}/requirements-dev.txt
Expand Down

0 comments on commit 93fbc0d

Please sign in to comment.