Closed to24toro closed 1 year ago
There is no way around this - the Hamiltonian is stored in the configuration()
, so we cannot use DynamicsBackend.from_backend
without this. Removing this constraint will require changing BackendV2
itself in terra to add the Hamiltonian somewhere. (There may also be other things in the configuration that we need to find a proper place for in BackendV2
, but can't recall - the Hamiltonian is the big one.)
I'm going to close this for now since there's nothing that can be done in Dynamics about this without changes to terra.
I think we don't get any conclusion for this. I don't think it's worth adding BackendV2.hamiltonian
because this is only used by the simulator and future IBM backends (with large qubits) may drop this information. The V2 backend has the options field to define arbitrary system configuration, so system Hamiltonian could be a part of this. DynamicsBackend
can override _default_options
to provide system Hamiltonian. This doesn't mean we can avoid missing configuration field problem though.
Because we cannot assume the backend always provides Hamiltonian, it might be reasonable to write
DynamicsBackend.from_backend(backend, hamiltonian: Optional = None)
and let this factory method check the getattr(backend, "configuration")
when hamiltonian
is empty. If the backend neither provide Hamiltonian nor configuration, user can still write own Hamiltonian by themself.
(edit)
Probably you may want to implement system Hamiltonian factory. Since IBMBackend and FakeBackend provide qubit properties (frequency and anharmonicity are available) you can still create realistic Hamiltonian by assuming some random Rabi rate and J coupling constant.
Do we expect that systems for which the hamiltonian
is not provided will even have pulse access at all? If not then the rest of the information extracted by from_backend
won't be present anyway (e.g. channel frequencies), in which case from_backend
will fail even if a hamiltonian
is provided.
With regards to having a Hamiltonian factory: it may not be a bad idea to have a function that generates DynamicsBackend
instances with CR Hamiltonians given a description of the qubits. Something like this was done here for the PulseSimulator. The function could have a similar argument list, but return a DynamicsBackend
.
I am not sure about what values will be reported. So far IBM devices report all qubit properties as an IBMQubitProperties. Since these values are acquired through the device calibration, I think the availability of them in the non-pulse devices is just a matter of high-level decision and limit of communication bandwidth.
Looking at this issue from short, medium, long term perspectives.
Short term
Medium term
Long term
Anyway we have to change the type hint of an attribute backend of from_backend as soon as possible.
Informations
What is the current behavior?
There is a bug we need to fix as soon as possible. When we execute the below code, we encounter
This is because backendV2, unlike backendV1, doesn't support a configuration method.
Steps to reproduce the problem
What is the expected behavior?
We would like to create the dynamics backend from FakeKolkataV2, retrieving its information.
Suggested solutions
from_backend
test about using backendV2.