-
|
It seems that the total memory requirement on GPUs increases almost linearly with growing number of time steps in time evolution of cudaq.dynamics (cu12-0.14.0), despite the fact that only a small number of observables are being monitored. Is there a way for a fixed problem which works well for a small number of time steps to scale up to a larger number of time steps, without running out of memory? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
|
Will look into it. Would you be able to post a sample example here? |
Beta Was this translation helpful? Give feedback.
-
|
Many thanks for getting back so quickly! Below is an example script, the number of time steps is controlled by 'n_steps' which is set to 50 currently:
```
import numpy as np
import cudaq
from cudaq import boson, Schedule, ScipyZvodeIntegrator, spin, RungeKuttaIntegrator
import cupy as cp
L=16
cudaq.set_target("dynamics")
#initial condition: every site is singly occupied
init=np.zeros(np.power(3,L))
index=0
for i in range(L):
index=index+pow(3,i)
init[index]=1
hamiltonian = boson.create(0)*boson.annihilate(L-1)
for i in range(L-1):
hamiltonian = hamiltonian + boson.number(i)*boson.number(i)
# Dimensions of sub-systems
dimensions={}
for i in range(L):
dimensions[i] = 3
# Initial state of the system (ground state).
rho0 = cudaq.State.from_data(cp.array(init , dtype=cp.complex128))
t_final=25
n_steps=50
# Schedule of time steps.
steps = np.linspace(0, t_final, n_steps)
schedule = Schedule(steps, ["t"])
# Run the simulation.
evolution_result = cudaq.evolve(hamiltonian,
dimensions,
schedule,
rho0,
observables=[boson.number(0), boson.number(L-1)],
collapse_operators=[],
store_intermediate_results=True)
```
…________________________________
From: Sachin Pisal ***@***.***>
Sent: Wednesday, April 8, 2026 2:37 PM
To: NVIDIA/cuda-quantum ***@***.***>
Cc: Xiao, Chengnian ***@***.***>; Author ***@***.***>
Subject: Re: [NVIDIA/cuda-quantum] Memory increases with growing number of time steps in cudaq.dynamics (Discussion #4279)
Will look into it. Would you be able to post a sample example here?
—
Reply to this email directly, view it on GitHub<#4279 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AJJHPHUCRXF5ROXRDNTUJFD4U2L63AVCNFSM6AAAAACXRN7QMGVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTMNBZGMYDKOI>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
|
The Please use |
Beta Was this translation helpful? Give feedback.
The
store_intermediate_results=Trueis deprecated alias forIntermediateResultSave.ALL. It saves the entire state vector to the GPU at every time step. So that's why the memory growth is like O(n_steps * state_size).Please use
store_intermediate_results=cudaq.IntermediateResultSave.EXPECTATION_VALUEinstead as it saves only the expectation values of 2 observables (boson.number(0) and boson.number(L-1)) at each step and not the state. It is like O(n_steps * 2) now.