Skip to content

Commit 16c2d31

Browse files
Remove verify_parallel_map script (#8962)
In #7658 we disabled multiprocessing as part of unittest runs in CI because the multiple layers of parallelism (subprocess from stestr, multiprocessing from qiskit, and multithreading from rust in qiskit) were triggering a latent bug in python's multiprocessing implementation that was blocking CI. To counter the lost coverage from disabling multiprocessing in that PR we added a script verify_parallel_map which force enabled multiprocessing and validated transpile() run in parallel executed correctly. However, in #8952 we introduced a model for selectively enabling multiprocessing just for a single test method. This should allow us to avoid the stochastic failure triggering the deadlock in python's multiprocessing by overloading parallelism but still test in isolation that parallel_map() works. This commit builds on the test class introduced in #8952 and adds identical test cases to what was previously in verify_parallel_map.py to move that coverage into the unit test suite. Then the verify_parallel_map script is removed and all callers are updated to just run unit tests instead of also executing that script. Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
1 parent d56ef8c commit 16c2d31

7 files changed

Lines changed: 22 additions & 79 deletions

File tree

.azure/test-linux.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ jobs:
8383
pip install -U "cplex" "qiskit-aer" "z3-solver" -c constraints.txt
8484
mkdir -p /tmp/terra-tests
8585
cp -r test /tmp/terra-tests/.
86-
cp tools/verify_parallel_map.py /tmp/terra-tests/.
8786
cp .stestr.conf /tmp/terra-tests/.
8887
cp -r .stestr /tmp/terra-tests/. || :
8988
sudo apt-get update
@@ -98,7 +97,6 @@ jobs:
9897
export PYTHONHASHSEED=$(python -S -c "import random; print(random.randint(1, 4294967295))")
9998
echo "PYTHONHASHSEED=$PYTHONHASHSEED"
10099
stestr run
101-
python ./verify_parallel_map.py
102100
popd
103101
env:
104102
QISKIT_PARALLEL: FALSE

.azure/test-macos.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ jobs:
4747
export PYTHONHASHSEED=$(python -S -c "import random; print(random.randint(1, 4294967295))")
4848
echo "PYTHONHASHSEED=$PYTHONHASHSEED"
4949
stestr run
50-
python ./tools/verify_parallel_map.py
5150
env:
5251
QISKIT_PARALLEL: FALSE
5352
RUST_BACKTRACE: 1

.azure/test-windows.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ jobs:
4848
export PYTHONHASHSEED=$(python -S -c "import random; print(random.randint(1, 1024))")
4949
echo "PYTHONHASHSEED=$PYTHONHASHSEED"
5050
stestr run
51-
python ./tools/verify_parallel_map.py
5251
env:
5352
LANG: 'C.UTF-8'
5453
PYTHONIOENCODING: 'utf-8:backslashreplace'

.github/workflows/coverage.yml

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,29 +42,17 @@ jobs:
4242
pip install -r requirements-dev.txt qiskit-aer
4343
stestr run
4444
./grcov . --binary-path ./target/debug/ -s . --llvm --parallel -t lcov --branch --ignore-not-existing --ignore "/*" -o ./rust_unittest.info
45-
mkdir rust_lcov
46-
mv ./rust_unittest.info rust_lcov/.
4745
rm *profraw
4846
env:
4947
QISKIT_TEST_CAPTURE_STREAMS: 1
5048
QISKIT_PARALLEL: FALSE
5149
PYTHON: "coverage3 run --source qiskit --parallel-mode"
52-
- name: Generate parallel_map test
53-
run: |
54-
set -e
55-
coverage3 run --source qiskit --parallel-mode ./tools/verify_parallel_map.py
56-
./grcov . --binary-path ./target/debug/ -s . --llvm --parallel -t lcov --branch --ignore-not-existing --ignore "/*" -o ./rust_parallel_map.info
57-
mv rust_lcov/rust_unittest.info .
58-
env:
59-
QISKIT_TEST_CAPTURE_STREAMS: 1
60-
QISKIT_PARALLEL: FALSE
61-
PYTHON: "coverage3 run --source qiskit --parallel-mode"
6250
- name: Convert to lcov and combine data
6351
run: |
6452
set -e
6553
coverage3 combine
6654
coveragepy-lcov --output_file_path python.info
67-
lcov --add-tracefile python.info -a rust_unittest.info -a rust_parallel_map.info -o combined.info
55+
lcov --add-tracefile python.info -a rust_unittest.info -o combined.info
6856
lcov --remove combined.info "target/*" -o coveralls.info
6957
- name: Coveralls
7058
uses: coverallsapp/github-action@master

test/python/compiler/test_transpiler.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1833,3 +1833,24 @@ def test_parallel_with_target(self, opt_level):
18331833
self.assertIsInstance(res, list)
18341834
for circ in res:
18351835
self.assertIsInstance(circ, QuantumCircuit)
1836+
1837+
@data(0, 1, 2, 3)
1838+
def test_parallel_dispatch(self, opt_level):
1839+
"""Test that transpile in parallel works for all optimization levels."""
1840+
backend = FakeRueschlikon()
1841+
qr = QuantumRegister(16)
1842+
cr = ClassicalRegister(16)
1843+
qc = QuantumCircuit(qr, cr)
1844+
qc.h(qr[0])
1845+
for k in range(1, 15):
1846+
qc.cx(qr[0], qr[k])
1847+
qc.measure(qr, cr)
1848+
qlist = [qc for k in range(15)]
1849+
tqc = transpile(
1850+
qlist, backend=backend, optimization_level=opt_level, seed_transpiler=424242
1851+
)
1852+
result = backend.run(tqc, seed_simulator=4242424242, shots=1000).result()
1853+
counts = result.get_counts()
1854+
for count in counts:
1855+
self.assertTrue(math.isclose(count["0000000000000000"], 500, rel_tol=0.1))
1856+
self.assertTrue(math.isclose(count["0111111111111111"], 500, rel_tol=0.1))

tools/verify_parallel_map.py

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

tox.ini

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ deps = setuptools_rust # This is work around for the bug of tox 3 (see #8606 fo
2020
-r{toxinidir}/requirements-dev.txt
2121
commands =
2222
stestr run {posargs}
23-
{toxinidir}/tools/verify_parallel_map.py
2423

2524
[testenv:lint]
2625
envdir = .tox/lint
@@ -64,7 +63,6 @@ deps = -r{toxinidir}/requirements.txt
6463
qiskit-aer
6564
commands =
6665
stestr run {posargs}
67-
coverage3 run --source qiskit --parallel-mode {toxinidir}/tools/verify_parallel_map.py
6866
coverage3 combine
6967
coverage3 report
7068

0 commit comments

Comments
 (0)