question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

parfor and brmesolve - Cythonizing problem in v5

See original GitHub issue

Bug Description

When combining parfor with brmesolve and a time-dependent Hamiltonian, the compilation of the Hamiltonian seems to interfer with the correct functioning of parfor. The call results in an error, that the coefficient file is too short.

I guess this could also happen when using parfor with other solvers.

Code to Reproduce the Bug

from qutip import brmesolve, sigmaz, sigmax, basis, parfor
import numpy as np

psi0 = basis(2, 0)
H_S = np.pi * sigmaz()
H_I = sigmax()
tlist = np.linspace(0, 100, 101)
pulse_shape = "exp(- t**2)"

def brme(A):
    H_tmp = [A * H_S, [H_I, pulse_shape]]

    return brmesolve(
        H_tmp, psi0, tlist, e_ops=[sigmaz()]
    ).expect[0][-1]

results = parfor(brme, np.linspace(0, np.pi, 10))

Code Output

ImportError: /home/chris/.qutip/qutip_coeffs_1.1/qtcoeff_4c859672674b8b603bd243ba3f4a8d.cpython-38-x86_64-linux-gnu.so: file too short

Expected Behaviour

parfor should wait for the compilation to finish and then start the parallel processes.

Your Environment

QuTiP Version:      5.0.0.dev0+c64f38e
Numpy Version:      1.23.0
Scipy Version:      1.8.1
Cython Version:     0.29.30
Matplotlib Version: 3.5.2
Python Version:     3.8.10
Number of CPUs:     4

Additional Context

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
hodgestarcommented, Aug 16, 2022

@christian512 Could you remove the “pre-compilation” of the Cython files from qutip/qutip-tutorials#31? Then if that works we can close this issue.

0reactions
christian512commented, Aug 17, 2022

I removed the “pre-compilation” and it worked in the tutorial. Since we will change from using brmesolve to BRSolver in that notebook (see https://github.com/qutip/qutip-tutorials/pull/31#discussion_r946862389) I will close this issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshoot Variables in parfor-Loops - MATLAB & Simulink
If MATLAB ® detects that the parfor -loop variable can overflow, it reports an error. Overflow condition, Example, Solution. The length of the...
Read more >
Error when trying to use parfor (parallel for loop) in MATLAB
Outputs from PARFOR loops must either be reduction variables (e.g. calculating a summation) or "sliced". See this page in the doc for more....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found