qutip / qutip

QuTiP: Quantum Toolbox in Python
https://qutip.org
BSD 3-Clause "New" or "Revised" License
1.69k stars 635 forks source link

qutip.testing.run() failed on test testPropHOSteadyPar #1711

Closed Chasmiccoder closed 2 years ago

Chasmiccoder commented 2 years ago

Describe the issue Hi there! Actually, I'm new to QuTiP, so I'm not sure about this, but here's my issue.

I tried to install it from source by following the documentation.
After installing the build requirements, I ran the following command,

qutip.testing.run() 

At around 61%, the testPropHOSteadyPar test failed and gave the following report

______________________________________________________ testPropHOSteadyPar ______________________________________________________ 
multiprocessing.pool.RemoteTraceback:
"""
Traceback (most recent call last):
  File "C:\ ... \Python\Python39\lib\multiprocessing\pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
  File "c:\ ... \qutip\qutip\propagator.py", line 279, in _parallel_mesolve    
    output = mesolve(
  File "c:\ ... \qutip\qutip\mesolve.py", line 237, in mesolve
    func, ode_args = ss.makefunc(ss, rho0, args, e_ops, options)
  File "c:\ ... \qutip\qutip\mesolve.py", line 323, in _qobjevo_set
    _test_liouvillian_dimensions(H_td.cte.dims, rho0.dims)
  File "c:\ ... \qutip\qutip\mesolve.py", line 304, in _test_liouvillian_dimensions
    raise ValueError("".join([
ValueError: incompatible Liouvillian and state dimensions: [[[2], [2]], [[2], [2]]] and [[5], [5]]

The above exception was the direct cause of the following exception:

    def testPropHOSteadyPar():
        "Propagator: steady state parallel"
        a = destroy(5)
        H = a.dag()*a
        c_op_list = []
        kappa = 0.1
        n_th = 2
        rate = kappa * (1 + n_th)
        c_op_list.append(np.sqrt(rate) * a)
        rate = kappa * n_th
        c_op_list.append(np.sqrt(rate) * a.dag())
>       U = propagator(H,2*np.pi,c_op_list, parallel=True)

qutip\qutip\tests\test_propagator.py:86:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
qutip\qutip\propagator.py:195: in propagator
    output = parallel_map(_parallel_mesolve, range(N * N),
qutip\qutip\parallel.py:234: in parallel_map
    return [ar.get() for ar in async_res]
qutip\qutip\parallel.py:234: in <listcomp>
    return [ar.get() for ar in async_res]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <multiprocessing.pool.ApplyResult object at 0x000001E7390028B0>, timeout = None

    def get(self, timeout=None):
        self.wait(timeout)
        if not self.ready():
            raise TimeoutError
        if self._success:
            return self._value
        else:
>           raise self._value
E           ValueError: incompatible Liouvillian and state dimensions: [[[2], [2]], [[2], [2]]] and [[5], [5]]

C:\ ... \Python\Python39\lib\multiprocessing\pool.py:771: ValueError
----------------------------------------------------- Captured stdout call ------------------------------------------------------ 

To Reproduce

import qutip.testing

inp = input("Proceed with full test? [Y/N]: ")
if inp == "y" or inp == "Y":
    qutip.testing.run()

print("Process Complete!")

System Information: Windows 10 Python 3.9.6

The error: - incompatible Liouvillian and state dimensions didn't seem like it was because of missing a requirement, so I'm posting this here. Also, as a side note, to reach 61% it took my system 4 hours, which doesn't sound right (I have a decent system with 8GB ram and core i5).

Thanks!

AGaliciaMartinez commented 2 years ago

Hi, thank you for opening an issue. Unfortunately, I have not being able to reproduce it. Here is my qutip.about() output:

QuTiP: Quantum Toolbox in Python
================================
Copyright (c) QuTiP team 2011 and later.
Current admin team: Alexander Pitchford, Nathan Shammah, Shahnawaz Ahmed, Neill Lambert, Eric Giguère, Boxi Li, Jake Lishman and Simon Cross.
Board members: Daniel Burgarth, Robert Johansson, Anton F. Kockum, Franco Nori and Will Zeng.
Original developers: R. J. Johansson & P. D. Nation.
Previous lead developers: Chris Granade & A. Grimsmo.
Currently developed through wide collaboration. See https://github.com/qutip for details.

QuTiP Version:      4.7.0.dev0+5c73300
Numpy Version:      1.21.2
Scipy Version:      1.7.1
Cython Version:     0.29.23
Matplotlib Version: 3.3.4
Python Version:     3.9.5
Number of CPUs:     4
BLAS Info:          OPENBLAS
OPENMP Installed:   False
INTEL MKL Ext:      False
Platform Info:      Linux (x86_64)
Installation path:  /home/kaladin/Documents/git/qutip/qutip4/qutip
================================================================================
Please cite QuTiP in your publication.
================================================================================
For your convenience a bibtex reference can be easily generated using `qutip.cite()`

Regarding to the tests being slow, I usually run only the test file related to the changes I do. For example, to run tests for qobj it suffices to use pytest qutip/tests/test_qobj.py from the command line. I then leave the CI do its job and run all the tests once I submit a pull request. I guess it is desirable to improve the speed of some tests, I do not think is a priority though. Also, it only took me 6 minutes in my local computer (i7-6700 and 16GB RAM)to run all the tests using your script. I wonder if there is something else going wrong.

Hope this helps!

Chasmiccoder commented 2 years ago

Hey @AGaliciaMartinez !

Thanks a lot for the reply. I tried it again on windows, but it didn't work. In the end I just redid the whole thing with WSL and the tests ran like the wind (12 minutes). All tests have passed, so that's great.

Also, thanks for the tip (running tests on the changed files). That will help a lot.

[ Will close this issue now ]