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

Backend.parse_backend_hamiltonian_dict() seems to include extra terms than subsystem_list #254

Closed KateYangzy closed 1 year ago

KateYangzy commented 1 year ago

Informations

What is the current behavior?

Hi, thank you for your time. I am using backend.parse_backend_hamiltonian_dict(ham_dict, subsystem_list=[0,1]) to parse the hamiltonian of FakeAlmaden restricted on qubit 0, 1. However the returned result includes channel 'u2', 'u3', which I find out to be related to qubit 2 and qubit 6. I am not sure whether it is the function that parses the subsystem wrong or I misunderstand something.

Steps to reproduce the problem

from qiskit.providers.fake_provider import * fake_backend = FakeAlmaden() ham_dict = fake_backend.configuration().to_dict()['hamiltonian'] from qiskit_dynamics import backend backend.parse_backend_hamiltonian_dict(ham_dict, subsystem_list=[0,1])

What is the expected behavior?

The returned result should only contain 'd0', 'd1','u0','u1', not including 'u2','u3'.

Thank you for reading this and pointing out where I made a mistake!

DanPuzzuoli commented 1 year ago

Hi @KateYangzy!

There is no mistake, it is just a weird case. For those ControlChannels, the Hamiltonian in FakeAlmaden says:

 'omegad6*X1||U3',
 'omegad2*X1||U2',

The reason U2 and U3 are included is that they only drive qubit 1. The code that decides whether or not to include a Hamiltonian term just looks only at what qubits the term acts on. In this case, even though these ControlChannels are meant to be used for two qubit interactions with qubit 6 and qubit 2, the operator acts only on qubit 1, and hence we keep these terms.

I know that it's a bit awkward to include these terms, as they are meant to be used for two qubit gates with qubits other than [0, 1], but technically ControlChannels are completely arbitrary, so even though in this case know these terms are for driving CR interactions, I don't think it's possible to exclude these terms from the model in a general routine for parsing the Hamiltonians.

KateYangzy commented 1 year ago

Hi @DanPuzzuoli ! Thank you very much! So when I use the parsing result to initialize a Solver class, what value should I assign to the "channel_carrier_freqs" to guarantee it work all right?

DanPuzzuoli commented 1 year ago

Ah I see - you can actually use the DynamicsBackend.from_backend method to build the backend. This will setup the channel carrier freqs as well.

Otherwise, if you want to build the Solver yourself - for the control channels you're not using you could just put a 0. for the frequency. The frequency there won't matter if you're not using the channels.

KateYangzy commented 1 year ago

Yes I want to build the Solver myself. I got it now! Thank you very much for your kind reply~

DanPuzzuoli commented 1 year ago

Okay sounds good! Feel free to reach out if you have any more questions. You can either post an issue, a discussion thread, or can message in the dynamics slack channel: https://qiskit.slack.com/archives/C03E7UVCDEV

I'll close this issue.