Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding PulseSystemModel class as higher level class containing HamiltonianModel #496

Merged
merged 61 commits into from
Dec 20, 2019

Conversation

DanPuzzuoli
Copy link
Contributor

@DanPuzzuoli DanPuzzuoli commented Dec 13, 2019

Update

This is no longer a [WIP] - and is ready for review.

Summary

This is a [WIP], but the purpose of the new class SimSystemModel is to:

  • Along the lines of the recent HamiltonianModel addition, detangle the options specifications for a pulse simulation. It contains a HamiltonianModel instance, along with any other remaining model information not naturally contained in HamiltonianModel, such as the sampling rate dt and u_channel_lo.
  • The place that users can manipulate/probe the properties of the model; along with HamiltonianModel, this is where model-based functions like frequency calculations can live that the user can use.

To instantiate from a backend:

from qiskit.providers.aer.openpulse.pulse_system_model import PulseSystemModel

backend_real = FakeOpenPulse2Q()
system_model = PulseSystemModel.from_backend(backend_real)

To simulate using this model, and an already assembled pulse qobj:

sim_result = backend_sim.run(qobj, system_model, backend_options=backend_options).result()

Now, the argument backend_options will contain only information specific to the simulator backend, like ODE options (as opposed to a combination of model and solver parameters as before).

Details and comments

I still need to make the following changes, but comments are welcome.

  • Change tests to use this object
  • Change example/calibration notebooks to use this object
  • Write docs for new functions,

I'm not crazy about the name SimSystemModel, any suggestions @chriseclectic @atilag ? SystemModel sounds better, but I thought it might be too general.

@DanPuzzuoli
Copy link
Contributor Author

DanPuzzuoli commented Dec 15, 2019

Update: Made some changes, but in terms of the to do list, migrated the digest test functions into a new file for testing behaviour of model classes.

There is a slight issue that will cause things to break at some point: terra now reports defaults in s/Hz, but some units in configuration for a backend seem to still be in GHz, including reporting of the Hamiltonian. This inconsistency makes things a bit awkward still; e.g. currently for things to work it's necessary to specify system_model.dt = 1 after constructing from a backend, as the Hamiltonian parameters in configuration has units of GHz, but configuration['dt'] is in seconds.

Edit: This inconsistency is apparently discussed in either a terra issue or PR, so should be changed at some-point soon, which will break the tests here, but I figure the only thing we can do is fix it when it happens does.

@DanPuzzuoli
Copy link
Contributor Author

DanPuzzuoli commented Dec 18, 2019

The latest updates are described by the previous comment; it has been edited as it is mostly the same. The only edit is the removal of the methods from PulseSystemModel that behave like a pulse backend configuration; when constructing schedules the current paradigm is for the user to just directly call pulse.DriveChannel(0) to reference the drive channel on qubit 0.

@DanPuzzuoli DanPuzzuoli changed the title [WIP] Adding SimSystemModel class as higher level class containing HamiltonianModel Adding SimSystemModel class as higher level class containing HamiltonianModel Dec 18, 2019
…default memory_slots setting in digest to be equal to the number of qubits
Copy link
Member

@chriseclectic chriseclectic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initial review. My main question is do both classes need channel information? Currently this seems to be duplicated in both classes.

qiskit/providers/aer/openpulse/hamiltonian_model.py Outdated Show resolved Hide resolved
Comment on lines 75 to 76
def from_string_spec(cls, hamiltonian, qubit_list=None):
"""Initialize from a Hamiltonian string specification.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

qubit_list -> subsystems or qargs (they could be oscillator systems etc)

qargs is kwarg uesd for QuantumCircuit and Operator classes for specifying subsystems

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding this to the list of things for future PRs.

qiskit/providers/aer/openpulse/hamiltonian_model.py Outdated Show resolved Hide resolved
qiskit/providers/aer/openpulse/hamiltonian_model.py Outdated Show resolved Hide resolved

# get relevant information from backend
defaults = backend.defaults().to_dict()
config = backend.configuration().to_dict()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for config

qiskit/providers/aer/openpulse/pulse_system_model.py Outdated Show resolved Hide resolved
qiskit/providers/aer/openpulse/pulse_system_model.py Outdated Show resolved Hide resolved
@@ -9,7 +9,7 @@
# Any modifications or derivative works of this code must retain this
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.
# pylint: disable=arguments-differ
# pylint: disable=arguments-differ, missing-return-type-doc
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't need to add this pylint skip, what functions were causing the missing-return-type-doc error?

Copy link
Member

@chriseclectic chriseclectic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, lets do rest of changes in a follow up PR

@chriseclectic chriseclectic merged commit 0f2d013 into Qiskit:openpulse-sim Dec 20, 2019
@atilag atilag changed the title Adding SimSystemModel class as higher level class containing HamiltonianModel Adding PulseSystemModel class as higher level class containing HamiltonianModel Dec 26, 2019
chriseclectic pushed a commit to chriseclectic/qiskit-aer that referenced this pull request Jan 23, 2020
…ianModel (Qiskit#496)

* added PulseSystemModel to extract information about backend relevant to simulation

* Moved HamiltonianModel.calculate_frequencies to PulseSystemModel.calculate_channel_frequencies

* Modifying constructors for HamiltonianModel to separate object specification from string parsing

* added PulseDefaults object into the pulse_simulator, and changed the default memory_slots setting in digest to be equal to the number of qubits

* changed digest default 'meas_level' to 2
chriseclectic pushed a commit to chriseclectic/qiskit-aer that referenced this pull request Jan 23, 2020
…ianModel (Qiskit#496)

* added PulseSystemModel to extract information about backend relevant to simulation

* Moved HamiltonianModel.calculate_frequencies to PulseSystemModel.calculate_channel_frequencies

* Modifying constructors for HamiltonianModel to separate object specification from string parsing

* added PulseDefaults object into the pulse_simulator, and changed the default memory_slots setting in digest to be equal to the number of qubits

* changed digest default 'meas_level' to 2
chriseclectic pushed a commit to chriseclectic/qiskit-aer that referenced this pull request Jan 23, 2020
…ianModel (Qiskit#496)

* added PulseSystemModel to extract information about backend relevant to simulation

* Moved HamiltonianModel.calculate_frequencies to PulseSystemModel.calculate_channel_frequencies

* Modifying constructors for HamiltonianModel to separate object specification from string parsing

* added PulseDefaults object into the pulse_simulator, and changed the default memory_slots setting in digest to be equal to the number of qubits

* changed digest default 'meas_level' to 2
chriseclectic pushed a commit to chriseclectic/qiskit-aer that referenced this pull request Jan 23, 2020
…ianModel (Qiskit#496)

* added PulseSystemModel to extract information about backend relevant to simulation

* Moved HamiltonianModel.calculate_frequencies to PulseSystemModel.calculate_channel_frequencies

* Modifying constructors for HamiltonianModel to separate object specification from string parsing

* added PulseDefaults object into the pulse_simulator, and changed the default memory_slots setting in digest to be equal to the number of qubits

* changed digest default 'meas_level' to 2
@DanPuzzuoli DanPuzzuoli deleted the pulse-sim-model branch June 4, 2020 13:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants