Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Python] Tests failing when running builder tests with all others. #2347

Open
3 of 4 tasks
boschmitt opened this issue Nov 1, 2024 · 2 comments
Open
3 of 4 tasks

Comments

@boschmitt
Copy link
Collaborator

Required prerequisites

  • Consult the security policy. If reporting a security vulnerability, do not report the bug using this form. Use the process described in the policy to report the issue.
  • Make sure you've read the documentation. Your issue may be addressed there.
  • Search the issue tracker to verify that this hasn't already been reported. +1 or comment there if it has.
  • If possible, make a PR with a failing test to give us a starting point to work on!

Describe the bug

The builder test seems to be breaking something when run together with all other tests. The issue does not happen when builder tests are run in isolation.

============================================ test session starts =============================================
platform linux -- Python 3.12.2, pytest-8.3.3, pluggy-1.5.0
rootdir: ~/dev/cuda-quantum
configfile: pyproject.toml
plugins: anyio-4.6.0
collected 654 items / 9 skipped

python/tests/backends/test_Quantinuum_LocalEmulation_builder.py .......                                [  1%]
python/tests/backends/test_Quantinuum_LocalEmulation_kernel.py ............                            [  2%]
python/tests/backends/test_stim.py .....                                                               [  3%]
python/tests/custom/test_custom_operations.py ................                                         [  6%]
python/tests/custom/test_euler_decomposition.py ...                                                    [  6%]
python/tests/custom/test_kak_decomposition.py ..                                                       [  6%]
python/tests/domains/test_qnn.py ..                                                                    [  7%]
python/tests/handlers/test_photonics_kernel.py .......s..                                              [  8%]
python/tests/interop/test_interop.py .........                                                         [ 10%]
python/tests/kernel/test_adjoint_operations.py ........                                                [ 11%]
python/tests/kernel/test_control_operations.py ..........                                              [ 12%]
python/tests/kernel/test_ir_operations.py ...                                                          [ 13%]
python/tests/kernel/test_kernel_complex.py .................                                           [ 15%]
python/tests/kernel/test_kernel_exp_pauli.py ..                                                        [ 16%]
python/tests/kernel/test_kernel_features.py .......................................................... [ 25%]
..............                                                                                         [ 27%]
python/tests/kernel/test_kernel_float.py ...............                                               [ 29%]
python/tests/kernel/test_kernel_qvector_init.py ..........................                             [ 33%]
python/tests/kernel/test_kernel_qvector_state_init.py ......................                           [ 36%]
python/tests/kernel/test_kernel_qview.py ..                                                            [ 37%]
python/tests/kernel/test_kernel_return.py .................                                            [ 39%]
python/tests/kernel/test_kernel_translate.py .................                                         [ 42%]
python/tests/kernel/test_library_kernels.py .                                                          [ 42%]
python/tests/kernel/test_observe_kernel.py .........                                                   [ 43%]
python/tests/kernel/test_sample_kernel.py .....                                                        [ 44%]
python/tests/kernel/test_state_kernel.py .....                                                         [ 45%]
python/tests/kernel/test_trotter.py ..                                                                 [ 45%]
python/tests/kernel/test_vqe_kernel.py .....                                                           [ 46%]
python/tests/mlir/test_output_qir.py .                                                                 [ 46%]
python/tests/mlir/test_output_translate_openqasm.py .                                                  [ 46%]
python/tests/mlir/test_output_translate_qir.py .                                                       [ 46%]
python/tests/parallel/test_mpi_api.py s                                                                [ 47%]
python/tests/parallel/test_mpi_mqpu.py ss                                                              [ 47%]
python/tests/parallel/test_mqpu.py ........                                                            [ 48%]
python/tests/visualization/test_draw.py ..                                                             [ 48%]
python/tests/builder/test_NoiseModel.py .Fatal Python error: Aborted

Current thread 0x000071f80da53740 (most recent call first):
  File "~/dev/cuda-quantum/build/python/cudaq/runtime/sample.py", line 88 in sample
  File "~/dev/cuda-quantum/build/python/tests/builder/test_NoiseModel.py", line 31 in test_depolarization_channel
  File "~/miniconda3/envs/cudaq/lib/python3.12/site-packages/_pytest/python.py", line 159 in pytest_pyfunc_call
  File "~/miniconda3/envs/cudaq/lib/python3.12/site-packages/pluggy/_callers.py", line 103 in _multicall
  File "~/miniconda3/envs/cudaq/lib/python3.12/site-packages/pluggy/_manager.py", line 120 in _hookexec
  File "~/miniconda3/envs/cudaq/lib/python3.12/site-packages/pluggy/_hooks.py", line 513 in __call__
  File "~/miniconda3/envs/cudaq/lib/python3.12/site-packages/_pytest/python.py", line 1627 in runtest
  File "~/miniconda3/envs/cudaq/lib/python3.12/site-packages/_pytest/runner.py", line 174 in pytest_runtest_call
  File "~/miniconda3/envs/cudaq/lib/python3.12/site-packages/pluggy/_callers.py", line 103 in _multicall
  File "~/miniconda3/envs/cudaq/lib/python3.12/site-packages/pluggy/_manager.py", line 120 in _hookexec
  File "~/miniconda3/envs/cudaq/lib/python3.12/site-packages/pluggy/_hooks.py", line 513 in __call__
  File "~/miniconda3/envs/cudaq/lib/python3.12/site-packages/_pytest/runner.py", line 242 in <lambda>
  File "~/miniconda3/envs/cudaq/lib/python3.12/site-packages/_pytest/runner.py", line 341 in from_call
  File "~/miniconda3/envs/cudaq/lib/python3.12/site-packages/_pytest/runner.py", line 241 in call_and_report
  File "~/miniconda3/envs/cudaq/lib/python3.12/site-packages/_pytest/runner.py", line 132 in runtestprotocol
  File "~/miniconda3/envs/cudaq/lib/python3.12/site-packages/_pytest/runner.py", line 113 in pytest_runtest_protocol
  File "~/miniconda3/envs/cudaq/lib/python3.12/site-packages/pluggy/_callers.py", line 103 in _multicall
  File "~/miniconda3/envs/cudaq/lib/python3.12/site-packages/pluggy/_manager.py", line 120 in _hookexec
  File "~/miniconda3/envs/cudaq/lib/python3.12/site-packages/pluggy/_hooks.py", line 513 in __call__
  File "~/miniconda3/envs/cudaq/lib/python3.12/site-packages/_pytest/main.py", line 362 in pytest_runtestloop
  File "~/miniconda3/envs/cudaq/lib/python3.12/site-packages/pluggy/_callers.py", line 103 in _multicall
  File "~/miniconda3/envs/cudaq/lib/python3.12/site-packages/pluggy/_manager.py", line 120 in _hookexec
  File "~/miniconda3/envs/cudaq/lib/python3.12/site-packages/pluggy/_hooks.py", line 513 in __call__
  File "~/miniconda3/envs/cudaq/lib/python3.12/site-packages/_pytest/main.py", line 337 in _main
  File "~/miniconda3/envs/cudaq/lib/python3.12/site-packages/_pytest/main.py", line 283 in wrap_session
  File "~/miniconda3/envs/cudaq/lib/python3.12/site-packages/_pytest/main.py", line 330 in pytest_cmdline_main
  File "~/miniconda3/envs/cudaq/lib/python3.12/site-packages/pluggy/_callers.py", line 103 in _multicall
  File "~/miniconda3/envs/cudaq/lib/python3.12/site-packages/pluggy/_manager.py", line 120 in _hookexec
  File "~/miniconda3/envs/cudaq/lib/python3.12/site-packages/pluggy/_hooks.py", line 513 in __call__
  File "~/miniconda3/envs/cudaq/lib/python3.12/site-packages/_pytest/config/__init__.py", line 175 in main
  File "~/miniconda3/envs/cudaq/lib/python3.12/site-packages/_pytest/config/__init__.py", line 201 in console_main
  File "~/miniconda3/envs/cudaq/bin/pytest", line 8 in <module>

Extension modules: numpy.core._multiarray_umath, numpy.core._multiarray_tests, numpy.linalg._umath_linalg, numpy.fft._pocketfft_internal, numpy.random._common, numpy.random.bit_generator, numpy.random._bounded_integers, numpy.random._mt19937, numpy.random.mtrand, numpy.random._philox, numpy.random._pcg64, numpy.random._sfc64, numpy.random._generator (total: 13)
Aborted (core dumped)

When run in isolation:

============================================ test session starts =============================================
platform linux -- Python 3.12.2, pytest-8.3.3, pluggy-1.5.0
rootdir: ~/dev/cuda-quantum
configfile: pyproject.toml
plugins: anyio-4.6.0
collected 334 items / 1 skipped

python/tests/builder/test_NoiseModel.py ....................                                           [  5%]
python/tests/builder/test_SpinOperator.py .............                                                [  9%]
python/tests/builder/test_kernel_builder.py ................................................           [ 24%]
python/tests/builder/test_observe.py ................................                                  [ 33%]
python/tests/builder/test_optimizer.py ..............................................                  [ 47%]
python/tests/builder/test_qalloc_init.py .......................................                       [ 59%]
python/tests/builder/test_qalloc_init_state.py ...................                                     [ 64%]
python/tests/builder/test_qpp_target.py .                                                              [ 65%]
python/tests/builder/test_quake_value.py .....                                                         [ 66%]
python/tests/builder/test_sample.py ...........................sssssssss............                   [ 81%]
python/tests/builder/test_state.py .....                                                               [ 82%]
python/tests/builder/test_vqe.py ..........................................................            [100%]

====================================== 325 passed, 10 skipped in 19.16s ======================================

Steps to reproduce the bug

Run: pytest python/tests/backends/ python/tests/custom/ python/tests/domains/ python/tests/handlers/ python/tests/interop/ python/tests/kernel/ python/tests/mlir/ python/tests/mlir/ python/tests/parallel/ python/tests/utils/ python/tests/visualization/ python/tests/builder/

Expected behavior

Tests to pass.

Is this a regression? If it is, put the last known working version (or commit) here.

Not a regression

Environment

Suggestions

No response

@bmhowe23
Copy link
Collaborator

bmhowe23 commented Nov 1, 2024

I believe the problem is related to the backends tests (not the builder tests) because our CI tests explicitly runs the backends tests separately:

https://github.com/NVIDIA/cuda-quantum/blame/1ca93a339d46edd5bcd498f96491ad435916135c/.github/workflows/test_in_devenv.yml#L226

            python3 -m pytest -v python/tests/ \
              --ignore python/tests/backends
            pytest_status=$?
            if [ ! $pytest_status -eq 0 ]; then
              echo "::error file=test_in_devenv.yml::Python tests failed with status $pytest_status."
              exit 1
            fi
            for backendTest in python/tests/backends/*.py; do
              python3 -m pytest -v $backendTest
              pytest_status=$?

              # Exit code 5 indicates that no tests were collected,
              # i.e. all tests in this file were skipped.
              if [ ! $pytest_status -eq 0 ] && [ ! $pytest_status -eq 5 ]; then
                echo "::error file=test_in_devenv.yml::Python $backendTest tests failed with status $pytest_status."
                exit 1
              fi 
            done 

@boschmitt
Copy link
Collaborator Author

I believe the problem is related to the backends tests (not the builder tests) because our CI tests explicitly runs the backends tests separately:

Thanks for the pointer. However, running the others, including backends, without the builder works:

====================================================== test session starts =======================================================
platform linux -- Python 3.12.2, pytest-8.3.3, pluggy-1.5.0
rootdir: ~/dev/cuda-quantum
configfile: pyproject.toml
plugins: anyio-4.6.0
collected 320 items / 8 skipped

python/tests/backends/test_Quantinuum_LocalEmulation_builder.py .......                                                    [  2%]
python/tests/backends/test_Quantinuum_LocalEmulation_kernel.py ............                                                [  5%]
python/tests/backends/test_stim.py .....                                                                                   [  7%]
python/tests/custom/test_custom_operations.py ................                                                             [ 12%]
python/tests/custom/test_euler_decomposition.py ...                                                                        [ 13%]
python/tests/custom/test_kak_decomposition.py ..                                                                           [ 14%]
python/tests/domains/test_qnn.py ..                                                                                        [ 14%]
python/tests/handlers/test_photonics_kernel.py .......s..                                                                  [ 17%]
python/tests/interop/test_interop.py .........                                                                             [ 20%]
python/tests/kernel/test_adjoint_operations.py ........                                                                    [ 23%]
python/tests/kernel/test_control_operations.py ..........                                                                  [ 26%]
python/tests/kernel/test_ir_operations.py ...                                                                              [ 27%]
python/tests/kernel/test_kernel_complex.py .................                                                               [ 32%]
python/tests/kernel/test_kernel_exp_pauli.py ..                                                                            [ 33%]
python/tests/kernel/test_kernel_features.py ........................................................................       [ 55%]
python/tests/kernel/test_kernel_float.py ...............                                                                   [ 60%]
python/tests/kernel/test_kernel_qvector_init.py ..........................                                                 [ 68%]
python/tests/kernel/test_kernel_qvector_state_init.py ......................                                               [ 75%]
python/tests/kernel/test_kernel_qview.py ..                                                                                [ 75%]
python/tests/kernel/test_kernel_return.py .................                                                                [ 81%]
python/tests/kernel/test_kernel_translate.py .................                                                             [ 86%]
python/tests/kernel/test_library_kernels.py .                                                                              [ 86%]
python/tests/kernel/test_observe_kernel.py .........                                                                       [ 89%]
python/tests/kernel/test_sample_kernel.py .....                                                                            [ 91%]
python/tests/kernel/test_state_kernel.py .....                                                                             [ 92%]
python/tests/kernel/test_trotter.py ..                                                                                     [ 93%]
python/tests/kernel/test_vqe_kernel.py .....                                                                               [ 95%]
python/tests/mlir/test_output_qir.py .                                                                                     [ 95%]
python/tests/mlir/test_output_translate_openqasm.py .                                                                      [ 95%]
python/tests/mlir/test_output_translate_qir.py .                                                                           [ 95%]
python/tests/parallel/test_mpi_api.py s                                                                                    [ 96%]
python/tests/parallel/test_mpi_mqpu.py ss                                                                                  [ 96%]
python/tests/parallel/test_mqpu.py ........                                                                                [ 99%]
python/tests/visualization/test_draw.py ..                                                                                 [100%]

================================================ 316 passed, 12 skipped in 39.62s ================================================

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants