Closed DanPuzzuoli closed 1 year ago
This issue actually even persists if I drop the JAX configuration and use a scipy solver, which is "good" in that it means it won't be necessary to dig further into JAX tracing or anything like that.
Okay bug has been figured out. It is somehow a huge mistake in the code that miraculously doesn't impact DynamicsBackend.run
results, but in some cases will accidentally make the computation excessively expensive.
Amazingly, the t_span
values being fed into Solver.solve
within DynamicsBackend.run
are the sample numbers, not the sample numbers * dt
. So, in the above example, the acquire instruction occurs at sample number 127
, so the integration time should be 127 * dt == 2.822222222222222e-08
, but the DynamicsBackend
is simply passing the integration interval as [0, 127]
.
This is a huge mistake, but amazingly it doesn't have a mathematical impact on the results of DynamicsBackend
:
dt
, so the correct simulation is occuring up to 127 * dt
.DynamicsBackend
are
computed in the dressed basis, the probabilities for each string are unaffected (aside from numerical error) for all evolution under the static hamiltonian after time 127 * dt
.Further, in cases where the rotating frame was set to be the full static Hamiltonian, after 127 * dt
, the RHS of the DE is exactly 0.
, so even though the integration was proceeding way beyond the desired limit (by 10 orders of magnitude), the variable step solvers would quickly start taking extremely large steps until they hit the endpoint. This resulted in no obvious difference in the simulation run time for the correct v.s. incorrect integration intervals.
The hanging was observed initially when first setting up the a DynamicsBackend
with a Solver
in sparse mode, as in this case the rotating frame is not set to the full static Hamiltonian, but to the diagonal part only. As a result, the RHS is no longer 0.
for all times after 127 * dt
, and the solver is therefore forced to continue to take small steps (hence it seeming to hang forever).
This will be easily fixed by correctly multiplying the integration times by dt
.
Informations
main
branchWhat is the current behavior?
This is a bizarre bug that I haven't been able to get to the bottom of. The code is below, but the setup is:
Solver
is constructed with a 2 transmon model, and configured for pulse simulation.DynamicsBackend
is constructed with this solver instance.With the above setup:
Solver.solve
on the pulse schedules works.DynamicsBackend.run
hangs - with some computation seeming to run indefinitely.In the cases in which this happens, the weird thing about this is that
DynamicsBackend.run
seems to hang at the step that the ODE solver is called (when debugging and stepping over things it gets stuck here), however allDynamicsBackend.run
does up to that point is create aDynamicsJob
instance then callSolver.solve
. I.e. for the purposes of this bugDynamicsBackend.run
is basically a light wrapper aroundSolver.solve
.Steps to reproduce the problem
Setting up things up:
Simulate the schedules using
Solver.solve
works:Building a
DynamicsBackend
with thisSolver
instance and callingrun
(with seemingly the same options) leads to a never-ending computation:Variations of the above code that work or don't
This was discovered when I was trying to see how a sparse simulation performed, hence the sparse configuration of the
Solver
.Additional tested situations:
"sparse"
evaluation mode, and change the rotating frame to the full static Hamiltonian, it works. (I.e. standard dense solver configuration).J = 0
(the coupling) also works.What's confusing is that the above would normally suggest some issue with the differential equation solving... however
Solver.solve
still always works in all of the above configurations. OnlyDynamicsBackend.run
hangs, and it specifically hangs when the ODE solver is called!I've also disabled jitting by changing the
Solver.solve
code to always skip the auto-jitting behaviour, and the issue persists, so it doesn't seem to be anything weird going on with the internal auto-jitting code.Further steps
I'll keep tryign to debug with jitting disabled to see where the difference might lie.