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

qt.propagator requires twice the memory usage of internally used numpy array u #2312

Open
s1-inoue opened this issue Jan 30, 2024 · 0 comments
Labels

Comments

@s1-inoue
Copy link

s1-inoue commented Jan 30, 2024

Problem Description

Hello, I am recently using qt.propagator to calculate the time evolution of states with collapse operators. I am having memory usage problem due to qutip's matrix conversion.
This matrix conversion is especially memory intensive when performing propagator calculation with collapse operators.

Current qutip propagator uses numpy array to store the raw calculation data.
u = np.zeros([N * N, N * N, len(tlist)], dtype=complex)

Qutip then converts matrices at each time list t at the end of this function.

if unitary_mode == 'batch':
    out[:] = [Qobj(u[k], dims=dims) for k in range(len(tlist))]
else:
    out[:] = [Qobj(u[:, :, k], dims=dims) for k in range(len(tlist))]

This conversion effectively requires the same memory usage as "u".
This behavior is problematic when raw results u consumes a lot of memory.
I would be happy if there is an optional argument to skip Qobj(u[k]) process

Proposed Solution

Add a feature to select if qt.propagator performs conversion to Qobj or just return numpy array.
Rewrite the code of "qutip/propagator.py" around line 221 something like

  if not skip_qutip_conversion:
      out = np.empty((len(tlist),), dtype=object)
      if unitary_mode == 'batch':
          out[:] = [Qobj(u[k], dims=dims) for k in range(len(tlist))]
      else:
          out[:] = [Qobj(u[:, :, k], dims=dims) for k in range(len(tlist))]
  else:
      out = u
  return out

Alternate Solutions

No response

Additional Context

No response

@s1-inoue s1-inoue added the ENH label Jan 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant