You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Problem with products of boson.number operator in latest CUDA-Q
#3434
When I am trying to run a multi-body dynamics simulation with the latest CUDA-Q version 0.12, I get an error whenever the Hamiltonian contains a product of two boson.number operators for the 3rd qubit and beyond, for example boson.number(index)*boson.number(index) where index>=2. The error message reads “Error in tensor callback: missing dimension for degree
#ERROR: Exception: #ERROR(CallbackError): External tensor callback function failed with error code 14
RuntimeError: [cudaq] %16 in computeImpl (line 92)”
No such error occurs for qubit index=0,1, or just the number operator itself (without product). The same simulation runs without issues on the older 0.10 version. Below is an example script to reproduce the error:
import numpy as np
import cudaq
from cudaq import boson, Schedule, ScipyZvodeIntegrator, spin, RungeKuttaIntegrator
import cupy as cp
import matplotlib.pyplot as plt
L=5
Nmax=1
cudaq.set_target("dynamics")
init=np.zeros(np.power(Nmax+1,L))
init[0]=1
index=1
hamiltonian = boson.number(index)*boson.number(index)
for i in range(L-1):
hamiltonian = hamiltonian + boson.identity(i)
dimensions={}
for i in range(L):
dimensions[i] = Nmax+1
rho0 = cudaq.State.from_data(
cp.array(init , dtype=cp.complex128))
t_final=25
n_steps=105
# 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=[],
collapse_operators=[],
store_intermediate_results=True)
get_result = lambda idx, res: [
exp_vals[idx].expectation() for exp_vals in res.expectation_values()
]
OK, I am using the latest docker image updated on August 20 here. Unfortunately I am still getting the same error for index=3 (but not for index=1,2) which reads "Error in tensor callback: missing dimension for degree 3
#ERROR: Exception: #ERROR(CallbackError): External tensor callback function failed with error code 14
RuntimeError: [cudaq] %16 in computeImpl (line 92)".
Sorry for this late follow-up. I tested the docker image version as suggested above, and it works without producing the previous errors with the Hamiltonian. However, the simulation results seem to be different than those from version 0.10. Using the same number of timesteps and total time, the result in 0.12 would blow up, whereas in 0.10 the same simulation would produce valid results. The stepsize needs to be reduced by factor 3 in version 0.12 compared to 0.10 in order to converge. I am using the RungeKutta scheme in both cases. Has anything changed with the time integrator from version 0.10 to 0.12?
Indeed, the built-in RK integrator has been migrated from Python to C++, and as part of the migration, some of the default parameters were adjusted. In 0.10, the RK integrator has a default number of sub-steps of 10.
This parameter (nsteps) is deprecated in 0.12. The new parameter is max_step_size, to be consistent with the C++ integrator. Also, we no longer set a heuristic default value for this anymore. We can keep the same timestep schedule, which determines time points to save expectation values, and set the max_step_size parameter of the integrator, e.g., RungeKuttaIntegrator(order=4, max_step_size=0.01).
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hello,
When I am trying to run a multi-body dynamics simulation with the latest CUDA-Q version 0.12, I get an error whenever the Hamiltonian contains a product of two boson.number operators for the 3rd qubit and beyond, for example boson.number(index)*boson.number(index) where index>=2. The error message reads “Error in tensor callback: missing dimension for degree
#ERROR: Exception: #ERROR(CallbackError): External tensor callback function failed with error code 14
RuntimeError: [cudaq] %16 in computeImpl (line 92)”
No such error occurs for qubit index=0,1, or just the number operator itself (without product). The same simulation runs without issues on the older 0.10 version. Below is an example script to reproduce the error:
All reactions