Nearly all cuQuantum-python tests fail (installed using conda on Fedora 35)

I Installed cuQuantum-python on Fedora 35 with Quadro P520 using conda:

   1. Install miniconda
       sudo wget https://repo.anaconda.com/miniconda/Miniconda3-py37_4.10.3-Linux-x86_64.sh
       sudo bash Miniconda3-py37_4.10.3-Linux-x86_64.sh

    2. Install cuQuantum Python
       conda install -c conda-forge cuquantum-python

   3. Test
       conda install pytest
       conda install pytorch (failed due to conflicts)
       cd /my path to NVIDIA_CUQUANTUM_Samples/cuQuantum/python
       pytest tests

Nearly all tests failed (see detailed notes below).

What can I do to diagnose/fix this problem?

The packages and versions in my conda environment are shown below.

Please note: this forum question relates to test failures from cuQuantum (with python) that was installed within a conda environment. I also installed cuQuantum (without python) outside conda (on the same machine) and all the cuStateVec tests failed. This issue is raised here. I don’t know if there is a common cause (even though they are completely separate environments).

At the test top level, the test aborts after 3 tests fail due to missing pytorch:

NVIDIA_CUQUANTUM_Samples/cuQuantum/python> pytest tests
================================================= test session starts ==================================================
platform linux -- Python 3.7.11, pytest-6.2.5, py-1.10.0, pluggy-1.0.0
rootdir: /home/sjeffrey/NVIDIA_CUQUANTUM_Samples/cuQuantum/python
collected 2755 items / 3 errors / 2752 selected                                                                        

======================================================== ERRORS ========================================================
______________________ ERROR collecting tests/cuquantum_tests/cutensornet_tests/test_contract.py _______________________
ImportError while importing test module '/home/sjeffrey/NVIDIA_CUQUANTUM_Samples/cuQuantum/python/tests/cuquantum_tests/cutensornet_tests/test_contract.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
../../../conda_envs/cuQuantum/lib/python3.7/importlib/__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
tests/cuquantum_tests/cutensornet_tests/test_contract.py:7: in <module>
    from .testutils import *
tests/cuquantum_tests/cutensornet_tests/testutils.py:2: in <module>
    import torch
E   ModuleNotFoundError: No module named 'torch'
____________________ ERROR collecting tests/cuquantum_tests/cutensornet_tests/test_contract_path.py ____________________
ImportError while importing test module '/home/sjeffrey/NVIDIA_CUQUANTUM_Samples/cuQuantum/python/tests/cuquantum_tests/cutensornet_tests/test_contract_path.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
../../../conda_envs/cuQuantum/lib/python3.7/importlib/__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
tests/cuquantum_tests/cutensornet_tests/test_contract_path.py:6: in <module>
    from .testutils import *
tests/cuquantum_tests/cutensornet_tests/testutils.py:2: in <module>
    import torch
E   ModuleNotFoundError: No module named 'torch'
_______________________ ERROR collecting tests/cuquantum_tests/cutensornet_tests/test_network.py _______________________
ImportError while importing test module '/home/sjeffrey/NVIDIA_CUQUANTUM_Samples/cuQuantum/python/tests/cuquantum_tests/cutensornet_tests/test_network.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
../../../conda_envs/cuQuantum/lib/python3.7/importlib/__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
tests/cuquantum_tests/cutensornet_tests/test_network.py:5: in <module>
    from .testutils import *
tests/cuquantum_tests/cutensornet_tests/testutils.py:2: in <module>
    import torch
E   ModuleNotFoundError: No module named 'torch'
=============================================== short test summary info ================================================
ERROR tests/cuquantum_tests/cutensornet_tests/test_contract.py
ERROR tests/cuquantum_tests/cutensornet_tests/test_contract_path.py
ERROR tests/cuquantum_tests/cutensornet_tests/test_network.py
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 3 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
================================================== 3 errors in 0.72s ===================================================

All tests at the tests/cuquantum_tests/cutensornet_tests level fail for the same reason. I cannot install pytorch (in the conda environment) due to conflicts.

At the tests/cuquantum_tests/custatevec_tests level, all tests fail with the error shown below (only the first failure is shown for brevity):

NVIDIA_CUQUANTUM_Samples/cuQuantum/python/tests/cuquantum_tests> pytest custatevec_tests/
============================================================ test session starts ============================================================
platform linux -- Python 3.7.11, pytest-6.2.5, py-1.10.0, pluggy-1.0.0
rootdir: /home/sjeffrey/NVIDIA_CUQUANTUM_Samples/cuQuantum/python
collected 117 items                                                                                                                         

custatevec_tests/test_custatevec.py .....FFFFFFFFFFFF....FFFFFFFFFF..FF..FF..FF..FFFFFFFFFF..FF..FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF [ 82%]
FFFFFFFFFFFF..FF..FF                                                                                                                  [100%]

================================================================= FAILURES ==================================================================
__________________________ TestAbs2Sum.test_abs2sum_on_z_basis[input_form0-_param_0_{dtype=complex64, n_qubits=3}] __________________________

self = <<cuquantum_tests.custatevec_tests.test_custatevec.TestAbs2Sum object at 0x7f432757bbd0>  parameter: {'dtype': <class 'numpy.complex64'>, 'n_qubits': 3, 'basis_bits': array([0, 1, 2], dtype=int32)}>
handle = 94412351753072, input_form = {'basis_bits': (<class 'numpy.int32'>, 'int')}

    @pytest.mark.parametrize(
        'input_form', (
            {'basis_bits': (numpy.int32, 'int'),},
            {'basis_bits': (numpy.int32, 'seq'),},
        )
    )
    def test_abs2sum_on_z_basis(self, handle, input_form):
        sv = self.get_sv()
        basis_bits = list(range(self.n_qubits))
        basis_bits, basis_bits_len = self._return_data(
            basis_bits, 'basis_bits', *input_form['basis_bits'])
        data_type = dtype_to_data_type[sv.dtype]
    
        # case 1: both are computed
        sum0, sum1 = custatevec.abs2sum_on_z_basis(
            handle, sv.data.ptr, data_type, self.n_qubits,
            True, True, basis_bits, basis_bits_len)
>       assert numpy.allclose(sum0+sum1, 1)
E       assert False
E        +  where False = <function allclose at 0x7f4381fd3290>((0.0 + 0.0), 1)
E        +    where <function allclose at 0x7f4381fd3290> = numpy.allclose

custatevec_tests/test_custatevec.py:131: AssertionError
_________________________ TestAbs2Sum.test_abs2sum_on_z_basis[input_form0-_param_1_{dtype=complex128, n_qubits=3}] __________________________

At the samples_tests level, about half the tests fail with a `results mismatch" error (only the first failure is shown for brevity):

NVIDIA_CUQUANTUM_Samples/cuQuantum/python/tests> pytest samples_tests/
============================================================ test session starts ============================================================
platform linux -- Python 3.7.11, pytest-6.2.5, py-1.10.0, pluggy-1.0.0
rootdir: /home/sjeffrey/NVIDIA_CUQUANTUM_Samples/cuQuantum/python
collected 24 items                                                                                                                          

samples_tests/test_samples.py FFFFFFFFFFF..s.........s                                                                                [100%]

================================================================= FAILURES ==================================================================
____ TestSamples.test_sample[/home/sjeffrey/NVIDIA_CUQUANTUM_Samples/cuQuantum/python/tests/samples_tests/../../samples/accessor_get.py] ____

self = <samples_tests.test_samples.TestSamples object at 0x7f5a5ea16e50>
sample = '/home/sjeffrey/NVIDIA_CUQUANTUM_Samples/cuQuantum/python/tests/samples_tests/../../samples/accessor_get.py'

    def test_sample(self, sample):
>       run_sample(sample)

samples_tests/test_samples.py:41: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

path = '/home/sjeffrey/NVIDIA_CUQUANTUM_Samples/cuQuantum/python/tests/samples_tests/../../samples/accessor_get.py', args = ()
fullpath = '/home/sjeffrey/NVIDIA_CUQUANTUM_Samples/cuQuantum/python/tests/samples_tests/../../samples/accessor_get.py'
result = CompletedProcess(args=('/home/sjeffrey/conda_envs/cuQuantum/bin/python', '/home/sjeffrey/NVIDIA_CUQUANTUM_Samples/cuQu...ples/accessor_get.py", line 55, in <module>\n    raise ValueError("results mismatch")\nValueError: results mismatch\n')
msg = 'Got error:\nTraceback (most recent call last):\n  File "/home/sjeffrey/NVIDIA_CUQUANTUM_Samples/cuQuantum/python/test...mples/accessor_get.py", line 55, in <module>\n    raise ValueError("results mismatch")\nValueError: results mismatch\n'

    def run_sample(path, *args):
        fullpath = os.path.join(samples_path, path)
        result = subprocess.run(
            (sys.executable, fullpath) + args, capture_output=True, env=os.environ)
        if result.returncode:
            msg = f'Got error:\n'
            msg += f'{result.stderr.decode()}'
            if "ModuleNotFoundError: No module named 'torch'" in msg:
                pytest.skip('PyTorch uninstalled, skipping related tests')
            else:
>               raise cuQuantumSampleTestError(msg)
E               samples_tests.test_samples.cuQuantumSampleTestError: Got error:
E               Traceback (most recent call last):
E                 File "/home/sjeffrey/NVIDIA_CUQUANTUM_Samples/cuQuantum/python/tests/samples_tests/../../samples/accessor_get.py", line 55, in <module>
E                   raise ValueError("results mismatch")
E               ValueError: results mismatch

Conda environment:

> conda list
# packages in environment at /home/sjeffrey/conda_envs/cuQuantum:
#
# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                 conda_forge    conda-forge
_openmp_mutex             4.5                      1_llvm    conda-forge
attrs                     21.2.0             pyhd3eb1b0_0  
ca-certificates           2021.10.26           h06a4308_2  
certifi                   2021.10.8        py37h06a4308_0  
cudatoolkit               11.5.0               h36ae40a_9    conda-forge
cupy                      10.0.0           py37hd2d9f0c_0    conda-forge
cuquantum                 0.1.0.30             h5c60f85_1    conda-forge
cuquantum-python          0.1.0.0          py37hac9ef86_2    conda-forge
cutensor                  1.4.0.6              h7537e88_1    conda-forge
fastrlock                 0.8              py37hcd2ae1e_1    conda-forge
importlib-metadata        4.8.2            py37h06a4308_0  
importlib_metadata        4.8.2                hd3eb1b0_0  
iniconfig                 1.1.1              pyhd3eb1b0_0  
ld_impl_linux-64          2.35.1               h7274673_9  
libblas                   3.9.0           12_linux64_openblas    conda-forge
libcblas                  3.9.0           12_linux64_openblas    conda-forge
libffi                    3.3                  he6710b0_2  
libgcc-ng                 11.2.0              h1d223b6_11    conda-forge
libgfortran-ng            11.2.0              h69a702a_11    conda-forge
libgfortran5              11.2.0              h5c6108e_11    conda-forge
liblapack                 3.9.0           12_linux64_openblas    conda-forge
libopenblas               0.3.18          pthreads_h8fe5266_0    conda-forge
libstdcxx-ng              11.2.0              he4da1e4_11    conda-forge
llvm-openmp               12.0.1               h4bd325d_1    conda-forge
ncurses                   6.3                  h7f8727e_2  
numpy                     1.21.5           py37hf2998dd_0    conda-forge
openssl                   1.1.1l               h7f8727e_0  
packaging                 21.3               pyhd3eb1b0_0  
pip                       21.2.2           py37h06a4308_0  
pluggy                    1.0.0            py37h06a4308_0  
py                        1.10.0             pyhd3eb1b0_0  
pyparsing                 3.0.4              pyhd3eb1b0_0  
pytest                    6.2.5            py37h06a4308_2  
python                    3.7.11               h12debd9_0  
python_abi                3.7                     2_cp37m    conda-forge
readline                  8.1                  h27cfd23_0  
setuptools                58.0.4           py37h06a4308_0  
sqlite                    3.37.0               hc218d9a_0  
tk                        8.6.11               h1ccaba5_0  
toml                      0.10.2             pyhd3eb1b0_0  
typing_extensions         3.10.0.2           pyh06a4308_0  
wheel                     0.37.0             pyhd3eb1b0_1  
xz                        5.2.5                h7b6447c_0  
zipp                      3.6.0              pyhd3eb1b0_0  
zlib                      1.2.11               h7f8727e_4

Runtime dependencies of the cuQuantum Python package include:

  • An NVIDIA GPU with compute capability 7.0+

Your device, aside from having a very low amount of memory, is also a 6.1.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.