qiskit-community / qiskit-dynamics

Tools for building and solving models of quantum systems in Qiskit
https://qiskit-community.github.io/qiskit-dynamics/
Apache License 2.0
105 stars 61 forks source link

Add explicit interface to DynamicsBackend for just returning results of ODE simulation #288

Closed DanPuzzuoli closed 10 months ago

DanPuzzuoli commented 1 year ago

Currently DynamicsBackend.run, is the only method of DynamicsBackend for running simulations. In accordance with the standard backend interfaces, it performs a state simulation and returns a probability dict.

It would be good to have a public interface just for ODE simulation with arbitrary "states" (including unitary simulation) - basically the equivalent of Solver.solve, but in which a user can take advantage of circuit transpilation. I think it probably makes sense to add a new DynamicsBackend.solve method for this. (The other option would be to add options to DynamicsBackend.run, but this would completely change the output type, and therefore complicate the interface, and also take it out of line with general backend.run.)

donsano33 commented 1 year ago

Hello Daniel, I would take a look at it and give it a shot. I agree, it like the choice to leave the DynamicsBackend.run method as is and add a new DynamicsBackend.solve which corresponds to the Solver.solve method. Can you assign the ticket to me? Thanks!

donsano33 commented 12 months ago

When calling DynamicsBackend.solve(...), shall we

I actually think I prefer option two, as it gives more direct access to the results of interest avoiding the detour to Job.result.results(). What we loose with this additional datastructure from Result, for example saving the metadatafrom the schedules, etc.

What do you think?

DanPuzzuoli commented 12 months ago

I agree. The job interface in Dynamics serves no purpose other than to imitate the container objects returned by a real backend. The solve method doesn't fit into the backend framework, so there's really no reason to use DynamicsJob.